// JavaScript Document
var home_0 = new Image(41,12);
home_0.src = 'images/main-nav-home0.gif';
var home_1 = new Image(41,12);
home_1.src = 'images/main-nav-home1.gif';


var weddings_0 = new Image(72,12);
weddings_0.src = 'images/main-nav-weddings0.gif';
var weddings_1 = new Image(72,12);
weddings_1.src = 'images/main-nav-weddings1.gif';


var fishing_0 = new Image(80,12);
fishing_0.src = 'images/main-nav-fly-fishing0.gif';
var fishing_1 = new Image(80,12);
fishing_1.src = 'images/main-nav-fly-fishing1.gif';


var conferencing_0 = new Image(106,12);
conferencing_0.src = 'images/main-nav-conferencing0.gif';
var conferencing_1 = new Image(106,12);
conferencing_1.src = 'images/main-nav-conferencing1.gif';


var accommodation_0 = new Image(128,12);
accommodation_0.src = 'images/main-nav-accommodation0.gif';
var accommodation_1 = new Image(128,12);
accommodation_1.src = 'images/main-nav-accommodation1.gif';


var contact_0 = new Image(89,12);
contact_0.src = 'images/main-nav-contact-us0.gif';
var contact_1 = new Image(89,12);
contact_1.src = 'images/main-nav-contact-us1.gif';


var reviews_0 = new Image(56,12);
reviews_0.src = 'images/main-nav-reviews0.gif';
var reviews_1 = new Image(56,12);
reviews_1.src = 'images/main-nav-reviews1.gif';

function SwapImage(objectname,objectnewstate) {
	var imageobj = document.getElementById(objectname);
	imageobj.src = this[objectnewstate].src;
}

function includeFlash(areaid,fileName,fWidth,fHeight,bgcolour,wmode) {
	var flashArea = { movie:fileName, width:fWidth, height:fHeight, majorversion:"9", build:"0", xi:"true", bgcolor:bgcolour, wmode:wmode };
	UFO.create(flashArea,areaid);
}

function openMap() {
	window.open("map.html","Map_to_Oxbow_Estate_Office","width=660,scrollbars=yes");
}

function openGallery(id) {	
	switch(id) {
		case 'weddings': window.open("wedding_gallery.html","Weddings_Gallery","width=455,height=653,scrollbars=no");
		break;
		case 'fly_fishing': window.open("flyfishing_gallery.html","Weddings_Gallery","width=600,height=400,scrollbars=no");
		break;
		case 'conferencing': window.open("conferencing_gallery.html","Conferencing Gallery","width=600,height=400,scrollbars=no");
		break;
		case 'accommodation': window.open("accommodation_gallery.html","Accommodation Gallery","width=600,height=400,scrollbars=no");
		break;
	}
}

/* CONTACT US FORM*/
function verifyContactFrm() {
	var theForm = document.getElementById("contactFrm");
	var requiredMessage = "";
	var validateMessage = "";
	var fullMessage = "";
	
	if (theForm.email.value == "") {
		requiredMessage += "\t* Email Address.\n";
	} else if (!isValidEmail(theForm.email.value)) {
		validateMessage += "\t* Email Address.\n";
	}
	
	if (requiredMessage != "") {
		fullMessage += "These fields are required:\n"+requiredMessage;
	}
	if (validateMessage != "") {
		fullMessage += "This field have invalid values:\n"+validateMessage;
	}
	
	if (fullMessage != "") {
		alert(fullMessage);
	} else {
		theForm.submit();
	}
}

function isValidEmail(strEmail){
	validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
	// search email text for regular exp matches
	if (strEmail.search(validRegExp) == -1) {
		return false;
	} 
	return true; 
}

/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
function echeck(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   //alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   //alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		//alert("Invalid E-mail ID")
		return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		//alert("Invalid E-mail ID")
		return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		//alert("Invalid E-mail ID")
		return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		//alert("Invalid E-mail ID")
		return false
	 }
	
	 if (str.indexOf(" ")!=-1){
		//alert("Invalid E-mail ID")
		return false
	 }

	 return true					
}



/* REVIEW FORM*/
function verifyRevFrm() {
	var theForm = document.getElementById("addReview");
	var requiredMessage = "";
	var validateMessage = "";
	var fullMessage = "";
	
	if (theForm.review.value == "") {
		requiredMessage += "\t* Review.\n";
	} 
	if (theForm.name.value == "") {
		requiredMessage += "\t* name.\n";
	} 
	
	if (requiredMessage != "") {
		fullMessage += "These fields are required:\n"+requiredMessage;
	}
	if (validateMessage != "") {
		fullMessage += "This field have invalid values:\n"+validateMessage;
	}
	
	if (fullMessage != "") {
		alert(fullMessage);
	} else {
		theForm.submit();
	}
}



function verifyEvntFrm() {
	var theForm = document.getElementById("Evt");
	var requiredMessage = "";
	var validateMessage = "";
	var fullMessage = "";
	
	if (theForm.page_id.value == "none") {
		requiredMessage += "\t* Page.\n";
	} 
	if (theForm.title.value == "") {
		requiredMessage += "\t* Title.\n";
	} 
	if (theForm.summary.value == "") {
		requiredMessage += "\t* Summary.\n";
	} 
	
	if (requiredMessage != "") {
		fullMessage += "These fields are required:\n"+requiredMessage;
	}
	if (validateMessage != "") {
		fullMessage += "This field have invalid values:\n"+validateMessage;
	}
	
	if (fullMessage != "") {
		alert(fullMessage);
	} else {
		theForm.submit();
	}
}


function verifyNwsFrm() {
	var theForm = document.getElementById("News");
	var requiredMessage = "";
	var validateMessage = "";
	var fullMessage = "";
	
	
	if (theForm.title.value == "") {
		requiredMessage += "\t* Title.\n";
	} 
	if (theForm.summary.value == "") {
		requiredMessage += "\t* Summary.\n";
	} 
	
	if (requiredMessage != "") {
		fullMessage += "These fields are required:\n"+requiredMessage;
	}
	if (validateMessage != "") {
		fullMessage += "This field have invalid values:\n"+validateMessage;
	}
	
	if (fullMessage != "") {
		alert(fullMessage);
	} else {
		theForm.submit();
	}
}
