//====================================================================================================
//	Function Name	:	popupWindowURL
//----------------------------------------------------------------------------------------------------
function popupWindowURL(url, winname, w, h, menu, resize, scroll)
{
    var x = (screen.width-w)/2;
    var y = (screen.height-h)/3;

	if (winname == null)
		winname = "newWindow";
	
	if (w == null)
		w = 800;
	
	if (h == null)
		h = 600;
	
	if (resize == null)
		resize = 1;

	menutype   = "nomenubar";
	resizetype = "noresizable";
	scrolltype = "noscrollbars";
	
	if (menu)
		menutype = "menubar";
	
	if (resize)
		resizetype = "resizable";
	
	if (scroll)
		scrolltype = "scrollbars";
	
    cwin = window.open(url,winname,"top=" + y + ",left=" + x + ",screenX=" + x + ",screenY=" + y + "," + "status," + menutype + "," + scrolltype + "," + resizetype + ",width=" + w + ",height=" + h);

	if (!cwin.opener)
		cwin.opener = self;

	cwin.focus();

	return true;
}

function ToggleLoader(flg, msg)
{
	if(flg)
	{
		DisableBodyArea(true);

		var x = (truebody().clientWidth - 200)/2;
		var y = (truebody().clientHeight - 100)/2;
		//var y = 475;
//		var y = 475+120;

		document.getElementById('stdLoader').style.left = x+"px";
		document.getElementById('stdLoader').style.top = y+"px";
		document.getElementById('stdLoader').style.display = '';
	}
	else
	{
		document.getElementById('stdLoader').style.display = 'none';
		DisableBodyArea(false)
	}
}
function DisableBodyArea(flg)
{
	if(flg)
	{
		document.getElementById('stdDisableArea').style.width	= truebody().scrollWidth + 'px';
		document.getElementById('stdDisableArea').style.height	= truebody().scrollHeight + 'px';
		document.getElementById('stdDisableArea').style.display = '';
	}
	else
	{
		document.getElementById('stdDisableArea').style.display = 'none';
	}
}

var offsetfrommouse=[15,25]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var displayduration=0; //duration in seconds image should remain visible. 0 for always.

var previewImageHeight;	// maximum image size.
var previewImageWidth;	// maximum image size.

var defaultImageHeight = 400;	// maximum image size.
var defaultImageWidth = 500;	// maximum image size.

var timer;

var previewImg;

function truebody(){
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

//====================================================================================================
//	Function Name	:	popupWin
//----------------------------------------------------------------------------------------------------
//var divPopup = 0;

function popupWin(title, content, w, h) {

    var x = (truebody().clientWidth-w)/2;
    var y = (truebody().clientHeight-h)/2;

	if(navigator.userAgent.indexOf("MSIE")!=-1 && navigator.userAgent.indexOf("Opera")==-1 ){
		y = 250;
	}

	var divWindow 	= document.createElement('div');

	divWindow.setAttribute('id', 'divPopup');
//	divWindow.innerHTML 		= '<table cellpadding=0 cellspacing=1 width=100% height=' + h + ' border=0 class=popupTable><tr><td width=99% class=popupTitle><div id=divPopupTitle>' + title + '</div></td><td class=popupTitle width=5 style="cursor:pointer;" onClick=JavaScript:document.body.removeChild(document.getElementById("divPopup"));DisableBodyArea(false);>&nbsp;X&nbsp;</td></tr><tr><td colspan=2 valign=top class=popupBody><div id=divPopupContent style="height:'+ (h-10) +'px;overflow:auto;">' + content + '</div></td></tr></table>';


	divStr			= '';
	divStr = divStr + '<div style="position:absolute;">';
		divStr = divStr + '<iframe frameborder="0" width="100%" style="position:absolute;"></iframe>';
		divStr = divStr + '<div style="position:relative; width:100%; " class=popupTable>';
		//divStr = divStr + '<div style="position:relative; width:100%; height:' + h + ';" class=popupTable>';
			divStr = divStr + '<table cellpadding=0 cellspacing=1 width=100% height=' + h + ' border=0>';
				divStr = divStr + '<tr>';
					divStr = divStr + '<td width=99% class=popupTitle>';
						divStr = divStr + '<div id=divPopupTitle>' + title + '</div>';
					divStr = divStr + '</td>';
					divStr = divStr + '<td class=popupTitle width=5 style="cursor:pointer;" onClick=JavaScript:document.body.removeChild(document.getElementById("divPopup"));DisableBodyArea(false);>&nbsp;X&nbsp;</td>';
				divStr = divStr + '</tr>';
				divStr = divStr + '<tr>';
					divStr = divStr + '<td colspan=2 valign=top class=popupBody>';
						divStr = divStr + '<div id=divPopupContent style="height:'+ (h+50) +'px;overflow:auto;">' + content + '</div>';
						//divStr = divStr + '<div id=divPopupContent style="height:'+ (h-10) +'px;overflow:auto;">' + content + '</div>';
					divStr = divStr + '</td>';
				divStr = divStr + '</tr>';
			divStr = divStr + '</table>';
		divStr = divStr + '</div>';
	divStr = divStr + '</div>';

	divWindow.innerHTML	= divStr;

//	divWindow.innerHTML 		= '<div id=divPopupTitle><div class=flotLeft>' + title + '</div><div class=flotRight width=5 style="cursor:pointer;" onClick=JavaScript:document.body.removeChild(document.getElementById("divPopup"));DisableBodyArea(false);>&nbsp;X&nbsp;</div></div><div class=popupBody><div id=divPopupContent style="height:'+ (h-10) +'px;overflow:auto;">' + content + '</div>';
//	divWindow.innerHTML			= '';
//	divWindow.innerHTML 		= divWindow.innerHTML + '<div id=popupTable>';
//	divWindow.innerHTML 		= divWindow.innerHTML + '<div id=divPopupTitle>'+ title + '</div>';
//	divWindow.innerHTML 		= divWindow.innerHTML + '</div>';

//	divWindow.innerHTML 		= '<div class=flotLeft>' <div class=flotRight width=5 style="cursor:pointer;" onClick=JavaScript:document.body.removeChild(document.getElementById("divPopup"));DisableBodyArea(false);>&nbsp;X&nbsp;</div></div><div class=popupBody><div id=divPopupContent style="height:'+ (h-10) +'px;overflow:auto;">' + content + '</div>';

//	divWindow.style.overflow 	= 'auto';
	divWindow.style.display		= 'none';
	divWindow.style.position 	= navigator.appVersion.indexOf("MSIE")!=-1 ? 'absolute' : 'fixed';
	divWindow.style.zIndex		= 1005;
	divWindow.style.left		= x + 'px';
	divWindow.style.top			= (y-50) + 'px';
	divWindow.style.width		= w + 'px';
	divWindow.style.height		= h + 'px';

	document.body.appendChild(divWindow);

	return true;
}

function popupWinShow() {

	DisableBodyArea(true);
	document.getElementById('divPopup').style.display = '';	
}

function popupWinClose() {
	document.body.removeChild(document.getElementById("divPopup"));
	DisableBodyArea(false);
}
