<!-- Begin

//Generates the captcha function
function GenerateCaptcha(){    
	var code = '';
	for(i=0; i<=6; i++){
		code += Math.ceil(Math.random() * 9) + '';
	}
	document.getElementById("txtCaptcha").value = code;
	document.getElementById("txtCaptchaDiv").innerHTML = code;	
}
	

// Validate the Entered input aganist the generated security code function   
function ValidCaptcha(){
	var str1 = removeSpaces(document.getElementById('txtCaptcha').value);
	var str2 = removeSpaces(document.getElementById('txtInput').value);
	if (str1 == str2){
		return true;	
	}else{
		return false;
	}
}

// Remove the spaces from the entered and generated code
function removeSpaces(string){
	return string.split(' ').join('');
}




function checkconEmail(myForm) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(stagecontact.Email.value)){
return (true)
}
alert("Invalid E-mail Address! Please re-enter.")
return (false)
}


function checkEmail(myForm) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(stage.email.value)){
return (true)
}
alert("Invalid E-mail Address! Please re-enter.")
stage.email.value="";
stage.email.focus();

return (false)
}


function isAlphabetic(val)
{
	if (val.match(/^[a-zA-Z\'\- ]+$/))
	{
		return true;
	}
	else
	{
		return false;
	}	
}


function isNumber(val)
{
	if (isNaN(val))
	{
		return false;
	}
	else
	{
		return true;
	}	
}

function isAlphaNumeric(val)
{
	if (val.match(/^[a-zA-Z0-9\'\- ]+$/))
	{
		return true;
	}
	else
	{
		return false;
	}	
}

function whitespace(val)
{

	val= (val).replace(/\s+/g,'');
	val=val.toUpperCase();
	stage.postcode.value=val;
}


function isEmail(val) {

	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(val)){return (true)}return (false)
}

function IsTelephone(tele){
	var Phone=tele	

	if (checkInternationalPhone(tele)==false){
		//alert("Please Enter a Valid Phone Number")
		//tele.focus()
		return false
	}
	return true
 }

function validchar(charvalue, fieldname)
{
  var iChars = "!@#$%^&*()+=[]\\\';,./{}|\":<>?";

  for (var i = 0; i < charvalue.length; i++) {
  	if (iChars.indexOf(charvalue.charAt(i)) != -1) {
  	alert ("Special Characters Have Been Detected. \nThese are not allowed.");
	fieldname.value="";
	fieldname.focus();
  	return false;
  	}
  }

}

function checkRequired(frmData) { 
var bFail; 
bFail = false; // Default to pass 

for(iElement = 0; iElement < frmData.elements.length; iElement++) { 

if(frmData.elements[iElement].className == 'RequiredTextBox' || 
frmData.elements[iElement].className == 'FailedTextBox') { 

if(frmData.elements[iElement].value == '') { 
bFail = true; 
frmData.elements[iElement].className = 'FailedTextBox'; 

} else { 

frmData.elements[iElement].className = 'RequiredTextBox'; 

} 

} 

} 

return !bFail; 

} 


function checkForm() { 
if(!checkRequired(document.forms['stage'])) { 

if(document.all) { 
document.all.spanError.innerText = 'Please fill in all required fields.'; 
} else { 
document.getElementById('spanError').innerHTML = 'Please fill in all required fields.'; 
} 
} else { 


var themessage = "";



if (!isAlphabetic(document.stage.firstname.value)){themessage = themessage + "Please Enter Your First Name\n";}
if (!isAlphabetic(document.stage.surname.value)){themessage = themessage + "Please Enter Your Surname\n";}
if (!isEmail(document.stage.email.value)){themessage = themessage + "Please Enter Correct Email\n";}
if (!IsTelephone(document.stage.telephone.value)){themessage = themessage + "Please Enter Your Telephone\n";}
if (!isAlphaNumeric(document.stage.postcode.value)){themessage = themessage + "Please Enter Your Postcode\n";}
//if (!isAlphabetic(document.stage.address1.value)){themessage = themessage + "Please Enter The First Line Of Your Address\n";}
if (!isAlphaNumeric(document.stage.town.value)){themessage = themessage + "Please Enter A Town\n";}

if ( (document.stage.deliverysame.checked==false) && (document.stage.orderplace.value==1) ) {
if (!isAlphabetic(document.stage.dfirstname.value)){themessage = themessage + "Please Enter Your Delivery First Name\n";}
if (!isAlphabetic(document.stage.dsurname.value)){themessage = themessage + "Please Enter Your Delivery Surname\n";}
if (!isAlphaNumeric(document.stage.dpostcode.value)){themessage = themessage + "Please Enter Your Delivery Postcode\n";}
//if (!isAlphabetic(document.stage.daddress1.value)){themessage = themessage + "Please Enter The First Line Of Your Delivery Address\n";}
//if (!isAlphaNumeric(document.stage.dtown.value)){themessage = themessage + "Please Enter A Delivery Town\n";}
}


if(themessage=="") 	{
			document.forms['stage'].submit();
			}
			else{
			alert(themessage);
			}

}
} 

function checkrForm() { 
if(!checkRequired(document.forms['register'])) { 

if(document.all) { 
document.all.rspanError.innerText = 'Please fill in all required fields.'; 
} else { 
document.getElementById('rspanError').innerHTML = 'Please fill in all required fields.'; 
} 
} else { 


document.forms['register'].submit(); 

}
} 

/**
 * DHTML phone number validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

function ValidateForm(tele){
	var Phone=tele	

	if (checkInternationalPhone(tele)==false){
		alert("Please Enter a Valid Phone Number")
		//tele.focus()
		return false
	}
	return true
 }


function callbackForm() { 
if(!checkRequired(document.forms['callback'])) { 

if(document.all) { 
document.all.spancError.innerText = 'Please fill in all required fields.'; 
} else { 
document.getElementById('spancError').innerHTML = 'Please fill in all required fields.'; 

} 
} else { 

var themessage = "";

if ((!isAlphabetic(document.callback.calname.value)) || (document.callback.calname.value=="Full Name")) {themessage = themessage + "Please Enter Your Name\n";}
if ((!isEmail(document.callback.calemail.value)) || (document.callback.calemail.value=="Email Address")) {themessage = themessage + "Please Enter Correct Email\n";}
//if (document.callback.caltelephone.value=="Telephone") {themessage = themessage + "Please Enter Your Telephone\n";}

if(themessage=="") 	{
			document.forms['callback'].submit();
			}
			else{
			alert(themessage);
			}

}
} 


function checksForm() { 
if(!checkRequired(document.forms['stage'])) { 

if(document.all) { 
document.all.spanError.innerText = 'Please fill in all required fields.'; 
} else { 
document.getElementById('spanError').innerHTML = 'Please fill in all required fields.'; 

} 
} else { 

var themessage = "";

//if (document.stage.perDeclerationAgree.checked==false) {themessage = themessage + "Please Accept Our Terms Before Proceeding\n";}
//if (document.stage.perDeclerationAgree.value==false) {themessage = themessage + "Please Accept Our Terms Before Proceeding\n";}

if(document.stage.nenquiry.value==""){themessage = themessage + "Please Tell Us The Nature of Your Enquiry\n";}
//if (!isAlphabetic(document.stage.surname.value)){themessage = themessage + "Please Enter Your Surname\n";}
//if (!isEmail(document.stage.Email.value)){themessage = themessage + "Please Enter Correct Email\n";}
//if (!IsTelephone(document.stage.telephone.value)){themessage = themessage + "Please Enter Your Telephone\n";}
//if (!IsTelephone(document.stage.mobile.value)){themessage = themessage + "Please Enter Your Mobile\n";}
//if (!isAlphaNumeric(document.stage.postcode.value)){themessage = themessage + "Please Enter Your Postcode\n";}
//if (!isAlphabetic(document.stage.address1.value)){themessage = themessage + "Please Enter The First Line Of Your Address\n";}
//if (!isAlphaNumeric(document.stage.town.value)){themessage = themessage + "Please Enter A Town\n";}
//if (!isAlphaNumeric(document.stage.county.value)){themessage = themessage + "Please Enter A County\n";}

if(themessage=="") 	{
			document.forms['stage'].submit();
			}
			else{
			alert(themessage);
			}

}
} 

function checkseForm() { 
if(!checkRequired(document.forms['stage'])) { 

if(document.all) { 
document.all.spanError.innerText = 'Please fill in all required fields.'; 
} else { 
document.getElementById('spanError').innerHTML = 'Please fill in all required fields.'; 

} 
} else { 

var themessage = "";

//if (document.stage.perDeclerationAgree.checked==false) {themessage = themessage + "Please Accept Our Terms Before Proceeding\n";}
//if (document.stage.perDeclerationAgree.value==false) {themessage = themessage + "Please Accept Our Terms Before Proceeding\n";}

//if(document.stage.nenquiry.value==""){themessage = themessage + "Please Tell Us The Nature of Your Enquiry\n";}
//if (!isAlphabetic(document.stage.surname.value)){themessage = themessage + "Please Enter Your Surname\n";}
//if (!isEmail(document.stage.Email.value)){themessage = themessage + "Please Enter Correct Email\n";}
//if (!IsTelephone(document.stage.telephone.value)){themessage = themessage + "Please Enter Your Telephone\n";}
//if (!IsTelephone(document.stage.mobile.value)){themessage = themessage + "Please Enter Your Mobile\n";}
//if (!isAlphaNumeric(document.stage.postcode.value)){themessage = themessage + "Please Enter Your Postcode\n";}
//if (!isAlphabetic(document.stage.address1.value)){themessage = themessage + "Please Enter The First Line Of Your Address\n";}
//if (!isAlphaNumeric(document.stage.town.value)){themessage = themessage + "Please Enter A Town\n";}
//if (!isAlphaNumeric(document.stage.county.value)){themessage = themessage + "Please Enter A County\n";}	 
//if(document.stage.txtInput.value == ""){	themessage = themessage + "Security code should not be empty.\n";}
//if(document.stage.txtInput.value != ""){	if(ValidCaptcha(document.stage.txtInput.value) == false){	themessage = themessage + "Security code did not match.\n";	}}



//if(document.stage.captchases.value!=document.stage.captchacode.value){themessage = themessage + "Please enter the same verification code as shown\n";}

if(themessage=="") 	{
			document.forms['stage'].submit();
			}
			else{
			alert(themessage);
			}

}
} 


function checkfForm() { 
if(!checkRequired(document.forms['stage'])) { 

if(document.all) { 
document.all.spanError.innerText = 'Please fill in all required fields.'; 
} else { 
document.getElementById('spanError').innerHTML = 'Please fill in all required fields.'; 

} 
} else { 

var themessage = "";

if (document.stage.perDeclerationAgree.checked==false) {themessage = themessage + "Please Accept Our Terms Before Proceeding\n";}
//if (document.stage.perDeclerationAgree.value==false) {themessage = themessage + "Please Accept Our Terms Before Proceeding\n";}
if(document.stage.captchases.value!=document.stage.captchacode.value){themessage = themessage + "Please enter the same verification code as shown\n";}

if(themessage=="") 	{
			document.forms['stage'].submit();
			}
			else{
			alert(themessage);
			}

}
} 

function check_date(field){
var checkstr = "0123456789";
var DateField = field;
var Datevalue = "";
var DateTemp = "";
var seperator = "-";
var day;
var month;
var year;
var leap = 0;
var err = 0;
var i;
   err = 0;
   DateValue = DateField.value;
   /* Delete all chars except 0..9 */
   for (i = 0; i < DateValue.length; i++) {
	  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
	     DateTemp = DateTemp + DateValue.substr(i,1);
	  }
   }
   DateValue = DateTemp;
   /* Always change date to 8 digits - string*/
   /* if year is entered as 2-digit / always assume 20xx */
   if (DateValue.length == 6) {
      DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); }
   if (DateValue.length != 8) {
      err = 19;}
   /* year is wrong if year = 0000 */
   year = DateValue.substr(4,4);
   if (year == 0) {
      err = 20;
   }
   /* Validation of month*/
   month = DateValue.substr(2,2);
   if ((month < 1) || (month > 12)) {
      err = 21;
   }
   /* Validation of day*/
   day = DateValue.substr(0,2);
   if (day < 1) {
     err = 22;
   }
   /* Validation leap-year / february / day */
   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
      leap = 1;
   }
   if ((month == 2) && (leap == 1) && (day > 29)) {
      err = 23;
   }
   if ((month == 2) && (leap != 1) && (day > 28)) {
      err = 24;
   }
   /* Validation of other months */
   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
      err = 25;
   }
   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
      err = 26;
   }
   /* if 00 ist entered, no error, deleting the entry */
   if ((day == 0) && (month == 0) && (year == 00)) {
      err = 0; day = ""; month = ""; year = ""; seperator = "";
   }
   /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
   if (err == 0) {
      DateField.value = day + seperator + month + seperator + year;
   }
   /* Error-message if err != 0 */
   else {
      alert("Date is incorrect!");
      DateField.select();
	  DateField.focus();
   }
}
//  End -->
