	function emailcheck(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr || str.indexOf(at,(lat+1))!=-1 || str.indexOf(" ")!=-1){
		   alert("Wrong e-mail!")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr || str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot || str.indexOf(dot,(lat+2))==-1){
		    alert("Wrong e-mail!")
		    return false
		}

		if (lstr<5) {
			alert("Wrong e-mail!");
			return false;
		}		
 		 return true					
	}
	
	function initRequest() {
     if (window.XMLHttpRequest) {
         return new XMLHttpRequest();
     } else if (window.ActiveXObject) {
         isIE = true;
         return new ActiveXObject("Microsoft.XMLHTTP");
     }
	}
	
	function submitForm() {
		var url = "contact_us.php";
		var req = initRequest();
		if(!emailcheck(document.contform.email.value)) return false;
		if(document.contform.country.value.length==0 ||document.contform.fname.value.length==0 || document.contform.lname.value.length==0) { alert('All fields with * must be filled!'); return false; }
		if(document.contform.email.value!=document.contform.retypeemail.value) { alert('Retype the correct email!'); return false; }
		
		req.onreadystatechange = function() {
			if (req.readyState == 4)
				if (req.status == 200) {
					document.getElementById('contactformdiv').innerHTML=req.responseText;
				}
		};
    req.open("POST", url, true);
    req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		req.send(
		'fname='+document.contform.fname.value+
		'&lname='+document.contform.lname.value+
		'&email='+document.contform.email.value+
		'&address='+document.contform.address.value+
		'&zip='+document.contform.zip.value+
		'&country='+document.contform.country.value+
		'&city='+document.contform.city.value+
		'&phone='+document.contform.phone.value+
		'&fax='+document.contform.fax.value+
		'&comments='+document.contform.comments.value);
	}
	
	function submitForm2() {
		var url = "news.php";
		var req = initRequest();
		if(!emailcheck(document.contform.email.value)) return false;
		if(document.contform.fname.value.length==0 || document.contform.lname.value.length==0) { alert('All fields with * must be filled!'); return false; }
		
		
		req.onreadystatechange = function() {
			if (req.readyState == 4)
				if (req.status == 200) {
					document.getElementById('contactformdiv').innerHTML=req.responseText;
				}
		};
    req.open("POST", url, true);
    req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		req.send(
		'address='+document.contform.address.value+
		'&zip='+document.contform.zip.value+
		'&country='+document.contform.country.value+
		'&city='+document.contform.city.value+
		'&email='+document.contform.email.value+
		'&fname='+document.contform.fname.value+
		'&lname='+document.contform.lname.value);
	}
	function getRadioValue(ro) {
		var i;
		for(i=0; i<ro.length; i++) if(ro[i].checked) return ro[i].value;
		return '';
	}
	function submitForm3() {
		var url = "booking_request.php";
		var req = initRequest();
		if(!emailcheck(document.contform.email.value)) return false;
		if(document.contform.fname.value.length==0 || document.contform.lname.value.length==0 || document.contform.address.value.length==0 || document.contform.city.value.length==0 || document.contform.zip.value.length==0 ||	document.contform.country.value.length==0 ||	document.contform.phone.value.length==0 || document.contform.email.value.length==0 ||	document.contform.retypeemail.value.length==0) { alert('All fields with * must be filled!'); return false; }

		
		req.onreadystatechange = function() {
			if (req.readyState == 4)
				if (req.status == 200) {
					//document.getElementById('contactformdiv').innerHTML=req.responseText;
					//document.getElementById('contactformdiv').scrollIntoView(true);
					eval(req.responseText);
				}
		};
    req.open("POST", url, true);
    req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		req.send(
		'email='+document.contform.email.value+
		'&fname='+document.contform.fname.value+
		'&lname='+document.contform.lname.value+
		'&ititle='+getRadioValue(document.contform.ititle)+
		'&address='+document.contform.address.value+
		'&city='+document.contform.city.value+
		'&zip='+document.contform.zip.value+
		'&country='+document.contform.country.value+
		'&phone='+document.contform.phone.value+
		'&fax='+document.contform.fax.value+
		'&retypeemail='+document.contform.retypeemail.value+
		'&numofadults='+document.contform.numofadults.value+
		'&numofinfants='+document.contform.numofinfants.value+
		'&numofchildren='+document.contform.numofchildren.value+
		'&agesofchildren='+document.contform.agesofchildren.value+
		'&selecthotel1='+document.contform.selecthotel1.options[document.contform.selecthotel1.selectedIndex].text+
		'&s_period1='+document.contform.s_period1.value+
		'&e_period1='+document.contform.e_period1.value+
		'&selecthotel2='+document.contform.selecthotel2.options[document.contform.selecthotel2.selectedIndex].text+
		'&s_period2='+document.contform.s_period2.value+
		'&e_period2='+document.contform.e_period2.value+
		'&selecthotel3='+document.contform.selecthotel3.options[document.contform.selecthotel3.selectedIndex].text+
		'&s_period3='+document.contform.s_period3.value+
		'&e_period3='+document.contform.e_period3.value+
		'&rentacar='+getRadioValue(document.contform.rentacar)+
		'&comments='+document.contform.comments.value+
		'&findus='+document.contform.findus.value		
		);
	}
	
	
	function hotel_booking() {

		
		var url = "hotel_booking_ajax.php";
		var req = initRequest();
	
		
		
		req.onreadystatechange = function() {
			if (req.readyState == 4)
				if (req.status == 200) {
					eval(req.responseText);
				}
		};
    req.open("POST", url, true);
    req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    
    var lektiko;
    for(i=1;i<=document.getElementById('num_rooms').value;i++){
					   if (document.getElementById('select_rt'+i)) lektiko=lektiko+'&num_days'+i+'='+document.getElementById('num_days'+i).value+'&rt_id'+i+'='+document.getElementById('select_rt'+i).value;
		}
		req.send(
		'hotelid='+document.contform.hotelid.value+
		'&s_date='+document.contform.s_date.value+
		'&num_rooms='+document.contform.num_rooms.value+
		lektiko
		);

	}