function getInsideWindowWidth() {
	isIE6CSS = (document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ? true : false;
	if (window.innerWidth) {
		return window.innerWidth;
	}
	else if (isIE6CSS) {
		// measure the html element's clientWidtht
		return document.documentElement.clientWidth;
	}
	else if (document.body && document.body.clientWidth) {
		return document.body.clientWidth;
	}
	return 1; // 0 could lead to dividing 0 by 2.
}




function flashcode() {
	var str='';
	str+='<embed width="663" height="280" pluginspage="http:\/\/www.macromedia.com\/go\/getflashplayer" src="flash\/Movie1.swf" play="true" loop="true" menu="true" type="application\/x-shockwave-flash"></embed>'
	document.write(str);
}


function checkAndSubmit1(tF) { //tF = ref to form

	var continueOn = "yes";
	if (tF.name.value == "") { alert("You need to type in your name please."); continueOn = "no"; }
	else if (tF.terms[0].checked) {
			alert("You have not accepted our terms and conditions"); continueOn = "no";
	}

	if ( continueOn  == "yes") {

		str = new String(tF.name.value);
		tF.name.value = replaceSpChars(str);

		str = new String(tF.address.value);
		tF.address.value = replaceSpChars(str);

		str = new String(tF.telephone.value);
		tF.telephone.value = replaceSpChars(str);

		str = new String(tF.email.value);
		tF.email.value = replaceSpChars(str);

		str = new String(tF.guest1.value);
		tF.guest1.value = replaceSpChars(str);

		str = new String(tF.guest2.value);
		tF.guest2.value = replaceSpChars(str);

		str = new String(tF.guest3.value);
		tF.guest3.value = replaceSpChars(str);

		str = new String(tF.guest4.value);
		tF.guest4.value = replaceSpChars(str);

		str = new String(tF.guest5.value);
		tF.guest5.value = replaceSpChars(str);

		str = new String(tF.guest6.value);
		tF.guest6.value = replaceSpChars(str);

		str = new String(tF.guest7.value);
		tF.guest7.value = replaceSpChars(str);
	
		str = new String(tF.dates1.value);
		tF.dates1.value = replaceSpChars(str);

		str = new String(tF.dates2.value);
		tF.dates2.value = replaceSpChars(str);


		tF.action = "http://www.whalesborough.co.uk/cgi-bin/whalesboroughbooking.pl";
		tF.submit();	
	}		
}





function replaceSpChars(str) {
		var re = /=/gi
		str = str.replace(re,"equalsSign")
		re = /&/gi
		str = str.replace(re,"amperSand")
		re = /\+/gi
		str = str.replace(re,"plusSign")
		re = /\n/gi
		str = str.replace(re,"newLineSi")
		return str;
}
		
		
function UnreplaceSpChars(str) {
		var re = /equalsSign/gi
		str = str.replace(re,"=")
		re = /amperSand/gi
		str = str.replace(re,"\&")
		re = /plusSign/gi
		str = str.replace(re,"\+")
		re = /newLineSi/gi
		str = str.replace(re,"\n")
		return str;
}




function checkAndSubmit2(tF) { //tF = ref to form


	var continueOn = "yes";
	var emailOK = checkEmail();
	if ( emailOK != "good" ) {
		continueOn = "no"; 
	}
	else if (tF.name.value == "") { alert("Please type your name."); continueOn = "no"; }
	else if (tF.message.value == "" || tF.message.value == "Enter Your Message Here" ) { alert("Please type your message."); continueOn = "no"; }

	if ( continueOn  == "yes") {

		str = new String(tF.name.value);
		tF.name.value = replaceSpChars(str);

		str = new String(tF.email.value);
		tF.email.value = replaceSpChars(str);

		str = new String(tF.subject.value);
		tF.subject.value = replaceSpChars(str);

		str = new String(tF.message.value);
		tF.message.value = replaceSpChars(str);

		tF.action = "http://www.whalesborough.co.uk/cgi-bin/whalesboroughcontact.pl";
		tF.submit();	
	}		
}




function checkEmail() {
		var myRegExp = / /gi
		str = new String(document.forms[0].email.value)
		str = str.replace(myRegExp,"")
		var myRegExp2 = /\./;
		var myRegExp3 = /\@/;
		var myRegExp4 = /\,/;
		var myRegExp5 = /www\./;

		if ( str.search(myRegExp4) != -1 ) {
		alert("Your email address appears to be wrong - you seem to have typed a comma instead of a full stop. Please correct it and click 'Submit Form' again.");
		return "bad";
		}
		else if ( str.search(myRegExp2) == -1 || str.search(myRegExp3) == -1) {
		alert("Your email address appears to be wrong. Please correct it and click 'Submit Form' again.");
		return "bad";
		}
		else if ( str.search(myRegExp5) != -1 ) {
		alert("Your email address appears to be wrong - it should not contain www. Please correct it and click 'Submit Form' again.");
		return "bad";
		}
		else {
		return "good";
		}
}





