
function getObj(nm) {
	if (document.getElementById) {
		return document.getElementById(nm);
	} else if (document.all) {
		return document.all[nm];
	} else {
		return eval("document." + nm);
	}
}

function EW_checkNesLetterForm(EW_this){
    if (EW_this.Name.value == ""  || EW_this.Name.value == "Your name" ) {
	     alert("Name is missing!");
		 EW_this.Name.focus();
		 return;
	}
	
	if ( EW_this.Email.value == "" || EW_this.Email.value == "Your email" ){
	    alert("Email is missing!");
		EW_this.Email.focus();
		return;
	}else{
		    if ( !EW_checkemail( EW_this.Email.value ) ){
			   alert("Email address is wrong.");
			   EW_this.Email.focus();
			   return;
			}
	}
	
	if (EW_this.countryCode.selectedIndex == 0 ) {
	     alert("Your country is missing!");
		 EW_this.countryCode.focus();
		 return;
	}
	
    EW_this.submit();
}

function clear_birthday()
{
	getObj('bd_month').selectedIndex = 0;
	getObj('bd_day').selectedIndex = 0;
	getObj('bd_year').value = '';
}

/* Forum.asp */
function expandCat(catid){
  var tbodyID = getObj('tbodyCat' + catid);
  var theadID = getObj('theadCat' + catid);
  tbodyID.style.display = "block";
  theadID.style.display = "none";
}

function closeCat(catid){
  var tbodyID = getObj('tbodyCat' + catid);
  var theadID = getObj('theadCat' + catid);
  tbodyID.style.display = "none";
  theadID.style.display = "block";
}

/* in edit Signature page */
function saveSignature(formName){
	formName.elements['preview'].value = "0";
	formName.submit();
}

function submitSignature(formName){
    var editor = document.getElementById('WebWizRTE').contentWindow.document.body.innerHTML;
	//alert(editor);
	formName.elements['signature'].value = editor;
    formName.submit();
}

function showSignaturePreview(formName){
    var editor = document.getElementById('WebWizRTE').contentWindow.document.body.innerHTML;
	//alert(editor);
	//formName.elements['signature'].value = editor;
    getObj('SignaturePreviewText').innerHTML = editor;
	getObj('SignaturePreviewDiv').style.display = 'block';
	document.location = "forum-profile.asp?do=editsignature#Preview";
}

function EW_checkRegForum(formName){

    var valid = 1;
    var fieldID = "";
    var message = "";
	if (formName.elements['UserName'].value == "") {
		valid = 0; if (fieldID.length == 0){ fieldID = "input1"; }
		message += "<li>User Name</li>";
		getObj("input1TD").style.color = "#aa0000";
	} else {
		getObj("input1TD").style.color = "#42706D";
	}
	
	if  ( (formName.elements['Email'].value == "") ){
		valid = 0; if (fieldID.length == 0){ fieldID = "input2"; }
		message += "<li>Email address</li>";
		getObj("input2TD").style.color = "#aa0000";
	} else {
	    if ( !EW_checkemail( formName.elements['Email'].value ) ){
		     valid = 0; if (fieldID.length == 0){ fieldID = "input2"; }
		     message += "<li>Email address is wrong</li>";
		     getObj("input2TD").style.color = "#aa0000";
		}else{
	       getObj("input2TD").style.color = "#42706D";
		}
	}
	
	if (formName.elements['Email2'].value != formName.elements['Email'].value ) {
		valid = 0; if (fieldID.length == 0){ fieldID = "input6"; }
		message += "<li>Cofirm Email doesn't match</li>";
		getObj("input6TD").style.color = "#aa0000";
	} else {
		getObj("input6TD").style.color = "#42706D";
	}
	
	if (formName.elements['Password'].value == "") {
		valid = 0; if (fieldID.length == 0){ fieldID = "input3"; }
		message += "<li>Password</li>";
		getObj("input3TD").style.color = "#aa0000";
	} else {
		getObj("input3TD").style.color = "#42706D";
	}
	
	if (formName.elements['Password2'].value != formName.elements['Password'].value ) {
		valid = 0; if (fieldID.length == 0){ fieldID = "input4"; }
		message += "<li>Cofirm Password doesn't match</li>";
		getObj("input4TD").style.color = "#aa0000";
	} else {
		getObj("input4TD").style.color = "#42706D";
	}
	
	if (formName.countryCode.selectedIndex == 0 ) {
		valid = 0; if (fieldID.length == 0){ fieldID = "input5"; }
		message += "<li>Your country</li>";
		getObj("input5TD").style.color = "#aa0000";
	}else{
	   getObj("input5TD").style.color = "#42706D";
	}
	
	if (valid == 1){
        formName.submit();
    }else{
// Print error message:
message = "<p class='error'>You have not completed all the required fields, please check:</p><ul>" + message;
message += "</ul>";	
        getObj(fieldID).focus();
	    getObj("messagaSummary").innerHTML = message;
		getObj("messagaSummary").style.display = 'block';
		alert("Please completed all the required fields!");
	}

}

