//<!--
hndl = "";

function closeWindow(){
	if(hndl!=null && hndl!=""){
		hndl.close();
	}
}

function showWindow(url, name, width, height){
	var lt = (window.screen.availWidth - width)/2;
	var tp = (window.screen.availHeight - height)/2;
	var features = 'status=yes,left=' + lt + ',top=' + tp + ',width=' + width + 'px, height=' + height+'px';
	if(hndl!=null && hndl!=""){hndl.close();}
	hndl = window.open(url, name, features, true);
	hndl.focus();	
}

function showScrollWindow(url, name, width, height){
	var lt = (window.screen.availWidth - width)/2;
	var tp = (window.screen.availHeight - height)/2;
	var features = 'scrollbars=yes,status=yes,left=' + lt + ',top=' + tp + ',width=' + width + 'px, height=' + height+'px';
	if(hndl!=null && hndl!=""){hndl.close();}
	hndl = window.open(url, name, features, true);
	hndl.focus();	
}

function showDialog(url, name, width, height){
	features = 'scroll:no; status:no;help:no;dialogWidth:' + width + 'px;dialogHeight:' + height+'px';
	window.showModalDialog(url, null, features);
	//var features = 'width=' + width + 'px, height=' + height+'px';
	//var hndl = window.open(url, 'winItems', features, true);
	//hndl.focus();	
}

function showScrollDialog(url, name, width, height){
	features = 'scroll:yes; status:no;help:no;dialogWidth:' + width + 'px;dialogHeight:' + height+'px';
	window.showModalDialog(url, null, features);
	//var features = 'width=' + width + 'px, height=' + height+'px';
	//var hndl = window.open(url, 'winItems', features, true);
	//hndl.focus();	
}

function showColors(colors, listboxName){
	var lbx = document.getElementById(listboxName);
	for(var i=0;i<colors.length;i++){
		if(colors[i]=='undefined' || colors[i]==null){
			lbx.options[i].style.color = 'black';
		}else{
			lbx.options[i].style.color = colors[i];
		}
	}
}

function hidePanel(pnlName){
	var pnl = document.getElementById(pnlName);
	pnl.style.visibility='hidden';
	
	var o = document.getElementById('pnlItems');
	if(o!=null && o!='undefined'){
		o.innerText='';
	}
}

// ------------- print functions  -------------
	var WSHShell;
	var myHeader;
	var myFooter;

	function setHeader(){
	try{
		WSHShell = new ActiveXObject("WScript.Shell");
		myHeader = WSHShell.RegRead("HKCU\\Software\\Microsoft\\Internet Explorer\\PageSetup\\header");
		myFooter = WSHShell.RegRead("HKCU\\Software\\Microsoft\\Internet Explorer\\PageSetup\\footer");

		WSHShell.RegWrite("HKCU\\Software\\Microsoft\\Internet Explorer\\PageSetup\\header", "");
		WSHShell.RegWrite("HKCU\\Software\\Microsoft\\Internet Explorer\\PageSetup\\footer", "&bDesigned & Developed by 2BEngineer. All Rights Reserved for Adaleh.____________&p/&P");
	}catch(e){
		return(false);
	}
	return(true);
	}

	function resetHeader(){
		try{
			var WSHShell = new ActiveXObject("WScript.Shell");
			WSHShell.RegWrite("HKCU\\Software\\Microsoft\\Internet Explorer\\PageSetup\\header", myHeader);
			WSHShell.RegWrite("HKCU\\Software\\Microsoft\\Internet Explorer\\PageSetup\\footer", myFooter);
		}catch(e){
			return(false);
		}
		return(true);
	}

	function printPage(){
		document.all('spnLowerPrint').innerHTML = '';
		document.all('spnUpperPrint').innerHTML = '';
		
		window.print();
		window.close();
		return;

		if(setHeader()){
			var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
			document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
			execScript("on error resume next: WebBrowser1.ExecWB 6, -1", "VBScript");
			execScript('on error resume next: WebBrowser1.outerHTML = ""', 'VBScript');
			window.setTimeout('resetHeader()',3000);
			window.close();
		}else{
			// var msg = 'You have to enable ActiveX Controls in order to print this page.\nDo you want to read more about this?';
			var msg = 'You have to enable ActiveX Controls in order to print this page';
			alert(msg);
			window.close();
	/*
			if(confirm(msg)){
				resetHeader();
				history.go(0);
				// document.location.href = 'activeX.htm';
			}else{
				window.close();
			}
	*/
		}
	}
//-->
