var errorMsg = new Array();
errorMsg['errMag'] = "We were unable to submit your request. Please enter the information requested.<br>";
errorMsg['title'] = "Please specify your title.";
errorMsg['firstname'] = "Please specify your first name.";
errorMsg['name'] = "Please specify your name.";
errorMsg['surname'] = "Please specify your surname.";
errorMsg['email'] = "Please enter a valid e-mail address.";
errorMsg['reusremail'] = "Please retype your e-mail address,";
errorMsg['password'] = "Please enter your password.";
errorMsg['repassword'] = "Please retype your password.";
errorMsg['phone'] = "Please specify your phone number.";
errorMsg['address1'] = "Please specify your first line of address.";
errorMsg['city'] = "Please specify your city.";
errorMsg['postcode'] = "Please specify your postcode.";
errorMsg['wouldlike'] = "Please specify what you would like us to send you more information on.";
errorMsg['group'] = "Please specify the number of travellers in your group.";
errorMsg['preferreddeparture'] = "Please specify your preferred departure airport.";
errorMsg['howlong'] = "Please specify the duration of your holiday.";
errorMsg['td_departdate'] = "Please specify when you would like to go.";
errorMsg['travelbefore'] = "Please specify if you have travelled with Tapestry before";
errorMsg['feedback'] = "Please give us your feedback.";
errorMsg['accommodationcomment'] = "Please give us your review.";
errorMsg['year'] = "Please specify your holiday year.";
errorMsg['month'] = "Please specify your holiday month.";
errorMsg['masterid'] = "Please specify resort you stayed.";
errorMsg['confirmcheck'] = "Please tick the checkbox for terms and conditions agreement";
errorMsg['hear_about'] = "Please specify how you heard about us.";
errorMsg['hear_about_other'] = "Please specify how you heard about us.";
errorMsg['liketogo'] = "Please specify where you would like to go";
errorMsg['flexibility'] = "Please specify your flexibility for travel dates";
errorMsg['spend'] = "Please specify your holiday budget";
errorMsg['flexibility_comment'] = "Please enter your comments regarding your flexibility to travel in the 'Your comments box'.";
errorMsg['spend_comment'] = "Please enter your comments regarding your holiday budget in the 'Your comments box'.";

//=================================================validation starts===========================
function funSubmit(thisForm)
  { 
   with(thisForm)
   {
    var ctr=0;
    for(var x=0; x<elements.length; x++)
    {
     if(elements[x].getAttributeNode('required') && elements[x].getAttributeNode('required').nodeValue == "Yes")
     {
	  if(!validate(elements[x])){
	  	var elementErrorMsg = errorMsg[elements[x].name];
	        if(elements[x].name == "flexibility" || elements[x].name == 'spend') {
	        	elementErrorMsg = errorMsg[elements[x].name+"_comment"];
	        }
		document.getElementById('spanerrors').innerHTML = "<span class=\"errmsgicon\">"+errorMsg['errMag']+elementErrorMsg+"</span>";
		//window.location.href="#errAnchor";
		
		elements[x].focus();
		if(document.getElementById(elements[x].name)) {document.getElementById(elements[x].name).style.color="red"; }
		return false;
	   }else{
		if(document.getElementById(elements[x].name)) {
			document.getElementById(elements[x].name).style.color="#777777";	
		}
	   }
     }       
    }
    return true;
   }
  }

  function validate(fieldObj)
  { 
	var validtype = '';
	var emailreg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var pwdreg = /[A-Za-z0-9!@#$%-_]{5,12}/;
	var namereg = /[A-Za-z0-9]{2,50}/;
	
	try{
		validtype = fieldObj.getAttributeNode('validationtype').nodeValue;
	}catch(e){
		validtype = 'blank';
	}
   with(fieldObj)
   {
   if(type == "text" || type == "textarea" || type == "select-one" )
    {
     var stripped = value.replace(/[\(\)\.\-\ ]/g, '');
     if((namereg.test(value) == false) && validtype == 'name'){
	  return false;
     }else if((pwdreg.test(value) == false) && validtype == 'password'){
	  return false;
     }else if((emailreg.test(value) == false) && validtype == 'email'){
	  return false;
     }else if((isNaN(parseInt(stripped))) && validtype == 'phone'){
	  return false;
     }else if (value == null || value == "" || value == " " || value == "0"){
      return false;
     } else if(value == 'note' && (name == 'flexibility' || name == 'spend')){
	var commentElement = document.getElementById("comments");
        if(commentElement.value == "") {
		return false;
	} else {
		return true;
	}
     } else if(name == 'td_departdate' && value == "dd/mm/yy") {
     	return false;
     }
     else{
      return true;
     }
    }
    else if(type == "radio")
    {
     var radioElements=document.getElementsByName(name);
     var returnValue=false;

     for (var i=0 ; i < radioElements.length; i++)
     {
      if(radioElements[i].checked)
       returnValue = true;
     }
     return returnValue;
    }
    else if(type == "checkbox")
    {
     return checked;
    }
    else
    {
     if (value == null || value == "0" || value == "" || value == " ")
      return false;
     else
      return true;
    }
   }
  }
//===========validation ends=============

function changeTime(day){
	  
   removeAllOptions(document.getElementById('call_back_time'));
   //addOption(document.getElementById('call_back_time'), "Select a time", "");
			  if(day.match('Saturday')!=null)
				 {
				  addOption(document.getElementById('call_back_time'),"10:00 - 13:00", "10:00 - 13:00");
				 } else {
				  addOption(document.getElementById('call_back_time'),"10:00 - 13:00", "10:00 - 13:00");
				  addOption(document.getElementById('call_back_time'),"13:00 - 16:00", "13:00 - 16:00");
			  }
}

function enableOther(by, other)
{ 
	if(by=='Other')
	{ 
		other.style.display='block';
	}
	else 
	{
		other.style.display='none';
	}
}

function addOption(selectbox,text,value )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;
	selectbox.options.add(optn);
}

