
//start div popup
var obj_div ;
var obj_div_over ;
function popup_div(obj_id)
{
	var obj = document.getElementById(obj_id);
	//obj.style.position = "fixed";
	if(obj)
	{
		obj_div = document.getElementById(obj_id);
		if(obj!=null)
		{
			//set_postion(obj);
			//obj.style.visibility = (obj.style.visibility == 'visible') ? 'hidden' : 'visible';

			set_postion(obj);
			if(obj.style.visibility == 'visible')
			{
				//hide the pop up
				obj.style.visibility = 'hidden';
				hideAlertLayer();
			}
			else
			{
				//show the pop up
				showAlertLayer();
				obj.style.visibility = 'visible';
				obj.style.zIndex = 101;
			}

		}
		else
		{
			alert(obj_id + ' popup is null');
		}
	}
	return false;
}
function set_postion(obj)
{
	if(obj)
	{
		var div_width = obj.offsetWidth
		var div_height = obj.offsetHeight;

		var theLeft = 0, theTop =0;
		if(screen.width)
		{
			var theLeft = 0;
			var theTop = 0;
			var isMozilla = document.getElementById&&!document.all;
			if(isMozilla)
			{
				theLeft = (window.innerWidth - div_width) / 2;;
				theTop = (window.innerHeight - div_height) / 4;
			}
			else
			{
				theLeft = (document.body.offsetWidth - div_width) / 2;
				theTop = (document.body.offsetHeight - div_height) / 4;
			}

		}
		if (theLeft < 0) theLeft = 0;
		if (theTop < 0) theTop = 0;
		//theTop = 80;
		
		//jQuery("html, body").scrollTop(100);
		//alert(jQuery(window).scrollTop());
		//alert($().scrollTop());
		//document.body.scrollTop

		obj.style.left = theLeft + 'px' ;
		
		obj.style.top = theTop+$().scrollTop() + 'px' ;
	}
}

function popup_postion_div(obj_id, theLeft, theTop)
{
	var obj = document.getElementById(obj_id);
	if(obj!=null)
	{
		if(theLeft > 0 && theTop > 0)
		{
			obj.style.left = theLeft + 'px' ;
			obj.style.top = theTop + 'px' ;
		}
		obj.style.visibility = (obj.style.visibility == 'visible') ? 'hidden' : 'visible';
	}
	else
	{
		alert(obj_id + ' popup is null');
	}
	return false;
}

//start popup window
function OpenBox(winWidth, winHeight, fileSrc, scrollbars)
{
	if(screen.width)
	{
		var winl = (screen.width - winWidth) / 2;
		var wint = (screen.height - winHeight) / 2;
	}
	else
	{
		winl = 0; wint =0;
	}
	if (winl < 0) winl = 0;
	if (wint < 0) wint = 0;
	var props = 'top='+wint+',left='+winl+',toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars='+scrollbars+',resizable=no,width='+winWidth+',height='+ winHeight;
	window.open(fileSrc, 'FullScreen', props);
}
function getPageSize()
{
	//alert(document.body.scrollLeft);
	arrayPageSize = new Array(document.body.clientWidth+document.body.scrollLeft,document.body.clientHeight+document.body.scrollTop)
	return arrayPageSize;
}

function showAlertLayer()
{
	var arrayPageSize = getPageSize();

	// setup the dividers
	var BodyObject = document.getElementsByTagName("body").item(0);

	// setup bg alert layer
	var OverlayObject = document.getElementById('da_overlay');
	if (!OverlayObject)
		OverlayObject = document.createElement("div");
	obj_div_over = OverlayObject;
	OverlayObject.setAttribute('id','da_overlay');
	OverlayObject.style.width = arrayPageSize[0] + "px";
	OverlayObject.style.height = (arrayPageSize[1]) + 'px';
	OverlayObject.style.left = '0px';
	OverlayObject.style.top = '0px';
	OverlayObject.style.position = "absolute";
	OverlayObject.style.backgroundColor = "#ffffff";
	//OverlayObject.style.backgroundColor = "#000000";
	OverlayObject.style.zIndex = 100;
	OverlayObject.style.filter = "alpha(opacity=65)";
	OverlayObject.style.mozOpacity = ".65";
	OverlayObject.style.opacity = ".65";
	OverlayObject.style.display = "block";

	// setup content alert layer

	BodyObject.appendChild(OverlayObject);

}

function hideAlertLayer()
{
	var OverlayObject = document.getElementById('da_overlay');
	if(OverlayObject)
	{
		OverlayObject.style.width = "0px";
		OverlayObject.style.height = "0px";
		OverlayObject.style.left = '0px';
		OverlayObject.style.top = '0px';
		OverlayObject.style.backgroundColor = "#000000";
		OverlayObject.style.zindex = "0";
		OverlayObject.style.filter = "alpha(opacity=0)";
		OverlayObject.style.mozOpacity = ".0";
		OverlayObject.style.opacity = ".0";
		OverlayObject.style.display = "none";
	}
}
function winOnResize()
{
	set_postion(obj_div);
	if(obj_div_over)
	{
		var arrayPageSize = getPageSize();
		obj_div_over.style.width = arrayPageSize[0] + "px";
		obj_div_over.style.height = (arrayPageSize[1]) + 'px';
	}
	//for erorrs
	if(typeof(obj_div_over_erorrs) != 'undefined' && obj_div_over_erorrs)
	{
		var arrayPageSize = getPageSize();
		obj_div_over_erorrs.style.width = arrayPageSize[0] + "px";
		obj_div_over_erorrs.style.height = (arrayPageSize[1]) + 'px';
	}
	if(typeof(obj_div_erorrs) != 'undefined' && obj_div_erorrs)
	{
		set_postion(obj_div_erorrs);
	}


}
window.onresize=winOnResize;
window.onscroll=winOnResize;

