// JavaScript Document
$(function () {
$(".tellfriend").click(function() {
var tellf = $("input#tellf").val();
if (tellf=="" || tellf=='enter email..') {
alert("Please Enter Email Address");
return false;
}
else
{
var dataString = 'tellf='+ tellf;
$.ajax({
type: "POST",
url: "submitmaillist.php",
data: dataString,
success: function(){
alert("Email Sucessfully Sent.");
document.forms['tellfr'].reset();
}
});
}
return false;
});
});
$(function () {
$(".newslet").click(function() {
var mailname = $("input#mailname").val();
var newsemail = $("input#newsemail").val();
if (mailname==""|| mailname=='Name' || newsemail=="" || newsemail=='Email') {
alert("Please provide Name and Email address.");
return false;
}
else
{
var dataString = 'mailname='+ mailname + '&newsemail=' + newsemail;
$.ajax({
type: "POST",
url: "submitmaillist.php",
data: dataString,
success: function(){
alert("Thank you for Signing up for Newsletter.");
document.forms['newslettermail'].reset();
}
});
}
return false;
});
});
   $(function () {
$('.error').hide();
$(".echdetails").click(function() {  
$('.error').hide();
 var phone = $("input#phone").val(); 
 var address1 = $("input#address1").val(); 
 var address2 = $("input#address2").val();
 var town = $("input#town").val();
 var county = $("input#county").val();
 var postcode = $("input#postcode").val(); 
 if (isNaN(phone)|| phone==" ` ( )  \\ ~ ! @ ^ & * + \" | : =  , < > " || phone == "" || address1 == "" || address2 == "" || town =="" || county =="" || postcode == "" ){	
	if (address1 == "") {  
      $("label#address1_error").show();  
      $("input#address1").focus();  
	}	
	
	if (town == "") {  
      $("label#town_error").show();  
      $("input#town").focus();  
	}
	if (county == "") {  
      $("label#county_error").show();  
      $("input#county").focus();  
	}
	if (postcode == "") {  
      $("label#postcode_error").show();  
      $("input#postcode").focus();  
	}	
	if (isNaN(phone)||(phone==" ` ( )  \\ ~ ! @ ^ & * + \" | : =  , < > ") || (phone=="") ) {
      $("label#phone_error").show();  
      $("input#phone").focus();  
    } 	  
return false; 
}
else
{document.updateacc.submit();}
  });  
});
$(function () {
$("input#retypepass").blur(function() {
var password = $("input#password").val();
var retypepass = $("input#retypepass").val();
if (password != retypepass ) {
$("label#repass_error").show();
} else{ $("label#repass_error").hide();
}
});
});
   $(function () {
$('.error').hide();
$(".button").click(function() {  
$('.error').hide();
 var name = $("input#name").val();
 var lastname = $("input#lastname").val();
 var email = $("input#email").val();  
 var password = $("input#password").val(); 
 var retypepass = $("input#retypepass").val(); 
 var phone = $("input#phone").val(); 
 var address1 = $("input#address1").val(); 
 var address2 = $("input#address2").val();
 var town = $("input#town").val();
 var county = $("input#county").val();
 var postcode = $("input#postcode").val();
 error = "";
 strng=password;   
    if ((strng.length < 6) || (strng.length > 12)) {
       error += "Must be 6 to 12 chars.\n";
    }    
 if (name == "" || lastname == "" || email == "" || password == "" || password != retypepass || isNaN(phone)|| phone==" ` ( )  \\ ~ ! @ ^ & * + \" | : =  , < > " || address1 == "" || town =="" || county =="" || postcode == "" || error!='' ){
 	
	if (lastname == "") {  
      $("label#last_error").show();  
      $("input#lastname").focus();  
	}
	
	if (email == "") {  
      $("label#email_error").show();  
      $("input#email").focus();  
    }
	if (password == "" ) {  
      $("label#pass_error").show();  
      $("input#password").focus();  
    }  
	
	if (password != retypepass ) {  
      $("label#repass_error").show();  
      $("input#retypepass").focus();  
    } 
	
	if (isNaN(phone)||(phone==" ` ( )  \\ ~ ! @ ^ & * + \" | : =  , < > ") ) {
      $("label#phone_error").show();  
      $("input#phone").focus();  
    } 
	
	if(error!=''){
 document.getElementById('invalid_pass').innerHTML=error;
      $("label#invalid_pass").show();  
 }
	
	if (address1 == "") {  
      $("label#address1_error").show();  
      $("input#address1").focus();  
	}
	
	
	
	if (town == "") {  
      $("label#town_error").show();  
      $("input#town").focus();  
	}
	
	if (county == "") {  
      $("label#county_error").show();  
      $("input#county").focus();  
	}
	
	if (postcode == "") {  
      $("label#postcode_error").show();  
      $("input#postcode").focus();  
	}
	
	if (name == "") {  
      $("label#name_error").show();  
      $("input#name").focus();  
	}
	  
return false; 
}
  });  
});


   $(function () {
$('.error').hide();
$(".rsbutton").click(function() {  
$('.error').hide();
 var password = $("input#newpassword").val(); 
 
 error = "";
 strng=password;
    var illegalChars = /[\W_]/; // allow only letters and numbers
    if ((strng.length < 6) || (strng.length > 12)) {
       error += "error";
    }
    if (illegalChars.test(strng)) {
      error += "error";
    }
 if (!((strng.search(/[a-z]+/) > -1)
  && (strng.search(/[A-Z]+/) > -1)
  && (strng.search(/[0-9]+/) > -1))) {
  error += "error";
  }
 
 if (password == "" || error!='' ){
 	
	if (password == "" ) {  
      $("label#newpass_error").show();  
      $("input#newpassword").focus();  
    }
	
	if(error!=''){
      $("label#invalid_pass").show();  
 }
	
return false; 
}
else
{document.loginform.submit();}
  });  
});



   $(function () {
$('.error').hide();
$(".button1").click(function() {  
$('.error').hide();
 var address1d = $("input#address1d").val(); 
 var address2d = $("input#address2d").val();
 var townd = $("input#townd").val();
 var countyd = $("input#countyd").val();
 var postcoded = $("input#postcoded").val();
 var comments = $("textarea#comments").val();
 if (address1d == "" ||  townd =="" || countyd =="" || postcoded == "" || comments.length>250){
 	
	if(comments.length>255){
	$("label#comments_error").html("Comments should not exceed 255 chars. You entered <b>"+comments.length+"</b> chars!");
	$("label#comments_error").show();
      $("textarea#comments").focus();  
	}
	
	if (postcoded == "") {  
      $("label#postcoded_error").show();  
      $("input#postcoded").focus();  
	}
	
	if (countyd == "") {  
      $("label#countyd_error").show();  
      $("input#countyd").focus();  
	}
	
	if (townd == "") {  
      $("label#townd_error").show();  
      $("input#townd").focus();  
	}
	
	if (townd == "") {  
      $("label#townd_error").show();  
      $("input#townd").focus();  
	}
	
	
	
	if (address1d == "") {  
      $("label#address1d_error").show();  
      $("input#address1d").focus();  
	}
return false; 
}
else
{document.confirmord.submit();}
  });  
});