function removeAllOptions(selectbox)
{
	var i;
	for(i=selectbox.options.length-1;i>=1;i--)
	{
	selectbox.remove(i);
	}
}
function removeAll(selectbox)
{
	var i;
	for(i=selectbox.options.length;i>=0;i--)
	{
	selectbox.remove(i);
	}
}
function generateDates(formname){
  var day = new Date();
  var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
  var monthname=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
  for(i=1; i<9; i++){
	day.setDate(day.getDate()+1);
	if(!(weekday[day.getDay()].match('Sunday')) ){
		newdate = weekday[day.getDay()]+" "+day.getDate()+" "+monthname[day.getMonth()]+" "+day.getFullYear();
		addOption(formname, newdate, newdate);
	}
  }
}
function generateSaturday(again){
  var now = new Date();
  var day = new Date(document.bookholiday.dep_mmyyy.value+'/01');
  if((day < now) || again == 1) {
     var d = now.getMonth();
     var year = now.getFullYear();
     d = d+1;
	 if(again == 1) {
	 	d = d + 1;
	 }
     if(d < 10) {
     	d = "0"+d;
     }
     document.bookholiday.dep_mmyyy.value = year+"/"+d;
     day = new Date(document.bookholiday.dep_mmyyy.value+'/01');
  }

  var weekday=new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
  var monthname=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
  removeAll(document.bookholiday.dep_day);
  for(i=1; i<30; i++){
	day.setDate(day.getDate()+1);
	if((weekday[day.getDay()].match('Sat'))  && now < day){
		newdate = day.getDate()+" "+weekday[day.getDay()];
		addOption(document.bookholiday.dep_day, newdate, day.getDate());	
	}
  }
  if((document.bookholiday.dep_day.length < 1) && again != 1) {
  	generateSaturday(1);
  }
}

function updateMonth(fieldname) {
	var now = new Date();
	var month = now.getMonth() + 1;
	month = month * 1;
	append = month < 10 ? '0' : '';
	month = append + month;
        var year = now.getFullYear();
        currentmonth  = year+"/"+month; 
	var listlength = fieldname.length;
	for(i=0;i<listlength;i++){
		if(fieldname.value == currentmonth) {
			fieldname.selectedIndex = i;
		}
	}
	fieldname.selec
}

function validate_bookaholiday(){
	if(document.bookholiday.accommodation.value == "" || document.bookholiday.accommodation.value == " "){
		document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\"> Please specify accommodation type.</span>';
		document.getElementById('accommodationtitle').style.color="red";
		return false;
	}
}

