//Copyrighted
// All Rights Reservet To Jhoobin Idea Processing(jhoobin.com)



var ie5=document.all&&document.getElementById;
var ns6=document.getElementById&&!document.all;
var ff15= navigator.userAgent.indexOf("Firefox")!=-1;

maximized = 0;

function maximize(windowname){
	if(maximized == 0){
		maximized = 1;
		document.getElementById('c' + windowname + 'frame').style.height =(window.document.body.clientHeight - 64) + "px";
		document.getElementById('c' + windowname + 'frame').style.width = (window.document.body.clientWidth -10) + "px";
		document.getElementById('d' + windowname + 'memory').style.top = document.getElementById('d' + windowname + 'window').style.top;
		document.getElementById('d' + windowname + 'memory').style.left = document.getElementById('d' + windowname + 'window').style.left;		
		document.getElementById('d' + windowname + 'window').style.top = "30px";
		document.getElementById('d' + windowname + 'window').style.left = "0px";
		document.getElementById('max' + windowname + 'name').src = "images/content/restore.gif";
	}else{
		maximized = 0;
		document.getElementById('c' + windowname + 'frame').style.height = "";
		document.getElementById('c' + windowname + 'frame').style.width= "";
		document.getElementById('d' + windowname + 'window').style.top = document.getElementById('d' + windowname + 'memory').style.top;
		document.getElementById('d' + windowname + 'window').style.left = document.getElementById('d' + windowname + 'memory').style.left;		
		document.getElementById('max' + windowname + 'name').src = "images/content/maximize.gif";
	}
	document.getElementById('d' + windowname + 'window').style.zIndex = dzIndex ++ ;				
}
function closeit(windowname){
	document.getElementById('d' + windowname + 'window').style.zIndex = dzIndex ++ ;
	document.getElementById('d' + windowname + 'window').style.display="none";
}

tempx = 0;
tempy = 0;
offsetx = 0;
offsety=0;
var dragapproved = null;
dzIndex = 1;

function drag_drop(e){
	e = e || event;
	if (ie5&&dragapproved&&e.button==1){
		dragapproved .style.left=tempx+e.clientX-offsetx+"px"
		dragapproved .style.top=tempy+e.clientY-offsety+"px"
	}else if (ns6&&dragapproved&&e.which==1){
		dragapproved .style.left=tempx+e.clientX-offsetx+"px"
		dragapproved .style.top=tempy+e.clientY-offsety+"px"
	}else if (ff15&&dragapproved){
		dragapproved .style.left=tempx+e.clientX-offsetx+"px"
		dragapproved .style.top=tempy+e.clientY-offsety+"px"
	}
	return true;
}

function stopdrag(){
	if(dragapproved){
		dragapproved.style.filter = "";
		dragapproved.style.opacity = ""; 
	}
	dragapproved=null;
}

function initializedrag(e,windowname){
	offsetx = e.clientX
	offsety = e.clientY
	dragapproved=document.getElementById('d' + windowname + 'window');
	//document.getElementById("dwindowcontent").style.display="none" //extra
	tempx=parseInt(dragapproved.style.left)
	tempy=parseInt(dragapproved.style.top)
	dragapproved.style.zIndex = dzIndex ++ ;

	dragapproved.style.opacity = 0.7; 
	dragapproved.style.filter = "Alpha(opacity=70)";
}		
function drawPortlet(windowname,src,title ,x ,y ,width , height){
	stringTowrite = "";
		stringTowrite += '<span id="d'+ windowname +'window" class="dwindow_main" style="left:'+ x +'px;top:'+ y +'px;display:block;width:'+ width +'" onSelectStart="return false">'
					+ '<span id="d'+ windowname +'memory" style="left:0px;top:30px;display:none;width:100%"></span>'
					+ '<table cellpadding=0 cellspacing=0  onSelectStart="return false"><tr><td><table cellpadding=0 cellspacing=0 width =100%>'
					+ '<tr><td class="dwindow_tb_right"><img src = "images/content/spacer.gif" border = 0 hspace= 0 width=6 ></td><td class="dwindow_tb" >'
					+ '<table cellpadding=0 cellspacing=0 width=100% style="margin: 0" ><tr><td width=100% onMousedown="initializedrag(event,\''+ windowname +'\')" onMouseup="stopdrag()">'
					+ title + '</td><td><img src="images/content/maximize.gif" id="max'+ windowname +'name" onClick="maximize(\''+windowname+'\')"></td><td><img src="images/content/close.gif" onClick="closeit(\''+windowname+'\')" >'
					+ '</td></tr></table></td><td class="dwindow_tb_left"><img src = "images/content/spacer.gif" border = 0 hspace= 0 width=6 ></td></tr></table></td></tr><tr><td><table cellpadding=0 cellspacing=0>'
					+ '<tr><td class="dwindow_frame_right"><img src="images/content/windowright.gif" ></td><td width=100%>	<iframe dir=rtl id="c'+windowname+'frame" src="'+src+'" style="border-style: none" FRAMEBORDER=0 width=100% height='+ height+'></iframe>'
					+ '</td><td class="dwindow_frame_left"><img src="images/content/windowleft.gif"></td></tr></table></td></tr><tr><td><table cellpadding=0 cellspacing=0 style="table-layout:fixed">'
					+ '<tr><td class="dwindow_bt_right"><img src="images/content/spacer.gif" border = 0 height=4></td><td class="dwindow_bt"></td><td class="dwindow_bt_left"><img src="images/content/spacer.gif" border = 0 height=4>'
					+ '</td></tr></table></td></tr></table></span>';
	return stringTowrite;
}

document.onmousemove=drag_drop;			
document.onmouseout=drag_drop;
 
function drop(mousEvent,target,ID){
	document.getElementById('t'+ID).style.display='block';
	document.getElementById('t'+ID).style.left=findPos(target)[0];
	document.getElementById('t'+ID).style.top=findPos(target)[1];
	document.getElementById('t'+ID).style.width=target.offsetWidth;
}
function dropTable(mousEvent,target,ID){
	document.getElementById(ID).style.display='block';
	document.getElementById(ID).style.left=findPos(target)[0];
	document.getElementById(ID).style.top=findPos(target)[1];	
	document.getElementById(ID).style.width=target.offsetWidth;	
}

function collect(mousEvent,target,ID){
	document.getElementById(ID).style.display='none';
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop 
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}
function overBgColor(mouseEvent,target,ID){
	document.getElementById(ID).bgColor="#6f88d8";
}
function outBgColor(mouseEvent,target,ID){
	document.getElementById(ID).bgColor="#cb8898";
}

function changeURL(strPage){
	curUrl = parent.parent.document.location.href.split("?");
	parent.parent.document.location = curUrl[0]+'?subpage=' + strPage;
}

function changeURL(strPage){
	document.location = 'http://www.jhoobin.com/' +strPage;
}
var timeout         = 500;
var closetimer		= 0;
var ddmenuitem      = 0;

// open hidden layer
function mopen(id)
{
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose;

