UsAg = window.navigator.userAgent; 
UsAgVers = parseInt(UsAg.charAt(UsAg.indexOf("/")+1),10);
var CurrLayer = "";
var winW = 0;
var winH = 0;


function IsMS() { 
	//return UsAg.indexOf("MSIE") > 0;
	return (navigator.appName.indexOf("Microsoft")!=-1);
}

function layerVisChange(objectStr,visStr) {
	var changeStr;
	var theObj;
	if (document.all) {
		if (visStr == "show") {
			visStr = "visible";
		} else if (visStr == "hide") {
			visStr = "hidden";
		}
		changeStr = "document.all['" + objectStr + "']";
		theObj = eval(changeStr);
		if (theObj) {
			theObj.style.visibility = visStr;
		}
	} else if (document.layers) {
		changeStr = "document.layers['" + objectStr + "']";
		theObj = eval(changeStr);
		if (theObj) {
			theObj.visibility = visStr;
		}
	} else if (document.getElementById) {
		if (visStr == "show") {
			visStr = "visible";
		} else if (visStr == "hide") {
			visStr = "hidden";
		}
		changeStr = "document.getElementById('" + objectStr + "')";
		theObj = eval(changeStr);
		if (theObj) {
			theObj.style.visibility = visStr;
		}
	}
}

function getWindowSize() { 
//To adjust the width and height values taking into accout the scrollbars: 
// in Netscape Navigator: subtract 16 from the width and height 
// in Microsoft Internet Explorer: subtract 20 from the width and height 
//Thus, the code adjusted for scrollbars might look as follows: 
	if (parseInt(navigator.appVersion)>3) {
	 if (navigator.appName=="Netscape") {
	  winW = window.innerWidth-16;
	  winH = window.innerHeight-16;
	 }
	 if (navigator.appName.indexOf("Microsoft")!=-1) {
	  winW = document.body.offsetWidth-20;
	  winH = document.body.offsetHeight-20;
	 }
   }
}

function getLayer(id) {
	if (IsMS()){
		for (i=0; i<document.all.length; i++){
			if    (document.all(i).id == id){
				return document.all(i); 
			}
		}
	}else{
		for (i=0; i<document.layers.length; i++){
			if    (document.layers[i].id == id){
				return document.layers[i]; 
			}
		}	
	}return 0
}

function doHide(id ){
	layerVisChange(id,"hide");
}

function doShow( id ){
	layerVisChange(id,"show");
}

function testMe(id){
	//alert('testMe');
	window.setTimeout(doHide('Invitation'),10);
	alert('testMe');
	}

function showMsg( text,time ){
	var width = 100;
	var height = 10;
	var left;
	var top = 160;
	var offsetH = 100;
    getWindowSize();
	if( winW >600 ){
		left = offsetH +30;
		if( winW > 750 ){
			width = winW - left -50;
		}else{
			width = winW - left;
		}
		//document.write("<div");
		document.write("<layer");
		document.write(" id='InvitationNL' style='position:absolute;width:"+width+"px; height:"+height+"px; ");
		document.write("z-index:1; left:" +left+ "px; top:"+ top+"px; background-color:#cccccc; layer-background-color:#FFcccc; border: 1px none #000000; background-image: url(../images/ornob2.gif); layer-background-image: url(../images/ornob2.gif);'>");
		document.write("<table width='100%'  border=5 cellspacing=1 cellpadding=0><tr><td bordercolor=#FFFF00 class='GreenBold'>");
		if( winW > 1000 ){
		document.write("<br>");
		}
		document.write(text);
		document.write("</td></tr></table>");
//		document.write("</div>");
		document.write("</layer>");
		wait('InvitationNL',time);
	}
}

function wait(id,delay){
	//string="pauseforalert("+delay+");";
	string="doHide('"+id+"');";
	setTimeout(string,delay);
	}
	
function pauseforalert(delay){
	//alert("Ok "+delay/1000+" seconds have elapsed");
	doHide('Invitation');
	}

function doAppear(id){
	alert('testMe');
	if(CurrLayer){
		doHide(CurrLayer);
		layerVisChange(CurrLayer,hide);
		CurrLayer = "";
	}
	else{
		CurrLayer = id;
		doShow(CurrLayer);
	}
}