function fillEmail(field,param){
	if(field == 'depdate'){
		var date = getURLParam(param);
		date = date.split('-');
		if (date[0] == 1) date[0] = '01';
		else if (date[0] == 2) date[0] = '02';
		else if (date[0] == 3) date[0] = '03';
		else if (date[0] == 4) date[0] = '04';
		else if (date[0] == 5) date[0] = '05';
		else if (date[0] == 6) date[0] = '06';
		else if (date[0] == 7) date[0] = '07';
		else if (date[0] == 8) date[0] = '08';
		else if (date[0] == 9) date[0] = '09';
	
		date = date[0]+'/'+date[1]+'/'+date[2];
		document.getElementById(field).value = date;
    }else if(field == 'propertyname' || field == 'depairport'){

		var uppercase = getURLParam(param).toUpperCase();
		document.getElementById(field).value = uppercase;
	} else{
		document.getElementById(field).value = getURLParam(param);
	}
}

function fillURL(field,param){
        if(field == 'depdate'){
                var date = getURLParam(param);
                date = date.split('-');
                if (date[0] == 1) date[0] = '01';
                else if (date[0] == 2) date[0] = '02';
                else if (date[0] == 3) date[0] = '03';
                else if (date[0] == 4) date[0] = '04';
                else if (date[0] == 5) date[0] = '05';
                else if (date[0] == 6) date[0] = '06';
                else if (date[0] == 7) date[0] = '07';
                else if (date[0] == 8) date[0] = '08';
                else if (date[0] == 9) date[0] = '09';

                date = date[0]+'/'+date[1]+'/'+date[2];
                document.getElementById(field).value = date;
    }else if(field == 'propertyname' || field == 'depairport' ){
                var uppercase = getURLParam(param).toUpperCase();
                document.getElementById(field).value = uppercase;
        }else{
        document.getElementById(field).value = getURLParam(param);
        }
}

