////////////////////////////////////////////////////////////////////////// Javascript function library for Stay In Wales website// 08 January 2003// Gareth Williams <gareth@kerbang.net>////////////////////////////////////////////////////////////////////////function popLateWin(id){	var u = "lates.cfm?idnum=" + id;	window.open(u, "SPECIALS", "toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=390,height=300");	return false;}function popCalWin(id){	var u = "viewcalendar.cfm?idnum=" + id;	window.open(u, "Calendar", "toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=350,height=350");	return false;}function popNewCalWin(id, clientId, siteURL){	//var u = "viewcalendar.cfm?idnum=" + id;	var u = "http://www.myholidayplanner.co.uk/pa/availability.php?pid=" + id + "&clientId=" + clientId + "&siteURL=" + siteURL;	window.open(u, "Calendar", "toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=600,height=460");	return false;}function popByMonthCalWin(categoryId, siteURL){	var u = "http://www.myholidayplanner.co.uk/pa/bymonth.php?categoryid=" + categoryId + "&siteURL=" + siteURL;	window.open(u, "Calendar", "toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=750,height=300");	return false;}function isFormDuplicate(){	//set the message the stupid, stupid user will see...	var m = "You have already submitted this form!";	var c = new String(document.cookie);   	if(c.indexOf(document.location) > -1)	{		alert(m);		return false;	}	else	{		document.cookie = 	window.location.href + " from " + 							document.referrer + "; path=/;";		return true;	}}function bookmarkPage(url){		if(url)	{		var b = new String(url);		var t = b;	}	else	{		var b = document.location.href;		var t = document.title;	}		var n = new String(navigator.appName);		if(n.indexOf("Internet Explorer")) 	{		window.external.AddFavorite(b, t);	}	else	{		alert("To bookmark this site, please press Ctrl+D");	}}//form validation functions an' ting...function isValidEmailAddress(email){	var r = false  	var e = new String(email)  	var i = e.indexOf("@");  	if(i)	{		var d = e.indexOf(".", i);		if ((d > (i + 1)) && (e.length > (d + 1)))		r = true;	}	return r;}function validateBookingForm(f){	//check form in not duplicate	//from stupid user		//if(!isFormDuplicate())	//{	//	return false;	//}	var n = new String(f.name.value);	var t = new String(f.tel.value);	var e = new String(f.email.value);		if(n.length == 0)	{		alert("Please enter your name");		f.name.focus();		return false;	}		if(e.length == 0)	{		alert("Please enter your email address");		f.email.focus();		return false;	}		if(e.length)	{		if(!(isValidEmailAddress(e)))		{			alert("Please enter a valid email address");			f.email.focus();			return false;		}	}		return true;	}function validateTellFriendForm(f){	var n = new String(f.name.value);	var s = new String(f.sender_email.value);	var r = new String(f.recipient_email.value);		if(n.length == 0)	{		alert("Please enter your name");		f.name.focus();		return false;	}		if(s.length == 0)	{		alert("Please enter your email address");		f.sender_email.focus();		return false;	}	else	{		if(!(isValidEmailAddress(s)))		{			alert("Please enter a valid email address");			f.sender_email.focus();			return false;		}		}	if(r.length == 0)	{		alert("Please enter their email address");		f.recipient_email.focus();		return false;	}	else	{		if(!(isValidEmailAddress(r)))		{			alert("Please enter a valid email address");			f.recipient_email.focus();			return false;		}		}		return true;	}    