// JavascriptStore

var isNS = (navigator.appName.indexOf("Netscape")!=-1);

function OpenDialogWindow(url, name, w, h)
{
	t = (screen.height/2)-(h/2);
	l = (screen.width/2)-(w/2);	
	win = window.open(url, name, 'toolbar=0, status=1, menubar=0, location=0, resizable=1, scrollbars=auto, dependent=1, width=' + w + ', height=' + h + ', top=' + t + ', left=' + l);
	win.focus();
}

function GetDialogResult(command, parameter)
{
	FindObject('DialogResultCommand').value=command;
	FindObject('DialogResultParameter').value=parameter;
	FindObject('DialogResultIsReceipt').value='1';
	FindObject('Form1').submit();
}

function Popup(url,name,w,h,rs,sc,mn)
{
	t = (screen.height/2)-(h/2);
	l = (screen.width/2)-(w/2);
	return window.open(url,name,'toolbar=0, status=1, menubar=' + mn + ', location=0, resizable=' + rs + ', scrollbars=' + sc + ', dependent=1, width=' + w + ', height=' + h + ', top=' + t + ', left=' + l);
}

// End Javascript store

// BasePage Scripts

function ScreenLock__()
{
	var myDiv = FindObject('__prcssDiv');
	myDiv.style.display = 'block'; 
	myDiv.style.height = window.screen.availHeight;   
	myDiv.style.width = window.screen.availWidth;
	myDiv.style.top = document.body.scrollTop;
	theForm = document.forms[0];
	for (i = 0; i < theForm.elements.length; i++) 
	{
		element = theForm.elements[i];
		if (element.tagName.toLowerCase() == 'select')
			element.style.visibility = 'hidden';
	}
}

function EnableScreenLock__()
{
	window.onbeforeunload = ScreenLock__;
}


// --

function SendXMLRequest(params, pageNameToRequest)
{
	var pageUrl = pageNameToRequest + '?callback=true&param=' + params;
	var xmlRequest;

	if (window.XMLHttpRequest) 
		xmlRequest = new XMLHttpRequest();
	else if (window.ActiveXObject) 
		xmlRequest = new ActiveXObject('Microsoft.XMLHTTP');
		
	xmlRequest.open('POST', pageUrl, false);
	xmlRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlRequest.send(null);

	return xmlRequest;
}

// --

function AvoidHistoryBack__()
{
	if (window.history.length > 0)
		window.history.forward();
}

// --

function SendWindowClosed__() 
{
	if (window.event.clientX < 0 && window.event.clientY < 0)
	{
		//Popup('SignOut.aspx',200,200,0,0)
		SendXMLRequest('WindowClosed',window.document.location);
	}
	return true;
}

function EnableWindowClosed__()
{
	window.onunload = SendWindowClosed__;
}
		
// END BasePageScripts			

function FindObject(n, d)
{
	
	var p,i,x;  if(!d) d=document; 
	
	if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; 
		n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x=d.all[n]; 
		for (i=0;!x&&i<d.forms.length;i++) 
			x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++)
			x=FindObject(n,d.layers[i].document)
		if(!x && document.getElementById) 
			x=document.getElementById(n); 
	return x;
}

function Toggle(id)
{
	var object = FindObject(id);
	if ( object )
	{
		if ( object.style.display == 'block')
			object.style.display = 'none';
		else
			object.style.display = 'block';
	}
}
