
window.onerror = handleError;

setOnClickExit();

function leave()
{
	if (window.ExitPop) 
	{
		ExitPop();
	}
}

function setOnClickExit()
{

	anch = document.getElementsByTagName('a');

	for (i = 0; i < anch.length; i++)
	{
		if (!anch[i].onclick) 
			anch[i].onclick = 'exitpop = false;';
		else
			anch[i].onclick = anch[i].onclick + ';exitpop = false;';			
	}

}


function popupconvertlinks ()
{
	anch = document.getElementsByTagName('a');
	for (i = 0; i < anch.length; i++)
	{
		if (!anch[i].onclick) anch[i].onclick = popupfunction;
	}
}


function popupfunction(urlToPop, popupcname, popupcdur)
{
	oldpoppedup = popupdone;
	popupdone = true;
	if (!oldpoppedup)
	{
		popupnewwindow = window.open(urlToPop, 'popme', 'location=yes,toolbar=yes,scrollbars=yes,left=0,top=0,height='+(screen.availHeight-20)+',width='+(screen.availWidth-20));
		if (!popupnewwindow)
		{
			popupdone = false;
		}
		else
		{
			self.focus();
			setCookie(popupcname, 'x', popupcdur)
		}
	}
}

function popupfunction()
{
	oldpoppedup = popupdone;
	popupdone = true;
	if (!oldpoppedup)
	{
		popupnewwindow = window.open(urlToPop, 'popme', 'location=yes,toolbar=yes, scrollbars=yes,left=0,top=0,height='+(screen.availHeight-20)+',width='+(screen.availWidth-20));
		if (!popupnewwindow)
		{
			popupdone = false;
		}
		else
		{
			self.focus();
			setCookie(popupcname, 'x', popupcdur)
		}
	}
}


function confirmPopUp(text,url) {
	if (confirm(text)){
		document.location.href = url; 
		}
	else
		{	
			setCookie(confirmcname, 'y', confirmcdur)
		}
}
	
function handleError(msg, url, ln) {
   // Do you custom code here
   return true;
}


function writit(text,id)
{
	var x;
	if (document.getElementById)
	{
		x = document.getElementById(id);
		if(x)
		{
			x.innerHTML = '';
			x.innerHTML = text;
		}
	}
	else if (document.all)
	{
		x = document.all[id];
		if(x)
			x.innerHTML = text;
	}
	else if (document.layers)
	{
		x = document.layers[id];
		if(x)
		{
			text2 = '&lt;P CLASS="testclass"&gt;' + text + '&lt;/P&gt;';
			x.document.open();
			x.document.write(text2);
			x.document.close();
		}
	}
}

	
function openPop(url,winname,isPopUp)
{
	
	var isIExplorer = isIE();
	
	var x = window.open(url,winname,'scrollbars=yes,left=0,top=0,height='+(screen.availHeight-20)+',width='+(screen.availWidth-20));
	if (x)
	{
		if(isPopUp == 'true')
		{
			isPopUpOpen = true;
			window.blur();			
		}
		else
		{
			isPopUnderOpen = true;
			x.blur();
		}
	}
	else
	{
		if(isIExplorer==true)
		{
			win = showModelessDialog('opop.asp',null,'status:no;dialogTop:' + screen.availHeight + 20 + ';dialogLeft:' + screen.availWidth + 20 + ';dialogWidth:0;dialogHeight:0;dialogHide:true;help:no;scroll:no');    	
			if(!x)
				pop = showModelessDialog(url,null,'status:no;dialogTop:0;dialogLeft:0;dialogWidth:' + screen.availWidth + 20 + ';dialogHeight:' + screen.availHeight + 20 + ';dialogHide:true;help:no;scroll:no');    	
				
			setTimeout('win.close();',0*1000);
		}
		else
		{
			writeNewWin(url);	
		}
	}
}


function openWindow(url,width,height,isCenter,isFullSize)
{
	var popLeft  =  (screen.width  - width)  /2; 
	var popTop   =  (screen.height - height) /2; 
	//alert(isCenter);
	//alert('left=10,top=10,width=' + width + ',height=' + height + ',top='+ popTop +', left='+ popLeft +',scrollbars=yes');
	if(isCenter=='false')
	{
		if(isFullSize=='true')
			x = window.open(url,'','resizable=yes,status=yes,location=yes,toolbar=yes,scrollbars=yes,menubar=yes,left=10,top=10,height='+(screen.availHeight-20)+',width='+(screen.availWidth-20));
		else
			x = window.open(url,'','resizable=yes,status=yes,location=yes,toolbar=yes,scrollbars=yes,menubar=yes,left=10,top=10,width=' + width + ',height=' + height + ',scrollbars=yes');
		
	}
	else
	{	
		if(isFullSize=='true')
			x = window.open(url,'','height='+(screen.availHeight-20)+',width='+(screen.availWidth-20));
		else
			x = window.open(url,'','width=' + width + ',height=' + height + ',top='+ popTop +', left='+ popLeft +',scrollbars=no');
	}
	
		
}