/* Forum - Edit password */
function checkEditPswdForum(formName){

    var valid = 1;
    var fieldID = "";
    var message = "";
	if  ( (formName.elements['Email'].value == "") ){
		valid = 0; if (fieldID.length == 0){ fieldID = "input2"; }
		message += "<li>Email address</li>";
		getObj("input2TD").style.color = "#aa0000";
	} else {
	    if ( !EW_checkemail( formName.elements['Email'].value ) ){
		     valid = 0; if (fieldID.length == 0){ fieldID = "input2"; }
		     message += "<li>Email address is wrong</li>";
		     getObj("input2TD").style.color = "#aa0000";
		}else{
	       getObj("input2TD").style.color = "#42706D";
		}
	}
	
	if (formName.elements['Password'].value == "") {
		valid = 0; if (fieldID.length == 0){ fieldID = "input3"; }
		message += "<li>Password</li>";
		getObj("input3TD").style.color = "#aa0000";
	} else {
		getObj("input3TD").style.color = "#42706D";
	}
	
	if (formName.elements['Password2'].value != formName.elements['Password'].value ) {
		valid = 0; if (fieldID.length == 0){ fieldID = "input4"; }
		message += "<li>Cofirm Password doesn't match</li>";
		getObj("input4TD").style.color = "#aa0000";
	} else {
		getObj("input4TD").style.color = "#42706D";
	}
	
	if (valid == 1){
        formName.submit();
    }else{
// Print error message:
message = "<p class='error'>You have not completed all the required fields, please check:</p><ul>" + message;
message += "</ul>";	
        getObj(fieldID).focus();
	    getObj("messagaSummary").innerHTML = message;
		getObj("messagaSummary").style.display = 'block';
		alert("Please completed all the required fields!");
	}

}

function CheckSendPswdForum(EW_this){
    if ( EW_this.Email.value == "" || EW_this.Email.value == "Your email" ){
	    alert("Email is missing!");
		EW_this.Email.focus();
		return;
	}else{
	    if ( !EW_checkemail( EW_this.Email.value ) ){
		   alert("Email address is wrong.");
		   EW_this.Email.focus();
		   return;
		}
	}	
    EW_this.submit();
}

function CheckSignInForum(EW_this){
    if (EW_this.name.value == "" ) {
	     alert("User Name is missing!");
		 EW_this.name.focus();
		 return;
	}
	
	if ( EW_this.password.value == "" ){
	    alert("Password is missing!");
		EW_this.password.focus();
		return;
	}
	
    EW_this.submit();
}

