ns=(document.layers)?true:false;
ns6=(document.getElementById&&!document.all)?true:false;
ie=(document.all)?true:false;
loaded=0;


function init(){
  if (ns){
		yachtsMenu=document.yachtsDiv;
		dealersMenu=document.dealersDiv;
		serviceMenu=document.serviceDiv;
		newsEventsMenu=document.newsEventsDiv;
		resourcesMenu=document.resourcesDiv;
		companyMenu=document.companyDiv;
  }
  if (ns6){
		yachtsMenu=document.getElementById('yachtsDiv').style;
		dealersMenu=document.getElementById('dealersDiv').style;
		serviceMenu=document.getElementById('serviceDiv').style;
		newsEventsMenu=document.getElementById('newsEventsDiv').style;
		resourcesMenu=document.getElementById('resourcesDiv').style;
		companyMenu=document.getElementById('companyDiv').style;
  }
  if (ie){
		yachtsMenu=yachtsDiv.style;
		dealersMenu=dealersDiv.style;
		serviceMenu=serviceDiv.style;
		newsEventsMenu=newsEventsDiv.style;
		resourcesMenu=resourcesDiv.style;
		companyMenu=companyDiv.style;
  }
  loaded=1
}


//Arrays for menu values
yachts=[['Heritage Series','yachts/heritage/index.cfm'],['Eastbay Series','yachts/eastbay/index.cfm'],['Aleutian Series','yachts/aleutian/index.cfm'],['Request Literature','company/forms/requestLiteratureForm.cfm']];
dealers=[['North America','dealers/northAmerica/index.cfm'],['Europe','dealers/europe/index.cfm'],['Australia','dealers/rmarine.cfm'],['Japan','dealers/japan.cfm'],['Mexico','company/forms/emailForm.cfm?a=byronc&d=grandbanks.com&fn=Byron&ln=Cox&co=gbasersm'],['New Zealand','dealers/rmarine.cfm'],['Russia','dealers/europe/htmarine.cfm'],['South America','dealers/southAmerica.cfm'],['S.E. Asia','dealers/seAsia.cfm'],['Contact Me Please','company/forms/requestDealerContactForm.cfm']];
service=[['North America','service/northAmerica/index.cfm'],['Europe','service/europe/index.cfm'],['Parts','newsEvents/pressroom/2007/052107.cfm']];
newsEvents=[['Grand Tour 2006','newsEvents/grandtour/index.cfm'],['Email Newsletter','enews/index.cfm'],['Spray Magazine','newsEvents/sprayMagazine.cfm'],['Press Room','newsEvents/pressroom/index.cfm'],['Library','newsEvents/library.cfm'],['Boat Shows','newsEvents/boatShows.cfm'],['Rendezvous','newsEvents/rendezvous.cfm']];
resources=[['GB Shipstore','shipstore/redirect.cfm'],['Discussion Forums','resources/discussionforums/index.cfm'],['Owners Associations','resources/ownersassociations/index.cfm'],['Parts','newsEvents/pressroom/2007/052107.cfm'],['Insurance','resources/insurance/index.cfm'],['Downloads','resources/downloads.cfm'],['Charters','resources/charters.cfm']];
company=[['GB Difference','company/index.cfm'],['Company Info','company/info/index.cfm'],['Executive Bios','company/info/bios.cfm'],['Awards','company/info/awards.cfm'],['Contact Us','company/contactUs.cfm'],['Careers','company/careers.cfm'],['GB Shipstore','shipstore/redirect.cfm']];


h=0;
newMenu = "yachts";
menuWidth = 136;
function buildMenu(thisMenu, whichLevel){
	if ( document.domain == "www.gbshipstore.com" ){
		thename = "http://www.grandbanks.com"; thetarget = "target=\"_new\"";
		}else{ 
			thename = ""; thetarget ="";}

	whichMenu = eval(thisMenu);
	h=(whichMenu.length-1)*24
	if(ns){
	  if(window.loc!="home"){
			thisDiv="document."+thisMenu+"Div.document"
		}else{
	  	thisDiv="document.main.document."+thisMenu+"Div.document"
		}
	} else {
		thisDiv="document"
	}
	createMenu='';
	createMenu+="<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td onMouseOver=\"hideAll()\"><ilayer><layer onMouseOver=\"hideAll()\"><img src=\""+whichLevel+"images/spacer.gif\" width=\"20\" height=\""+h+"\" alt=\"\" border=\"0\"></layer></ilayer></td><td valign=\"middle\"><table border=\"0\" class=\"tblHeaderFooterBackground\" cellspacing=\"1\" cellpadding=\"0\">"
  for(var x=0;x<whichMenu.length; x++){
		href=whichLevel+whichMenu[x][1];
		label=whichMenu[x][0];
		
		createMenu+="<tr height=\"20\"><a href=\""+href+"\"><td valign=\"middle\" class=\"topNavLinks\" bgcolor=\"#7498B6\" onMouseOver=\"this.className='tnavMenuHiLite';\" onmouseout=\"this.className='tnavMenuPlain';\">&nbsp;<a href=\" "+thename+""+href+"\" class=\"topNavLinks\" onMouseOver='window.status=\""+label+"\";return true'  onMouseOut=\"window.status='';return true\" "+thetarget+">"+label+"</a><img src=\""+whichLevel+"images/spacer.gif\" height=\"8\" alt=\"\" border=\"0\"></td></a></tr>";
		if(ns6){
			document.getElementById(newMenu+"Div").style.height=h
		}
	}
	createMenu+="</table></td><td onMouseOver=\"hideAll()\"><ilayer><layer onMouseOver=\"hideAll()\" height=\""+h+"\"><img src=\""+whichLevel+"images/spacer.gif\" width=\"20\" height=\"1\" alt=\"\" border=\"0\"></layer></ilayer></td></tr><tr><td colspan=\"3\" onMouseOver=\"hideAll()\"><ilayer><layer onMouseOver=\"hideAll()\"><img src=\""+whichLevel+"images/spacer.gif\" height=\"20\" alt=\"\" border=\"0\"></layer></ilayer></td></tr></table>"
	eval(thisDiv).write(createMenu)
}

