// suckerfish menus

sfHover = function() {
	var sfEls = document.getElementById("globalNavigation").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
	
	// add global backdrop
	document.getElementById("globalNavigation").onmouseover=function() {
		this.className+=" sfhover";
	}
	document.getElementById("globalNavigation").onmouseout=function() {
		this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
	}

	
}

if (window.attachEvent) window.attachEvent("onload", sfHover);




// swaps out main image in gallery
var galleryImages = [];
var currentImageIndex = 0;
function replaceMainImage(imageNum) {
     document.getElementById('mainImage').innerHTML = '<img src="images/' + galleryImages[imageNum] + '">' ;
     currentImageIndex = imageNum;
}

function nextImage() {
     if (currentImageIndex == galleryImages.length - 1) {
          replaceMainImage(0);
     } else {
          replaceMainImage(currentImageIndex + 1);
     }
}

function previousImage() {
     if (currentImageIndex == 0) {
          replaceMainImage(galleryImages.length - 1);
     } else {
          replaceMainImage(currentImageIndex - 1);
     }
}

//-->






    function loadMap(mapnumber) {
      if (mapnumber==1) {
            if (GBrowserIsCompatible()) {
				var map = new GMap2(document.getElementById("map"));
				map.setCenter(new GLatLng(34.698613,-76.700621), 10);
				map.setMapType(G_HYBRID_MAP);
				map.addControl(new GSmallMapControl());
				
				var point = new GLatLng(34.686769,-76.895353);
				var options = { title: "The Nautical Club" };
				var marker = new GMarker(point, options);
				map.addOverlay(marker);
				
				var point = new GLatLng(34.717749,-76.667007);
				var options = { title: "North Carolina Maritime Museum" };
				var marker = new GMarker(point, options);
				map.addOverlay(marker);
				
				var point = new GLatLng(34.698613,-76.700621);
				var options = { title: "Fort Macon State Park" };
				var marker = new GMarker(point, options);
				map.addOverlay(marker);
				
				var point = new GLatLng(34.699143,-76.827736);
				var options = { title: "North Carolina Aquarium at Pine Knolls" };
				var marker = new GMarker(point, options);
				map.addOverlay(marker);
				
				var point = new GLatLng(34.626993,-76.521835);
				var options = { title: "Cape Lookout Lighthouse" };
				var marker = new GMarker(point, options);
				map.addOverlay(marker);
				
				var point = new GLatLng(34.668229,-76.672211);
				var options = { title: "Black Beards Flag Ship ?" };
				var marker = new GMarker(point, options);
				map.addOverlay(marker);
				
				var point = new GLatLng(34.721685,-76.715598);
				var options = { title: "The Carteret County Museum" };
				var marker = new GMarker(point, options);
				map.addOverlay(marker);		
            }
      }
      else if (mapnumber==2) {
            if (GBrowserIsCompatible()) {
                  var map = new GMap2(document.getElementById("map"));
                  map.setCenter(new GLatLng(34.687746,-76.893826), 15);
                  map.setMapType(G_NORMAL_MAP);
        map.addControl(new GSmallMapControl());
            }
      }
      else if (mapnumber==3) {
            if (GBrowserIsCompatible()) {
                  var map = new GMap2(document.getElementById("map"));
                  map.setCenter(new GLatLng(34.68666,-76.895338), 15);
                  map.setMapType(G_NORMAL_MAP);
                  map.openInfoWindowHtml(map.getCenter(),'<a href="http://maps.google.com/maps?daddr=The+Nautical+Club+%4034.686769,-76.895353&geocode=&dirflg=&saddr=&f=d&hl=en&sll=34.768691,-76.756668&sspn=0.307972,0.466919&ie=UTF8&ll=34.688398,-76.895349&spn=0.009633,0.014591&z=16&msa=0&msid=111597189823318720607.00044a02b5664bd5a0a4d">Click here to get directions.</a>');
        map.addControl(new GSmallMapControl());
            }
      }
}