function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?"));
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return unescape(strReturn);
}
function checkonsubmit(thisform){   //sign up form validation
	var emailreg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var pwdreg1 = new RegExp('[A-Za-z]');
	var pwdreg2 = new RegExp('[0-9!@#$%-_]');
	var textValidation = /^[a-z][-a-z0-9_ ]{0,49}$/i;
	var invalid = " ";
	   
	   var usrtitle = document.sign_up.title.value;
	   var ursfname = document.sign_up.firstname.value;
	   var usrsurname = document.sign_up.surname.value;
	   var email = document.sign_up.usremail.value;
	   var remail = document.sign_up.reusremail.value;
	   var news = document.sign_up.newsletter.checked;
	   var depcity = document.sign_up.depcity.value;
	   var urspwd = document.sign_up.password.value;
	   var ursrpwd = document.sign_up.repassword.value;
	   var urspwdhint = document.sign_up.passwordhint.value;
      
		document.getElementById('titl').style.color="#777777"; 
		document.getElementById('fname').style.color="#777777";
		document.getElementById('sname').style.color="#777777";
		document.getElementById('email').style.color="#777777";
		document.getElementById('reemail').style.color="#777777";
		document.getElementById('psword').style.color="#777777";
		document.getElementById('repsword').style.color="#777777";
		document.getElementById('pswordhint').style.color="#777777";
		document.getElementById('depcityname').style.color="#777777";	
		
	   var errorTxt = 'We were unable to submit your request. Please see below for details.<br/>';

	   if(usrtitle == null || usrtitle == '' || usrtitle == ' '){ 
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please specify your title.</span>';
		  document.getElementById('titl').style.color="red";
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
		}
	  if(textValidation.test(ursfname) == false){ 
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please specify your first name.</span>';
		  document.getElementById('fname').style.color="red";
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
		}
	   if(textValidation.test(usrsurname) == false){
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please specify your surname.</span>';
		  document.getElementById('sname').style.color="red";
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
		}
		if(emailreg.test(email) == false){
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please enter your e-mail address. Your e-mail address will be your Tapestry member ID and used for sending you ticket confirmations and any other information that you request.</span>';
		  document.getElementById('email').style.color="red";
		  document.getElementById('usremail').value = '';
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
	   }
	   if(remail == '' || remail == null || remail == ' '){
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please retype your e-mail address.</span>';
		  document.getElementById('reemail').style.color="red";
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
	   }
	   if(email != remail){
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Your second e-mail address does not match the first. Please retype and try again.</span>';
		  document.getElementById('reemail').style.color="red";
		  document.getElementById('reusremail').value = '';
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
	   }
       if(news == true && (depcity == '' || depcity == null)){
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please enter your departure city so we can find deals for you.</span>';
		  document.getElementById('depcityname').style.color="red";
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;	
	   } 
	   if( (pwdreg1.test(urspwd) == false) || (pwdreg2.test(urspwd) == false) ){
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please enter your password.</span>';
		  document.getElementById('psword').style.color="red";
		  document.getElementById('password').value = '';
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
	   }
	   if(urspwd.indexOf(invalid) > -1){
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please enter your password.</span>';
		  document.getElementById('psword').style.color="red";
		  document.getElementById('password').value = '';
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
	   }
	   if(urspwd.length < 5 || urspwd.length > 12){
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' You password needs to be 5-12 characters long and a combination of letters and numbers without any spaces.</span>';
		  document.getElementById('psword').style.color="red";
		  document.getElementById('password').value = '';
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
	   }
	   if(ursrpwd == null || ursrpwd == '' || ursrpwd == ' '){
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please retype your password.</span>';
		  document.getElementById('repsword').style.color="red";
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
	   }
	   if(ursrpwd != urspwd){
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' The two passwords that you have entered are not the same. Please try again.</span>';
		  document.getElementById('repsword').style.color="red";
		  document.getElementById('repassword').value = '';
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
	   }
	   if(urspwdhint != '' && urspwdhint == urspwd){
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please choose another hint. Your hint cannot be the same as your password.</span>';
		  document.getElementById('psword').style.color="red";
		  document.getElementById('repsword').style.color="red";
		  document.getElementById('pswordhint').style.color="red";
		  document.getElementById('password').value = '';
		  document.getElementById('repassword').value = '';
		  document.getElementById('passwordhint').value = '';
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
	   }
}
function validate_newsletter(){ 
           
		   var emailreg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
           var email = document.getElementById('email').value;
		   var errorTxt = 'We were unable to submit your request. Please see below for details.<br/>';
		   document.getElementById('eml').style.color="#777777";
        
		if(email == '' || email == ' ' || email == null){
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please specify your e-mail address.</span>';
		  document.getElementById('eml').style.color="red";
		  document.getElementById('email').value = '';
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
		}
		if(emailreg.test(email) == false){
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please enter valid e-mail address.</span>';
		  document.getElementById('eml').style.color="red";
		  document.getElementById('email').value = '';
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
		}
}
function validate_callme(form){ 
           
		   var textValidation = /^[a-z][-a-z0-9_ ]{0,49}$/i ;
           
		   var firstname = null;
		   var nametext = null;
		   if (form == 'callmepage'){
			   firstname = document.getElementById('firstname').value;
			   nametext = 'first name';
		   }else if(form == 'contact'){
			   firstname = document.getElementById('name').value;
			   nametext = 'name';
		   }
		   var phone = document.getElementById('phone').value;
		   var callbackdate = document.getElementById('call_back_day').value;
		   var callbacktime = document.getElementById('call_back_time').value;
	   
			document.getElementById('fname').style.color="#777777"; 
			document.getElementById('phn').style.color="#777777";
			document.getElementById('call').style.color="#777777";
		
		var errorTxt = 'We were unable to submit your request. Please see below for details.<br/>';

		if(textValidation.test(firstname) == false){ 
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please specify your '+nametext+'.</span>';
		  document.getElementById('fname').style.color="red";
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
		}
		var stripped = phone.replace(/[\(\)\.\-\ ]/g, '');
		if(phone == '' || phone == null || isNaN(parseInt(stripped))){ 
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please specify your phone number.</span>';
		  document.getElementById('phn').style.color="red";
		  document.getElementById('phone').value = '';
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
		}
		if(callbackdate == null || callbackdate == '' || callbackdate == ' '){
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please specify the day that you would like us to call you back.</span>';
		  document.getElementById('call').style.color="red";
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
	   }
	   if(callbacktime == null || callbacktime == '' || callbacktime == ' '){
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please specify the time that you would like us to call you back.</span>';
		  document.getElementById('call').style.color="red";
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
	   }
}
function validate_moreinfo(){ 
           
		   var textValidation = /^[a-z][-a-z0-9_ ]{0,49}$/i ;
		   var emailreg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
           
            var firstname = document.getElementById('firstname').value;
			var phone = document.getElementById('phone').value;
			var stripped = phone.replace(/[\(\)\.\-\ ]/g, '');
			var email = document.getElementById('email').value;
			var wouldlike = document.getElementById('wouldlike').value;
			
			   document.getElementById('fname').style.color="#777777";
			   document.getElementById('phn').style.color="#777777";
			   document.getElementById('eml').style.color="#777777";
			   document.getElementById('wudlik').style.color="#777777";		

		    var errorTxt = 'We were unable to submit your request. Please see below for details.<br/>';

		if(textValidation.test(firstname) == false){ 
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please specify your first name.</span>';
		  document.getElementById('fname').style.color="red";
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
		}
		if(phone == '' || phone == null || isNaN(parseInt(stripped))){ 
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please specify your phone number.</span>';
		  document.getElementById('phn').style.color="red";
		  document.getElementById('phone').value = '';
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
		}
		if(emailreg.test(email) == false){
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please specify your e-mail address.</span>';
		  document.getElementById('eml').style.color="red";
		  document.getElementById('email').value = '';
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
	   }
	   if(wouldlike == null || wouldlike == '' || wouldlike == ' '){
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please specify what you would like us to send you more information on.</span>';
		  document.getElementById('wudlik').style.color="red";
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
	   }
	  
}
function validate_emailpage(){ 
           
		   var textValidation = /^[a-z][-a-z0-9_ ]{0,49}$/i ;
		   var emailreg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
           
            var firstname = document.getElementById('firstname').value;
			var email = document.getElementById('email').value;
			var rec_firstname = document.getElementById('recipient_firstname').value;
			var rec_email = document.getElementById('recipient_email').value;
						
			   document.getElementById('fname').style.color="#777777";
			   document.getElementById('eml').style.color="#777777";
			   document.getElementById('refname').style.color="#777777"; 
			   document.getElementById('reeml').style.color="#777777";	

		    var errorTxt = 'We were unable to submit your request. Please see below for details.<br/>';

		if(textValidation.test(firstname) == false){ 
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please specify your first name.</span>';
		  document.getElementById('fname').style.color="red";
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
		}
		if(emailreg.test(email) == false){
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please specify your e-mail address.</span>';
		  document.getElementById('eml').style.color="red";
		  document.getElementById('email').value = '';
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
	   }
	   if(textValidation.test(rec_firstname) == false){ 
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please specify the recipient\'s first name.</span>';
		  document.getElementById('refname').style.color="red";
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
		}
		if(emailreg.test(rec_email) == false){
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please specify the recipient\'s e-mail address.</span>';
		  document.getElementById('reeml').style.color="red";
		  document.getElementById('recipient_email').value = '';
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
	   }
	  
}

