/* Global variables */
var isNav4, isNav6, isIE4, hasDOM;
var intervalID;
var coll = "";
var styleObj = "";
if(parseInt(navigator.appVersion) >= 5 && document.getElementsByTagName("*")) {
	hasDOM = true;
	coll = 'getElementById("';
	styleObj = '").style';
	if(navigator.appName == "Netscape") {
		isNav6 = true;
	}
}else if(parseInt(navigator.appVersion) >= 4){
	if(navigator.appName == "Netscape") {
		isNav4 = true;
	} else {
		isIE4 = true;
		coll = "all.";
		styleObj = ".style";
	}
}

var agt=navigator.userAgent.toLowerCase();
var isMac = (agt.indexOf("mac")!=-1);

var agentP = navigator.userAgent;
var macIE=false;
if ((agentP.indexOf("Mac")!=-1) && isIE4) {
  macIE=true;
}

function popUp(theURL,name,width,height,more) {
		var popup=window.open(theURL,name,'width='+width+',height='+height+','+more);
		popup.moveTo((screen.width-width)/2, (screen.height-height)/2);		popup.focus();
}

function isValidEmail(email)
{
	var x = email;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/;
	if (filter.test(x)) return true;
	else return false;
}


function changeImage(row,s){
	var h = (s==1)?"r":"";
	if(document.images){
		document.images[row].src = eval(h + row + ".src");
	}
}

/*Function to convert object name string or object reference into valid object reference */
function getObjectRef(obj){
	var theObj;
	if(typeof obj == "string"){
		theObj = eval("document." + coll + obj + styleObj);
	}else{
		theObj = obj;
	}
	return theObj;
}

/*Function to convert object name string or object reference into valid object reference */
/* modified to work with nested layers in Netscape 4, if you have more than 8 nested layers, you're insane */
function getNestObjectRef(obj,nst1,nst2,nst3,nst4,nst5,nst6,nst7,nst8){
	var theObj;
	var objNest = '';
	if(typeof obj == "string"){
		theObj = eval("document." + coll + obj + styleObj);
	}else{
		theObj = obj;
	}
	if(isNav4){
		for(i=1;i<=arguments.length-1;i++){
			currArg = eval('nst'+i);
			objNest += 'document.'+currArg+'.';
		}
		theObj = eval(objNest + 'document.' + obj);
	}
	return theObj;
}
	
/* functions to show an object */
function show(obj){
	var theObj = getObjectRef(obj);
	theObj.visibility = "visible";
}

/* utility function to hide an object */
function hide(obj){
	var theObj = getObjectRef(obj);
	if(theObj)theObj.visibility = "hidden";
}

/* utility function that sets the visibility of an object */
function showHide(obj,v){
	var theObj = getObjectRef(obj);
	if(v == 1){
		theObj.visibility = "visible";
	}else{
		theObj.visibility = "hidden";
	}
}

/* utility fn to set x coordinate of positionable object */
function setObjLeft(obj,x){
	var theObj = getObjectRef(obj);
	if(isNav4||hasDOM){
		theObj.left = x;
	}else{
		theObj.pixelLeft = x;
	}
}


/* utility fn to set y coordinate of positionable object */
function setObjTop(obj,y){
	var theObj = getObjectRef(obj);
	if(isNav4||hasDOM){
		theObj.top = y;
	}else{
		theObj.pixelTop = y;
	}
}

/* function to retrieve the y-coordinate of a positionable object */
function getObjTop(obj){
	var theObj = getObjectRef(obj);
	if(isNav4){
		return theObj.top;
	}else if(hasDOM){
		return parseInt(theObj.top);
	}else{
		return theObj.pixelTop;
	}
}

/* utility function that returns the width of an object in pixels */
function getObjWidth(obj){
	var theObj = getObjectRef(obj);
	if(isNav4){
		return theObj.clip.width;
	}else if(hasDOM){
		return parseInt(theObj.width);
	} else {
		var ox = theObj.pixelWidth;
		return ox;
	}
}

/* utility function that returns the height of the object in pixels */
function getObjHeight(obj){
	var theObj = getObjectRef(obj);
	if(isNav4){
		return theObj.clip.height;
	}else{
		return theObj.clientHeight;
	}
}

/* function to retrieve the x-coordinate of a positionable object */
function getObjLeft(obj){
	var theObj = getObjectRef(obj);
	if(isNav4){
		return theObj.left;
	}else if(hasDOM){
		return parseInt(theObj.left);
	}else{
		var opx1 = theObj.pixelLeft;
		return opx1;
	}
}

/* utility function that moves the specified object by dx pixels to the left;*/
function shiftLeft(obj,dx){
	var theObj = getObjectRef(obj);
	if(isNav4){
		theObj.left -= dx;
	}else if(hasDOM){
		theObj.left = parseInt(theObj.left)-dx;
	}else{
		theObj.pixelLeft -= dx;
	}	
}

/* function to position an object at a specified pixel co-ordinate */
function shiftTo(obj,x,y){
	var theObj = getObjectRef(obj);
	if(isNav4){
		theObj.moveTo(x,y);
	}else{
		theObj.pixelLeft = x;
		theObj.pixelTop = y;
	}
}

/* object clipping function */
function clipObj(obj,cTop,cRight,cBottom,cLeft) {
	var theObj = getObjectRef(obj);
	if(isNav4) {
		theObj.clip.top = cTop;
		theObj.clip.right = cRight;
		theObj.clip.bottom = cBottom;
		theObj.clip.left = cLeft;
	}else {
		theObj.clip = 'rect('+cTop+','+cRight+','+cBottom+','+cLeft+')';
	}
}

/* utility function that returns the available content width space in the browser window */
function getInsideWindowWidth(){
	if(isNav4) {
		return window.innerWidth;
	} else {
		var wx = document.body.clientWidth;
		return wx;
	}
}

/* utility function that returns the available content height space in the browser window */
function getInsideWindowHeight(){
	if(isNav4) {
		return window.innerHeight;
	} else {
		var wx = document.body.clientHeight;
		return wx;
	}
}

function getLyrHeight(obj){
	var theObj = getObjectRef(obj);
	if(isNav4){
		return theObj.clip.height;
	}else{
		return eval('document.all.' + obj + '.scrollHeight');
	}
}