browserName = navigator.appName;          
browserVer = parseInt(navigator.appVersion);

hasImageSupport  = false;
hasInvalidFields = false;

buttonLoc = relativePath + "images/btn_";
buttonName = new Array ('contact','gallery','home','products','services');

var arrow_on = new Image ();
arrow_on.src = "images/arrow_on.gif";
var arrow_off = new Image ();
arrow_off.src = "images/arrow_off.gif";

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;

var current_button_on = "";   
function buttonAction (imgName, isItOn) {   
  if (hasImageSupport) {
      if (isItOn) {
         document[imgName].src = eval(imgName + "_on.src");
		 current_button_on = imgName;
      } else {
         document[imgName].src = eval (imgName + "_off.src");
		 current_button_on = "";		 
      }
   }
}

function buttonArrowAction (target, isItOn)
{
  if (hasImageSupport) {
      if (isItOn) {
         document[target].src = arrow_on.src;
      } else {
         document[target].src = arrow_off.src;
      }
   }
}

function hideMainButton ()
{
	for (var i =0; i < buttonName.length; i++)
	{
		var tmp = document[buttonName[i]].src;
		
		if (tmp.indexOf("_on.gif") != -1)
		  document[buttonName[i]].src = eval (buttonName[i] + "_off.src");
	}
	hideActiveMenus()
}

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 viewImage (filename, width, height,scroll,title)
{
	var tmp = filename.split ("/");
	var str = 'toolbar=0,scrollbars='+scroll+',location=0,statusbar=0,menubar=1,resizable=1,width='+width+',height='+height

	var html ='<html>\n<head>\n<title>'+title+'</title></head>\n';
	html += '<body bgcolor="white" leftmargin=0 rightmargin=0 topmargin=0 bottommargin=0 marginwidth=0 marginheight=0>\n';
	html += '<a href="javascript:window.close();"><img src="'+filename+'" border=0 alt="Click to Close Window"></a></td></tr></table>';
	html += '\n</body>\n</html>';

	var win = window.open("","_blank", str);
	win.document.open("text/html", "replace");	
	win.document.write(html);
	win.document.close();
	win.window.focus();	
}

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))
			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;
}
