// ---------------------------------------------------------------------------------------
// browser sniffer, defines variables for the rest of the functions below to use.

ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false
sNS6 = (!document.all && document.getElementById) ? true : false;


var g_el =0;
var IF_PADDING = 90;

// ---------------------------------------------------------------------------------------
// Rollover code when using images

function swapimg(name, state){
if (state == "on") document.images[name].src="/images/rollovers/"+name+"_on.gif";
else if (state == "off")  document.images[name].src="/images/rollovers/"+name+"_off.gif";
}

// ---------------------------------------------------------------------------------------
// Rollover code when using images DEC 31 added ........

function swapimgPath (name, state, path){
if (state == "on") document.images[name].src=path+name+"_on.jpg";
else if (state == "off")  document.images[name].src=path+name+"_off.jpg";
}


// ---------------------------------------------------------------------------------------
// Rollover code when using images

function SwapImgExternal(name, state){
if (state == "on") document.images[name].src="http://dev.royallepage.ca/images/rollovers/"+name+"_on.gif";
else if (state == "off")  document.images[name].src="http://dev.royallepage.ca/images/rollovers/"+name+"_off.gif";
}

// ---------------------------------------------------------------------------------------

// resizes page to its proper dimension

function resizeFix() {
	if(widthCheck != window.innerWidth || heightCheck != window.innerHeight) {
		window.location.reload();
   }
}


// ---------------------------------------------------------------------------------------
// handles netscape resizing problem by forcing to reload when window is resized

if(ns4) {
	widthCheck = window.innerWidth;
    	heightCheck = window.innerHeight;
    	window.onresize = resizeFix();
}


// ---------------------------------------------------------------------------------------
//To be used for popup windows all parameters passed

function popup_all(topic,namer,tool,loc,dir,stat,menu,scroll,resize,x,y) {
eval('window.open(topic, namer, "history=no,toolbar='+tool+',location='+loc+',directories='+dir+',status='+stat+',menubar='+menu+ ',scrollbars='+scroll+',resizable='+resize+',width=' +  x  + ',height=' +  y + '");');
}
// ---------------------------------------------------------------------------------------
//Close window function

function closeMe() {
	window.close();
}

// ---------------------------------------------------------------------------------------
//Function used for Navigation on PC IE 5.x

function over (a) {
	a.className+=" over";
}
function off (a) {
	a.className=a.className.replace(" over", "");;
}

startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");


		// ******** krishan added 
		if (navRoot == null) {
			return;
		}

		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className =" over";
				}
				node.onmouseout=function() {
					
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}

window.onload=startList;

function setSelected (id) {
	//alert (document.location.href);
	var id = "nav";
	var d = document;
	el = d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
	if (el == null) {
		return;
	}
	var x = el.getElementsByTagName("A");
	for (i=0;i<x.length;i++) {
		if (x.item(i).toString() == document.location.href) {

//alert (document.location.href);
			
			if (x.item(i).className == "Sub") {
				x.item(i).parentNode.parentNode.parentNode.firstChild.className = "selected";
				x.item(i).className = "SubSelected";
			}
			else {
				x.item(i).className = "selected";
			}
		}
	}

}



function checkEmail(myForm) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.Email.value)){
return (true)
}
alert("Invalid E-mail Address! Please re-enter.")
return (false)
}

var JSbanner = "";
function changeImage () {
	var id = "bannerImage";
	var d = document;
	el = d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
	if ( JSbanner != "" ) {
		el.src =  JSbanner;
	}
}


function init() {
	changeImage ();
	startList ();
	setSelected ();
}

function initb(a) {
//	alert ("jere");
	a.onmouseover=null;
	checkLinks ();
	startList ();
}



window.onload=init;