function ecardValidate() {
	var themessage = "Please complete the following fields: ";
	if (document.ecardform.yourname.value=="") {
		themessage = themessage + " - Your Name";
	}
	if (document.ecardform.friendsname.value=="") {
		themessage = themessage + " -  Friend's Name";
	}
	if (document.ecardform.youremail.value=="") {
		themessage = themessage + " -  Your Email Address";
	}
	if (document.ecardform.friendsemail.value=="") {
		themessage = themessage + " -  Friend's Email Address";
	}
	if (document.ecardform.yourmessage.value=="") {
		themessage = themessage + " -  Your Message";
	}
	//alert if fields are empty and cancel form submit
	if (themessage == "Please complete the following fields: ") {
		document.ecardform.submit();
	} else {	
		alert(themessage);
	return false;
	}
}


function contactValidate() {
	var themessage = "Please complete the following fields: ";
	if (document.contactform.firstname.value=="") {
		themessage = themessage + " - First Name";
	}
	if (document.contactform.lastname.value=="") {
		themessage = themessage + " -  Last Name";
	}
	if (document.contactform.address1.value=="") {
		themessage = themessage + " -  Street Address";
	}
	if (document.contactform.city.value=="") {
		themessage = themessage + " -  City";
	}
	
	if (document.contactform.state.value=="") {
		themessage = themessage + " -  State";
	}
	
	if (document.contactform.zipcode.value=="") {
		themessage = themessage + " -  Zip Code";
	}
	
	if (document.contactform.email.value=="") {
		themessage = themessage + " -  E-mail";
	}

	//alert if fields are empty and cancel form submit
	if (themessage == "Please complete the following fields: ") {
		document.contactform.submit();
	} else {	
		alert(themessage);
	return false;
	}
}



function brokerValidate() {
var themessage = "Please complete the following fields: ";
	if (document.brokerform.firstname.value=="") {
		themessage = themessage + " - First Name";
	}
	if (document.brokerform.lastname.value=="") {
		themessage = themessage + " -  Last Name";
	}
	
	if (document.brokerform.company.value=="") {
		themessage = themessage + " -  Company Name";
	}

	if (document.brokerform.address1.value=="") {
		themessage = themessage + " -  Street Address";
	}
	if (document.brokerform.city.value=="") {
		themessage = themessage + " -  City";
	}
	
	if (document.brokerform.state.value=="") {
		themessage = themessage + " -  State";
	}
	
	if (document.brokerform.zipcode.value=="") {
		themessage = themessage + " -  Zip Code";
	}
	
	if (document.brokerform.emailaddress.value=="") {
		themessage = themessage + " -  E-mail";
	}

	if (document.brokerform.officephone.value=="") {
		themessage = themessage + " -  Office Phone Number";
	}

	if (document.brokerform.agentphone.value=="") {
		themessage = themessage + " -  Agent Phone Number";
	}

	if (document.brokerform.broker.value=="") {
		themessage = themessage + " -  Broker Name";
	}


	if (document.brokerform.license.value=="") {
		themessage = themessage + " -  License Number";
	}

	//alert if fields are empty and cancel form submit
	if (themessage == "Please complete the following fields: ") {
		document.brokerform.submit();
	} else {	
		alert(themessage);
	return false;
	}

}





function initNav() {

  if (document.getElementById("activeSubNav") != null) {

     document.getElementById("activeSubNav").style.left="-50px";
     document.getElementById("globalNavigation").style.backgroundImage="url(images/header-subnavigation-background.png)";
     document.getElementById("globalNavigation").style.backgroundRepeat="repeat-x";
     document.getElementById("globalNavigation").style.backgroundPosition="left 30px";
  }
}

function clearNav() {
  if (document.getElementById("activeSubNav") != null) {
    document.getElementById("activeSubNav").style.left="";
    document.getElementById("globalNavigation").style.backgroundImage="";
  }
}




function displayFloorplan(plan) {
	if(plan=="a") {
		document.getElementById("floorplanA").style.display="inline";
		document.getElementById("floorplanB").style.display="none";
		document.getElementById("aLink").className="greenLink";
		document.getElementById("bLink").className="brownLink";
	} else if (plan=="b") {
		document.getElementById("floorplanB").style.display="inline";
		document.getElementById("floorplanA").style.display="none";
		document.getElementById("bLink").className="greenLink";
		document.getElementById("aLink").className="brownLink";
	}
}