function validate_feedback(){ 
           
		   var textValidation = /^[a-z][-a-z0-9_ ]{0,49}$/i ;
		   var emailreg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
           		
            var firstname = document.getElementById('firstname').value;
			var email = document.getElementById('email').value;
			var feedback = document.getElementById('feedback').value;
									
			   document.getElementById('fname').style.color="#777777";
			   document.getElementById('eml').style.color="#777777";
			   document.getElementById('fdbck').style.color="#777777";

		    var errorTxt = 'We were unable to submit your request. Please see below for details.<br/>';

		if(textValidation.test(firstname) == false){ 
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please specify your first name.</span>';
		  document.getElementById('fname').style.color="red";
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
		}
		if(emailreg.test(email) == false){
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please specify your e-mail address.</span>';
		  document.getElementById('eml').style.color="red";
		  document.getElementById('email').value = '';
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
	   }
	   if(feedback == null || feedback == '' || feedback == ' '){
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please give us your feedback.</span>';
		  document.getElementById('fdbck').style.color="red";
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
	   }
	  
}
function validate_signin(){ 
           
		  var emailreg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
          var pwdreg = /[A-Za-z0-9!@#$%-_]/; 		
            
			var useremail = document.getElementById('useremail').value;
			var password = document.getElementById('password').value;
												
			   document.getElementById('email').style.color="#777777";
			   document.getElementById('pass').style.color="#777777";
			   
		if(emailreg.test(useremail) == false){
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\"> Please enter your registered e-mail address.</span>';
		  document.getElementById('email').style.color="red";
		  document.getElementById('useremail').value = '';
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
	   }
	   if(pwdreg.test(password) == false){
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\"> Please enter your password.</span>';
		  document.getElementById('pass').style.color="red";
		  document.getElementById('password').value = '';
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
	   }
	  
}
function validate_password(){ 
           
		  var pwdreg = /[A-Za-z0-9!@#$%-_]/; 		
            
			var password = document.getElementById('password').value;
			var password2 = document.getElementById('password2').value;
												
			   document.getElementById('pass').style.color="#777777";
			   document.getElementById('pass2').style.color="#777777";
			   
		if(pwdreg.test(password) == false){
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\"> Please ensure that your enter valid new password.</span>';
		  document.getElementById('pass').style.color="red";
		  document.getElementById('password').value = '';
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
	   }
	   if(password2 != password){
		  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\"> Please ensure that you retype your new password correctly.</span>';
		  document.getElementById('pass2').style.color="red";
		  document.getElementById('password2').value = '';
		  document.getElementById('spanerrors').scrollIntoView();
		  return false;
	   }
	  
}
function validate_bookingEnquiry(){
			
			   var emailreg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
			   var textValidation = /^[a-z][-a-z0-9_ ]{0,49}$/i ;
			   var depdate = document.getElementById('depdate').value;
			   var duration = document.getElementById('duration').value;
			   var depairport = document.getElementById('depairport').value;
			   var property = document.getElementById('propertyname').value;
			   var paxTitle1 = document.getElementById('paxTitle1').value;
			   var paxSurname1 = document.getElementById('paxSurname1').value;
			   var paxFirstname1 = document.getElementById('paxFirstname1').value;
			   var paxDOB1 = document.getElementById('paxDOB1').value;
			   var phoneDay = document.getElementById('phoneDay').value;
			   var email = document.getElementById('email').value;
			   var email2 = document.getElementById('email2').value;
			   var traveled = document.getElementById('traveled').value;
			   var stripped = phoneDay.replace(/[\(\)\.\-\ ]/g, '');
			   var errorTxt = 'We were unable to submit your request. Please see below for details.<br/>';

				   document.getElementById('ddate').style.color="#777777";
				   document.getElementById('nights').style.color="#777777";
				   document.getElementById('dairport').style.color="#777777";
				   document.getElementById('pname').style.color="#777777";
				   document.getElementById('pax1').style.color="#777777";
				   document.getElementById('phn').style.color="#777777";
				   document.getElementById('e-mail').style.color="#777777";
				   document.getElementById('e-mail2').style.color="#777777";
				   document.getElementById('trvbefore').style.color="#777777";
				
				if(depdate == null || depdate == '' || depdate == ' '){
				  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please specify the depature date.</span>';
				  document.getElementById('ddate').style.color="red";
				  document.getElementById('spanerrors').scrollIntoView();
				  return false;
				}
				if(duration == null || duration == '' || duration == ' '){
				  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please specify the duration.</span>';
				  document.getElementById('nights').style.color="red";
				  document.getElementById('spanerrors').scrollIntoView();
				  return false;
				} 
				if(depairport == null || depairport == '' || depairport == ' '){
				  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please specify the departure airport.</span>';
				  document.getElementById('dairport').style.color="red";
				  document.getElementById('spanerrors').scrollIntoView();
				  return false;
				} 
				if(property == null || property == '' || property == ' '){
				  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please specify the property name.</span>';
				  document.getElementById('pname').style.color="red";
				  document.getElementById('spanerrors').scrollIntoView();
				  return false;
				}
				if(paxTitle1 == null || paxTitle1 == '' || paxTitle1 == ' '){
				  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please specify the title of the lead passenger.</span>';
				  document.getElementById('pax1').style.color="red";
				  document.getElementById('spanerrors').scrollIntoView();
				  return false;
				}
				if(paxSurname1 == null || paxSurname1 == '' || paxSurname1 == ' '){
				  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please specify the surname of the lead passenger.</span>';
				  document.getElementById('pax1').style.color="red";
				  document.getElementById('spanerrors').scrollIntoView();
				  return false;
				}
				if(paxFirstname1 == null || paxFirstname1 == '' || paxFirstname1 == ' '){
				  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please specify the first name of the lead passenger.</span>';
				  document.getElementById('pax1').style.color="red";
				  document.getElementById('spanerrors').scrollIntoView();
				  return false;
				}
				if(paxDOB1 == null || paxDOB1 == '' || paxDOB1 == ' '){
				  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please specify the date of birth of the lead passenger.</span>';
				  document.getElementById('pax1').style.color="red";
				  document.getElementById('spanerrors').scrollIntoView();
				  return false;
				}
				if(phoneDay == '' || phoneDay == null || isNaN(parseInt(stripped))){ 
				  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please specify your phone number.</span>';
				  document.getElementById('phn').style.color="red";
				  document.getElementById('phoneDay').value = '';
				  document.getElementById('spanerrors').scrollIntoView();
				  return false;
				}
				if(emailreg.test(email) == false){
				  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\"> Please specify your e-mail address.</span>';
				  document.getElementById('e-mail').style.color="red";
				  document.getElementById('email').value = '';
				  document.getElementById('spanerrors').scrollIntoView();
				  return false;
			   }
			   if(email2 == '' || email2 == null || email2 == ' '){
				  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please retype your e-mail address.</span>';
				  document.getElementById('e-mail2').style.color="red";
				  document.getElementById('spanerrors').scrollIntoView();
				  return false;
			   }
			   if(email2 != email){
				  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Your second e-mail address does not match the first. Please retype and try again.</span>';
				  document.getElementById('e-mail2').style.color="red";
				  document.getElementById('email2').value = '';
				  document.getElementById('spanerrors').scrollIntoView();
				  return false;
			   } 	
			   if(traveled == null || traveled == '' || traveled == ' '){
				  document.getElementById("spanerrors").innerHTML = '<span class=\"errmsgicon\">'+ errorTxt +' Please specify the duration.</span>';
				  document.getElementById('trvbefore').style.color="red";
				  document.getElementById('spanerrors').scrollIntoView();
				  return false;
			   }
}
// funtion to add new div element for Add More Passenger section
function addNewElement() {
  var ni = document.getElementById('paxDetails');
  var numi = document.getElementById('paxValue');
  var num = (document.getElementById('paxValue').value -1)+ 2;
  numi.value = num;
  var newdiv = document.createElement('div');
  var divIdName = 'paxDetails'+num;
  newdiv.setAttribute('id',divIdName);
  newdiv.innerHTML = '<div class="FormRow" ><div class="FormRowColLeft"><strong>Passenger #'+num+'</strong></div><div class="FormRowColRight"><select name="paxTitle'+num+'" id="paxTitle'+num+'"><option value=" ">Title</option><option value="Mr">Mr</option><option value="Dr">Dr</option><option value="Mrs">Mrs</option><option value="Miss">Miss</option><option value="Ms">Ms</option></select><input type="text" name="paxSurname'+num+'" id="paxSurname'+num+'"/><input type="text" name="paxFirstname'+num+'" id="paxFirstname'+num+'"/><input id="paxDOB'+num+'" name="paxDOB'+num+'" type="text" size="10" onclick="displayCalendar(document.getElementById(\'paxDOB'+num+'\'),\'dd/mm/yyyy\',this)" /> <img id="calimg'+num+'" src="images/tapestry/icon_checkcal.gif" onclick="displayCalendar(document.getElementById(\'paxDOB'+num+'\'),\'dd/mm/yyyy\',this)" border="0" alt="" /> </div></div>';
  ni.appendChild(newdiv);
}

function hearabout_addfield() {
	var dd = document.getElementById('hear_about_select');
	var other = document.getElementById('hear_about_other_box');
	var othervalue = document.getElementById('hear_about_other_value');
	if(dd.value == "OTH") {
		other.className = 'FormRow visible';
		othervalue.value = "";
	} else {
		other.className = 'FormRow invisible';
		othervalue.value = "Other";
	}

}