function CheckPersonalDetail(formName){

    var valid = 1;
    var fieldID = "";
    var message = "";
	if (formName.elements['Forename'].value == "") {
		valid = 0; if (fieldID.length == 0){ fieldID = "input1"; }
		message += "<li>First name</li>";
		getObj("Forename").style.color = "#aa0000";
	} else {
		getObj("Forename").style.color = "#42706D";
	}

	if  ( (formName.elements['Surname'].value == "") ){
		valid = 0; if (fieldID.length == 0){ fieldID = "input2"; }
		message += "<li>Surname</li>";
		getObj("Surname").style.color = "#aa0000";
	} else {
	    getObj("Surname").style.color = "#42706D";
	}
	/*
	if  ( (formName.elements['Address'].value == "") ){
		valid = 0; if (fieldID.length == 0){ fieldID = "input3"; }
		message += "<li>Address</li>";
		getObj("Address").style.color = "#aa0000";
	} else {
	    getObj("Address").style.color = "#42706D";
	}
	*/
	if  ( (getObj("input5").selectedIndex == 0) ){
		valid = 0; if (fieldID.length == 0){ fieldID = "input5"; }
		message += "<li>Country</li>";
		getObj("input5TD").style.color = "#aa0000";
	} else {
	    getObj("input5TD").style.color = "#42706D";
	}
	/*
    if  ( (formName.elements['Town'].value == "") ){
		valid = 0; if (fieldID.length == 0){ fieldID = "input4"; }
		message += "<li>Town</li>";
		getObj("Town").style.color = "#aa0000";
	} else {
	    getObj("Town").style.color = "#42706D";
	}
	
	if  ( (formName.elements['Postcode'].value == "") ){
		valid = 0; if (fieldID.length == 0){ fieldID = "input6"; }
		message += "<li>Postcode</li>";
		getObj("Postcode").style.color = "#aa0000";
	} else {
	    getObj("Postcode").style.color = "#42706D";
	}
	
	if  ( (formName.elements['Telephone'].value == "") ){
		valid = 0; if (fieldID.length == 0){ fieldID = "input7"; }
		message += "<li>Telephone</li>";
		getObj("Telephone").style.color = "#aa0000";
	} else {
	    getObj("Telephone").style.color = "#42706D";
	}*/
	
	if  ( (formName.elements['Email'].value == "") ){
		valid = 0; if (fieldID.length == 0){ fieldID = "input8"; }
		message += "<li>Email address</li>";
		getObj("EmailTD").style.color = "#aa0000";
	} else {
	    if ( !EW_checkemail( formName.elements['Email'].value ) ){
		     valid = 0; if (fieldID.length == 0){ fieldID = "input8"; }
		     message += "<li>Email address is wrong</li>";
		     getObj("EmailTD").style.color = "#aa0000";
		}else{
	       getObj("EmailTD").style.color = "#42706D";
		}
	}
	
	validationForm[0] = valid;
    validationForm[1] = fieldID;
    validationForm[2] = message;
    
}

// Global variable for form validation:
var validationForm = new Array(3);
validationForm[0] = 0; //valid
validationForm[1] = "field id";
validationForm[2] = "message";

function  CheckContactForm(formName){
	
	CheckPersonalDetail(formName);
	var valid = validationForm[0];
    var fieldID = validationForm[1];
    var message = validationForm[2];
	
	if  ( (formName.elements['Passengers'].value == "") ){
		valid = 0; if (fieldID.length == 0){ fieldID = "input9"; }
		message += "<li>Passengers</li>";
		getObj("Passengers").style.color = "#aa0000";
	} else {
	    getObj("Passengers").style.color = "#42706D";
	}
	
	if  ( (formName.elements['Childs'].value == "") ){
		valid = 0; if (fieldID.length == 0){ fieldID = "input10"; }
		message += "<li>Childs</li>";
		getObj("Childs").style.color = "#aa0000";
	} else {
	    getObj("Childs").style.color = "#42706D";
	}
	
	if  ( (formName.elements['Departure'].value == "") ){
		valid = 0; if (fieldID.length == 0){ fieldID = "input11"; }
		message += "<li>Departure Location</li>";
		getObj("Departure").style.color = "#aa0000";
	} else {
	    getObj("Departure").style.color = "#42706D";
	}
	
	if  ( (formName.elements['Date'].value == "") ){
		valid = 0; if (fieldID.length == 0){ fieldID = "input12"; }
		message += "<li>Departure Date</li>";
		getObj("Date").style.color = "#aa0000";
	} else {
	    getObj("Date").style.color = "#42706D";
	}
	
	if  ( (formName.elements['Arrival'].value == "") ){
		valid = 0; if (fieldID.length == 0){ fieldID = "input13"; }
		message += "<li>Arrival Location</li>";
		getObj("Arrival").style.color = "#aa0000";
	} else {
	    getObj("Arrival").style.color = "#42706D";
	}
	
	if  ( (formName.elements['ArrivalDate'].value == "") ){
		valid = 0; if (fieldID.length == 0){ fieldID = "input14"; }
		message += "<li>Arrival date</li>";
		getObj("ArrivalDate").style.color = "#aa0000";
	} else {
	    getObj("ArrivalDate").style.color = "#42706D";
	}
	
    if (valid == 1){
        formName.submit();
    }else{
// Print error message:
message = "<p class='error'>You have not completed all the required fields, please check:</p><ul>" + message;
message += "</ul>";	
        getObj(fieldID).focus();
	    getObj("messagaSummary").innerHTML = message;
		getObj("messagaSummary").style.display = 'block';
		alert("Please completed all the required fields!");
	}

}

