<!--
// for validation
var iNrErr = 0;
var sErr = "";
var blnProcessing = false;
//---------------------------------------------------------------------------------------
// Navigate to page without showing page name
//--------------------------------------------------------------------------------------
function go_to (f, inURL) {
	f.action = inURL;
	f.submit();
}
//----------------------------------------------------------------------------------------
// Normal Popup Window
//---------------------------------------------------------------------------------------
function win_popup(inURL, inName, inW, inH) {
	if (inName=="") {inName="eCWindow"}
	var windowW=700
	var windowH=500
	mywins = window.open (inURL, inName, "height=600,width=800,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0");
	  	if (!mywins.closed) {
	            // still open
	            mywins.focus();
	     }
		windowX = (screen.width) ? (screen.width-windowW)/2 : 0;
		windowY = (screen.height) ? (screen.height-windowH)/2 : 0;
		mywins.focus();
		if (inW!="" && inW > 0) {windowW=inW;}
		if (inH!="" && inH > 0) {windowH=inH;}
		mywins.resizeTo(windowW,windowH);
		mywins.moveTo(windowX,windowY);
		if (mywins.opener==null) {mywindows.opener = self;}
}
//----------------------------------------------------------------------------------------
// Popup Window - No Menus
//---------------------------------------------------------------------------------------
function win_popup_nm(inURL, inName, inW, inH) {
	if (inName=="") {inName="eCWindow"}
	var windowW=810
	var windowH=600
	var mywins = window.open (inURL, inName, "height=600,width=800,toolbar=no,scrollbars=yes,status=yes,copyhistory=no,resizable=yes,alwaysRaised");
	  	if (!mywins.closed) {
	            // still open
	            mywins.focus();
	     }
		 mywins.name = inName;
		windowX = (screen.width) ? (screen.width-windowW)/2 : 0;
		windowY = (screen.height) ? (screen.height-windowH)/2 : 0;
		mywins.focus();
		if (inW!="" && inW > 0) {windowW=inW;}
		if (inH!="" && inH > 0) {windowH=inH;}
		mywins.resizeTo(windowW,windowH);
		mywins.moveTo(windowX,windowY);
		if (mywins.opener==null) {mywindows.opener = self;}
}
//---------------------------------
// Validate Email Address
//---------------------------------
function validEmail(str) {	
	var emailexp = /^[a-z][a-z_0-9\-\.]+@[a-z_0-9\.\-]+\.[a-z]{2,3}$/i;
	return emailexp.test(str)
}
//--------------------------------------------------
//	Makes String Blank if noting but spaces
//--------------------------------------------------
function AllSpace(str) { 
	for (i=0; i < str.length; i++) {
		if (str.charAt(i) != " ") {
			return str;
		}
	}
	return "";
}
//-----------------------------------------------------------------------------------
// Validate Date DDMMCCYYY
//-----------------------------------------------------------------------------------
function IsValidDate(strDate) 
{
	var ValidDate="0123456789"
	
	if (strDate.length<8){return false;}
	for (var i = 0; i < strDate.length; i++) 
		{
			var ch =strDate.substr(i, 1)
			var a = ValidDate.indexOf(ch, 0)
			if (a == -1){return false;}
		}
	todayDate = new Date();
	var strDay=strDate.substr(0,2)
	var strMonth=strDate.substr(2,2)
	var strYear=strDate.substr(4,4)
	var intDay=parseInt(strDay,10)
	var intMonth=parseInt(strMonth,10)
	var intYear=parseInt(strYear,10)
	var intNowYear = todayDate.getFullYear();
	var intNowDay = todayDate.getDate();
	var intNowMonth = todayDate.getMonth(); // 0 based therefor add 1
	intNowMonth = intNowMonth + 1
	if (intMonth < 1 || intMonth > 12) {return false;}
	if (intYear < 1 || intYear > intNowYear) {return false;}
	if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intDay > 31 || intDay < 1)) 
	{ return false;}
	if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intDay > 30 || intDay < 1)) 
	{ return false;}
	if (intMonth == 2) 
	{
		if (intDay < 1) {return false;}
		if (isLeapYear(intYear) == true) 
		{
			if (intDay > 29) {return false;}
		}
		else 
		{
		if (intDay > 28) {return false;}
		}
	}
	return true;
}
function ValidateKey(f1,f2,f3,f4,f5){
   var key=window.event.keyCode;
   if (f3=='a')   {
     var allowed='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ :;,.?!$%^&*()_+-*{}@~<>&"\'';
   }
   else if (f3=='n')   {
     var allowed='0123456789.-';
   }
   else if (f3=='i')   {
     var allowed='0123456789-';
   }
   else if (f3=='s')   {
     //var allowed=f4;
	 if (f4 == "Numeric Only") {var allowed = '0123456789'; }
	 else 
	 	if (f4 == "Numeric TelNr") {var allowed = '0123456789/- '; }
	 	else if (f4 == "Numeric DialC") {var allowed = '0123456789+ ()'; }
		else if (f4 == "Email") {var allowed = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@.'; }
		else if (f4 == "Email Body") {var allowed = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@.\/)(&#*_-+=;:,.?! 	'; }
		else if (f4 == "CellNr") {var allowed = '0123456789 -+'; }
		else if (f4 == "Currency") {var allowed = '0123456789.'; }
		else
	 		{var allowed=f4;}
   }
   if (f3!='')   {
      if (key!=13)      {
         if (allowed.indexOf(String.fromCharCode(key))==-1)     {
            key=0;
         }
      }
   }
   if (f3=='n'||f3=='i')   {
      if (key==46)      {
         if (f1.value.indexOf('.')>-1)     {
            key=0;
         }
      }
   }

   if (f5=='u')   {
      var newkey=String.fromCharCode(key).toUpperCase();
      key=newkey.charCodeAt(0);
   }
   else if (f5=='l')   {
      var newkey=String.fromCharCode(key).toLowerCase();
      key=newkey.charCodeAt(0);
   }
   window.event.keyCode=key;
}
//--------------------------------------------------
//	Validate all errors and show all at once
//--------------------------------------------------
function formatError(strErr) {
	iNrErr++;
	sErr += "\n" + iNrErr +") "  + strErr
}
//---------------------------------------------------------------------------------------
//  Change Font Sizes
//---------------------------------------------------------------------------------------
function changeFontSize(amt) {  
	for (var sIndex=0;sIndex < document.styleSheets.length;sIndex++){
		var styleSheet=document.styleSheets[sIndex];
		for (var rIndex=0;rIndex < styleSheet.rules.length;rIndex++){
			var rule=styleSheet.rules[rIndex];
			if (""+rule.style.fontSize!="null"){
				var fontSize=parseInt(rule.style.fontSize,10);
				if (!isNaN(fontSize)) {
					if (fontSize<1){fontSize=10;}
					if ((fontSize<=12 && amt > 0) || (amt < 0)){fontSize = fontSize + amt;}
					if (fontSize < 9) {fontSize=9;}
					rule.style.fontSize=fontSize + "px";
						//alert('fontSize new =' +rule.style.fontSize);
				}
			}
		}
	}	
}
//----------------------------------------------------------------------------------------
// Validate the ContactUs.php form
//---------------------------------------------------------------------------------------
function ValidateContactUs (f) {
	iNrErr = 0;
	sErr = "";
	if (blnProcessing) {alert("The form is being processed."); return false;}
// Name is mandatory
	if (AllSpace(f.Name.value) == "") {formatError("Your name is mandatory. Mandatory means you have to enter the information.");}
// Email address is mandatory
	if (AllSpace(f.Email.value) == "") { formatError("You have to enter your email address.");}
	else { if (!validEmail(f.Email.value)) {formatError("Invalid Email Address entered!");}}
// Contact Number
	if (AllSpace(f.DialCode.value) == "" && AllSpace(f.ContactNr.value) == "")  { formatError("You have to enter your contact number.");}
// Message
	if (AllSpace(f.Message.value) == "")  { formatError("Please enter a message.");}
// Was there an error?
	if (iNrErr > 0) {
		if (sErr != "") {alert ("The the following " + iNrErr + " errors were detected during validation.\n" + sErr + "\n\nPlease fix these errors and resubmit.\n");}
		else {alert ("There were " + iNrErr + " errors detected during validation.\n\n Please check the information entered before you resubmit the page.");}
		return false;
	}
	else {
		f.frmaction.value="sendme";
		f.submit();
		blnProcessing = false;
		return true;
	}
}
//----------------------------------------------------------------------------------------
// Validate the Bookings.php form
//---------------------------------------------------------------------------------------
function ValidateBookings (f) {
	iNrErr = 0;
	sErr = "";
	if (blnProcessing) {alert("The form is being processed."); return false;}
	blnProcessing = true;
// Name is mandatory
	if (AllSpace(f.Name.value) == "") {formatError("Your name is mandatory. Mandatory means you have to enter the information.");}
// Email address is mandatory
	if (AllSpace(f.Email.value) == "") { formatError("You have to enter your email address.");}
	else { if (!validEmail(f.Email.value)) {formatError("Invalid Email Address entered!");}}
// Contact Number
	if (AllSpace(f.TelH.value) == "" &&  AllSpace(f.TelW.value) == "" && AllSpace(f.Cell.value) == "") { formatError("You have to enter at least one contact number.");}
// Booking Date
	if (AllSpace(f.Date.value) == "") { formatError("Please specify the date.");}
	else {if (!IsValidDate(f.Date.value)) { formatError("Please enter a valid date in format DDMMCCYYY.");}}
// Nr Guests
	if (AllSpace(f.NrGuests.value) == "") { formatError("Please specify the number of guests that will attend the function.");}
// Was there an error?
	if (iNrErr > 0) {
		if (sErr != "") {alert ("The the following " + iNrErr + " errors were detected during validation.\n" + sErr + "\n\nPlease fix these errors and resubmit.\n");}
		else {alert ("There were " + iNrErr + " errors detected during validation.\n\n Please check the information entered before you resubmit the page.");}
		blnProcessing = false;
		return false;
	}
	else {
		f.submit();
		blnProcessing = false;
		return true;
	}
}
//------------------------------------
// Validate Login Form
//-----------------------------------
function ValidateLogin(f) {
	iNrErr = 0;
	sErr = "";
	if (blnProcessing) {alert("The form is being processed."); return false;}
	blnProcessing = true;
	// Email address is mandatory
	if (AllSpace(f.usr.value) == "") { formatError("You have to enter your email address.");}
	else { if (!validEmail(f.usr.value)) {formatError("Invalid Email Address entered!");}}
	// Password is mandatory
	if (AllSpace(f.pass.value) == "") { formatError("You have to enter your password.");}
	// Was there an error?
	if (iNrErr > 0) {
		if (sErr != "") {alert ("The the following " + iNrErr + " errors were detected during validation.\n" + sErr + "\n\nPlease fix these errors and resubmit.\n");}
		else {alert ("There were " + iNrErr + " errors detected during validation.\n\n Please check the information entered before you resubmit the page.");}
		blnProcessing = false;
		return false;
	}
	else {
		f.frmaction.value = "li";
		f.action = "default.asp";
		f.submit();
		blnProcessing = false;
		return true;
	}
}
//------------------------------------
// Validate Password Form
//-----------------------------------
function ValidatePassword(f) {
	iNrErr = 0;
	sErr = "";
	if (blnProcessing) {alert("The form is being processed."); return false;}
	blnProcessing = true;
	// Email address is mandatory
	if (AllSpace(f.usr.value) == "") { formatError("You have to enter your email address.");}
	else { if (!validEmail(f.usr.value)) {formatError("Invalid Email Address entered!");}}
	// Was there an error?
	if (iNrErr > 0) {
		if (sErr != "") {alert ("The the following " + iNrErr + " errors were detected during validation.\n" + sErr + "\n\nPlease fix these errors and resubmit.\n");}
		else {alert ("There were " + iNrErr + " errors detected during validation.\n\n Please check the information entered before you resubmit the page.");}
		blnProcessing = false;
		return false;
	}
	else {
		f.frmaction.value = "send";
		f.submit();
		blnProcessing = false;
		return true;
	}
}
//-->
