
function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable = no'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}






$(document).ready(function() {

	//
	// top banner rotaror
	//
	var auto_refresh = setInterval(
	function ()
		{
			var ID = $(".reload").attr("rel");
			$('#fillBanner').load('banner_selector.php?id='+ID).fadeIn("slow");
			
			
		}, 5000
	); // refresh every 10000 milliseconds
	
	
	$('.reload').live("click", function() {
		var ID = $(".reload").attr("rel");
		$('#fillBanner').load('banner_selector.php?id='+ID).fadeIn("slow");
	return false;
	});	
	

	

	

	//
	// side search engine
	//
    $("#continentSelector").jCombo("_ajax_continet_selector.php", { 
		initial_text: "-- Επιλέξτε Ήπειρο --",
		selected_value : '45'
		} 
	);
	
    $("#countrySelector").jCombo("_ajax_country_selector.php?id=", { 
		initial_text: "-- Επιλέξτε Χώρα --",
		parent: "#continentSelector"
		}
	);	
					
    $("#townSelector").jCombo("_ajax_town_selector.php?id=", {
		initial_text: "-- Επιλέξτε Πόλη --",
		parent: "#countrySelector"
		}
	);



	//
	// calendar for search section
	//
	var dates = $( "#from, #to" ).datepicker({

		minDate: 1,
		changeMonth: true,
		changeYear: true,
		dateFormat: 'dd-mm-yy',
		numberOfMonths: 1,
		onSelect: function( selectedDate ) {
			var option = this.id == "from" ? "minDate" : "maxDate",
				instance = $( this ).data( "datepicker" ),
				date = $.datepicker.parseDate(
					instance.settings.dateFormat ||
					$.datepicker._defaults.dateFormat,
					selectedDate, instance.settings );
			dates.not( this ).datepicker( "option", option, date );
		}
	});


	//
	// galleries
	//
	$("a[rel='gallery']").colorbox({
		transition:"elastic",
		opacity: 0.50
	});

	//
	// newsletter
	//
	$('#newsletterSub').live("submit", function() {
		
		var myData = $('#newsletterSub').serialize();
		$.ajax({
		   type: "POST",
		   url: "newsleter_subscribe.php",
		   data: myData,
		   cache: false,
			success: function(html){
				$("#newsletterHolder").empty();
				$("#newsletterHolder").html(html);
			}
		 });

	return false;
	});
	
	
	//
	// tour form submit
	//
	//global vars
	var form = $("#RESERV2");
	var customer_name = $("#customer_name");
	var customer_email = $("#customer_email");
	var customer_phone = $("#customer_phone");
	var customer_pax = $("#customer_pax");
	
	//On blur
	customer_name.blur(validatecustomer_name);
	customer_email.blur(validatecustomer_email);
	customer_phone.blur(validatecustomer_phone);
	customer_pax.blur(validatecustomer_pax);	
	
	//On Submitting
	form.submit(function()
	{
		if(validatecustomer_name() && validatecustomer_email() & validatecustomer_phone() & validatecustomer_pax())
		{
			var myData = $('#RESERV2').serialize();
			$.ajax({
			   type: "POST",
			   url: "send_mail.php",
			   data: myData,
			   cache: false,
				success: function(html){
					$("#sendFinalForm").empty();
					$("#sendFinalForm").html(html);
				}
			 });
			
		
			
		}
		else
		{
			alert("Πεδία μαρκαρισμένα με κόκκινο πρέπει να συμπληρωθούν σωστά!");
		}
	
	return false;
	});


	//validation functions
	function validatecustomer_pax()
	{
		if(customer_pax.val().length < 1) { customer_pax.addClass("error");	return false; }	else  { customer_pax.removeClass("error");	return true; }
	}

	function validatecustomer_name()
	{
		if(customer_name.val().length < 1) { customer_name.addClass("error");	return false; }	else  { customer_name.removeClass("error");	return true; }
	}
	
	function validatecustomer_phone()
	{
		if(customer_phone.val().length < 1) { customer_phone.addClass("error");	return false; }	else  { customer_phone.removeClass("error");	return true; }
	}	

	function validatecustomer_email()
	{
		var a = $("#customer_email").val();
		var filter = /^[a-zA-Z0-9]+[a-zA-Z0-9_.-]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$/;

		if(filter.test(a))  { customer_email.removeClass("error");	return true; } else  { customer_email.addClass("error");	return false; }
	}

	
});


var letters=' ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
var numbers='1234567890'
var signs=',.:;@-\''
var mathsigns='+-=()*/'
var custom='<>#$%&?¿'

function alpha(e,allow) {
     var k;
     k=document.all?parseInt(e.keyCode): parseInt(e.which);
     return (allow.indexOf(String.fromCharCode(k))!=-1);
}