$(function () {
$("input#retypepass1").blur(function() {
var password = $("input#npassword").val();
var retypepass = $("input#retypepass1").val();
if (password != retypepass ) {
$("label#repass_error1").show();
} else{ $("label#repass_error1").hide();
}
});
});

 $(function () {
$('.error').hide();
$(".echpas").click(function() {  
$('.error').hide();
 
 var npassword = $("input#npassword").val(); 
 var retypepass = $("input#retypepass1").val(); 
  error = "";
 strng=npassword;  
    if ((strng.length < 6) || (strng.length > 12)) {
       error += "Must be 6 to 12 chars.\n";
    } 
 if (npassword == "" || npassword != retypepass || error!=''){
	
	if (npassword != retypepass ) {  
      $("label#repass_error1").show();  
      $("input#retypepass1").focus();  
    } 
	if (npassword == "" ) {  
      $("label#npass_error").show();  
      $("input#npassword").focus();  
    } 
	
	if(error!=''){
 document.getElementById('invalid_pass').innerHTML=error;
      $("label#invalid_pass").show();  
 	}
		  
return false; 
}
else
{document.resetpass.submit();}
  });  
});

$(function () {
$('.error').hide();
$(".enbutton").click(function() {  
$('.error').hide();
 var name = $("input#name").val();
 var enemail = $("input#enemail").val();  
 var phone = $("input#phone").val(); 
 var subject = $("input#subject").val();
 var comments = $("textarea#comments").val(); 
 if (name == "" || isNaN(phone)|| phone==" ` ( )  \\ ~ ! @ ^ & * + \" | : =  , < > "  || enemail == "" || comments.length>255){
 	if(comments.length>255){
	$("label#comments_error").html("Comments should not exceed 255 chars. <br/><br/>You entered <b>"+comments.length+"</b> chars!");
	$("label#comments_error").show();  
      $("textarea#comments").focus();  
	}
  	if (enemail == "") {  
      $("label#enemail_error").show();  
      $("input#enemail").focus();  
    }
	if (isNaN(phone)||(phone==" ` ( )  \\ ~ ! @ ^ & * + \" | : =  , < > ") ) {  
      $("label#phone_error").show();  
      $("input#phone").focus();
    }   
	if (name == "") {  
      $("label#name_error").show();  
      $("input#name").focus();  
	}  
return false; 
}
else
{
var dataString = 'name='+ name + '&enemail=' + enemail + '&phone=' + phone + '&subject=' + subject + '&comments=' + comments;
$.ajax({
type: "POST",
url: "submitmaillist.php",
data: dataString,
success: function(){
alert("Thank you for your enquiry. We will contact you soon.");
document.forms['contactdetails'].reset();
}
});
}
return false;
});
});