// Advertise with us: validation
function CheckAdvertiseForm(formName){
	CheckPersonalDetail(formName);
	var valid = validationForm[0];
    var fieldID = validationForm[1];
    var message = validationForm[2];
	
	if (formName.elements['Password'].value.length < 6){
		valid = 0; if (fieldID.length == 0){ fieldID = "Password"; }
		message += "<li>Password has to contain at least 6 carachters</li>";
		getObj("PasswordTD").style.color = "#aa0000";
	} else {
	    getObj("PasswordTD").style.color = "#42706D";
	}

    if (formName.elements['Password'].value != formName.elements['cPassword'].value){
		valid = 0; if (fieldID.length == 0){ fieldID = "cPassword"; }
		message += "<li>Confirm password doesn't match</li>";
		getObj("cPasswordTD").style.color = "#aa0000";
	} else {
	    getObj("cPasswordTD").style.color = "#42706D";
	}
	
	if (formName.elements['Company'].value== ""){
		valid = 0; if (fieldID.length == 0){ fieldID = "Company"; }
		message += "<li>Company Name</li>";
		getObj("CompanyTD").style.color = "#aa0000";
	} else {
	    getObj("CompanyTD").style.color = "#42706D";
	}
	
	if  ( (formName.elements['input9'].value.length < 10) ){
		valid = 0; if (fieldID.length == 0){ fieldID = "input9"; }
		message += "<li>URL</li>";
		getObj("input9TD").style.color = "#aa0000";
	} else {
	    getObj("input9TD").style.color = "#42706D";
	}
	
	if  ( (formName.elements['input11'].value== "") && (formName.elements['services'].selectedIndex == 0) ){
		valid = 0; if (fieldID.length == 0){ fieldID = "services"; }
		message += "<li>Main products or services</li>";
		getObj("servicesTD").style.color = "#aa0000";
	} else {
	    getObj("servicesTD").style.color = "#42706D";
	}
	
    if (valid == 1){
        formName.submit();
    }else{
// Print error message:
message = "<p class='error'>You have not completed all the required fields, please check:</p><ul>" + message;
message += "</ul>";	
        getObj(fieldID).focus();
	    getObj("messagaSummary").innerHTML = message;
		getObj("messagaSummary").style.display = 'block';
		alert("Please completed all the required fields!");
	}
}

// Work with us: validation:
function  CheckWorkWithUsForm(formName){
	CheckPersonalDetail(formName);
	var valid = validationForm[0];
    var fieldID = validationForm[1];
    var message = validationForm[2];
    if (valid == 1){
        formName.submit();
    }else{
// Print error message:
message = "<p class='error'>You have not completed all the required fields, please check:</p><ul>" + message;
message += "</ul>";	
        getObj(fieldID).focus();
	    getObj("messagaSummary").innerHTML = message;
		getObj("messagaSummary").style.display = 'block';
		alert("Please completed all the required fields!");
	}
}