function showDiv(state,status,div2){
  if (loaded){ //1,'Yachts','yachtsMenu'
		
		if (state == 1){
			if(div2!='' && div2!=null){
				eval(div2).visibility="visible";
			}
		} else {
			if(div2!='' && div2!=null){
				eval(div2).visibility="hidden";
			}
		}
		window.status = status
  }
}

function hideAll(){
	if (loaded){
		yachtsMenu.visibility="hidden";
		dealersMenu.visibility="hidden";
		serviceMenu.visibility="hidden";
		newsEventsMenu.visibility="hidden";
		resourcesMenu.visibility="hidden";
		companyMenu.visibility="hidden";
	}
}

// Popup Window Functions 
	var newWin;

	function popUp200x150(theUrl){
		var thisUrl = theUrl;
		var theFeatures = "WIDTH=220,HEIGHT=175,resizable=no,scrollbars=no,toolbar=no,status=no,menubar=no";
		if (newWin != null && !newWin.closed) { 
		      newWin.close();
			}
		newWin=window.open(thisUrl,"pop","WIDTH=220,HEIGHT=175,resizable=no,scrollbars=no,toolbar=no,status=no,menubar=no");
		newWin.focus();
	}

	function popUp600x400(theUrl){
		var thisUrl = theUrl;
		var theFeatures = "WIDTH=600,HEIGHT=400,resizable=no,scrollbars=no,toolbar=no,status=no,menubar=no";
		if (newWin != null && !newWin.closed) { 
		      newWin.close();
			}
		newWin=window.open(thisUrl,"pop","WIDTH=600,HEIGHT=400,resizable=no,scrollbars=no,toolbar=no,status=no,menubar=no");
		newWin.focus();
	}


	function popUp640x480(theUrl){
		var thisUrl = theUrl;
		var theFeatures = "WIDTH=640,HEIGHT=480,resizable=no,scrollbars=no,toolbar=no,status=no,menubar=no";
		if (newWin != null && !newWin.closed) { 
		      newWin.close();
			}
		newWin=window.open(thisUrl,"pop","WIDTH=640,HEIGHT=480,resizable=no,scrollbars=no,toolbar=no,status=no,menubar=no");
		newWin.focus();
	}


	function opencredit(){
 		window.open('ccv/ccard.htm', 'ccv', 'width=450,height=320')
	}


	function popUp750x500(theUrl){
		var thisUrl = theUrl;
		var theFeatures = "WIDTH=750,HEIGHT=523,resizable=no,scrollbars=no,toolbar=no,status=no,menubar=no";
		if (newWin != null && !newWin.closed) { 
		      newWin.close();
			}
		newWin=window.open(thisUrl,"pop","WIDTH=750,HEIGHT=523,resizable=no,scrollbars=no,toolbar=no,status=no,menubar=no");
		newWin.focus();
	}


	function opencredit(){
 		window.open('ccv/ccard.htm', 'ccv', 'width=450,height=320')
	}

	
//Fix for Netscape issue with DHTML
myBrowser=navigator.appName
myVersion=navigator.appVersion
var version45=(myVersion.indexOf("4.")!=-1||myVersion.indexOf("5.")!=-1||myVersion.indexOf("6.")!=-1)
//alert(version45)
var NS=(myBrowser.indexOf("Netscape")!=-1 && version45)
if(NS){
 origWidth=innerWidth;
 origHeight=innerHeight;
 window.onresize=reloadAgain();
}

function reloadAgain(){
  if(innerWidth!=origWidth||innerHeight!=origHeight){
    location.reload()
 }
}

function validEmail(email) {
	invalidChars = " /:,;"
	for (i=0; i<invalidChars.length; i++) {	// does it contain any invalid characters?
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) > -1) {
			return false
		}
	}
	atPos = email.indexOf("@",1)			// there must be one "@" symbol
	if (atPos == -1) {
		return false
	}
	if (email.indexOf("@",atPos+1) != -1) {	// and only one "@" symbol
		return false
	}
	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) {					// and at least one "." after the "@"
		return false
	}
	if (periodPos+3 > email.length)	{		// must be at least 2 characters after the "."
		return false
	}
	return true
}