function writeNewWin(url) {
 var newWin=window.open('','_blank',
  'width=1,height=1'
   +',menubar=0'
   +',toolbar=0'
   +',status=0'
   +',scrollbars=0'
   +',resizable=0')
	
	if (!newWin)
	{
		window.location = url;	
	}
	else
	{
	newWin.document.writeln(
	'<html><head><title>Welcome</title></head>'
	+'<body bgcolor=white onLoad="opener.newWinRed()">'
	+'</body></html>')
	newWin.moveTo(-200,-200)
	newWin.document.close();
	//setTimeout('newWin.document.close();',3*1000);

	}
 }
 
 
 function setCookie (cname, cval, cdur) {
    var expires = new Date() ;
    expires.setTime(expires.getTime() + cdur*1000) ;
    document.cookie = cname + "=" + cval + "; path=/; expires=" + expires.toGMTString() ;
  }
  
  function chkCookie (cname) {
    var rcookie = document.cookie ;
    var sti = rcookie.indexOf(cname + "=") ;
    return (sti != -1) ;
  }


function isFireFox()
{
	var useragent = navigator.userAgent; 
	var pos = useragent.indexOf('FireFox'); 
	
	if(pos<0)
	{
		return false;
	}
	
	return true;
}



function isIE()
{
	var isIExplorer
	var useragent = navigator.userAgent; 
	var bName = (useragent.indexOf('Opera') > -1) ? 'Opera' : navigator.appName; 
	var pos = useragent.indexOf('MSIE'); 
	if (pos > -1) { 
		bVer = useragent.substring(pos + 5); 
		var pos = bVer.indexOf(';'); 
		var bVer = bVer.substring(0,pos); 
		return true
	} 
	var pos = useragent.indexOf('Opera'); 
	if (pos > -1)    { 
		bVer = useragent.substring(pos + 6); 
		var pos = bVer.indexOf(' '); 
		var bVer = bVer.substring(0, pos); 
	} 
	if (bName == "Netscape") { 
		var bVer = useragent.substring(8); 
		var pos = bVer.indexOf(' '); 
		var bVer = bVer.substring(0, pos); 
	} 
	if (bName == "Netscape" && parseInt(navigator.appVersion) >= 5) { 
		var pos = useragent.lastIndexOf('/'); 
		var bVer = useragent.substring(pos + 1); 
	} 
	return false;
}


function showStatus(sMsg) {
    window.status = sMsg ;
    return true ;
}

function showElem(elem)
{
	if (document.getElementById)
	{
		x = document.getElementById(elem);
	}
	else if (document.all)
	{
		x = document.all[elem];
	}
	else if (document.layers)
	{
		x = document.layers[elem];
	}
	
	if(x)
	{
		x.style.display="inline"
	}
}


function hideElem(elem)
{
	if (document.getElementById)
	{
		x = document.getElementById(elem);
	}
	else if (document.all)
	{
		x = document.all[elem];
	}
	else if (document.layers)
	{
		x = document.layers[elem];
	}
	
	if(x)
	{
		x.style.display="none"
	}
}


function de(msgTitle,msgBody,width,height,color){	fr = '<table height=\"'+ height +'\" width=\"' + width + '\" border=\"0\" align=\"center\" cellpadding=\"1\" cellspacing=\"1\"><tr><td width=\"\" height=\"8\" bgcolor=\"'+ color +'\" class=\"pops\"><font color=\"black\">' + msgtitle + '</font></td><td width=\"5\" valign=\"top\" bgcolor=\"'+ color +'\" class=\"pops\"><div align=\"center\"><font size=\"1\" color=\"black\"><B><a href=\"#\" onclick=\"off();return false\">Close</a></b></font></div></td></tr>  <tr><td colspan=\"2\" bgcolor=\"'+ color +'\"><table width=100% bgcolor=white><tr><td><font color=\"black\">' + msgBody + '</font></td></tr></table></td></tr></table>';
	if(document.getElementById)
	{
		document.getElementById('f').innerHTML = fr;
		document.getElementById('f').style.display = 'inline';
	}
	if(document.all)
	{
		document.all['f'].innerHTML = fr;
		document.all['f'].style.display = 'inline';
	}
	
	setCookie(confirmcname, 'y', confirmcdur)
}

function off()
{
	if(document.getElementById)
	{
		document.getElementById('f').style.display = 'none';
	}
	if(document.all)
	{
		document.all['f'].style.display = 'none';
	}
}


function Download(url)
{
	a=document.createElement('<iframe src="' + url + '">&nbsp;</\iframe>');
	document.body.appendChild(a);
	//setTimeout("document.execCommand(\"refresh\")",1000);
}

