function embedObject(flash_file, width, height) {
	document.write('<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\"'+width+'\" height=\"'+height+'\">' +
	'    <param name=\"movie\" value=\"'+flash_file+'\" />' +
	'    <param name=\"quality\" value=\"high\" />' +
	'	 <param name=\"wmode\" value=\"transparent\" />' +
	'    <embed src=\"'+flash_file+'\" quality=\"high\" wmode=\"transparent\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"'+width+'\" height=\"'+height+'\"></embed>' +
	'  </object>');
}

var message = "Print this Page";
function printpage(o){
    alert("Please set your printer orientation to " + o +" and your paper size to A4")
    window.print()
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}
function val_email(ele) { 
    if (/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test($(ele).val())) {
        return false; 
    } else {
        return true;
    }
}
function validateSearch() {
    if ($('#id_location').val() == '') {
        alert("Please select a location.");
    } else if ($('#id_type').val() == '') {
        alert("Please select an accommodation type.");
    } else {
        document.location = '/' + $('#id_location').val() + '-self-catering-' + $('#id_type').val();
    } 
}
function validateEstablishmentSearch() {
    document.location = $('#id_establishmentsearch').val()
}
function calcGuests() {
    total_guests = parseInt($('#adults').val())+parseInt($('#children').val());
   $('#lbl_total_guests').html(total_guests);
   $('#total_guests').val(total_guests);
}
function setMinToDate() {
    //alert('hai2u');
    date_split = $("#arrival").val().split('-');
    from_date = new Date();
    from_date.setFullYear(date_split[2],(date_split[1]-1), (date_split[0]));
    from_date.setDate(from_date.getDate()+1)
    
    $('#departure').datepicker('option', 'minDate', from_date);
}
function calcNights() {
    date_split = $("#departure").val().split('-');
    from_date = new Date();
    from_date.setFullYear(date_split[2],(date_split[1]-1), (date_split[0]));
    
    date_split = $("#arrival").val().split('-');
    to_date = new Date();
    to_date.setFullYear(date_split[2],(date_split[1]-1), (date_split[0]));
    one_day=1000*60*60*24;

    total_nights = Math.ceil((from_date.getTime()-to_date.getTime())/(one_day));
    
    $('#lbl_total_nights').html(total_nights);
    $('#total_nights').val(total_nights);
}
function validateListYourEstablishment() {
    if($('#id_name').val() == 'Name *'){
        alert('Please enter the Contact Person.');
    } else if($('#id_number').val() == 'Contact Number *'){
        alert('Please enter your Contact Number.');
    } else if($('#id_email').val() == 'Email Address *'){
        alert('Please enter your email address.');
    } else if (!(val_email($("#id_email").val()))) {
        alert('Please enter a valid email address.');
    } else if($('#id_pyhsical_addres').val() == 'Physical Address *'){
        alert('Please enter your physical address.');
    } else if($('#id_property_description').val() == 'Property Description *'){
        alert('Please enter your property description.');
    } else {
        $('#listestablishmentform').submit();
    }
}
function validateMLM() {
    if($('#id_name').val() == 'Name *'){
        alert('Please enter your name.');
    } else if($('#id_number').val() == 'Contact Number *'){
        alert('Please enter your contact number.');
    } else if($('#id_email').val() == 'Email Address *'){
        alert('Please enter your email address.');
    } else if (!(val_email($("#id_email").val()))) {
        alert('Please enter a valid email address.');
    } else {
        $('#alertform').submit();
    }
}
function validateReview() {
    if($('#id_name').val() == 'Name *'){
        alert('Please enter your name.');
    } else if($('#id_impression').val() == 'Contact Number *'){
        alert('Please enter your contact number.');
    } else if($('#id_email').val() == 'Email Address *'){
        alert('Please enter your email address.');
    } else if (!(val_email($("#id_email").val()))) {
        alert('Please enter a valid email address.');
    } else if($('#date_of_stay').val() == 'Date of Stay *'){
        alert('Please enter your date of stay.');
    } else if($('#date_of_stay').val() == 'Review *'){
        alert('Please enter your review.');
    } else {
        $('#reviewform').submit();
    }
}
function validateReservation() {
    if ($("#name").val()=="Contact Person *") {
        alert('Please enter your name.');   
    } else if ($("#cell").val()=="Cell Number *") {
        alert('Please enter your cell number.');
    } else if ($("#email").val()=="Email Address *") {
        alert('Please enter your email address.');
    } else if (!(val_email($("#email").val()))) {
        alert('Please enter enter a valid email address.');
    } else if ($("#establihment").is(":visible") && $("#establihment").val()=="") {
        alert('Please select an establihment.');
    } else if ($("#location").is(":visible") && $("#location").val()=="") {
        alert('Please select a location.');
    } else if ($("#accomm_type").is(":visible") && $("#accomm_type").val()=="") {
        alert('Please select an accommodation type.');
    } else if ($("#transport_required").val()=="") {
        alert('Please select whether transport is required.');
    } else if (parseInt($("#lbl_total_guests").html())<1) {
        alert('Please select the total number of guests.');
    } else {
        $('#reservationform').submit();
    }
}
function validateEmailFriend(name, email, rec_name, rec_email, form) {
    if($('#'+name).val() == 'Your Name'){
        alert('Please enter your name.');
    } else if($('#'+email).val() == 'Your Email Address'){
        alert('Please enter your email.');
    } else if (!(val_email($('#'+email).val()))){
        alert('Please enter a valid email address.');
    } else if($('#'+rec_name).val() == 'Recipients Name'){
        alert('Please enter your recipient\'s name.');
    } else if($('#'+rec_email).val() == 'Recipients Email Address'){
        alert('Please enter your recipient\'s email.');
    } else if(!(val_email($('#'+rec_email).val()))){
        alert('Please enter a valid recipient\'s email address.');
    } else {
        $('#'+form).submit();
    }
}
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}