
    
function getElement(id) {
	if (document.getElementById && document.all) {
	   	return document.getElementById(id);
	} else if (document.getElementById) {
	   	return document.getElementById (id);
	} else if (!document.getElementById && document.all) {
	   	return document.all(id);
	}
}

function DoRightEffect(blOn, obj) {
	if (obj.tagName == "TD") {
		FlickRight(blOn, obj);
	} else {
		var rowColl = obj.rows;
		for (i=0; i<rowColl.length; i++) {
			var cellColl = rowColl[i].cells;
			for (o=0; o<cellColl.length; o++) {
				var oCell = cellColl[o];
				if (oCell.className.indexOf("rightbody")>-1) {
					FlickRight(blOn, oCell);
				}
			}
		}
	}
}

function FlickRight(blOn, obj) {
	if (obj.className == "rightbody" && blOn) {
		obj.className = "rightbody_hover";
	}
	if (obj.className == "rightbody_hover" && !blOn) {
		obj.className = "rightbody";
	}
}


function PostRefSearch() {
	if (event.keyCode == 13) {
		event.cancelBubble = true;
		event.returnValue = false;
		var button = document.getElementById("RefButton");
		if (button != null) {
			button.click();
		}
	}
}
/*

function NewsSubscribe(r, act, o) {
	var isValid = true;
	var oe = o.elements;
	HideError("1");
	HideError("2");
	if (oe["1"].value=="") {ShowError("1");isValid = false;}
	if (!isValidEmail(oe["2"].value)) {ShowError("2");isValid = false;}
	if (isValid) {
		location.href = "/Forms/newsletter.aspx?1="+oe["1"].value+"&2="+oe["2"].value+"&3="+oe["3"].value+"&4="+oe["4"].value+"&5="+oe["5"].value+"&6="+oe["6"].value+"&7="+oe["7"].value+"&act="+act+"&r="+r;
		return true;
	}
	return false;
}
*/
function NewsSubscribe(act,o) {
	var isValid = true;
	var oe = o.elements;
	HideError("1");
	HideError("2");
	if (oe["name"].value=="") {ShowError("1");isValid = false;}
	if (!isValidEmail(oe["email"].value)) {ShowError("2");isValid = false;}
	if (isValid) {
		oe["act"].value = act;
		o.action = "/Forms/newsletter.aspx";
		o.submit();
		return true;
	}
	return false;
}

function ContactRequest(r,o) {
	var isValid = true;
	var oe = o.elements;
	HideError("1");
	HideError("2");
	HideError("3");
	HideError("4");
	HideError("5");
	if (oe["subject"].value=="") {ShowError("1");isValid = false;}
	if (oe["firstname"].value=="") {ShowError("2");isValid = false;}
	if (oe["lastname"].value=="") {ShowError("3");isValid = false;}
	if (oe["email"].value=="" && oe["phone"].value=="") {
		ShowError("4");
		ShowError("5");
		isValid = false;
	}
	if (!oe["email"].value=="" && !isValidEmail(oe["email"].value)) {
		ShowError("4");
		isValid = false;
	}
	if (isValid) {
		o.action = "/Forms/contact.aspx";
		o.submit();
		return true;
	}
	return false;
}



function ShowError(oID) {
	document.getElementById("error"+oID).style.display = "inline";
}

function HideError(oID) {
	document.getElementById("error"+oID).style.display = "none";
}

function isValidEmail(emailAddress) {
	var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
	return re.test(emailAddress);
}


function DoSearch(itemid) {
	location.href = "/?path="+itemid+"&search="+document.getElementById("searchfield").value;
}

function PostSearch(buttonName) {    
	if (event.keyCode == 13) {
		event.cancelBubble = true;
		event.returnValue = false;
		var button = document.getElementById(buttonName);
		if (button != null) {
			button.click(); 
		}
	}
}

