jQuery(document).ready(function($) {
  $('a[rel*=facebox]').facebox({loading_image : 'loading.gif', close_image : 'closelabel.gif'}) 
  $('#slideshow').cycle({ 
    fx:      'fade', 
    speed:    1300, 
    timeout:  3000 
	});
})
function sendRequest() { 
$(document).ready(function() { 
    var options = { 
        target:        '#hiddenResponse',   // target element(s) to be updated with server response 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse, // post-submit callback 
 		url:       	   'enquiry-script.php',        // override for form's 'action' attribute 
        //type:      type        // 'get' or 'post', override for form's 'method' attribute 
        //dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 
        //clearForm: true       // clear all form fields after successful submit 
        resetForm: true        // reset the form after successful submit 
 
        // $.ajax options can be used here too, for example: 
        //timeout:   3000 
    }; 
	var name    = document.getElementById("name").value;
	var phone   = document.getElementById("phone").value;
	var country = document.getElementById("country").value;
	var email   = document.getElementById("email").value;
	var at = "@";
	var dot = ".";
	var lat = email.indexOf(at);
	var lstr = email.length;
	var ldot = email.indexOf(dot);
	
	if (name == "")
	{
	   
	   jQuery.facebox("REQUIRED FIELD: Please enter your name");
	}else if (email.indexOf(at)==-1){
	   jQuery.facebox("Invalid E-mail");
	}else if (email.indexOf(at)==-1 || email.indexOf(at)==0 || email.indexOf(at)==lstr){
	   jQuery.facebox("Invalid E-mail");
	}else if (email.indexOf(dot)==-1 || email.indexOf(dot)==0 || email.indexOf(dot)==lstr){
		jQuery.facebox("Invalid E-mail");
	}else if (email.indexOf(at,(lat+1))!=-1){
		jQuery.facebox("Invalid E-mail");
		return false;
	}else if (email.substring(lat-1,lat)==dot || email.substring(lat+1,lat+2)==dot){
		jQuery.facebox("Invalid E-mail");
	}else if (email.indexOf(dot,(lat+2))==-1){
		jQuery.facebox("Invalid E-mail");
	}else if (email.indexOf(" ")!=-1){
		jQuery.facebox("Invalid E-mail");
	}else if (country == "")
	{
			jQuery.facebox("REQUIRED FIELD: Please enter your country");
	}else if (phone == "")
	{
			jQuery.facebox("REQUIRED FIELD: Please enter a contact phone");
	}else
	{
		$('#searchform').ajaxForm(options);
	}
}); 
}

function contactRequest() { 
$(document).ready(function() { 
    var options = { 
        target:        '#hiddenResponse',   // target element(s) to be updated with server response 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse, // post-submit callback 
 		url:       	   'contact-script.php',        // override for form's 'action' attribute 
        //type:      type        // 'get' or 'post', override for form's 'method' attribute 
        //dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 
        //clearForm: true       // clear all form fields after successful submit 
        resetForm: true        // reset the form after successful submit 
 
        // $.ajax options can be used here too, for example: 
        //timeout:   3000 
    }; 
	var name    = document.getElementById("name2").value;
	var phone   = document.getElementById("phone2").value;
	var country = document.getElementById("country2").value;
	var email   = document.getElementById("email2").value;
	var at = "@";
	var dot = ".";
	var lat = email.indexOf(at);
	var lstr = email.length;
	var ldot = email.indexOf(dot);
	
	if (name == "")
	{
	   
	   jQuery.facebox("REQUIRED FIELD: Please enter your name");
	}else if (email.indexOf(at)==-1){
	   jQuery.facebox("Invalid E-mail");
	}else if (email.indexOf(at)==-1 || email.indexOf(at)==0 || email.indexOf(at)==lstr){
	   jQuery.facebox("Invalid E-mail");
	}else if (email.indexOf(dot)==-1 || email.indexOf(dot)==0 || email.indexOf(dot)==lstr){
		jQuery.facebox("Invalid E-mail");
	}else if (email.indexOf(at,(lat+1))!=-1){
		jQuery.facebox("Invalid E-mail");
		return false;
	}else if (email.substring(lat-1,lat)==dot || email.substring(lat+1,lat+2)==dot){
		jQuery.facebox("Invalid E-mail");
	}else if (email.indexOf(dot,(lat+2))==-1){
		jQuery.facebox("Invalid E-mail");
	}else if (email.indexOf(" ")!=-1){
		jQuery.facebox("Invalid E-mail");
	}else if (country == "")
	{
			jQuery.facebox("REQUIRED FIELD: Please enter your country");
	}else if (phone == "")
	{
			jQuery.facebox("REQUIRED FIELD: Please enter a contact phone");
	}else
	{
		$('#contactform').ajaxForm(options);
	}
}); 
}

// pre-submit callback 
function showRequest(formData, jqForm, options) { 
    // formData is an array; here we use $.param to convert it to a string to display it 
    // but the form plugin does this for you automatically when it submits the data 
    var queryString = $.param(formData); 
 
    // jqForm is a jQuery object encapsulating the form element.  To access the 
    // DOM element for the form do this: 
    // var formElement = jqForm[0]; 
 
    // here we could return false to prevent the form from being submitted; 
    // returning anything other than false will allow the form submit to continue 
    return true; 
} 
 
// post-submit callback 
function showResponse(responseText, statusText)  { 
    // for normal html responses, the first argument to the success callback 
    // is the XMLHttpRequest object's responseText property 
 
    // if the ajaxForm method was passed an Options Object with the dataType 
    // property set to 'xml' then the first argument to the success callback 
    // is the XMLHttpRequest object's responseXML property 
 
    // if the ajaxForm method was passed an Options Object with the dataType 
    // property set to 'json' then the first argument to the success callback 
    // is the json data object returned by the server 
 	jQuery.facebox(responseText);
}
var locations_data = { locations: [
	{
		simpleContent: "<b>Helios Apartments</b><br />Plakias, Rethymno, Crete<br /><br />...just a few meters from the sea",
		maximizedContent: "",
		latitude: 35.191168,
		longitude: 24.392782,
		zoom:  17,
		icon: "pin.png"
	}
]};

var now = new Date();
var calendar1 = new CalendarPopup("calendar1"); 
var calendar2 = new CalendarPopup("calendar2"); 
calendar1.setCssPrefix("TEST");
calendar2.setCssPrefix("TEST");
calendar1.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
calendar2.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
