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 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()) == false){
        return false;
    }
    else{
	   return true;
    }
}
function validateListingSearch(listing) {
    listing = listing.replace(/[^0-9]/gi, '');;
    if (listing == '') {
        alert('Please enter a valid listing number. Example: EG1 or 1');
    } else {
        $.post('/ajax/check-listing/'+listing+'/', function(data){ (data=='false') ? alert('Sorry, the listing you searched for does not exist.') : window.location = data;});
    } 
}
function validateContact() {
    if($('#id_contact_name').val() == 'Name'){
        alert('Please enter your name.');
    } else if($('#id_contact_number').val() == 'Contact Number'){
        alert('Please enter your contact number.');
    } else if($('#id_contact_email').val() == 'Email Address'){
        alert('Please enter your email address.');
    } else if(val_email('#id_contact_email') == false){
        alert('Please enter a valid email address.');
    } else if($('#id_contact_comments').val() == 'Comments'){
        alert('Please enter your comments.');
    } else {
        $('#contactform').submit();
    }
}
function validateTenant() {
    if($('#id_alert_name').val() == 'Name'){
        alert('Please enter your name.');
    } else if($('#id_alert_number').val() == 'Contact Number'){
        alert('Please enter your contact number.');
    } else if($('#id_alert_email').val() == 'Email Address'){
        alert('Please enter your email address.');
    } else if(val_email('#id_alert_email') == false){
        alert('Please enter a valid email address.');
    } else if($('#id_alert_region').val() == ''){
        alert('Please enter select your region.');
    } else if($('#id_alert_comments').val() == 'Comments / Additional Requirements'){
        alert('Please enter your comments.');
    } else {
        $('#alertform').submit();
    }
}
function validateLandlord() {
    if($('#id_landlord_name').val() == 'Name'){
        alert('Please enter your name.');
    } else if($('#id_landlord_number').val() == 'Contact Number'){
        alert('Please enter your contact number.');
    } else if($('#id_landlord_email').val() == 'Email Address'){
        alert('Please enter your email address.');
    } else if(val_email('#id_landlord_email') == false){
        alert('Please enter a valid email address.');
    } else if($('#id_landlord_region').val() == ''){
        alert('Please enter select your region.');
    } else if($('#id_landlord_address').val() == 'Property Address'){
        alert('Please enter your property\s address.');
    } else if($('#id_landlord_description').val() == 'Property Description'){
        alert('Please enter your property description.');
    } else {
        $('#landlordform').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)) == false){
        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)) == false){
        alert('Please enter a valid recipient\'s email address.');
    } else {
        $('#'+form).submit();
    }
}