//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)";
}		

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;


