
function showHide(newDivId) {

	var pageDivs = new Array('t1', 't2', 't3', 't4', 't5', 't6', 't7', 't8', 't9', 't10');

	for(var i = 0; i < pageDivs.length; i++) {
		if(pageDivs[i] == newDivId) {
			document.getElementById(newDivId).style.display = 'block';
		} else {
  			var tab=document.getElementById(pageDivs[i]);
			if(tab != undefined)
				tab.style.display = 'none';
		}
	}
}


function showHideElem(elemId){
	var elem=document.getElementById(elemId);
	if(elem.style.display=='none'){
		elem.style.display='block';
	}else{
		elem.style.display='none';
	}
}

function validate_bookingform() {
    validateError="";
    document.booking.action="reservation.php";

    if (document.booking.firstname.value == "") {
        validateError = "You must fill in all the mandatory fields\n";
       }

	else if (document.booking.lastname.value == "") {
        validateError = "You must fill in all the mandatory fields \n";
       }

    else if (document.booking.primary_contact.value == "") {
        validateError = "You must fill in all the mandatory fields\n";
       }
    else if (document.booking.room_type.value == "") {
        validateError = "You must fill all the required fields \n";
       }
    else if (document.booking.numofrooms.value == "") {
        validateError = "You must fill in all the mandatory fields \n";
       }
    else if (document.booking.numofpersons.value == "") {
        validateError = "You must fill in all the mandatory fields \n";
       } 
	else if (document.booking.checkin.value == "") {
        validateError = "You must fill in all the mandatory fields \n";
       }
	else if (document.booking.checkout.value == "") {
        validateError = "You must fill in all the mandatory fields \n";
       }

  if (validateError!="") {
         alert(validateError);
         return false;
    }
  else
      {
       var pcontact = document.booking.primary_contact.value;
       if (pcontact.length < 6) {
			  alert("Invalid email address or phone number\nFor phone number please enter area code with phone number.");
			  return false;
	       }
    }

}


function validate_contactform() {
    validateError="";
    document.contact.action="contact-us.php";

    if (document.contact.name.value == ""){
            validateError = "You must fill in all the mandatory fields marked with (*).";
       }
    else if (document.contact.email.value == "") {
        validateError = "You must fill in all the mandatory fields marked with (*).";
       }

	else if (document.contact.subject.value == "") {
        validateError = "You must fill in all the mandatory fields marked with (*).";
       }

    else if (document.contact.msg.value == "") {
        validateError = "You must fill in all the mandatory fields marked with (*).";
       }
if (validateError!="") {
         alert(validateError);
         return false;
    }
  else
      {
       var email = document.contact.email.value;
       emaillen = email.length;
	       if (email.length < 6) {
			  alert("Invalid email address! \n Please enter a valid email address.");
			  return false;
	       }
        else {
          var passed1Counter = 0;
	         var passed2Counter = 0;

		       for (i = 0; i < email.length; i++) {
				 var character = email.charAt(i);
					switch(character) {
						case '@':
							 passed1Counter++;
						     break;
						case '.':
	                         passed2Counter++;
						     break;
					}
		       }

		       if (passed1Counter != 1 || passed2Counter == 0) {
	               alert("Invalid email address! \n Please enter a valid email address.");
	               return false;
		       }
         }

      }

}

function validate_cvform() {
    var validateError="";
    if (document.cv.fullname.value == ""){
          validateError = "You must fill in all the mandatory fields marked with (*).";
		  alert(validateError);
          return false;
       }
    else if (document.cv.address.value == "") {
        validateError = "You must fill in all the mandatory fields marked with (*).";
		alert(validateError);
        return false;
       }

	else if (document.cv.phone.value == "") {
        validateError = "You must fill in all the mandatory fields marked with (*).";
		alert(validateError);
        return false;
       }

    else if (document.cv.cvf.value == "") {
        validateError = "You must fill in all the mandatory fields marked with (*).";
		alert(validateError);
        return false;
       }
    else
      {
	   document.cv.action="career.php";	  
       return true;
      }

}

function preloadImages() {
  var d=document; if(d.images){ if(!d.p) d.p=new Array();
    var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}

