browserName = navigator.appName;          
browserVer = parseInt(navigator.appVersion);

hasImageSupport  = false;
hasInvalidFields = false;

if (menu_selection == "main")
{
	var buttonName = new Array ('m_canadiansigns','m_contactus','m_krisleesigns','m_services');
	buttonLoc = relativePath + "images/btn_";	
}
else if (menu_selection == "canadian_signs")
{
	var buttonName = new Array ('aboutus','apartment_id','banners','billboards','contacts','careers','clients','custom_displays','digital_images','directories','history','inquire','letters','mission_statement','owners','portfolio','real_estate','regulation','send_artwork','vehicle_graphics','wayfinding','whatwedo');	
	buttonLoc = relativePath + "images/canadian_signs/btn_";	
}
else if (menu_selection == "krislee_signs")
{
	var buttonName = new Array ('aboutus','awnings','careers','channel_letters','clients','contacts','electronic_displays','fascia_bands','history','illuminated_signs','inquire','manual_displays','menu_boards','message_centers','mission_statement','neon','owners','portfolio','pylon_sign','send_artwork','wayfinding');	
	buttonLoc = relativePath + "images/krislee_signs/btn_";		
}
	
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;
			}
		}
	}
}

function viewImage (filename, width, height,menubar)
{
	var str = 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar='+menubar+',resizable=1,width='+width+',height='+height
	var html ='<html>\n<head>\n<title>Preview</title></head>\n';
	html += '<body bgcolor="white" leftmargin=0 rightmargin=0 topmargin=0 bottommargin=0 marginwidth=0 marginheight=0>\n';
	html += '<table border=0 cellpadding=0 cellspacing=0 width="100%" height="100%"><tr><td align=center id="s"><a href="javascript:window.close();"><img src="'+filename+'" width="'+width+'" height="'+height+'" 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();	
}