browserName = navigator.appName;          
browserVer = parseInt(navigator.appVersion);

hasImageSupport  = false;
hasInvalidFields = false;

buttonLoc = relativePath + "images/btn_";
buttonName = new Array ('aboutus','contactus','gallery','products','home');
var height_offset = 0;

for (var cnt=0; cnt < buttonName.length; cnt++) {
	eval ('var '+buttonName[cnt]+'_on = new Image();');
	eval (buttonName[cnt] + '_on.src = "'+buttonLoc + buttonName[cnt] + '_on.gif"');
	eval ('var '+buttonName[cnt]+'_off = new Image();');
	eval (buttonName[cnt] + '_off.src = "'+buttonLoc + buttonName[cnt] + '_off.gif"');
}	

if (browserName == "Netscape" && browserVer >= 3)
   hasImageSupport = true;
else if (browserVer > 3)
   hasImageSupport = true;
   
  
function buttonAction (imgName, isItOn) {   
  if (hasImageSupport) {
      if (isItOn) {
         document[imgName].src = eval(imgName + "_on.src");
      } else {
         document[imgName].src = eval (imgName + "_off.src");
      }
   }
}

function goPopup(url,width,height,scroll,menu)
{
	if (menu == "yes")
		window.open(url, 'newWin', 'width='+width+',height='+height+',scrollbars='+scroll+',menubar=yes,toolbar=yes');	
	else
		window.open(url, 'newWin', 'width='+width+',height='+height+',scrollbars='+scroll);
}


function validForm(formName, msg)
{
	var myForm   = eval ("document."+formName);
	var reqField = (myForm["req"].value).split(",");
	var valid    = true;	
	for (i=0; i < reqField.length; i++)
	{
		var tmp = reqField[i].split("|");
		
		if (tmp[0] == "text" && myForm[tmp[1]].value == "")
			valid = false;
		else if (tmp[0] == "email" && ((myForm[tmp[1]].value).indexOf("@") == -1 || (myForm[tmp[1]].value).indexOf(".") == -1))
		{
			msg  += " Please enter a valid email address.";
			valid = false;
		}
		else if (tmp[0] == "select" && myForm[tmp[1]].options[ myForm[tmp[1]].selectedIndex].value == "")
			valid = false;
		else if (tmp[0] == "option")
		{
			if (tmp[1] == "email" && myForm[tmp[2]].value != "")
			{
				if ((myForm[tmp[2]].value).indexOf("@") == -1 || (myForm[tmp[2]].value).indexOf(".") == -1)
				{
					msg  += " Please enter a valid email address.";
					valid = false;
				}
			}
		} 
	}
	if (!valid)
		alert (msg);
	return valid;
}


function getImageY_Pos (y, imgname) {
	var img = FIND(imgname) || document.images[imgname] || document.links[imgname] || document.anchors[imgname];

	if(!document.layers) {
		var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
		var macIE45 = document.all && !onWindows && getExplorerVersion() == 4.5;
		var par = img;
		var lastOffset = 0;
		while(par){
			if( par.topMargin && !onWindows ) y += parseInt(par.topMargin);
			if( (par.offsetTop != lastOffset) && par.offsetTop ) y += parseInt(par.offsetTop);
			if( par.offsetTop != 0 ) lastOffset = par.offsetTop;
			par = macIE45 ? par.parentElement : par.offsetParent;
		}		
	} else if (img.y >= 0) y += img.y;
	return y;
}


//window.onresize = (document.layers) ? redo:enlarge;

function redo() {
	window.location.reload();
}

function myRuler () {
	if (document.layers) {
		if (window.outerHeight >236 - height_offset)
			myHeight = window.outerHeight-236 - height_offset;
		else
			myHeight = 1;
		document.write ('<img src="'+relativePath+'images/spacer.gif" width="1" height="'+myHeight+'" name="ruler">');	
	} else
		document.write ('<img src="'+relativePath+'images/spacer.gif" width="1" height="1" name="ruler">');
}

function enlarge() {
	if (!noruler) {
		if (browserName == "Netscape" && document.getElementById ) {
			if (window.outerHeight >370 - height_offset)
				document.images['ruler'].height = window.outerHeight -370 - height_offset;	
		} else if (document.all) {
			if (document.body.offsetHeight >236 - height_offset) {
				document.images['ruler'].height = document.body.offsetHeight - 236 - height_offset;
			}
		}
	}
}