/* Function to open/close div */
function OpenDiv(div_id, MAX){

 if( document.getElementById("radio" + div_id).checked ){
   return;
 }

  var i;
  var sfEls;
  for(i=1;i<=MAX;i++){
    if( div_id != i ){
      sfEls = document.getElementById("div" + i);
	  //alert( sfEls.className );
	  sfEls.className = "Hide4Now";
	}
  }
  
  sfEls = document.getElementById("div" + div_id);
  if( sfEls.className == "Hide4Now" ){
    sfEls.className = "Show4Now";
  }else{
    sfEls.className = "Hide4Now";
  }
  
  document.getElementById("radio" + div_id).checked = "checked";
  
  if( div_id == 1 ){
    document.getElementById("harriernavigation").innerHTML = "Airport Hotels Search";
  }
  
  if( div_id == 2 ){
    document.getElementById("harriernavigation").innerHTML = "Airport Parking Search";
  }
  
  if( div_id == 3 ){
    document.getElementById("harriernavigation").innerHTML = "Flights Search";
  }
  
  if( div_id == 4 ){
    document.getElementById("harriernavigation").innerHTML = "Car rental Search";
  }
  
  if( div_id == 5 ){
    document.getElementById("harriernavigation").innerHTML = "Airport Lounges Search";
  }
  
  if( div_id == 6 ){
    document.getElementById("harriernavigation").innerHTML = "Theatre Breaks Search";
  }
  
  if( div_id == 7 ){
    document.getElementById("harriernavigation").innerHTML = "Theme Park Breaks Search";
  }
  
  if( div_id == 8 ){
    document.getElementById("harriernavigation").innerHTML = "Airports by Rail Search";
  }
  
  if( div_id == 9 ){
    document.getElementById("harriernavigation").innerHTML = "Airport Hotels with Coach Search";
  }
  
}

// This Javascript is for the form validation in Forum...

// forumAddTopic: validation URL
function CheckUrlAddTopicForm(formName){
    var valid = 1;
    var fieldID = "";
    var message = "";
	
	if  ( (formName.elements['url'].value.length < 10) ){
		valid = 0; if (fieldID.length == 0){ fieldID = "url"; }
		message += "<li>URL</li>";
		getObj("urlTD").style.color = "#aa0000";
	} else {
	    getObj("urlTD").style.color = "#42706D";
	}
	
	if  ( (formName.elements['newTopic'].value == "") ){
		valid = 0; if (fieldID.length == 0){ fieldID = "newTopic"; }
		message += "<li>New topic</li>";
		getObj("newTopicTD").style.color = "#aa0000";
	} else {
	    getObj("newTopicTD").style.color = "#42706D";
	}
	
    if (valid == 1){
        formName.submit();
    }else{
// Print error message:
message = "<p class='error'>You have not completed all the required fields, please check:</p><ul>" + message;
message += "</ul>";	
        getObj(fieldID).focus();
	    getObj("messagaSummary").innerHTML = message;
		getObj("messagaSummary").style.display = 'block';
		alert("Please completed all the required fields!");
	}
}

// forumAddTopic: validation URL
function CheckAddDiscussionForm(formName){
    var valid = 1;
    var fieldID = "";
    var message = "";
	
	if  ( (formName.elements['title'].value == "") ){
		valid = 0; if (fieldID.length == 0){ fieldID = "title"; }
		message += "<li>Title</li>";
		getObj("titleTD").style.color = "#aa0000";
	} else {
	    getObj("titleTD").style.color = "#42706D";
	}
	/*
	if  ( (formName.elements['text'].value == "") ){
		valid = 0; if (fieldID.length == 0){ fieldID = "text"; }
		message += "<li>Description</li>";
		getObj("textTD").style.color = "#aa0000";
	} else {
	    getObj("textTD").style.color = "#42706D";
	}*/
	
    if (valid == 1){
        formName.submit();
    }else{
// Print error message:
message = "<p class='error'>You have not completed all the required fields, please check:</p><ul>" + message;
message += "</ul>";	
        getObj(fieldID).focus();
	    getObj("messagaSummary").innerHTML = message;
		getObj("messagaSummary").style.display = 'block';
		alert("Please completed all the required fields!");
	}
}