function DontPost(buttonName) {    
	if (event.keyCode == 13) {
		event.cancelBubble = true;
		event.returnValue = false;
	}
}

function DoPrint() {
	var loc = location.href;
	var pri = "?print=1";
	if (loc.indexOf("?")>0) {
		pri = "&print=1";
	}
	if (loc.indexOf("#")>0) {
		loc = loc.substring(0, loc.indexOf("#"));
	}
	window.open(loc+pri, "", "toolbar=1,location=0,directories=0,status=0,menubar=yes,scrollbars=yes,resizable=yes,width=769,height=400");
}

function DoLanguage(l) {
	location.href="/?lang="+l;
}



function PrepPrint() {
	for (i=0; i<document.body.all.tags("A").length; i++) {
		document.body.all.tags("A")[i].href = 'JavaScript:void(0)';
		document.body.all.tags("A")[i].target = '';
	}
	for (i=0; i<document.body.all.length; i++) {
		document.body.all[i].setAttribute('onclick','');
	}
	window.print();
}

function DoMail(p, l) {
	var loc = location.href;
	window.open("/global/Email page.aspx?id="+p+"&la="+l+"&loc="+loc, "enzymSend", "toolbar=0,location=0,directories=0,status=0,menubar=no,scrollbars=no,resizable=no,width=450,height=350");
}

function SendLink() {
	var isValid = true;
	var o = document.forms[0];
	var oe = o.elements;
	HideError("1");
	HideError("2");
	if (oe["from"].value=="") {ShowError("1");isValid = false;}
	if (!isValidEmail(oe["to"].value)) {ShowError("2");isValid = false;}
	if (isValid) {
		o.action = "/Forms/email.aspx";
		o.submit();
		return true;
	}
	return false;
}

function PostSailing(elem) {
	if (elem.value!="") {
		var loc = location.href;
		if (loc.indexOf("?")>0) {
			loc = loc.substring(0, loc.indexOf("?"));
		}
		if (loc.indexOf("#")>0) {
			loc = loc.substring(0, loc.indexOf("#"));
		}
		location.href= loc+"?city="+elem.value;
		return true;
	}
	return false;
}

function PostSailingSpec(elem, n) {
	var sTest = QS(n);
	var sCity = QS("city");
	var loc = location.href;
	if (loc.indexOf("?")>0) {
		loc = loc.substring(0, loc.indexOf("?"));
	}
	if (loc.indexOf("#")>0) {
		loc = loc.substring(0, loc.indexOf("#"));
	}
	if (elem.value!="") {
		location.href= loc+"?city="+sCity+"&"+n+"="+elem.value;
		return true;
	} else if (elem.value=="" && sTest!="") {
		location.href= loc+"?city="+sCity;
		return true;
	}
	return false;
}

function PostContact(elem) {
	if (elem.value!="") {
		var loc = location.href;
		if (loc.indexOf("?")>0) {
			loc = loc.substring(0, loc.indexOf("?"));
		}
		if (loc.indexOf("#")>0) {
			loc = loc.substring(0, loc.indexOf("#"));
		}
		location.href= loc+"?location="+elem.value;
		return true;
	}
	return false;
}

function ShiftFromMap(c) {
	var loc = location.href;
	if (loc.indexOf("?")>0) {
		loc = loc.substring(0, loc.indexOf("?"));
	}
	if (loc.indexOf("#")>0) {
		loc = loc.substring(0, loc.indexOf("#"));
	}
	location.href= loc+"?location="+c;
}



//=====================================
// Utilities
//=====================================
function QS(name) {
	var tmp = unescape( location.search.substring(1) );
	var i   = tmp.toUpperCase().indexOf(name.toUpperCase()+"=");
	if ( i >= 0 ) {
		tmp = tmp.substring( name.length+i+1 );
		i = tmp.indexOf("&");
		return( tmp = tmp.substring( 0, (i>=0) ? i : tmp.length ));
	}
	return("");
}