<!--
// ==================================================================== //
// ==================================================================== //
//                    OBISO INTERNET Tec. & Solutions                   //
//                        coder : Ozan BESINCI                          //
//   izin almaniz dogrultusunda kodlar ücretsiz olarak kullanilabilir   //
//              yardima ihtiyaciniz olursa info@obiso.com               //
// ==================================================================== //
// ==================================================================== //

// ==================== RESERVATION FORMU KONTROLU ==================== //
function rezervasyon(){
	var obiso = (document.form1)
	var d_ArrDate         = obiso.giris_tarihi.value.Trim();
	var d_DepDate         = obiso.bitis_tarihi.value.Trim();
	
	if (obiso.lakap[obiso.lakap.selectedIndex].value == "0") {
		alert("Please select your title.");
		obiso.lakap.focus();
		return false;
	}
	 
	if (obiso.ad.value == "") {
		alert("Please enter your first name.");
		obiso.ad.focus();
		return false;
	}
	if (obiso.ad.value.length<2){
         alert("Please enter your right first name.");
         return false;
	}
	if (obiso.soyad.value == "") {
		alert("Please enter your sur name.");
		obiso.soyad.focus();
		return false;
	}
	if (obiso.soyad.value.length<2){
         alert("Please enter your right sur name.");
         return false;
	}
	if (obiso.email.value == "") {
		alert("Please enter your e-mail.");
		obiso.email.focus();
		return false;	
	}
	
	if (chk(/^[a-z0-9\#\+\.\_\!\-]{1,20}\@[a-z0-9\.\_\-]{2,30}\.[a-z]{1,4}$/,obiso.email.value)==null) {
		alert("Please enter your right e-mail.");
		obiso.email.focus();
		return false;
		}
	
	if (obiso.adres.value == "") {
		alert("Please enter your address.");
		obiso.adres.focus();
		return false;
	}
     if (obiso.adres.value.length<8){
         alert("Please enter your right address.");
         return false;
	}
	if (obiso.sehir.value == "") {
		alert("Please enter your city.");
		obiso.sehir.focus();
		return false;
	
	}
	if (obiso.sehir.value.length<2){
         alert("Please enter your right city.");
         return false;
	}
	if (obiso.posta.value == "") {
		alert("Please enter your postal code.");
		obiso.posta.focus();
		return false;
	}
	if (obiso.posta.value.length<2){
         alert("Please enter your right postal code.");
         return false;
	}
	
	if (obiso.ulke[obiso.ulke.selectedIndex].value == "0") {
		alert("Please select your country.");
		obiso.ulke.focus();
		return false;
	}
	if (obiso.tel.value == "") {
		alert("Please enter your phone number. Ex.441254796587. ");
		obiso.tel.focus();
		return false;
	}
    if (obiso.tel.value>"99999999" || obiso.tel.value<"00000000"){
        alert("Please enter your numeral phone number. Ex.441254796587.");
        return false;
	}
     if (obiso.tel.value.length<7){
         alert("Please enter your complete phone number. Ex.441254796587.");
         return false;
	}
	
	if (obiso.giris_tarihi.value == "") {
		alert("Please enter your check-in date.");
		obiso.giris_tarihi.focus();
		return false;
	}
	if (obiso.bitis_tarihi.value == "") {
		alert("Please enter your check-out date.");
		obiso.bitis_tarihi.focus();
		return false;
	}
	if (check_date(d_ArrDate, '.') != 1){
	    alert("Please check your check-in date (ex: 01.01.2003).");
		obiso.giris_tarihi.focus();
		return false;
	}
	if (check_date(d_DepDate, '.') != 1){
		alert("Please check your check-out date (ex: 01.01.2003).");
		obiso.bitis_tarihi.focus();
		return false;
	}
	if (check_date(d_ArrDate, '.') == 1 && check_date(d_DepDate, '.') == 1){
		if (date_ms(d_ArrDate, '.') < date_ms(get_today_date('.'), '.')){
		alert("Check-in date must be older than today.");
		obiso.bitis_tarihi.focus();
		return false;
	}
	if (date_ms(d_ArrDate, '.') >= date_ms(d_DepDate, '.')){
		alert("Check-out date must be older than check-in date.");
		obiso.bitis_tarihi.focus();
		return false;
			
		}
	}
	if (obiso.kisi.value == "") {
		alert("Please enter your number of party.");
		obiso.kisi.focus();
		return false;
	}
function chk(re,a){
  a=a.replace(/(^\s*)|(\s*$)/g, "");
  a=a.replace(/\s{1,}/g, " ");
  return a.match(re);
		
	}
	return true;
}	
// == Rezervasyon Formundaki tarih doğrulama ile ilgili fonksiyonlar == //
// 	fonksiyonları temizleme
String.prototype.Trim = function(){
	return this.replace(/(^\s*)|(\s*$)/g, "");
}

String.prototype.LTrim = function(){
	return this.replace(/(^\s*)/g, "");
}

String.prototype.Rtrim = function(){
	return this.replace(/(\s*$)/g, "");
}
// Tarihi "dd.mm.yyyy" formatina göre onaylama
function check_date(d_Date, str_Separator){
	var arr_DateParts;
	var n_Errors = 0;
	
	arr_DateParts = d_Date.split(str_Separator);
	
	if (arr_DateParts[0].Trim().length > 2 || arr_DateParts[1].Trim().length > 2 ||
		arr_DateParts[2].Trim().length > 4 || arr_DateParts[2].Trim().length < 4){
		n_Errors++;
	}
	
	for (i in arr_DateParts){
		if (isNaN(parseInt(arr_DateParts[i])) == true){
			n_Errors++;
		}
	}
	
	if (isNaN(parseInt(arr_DateParts[0])) == false){
		if (arr_DateParts[0] > 31){
			n_Errors++;
		}
	}
	
	if (isNaN(parseInt(arr_DateParts[1])) == false){
		if (arr_DateParts[1] > 12){
			n_Errors++;
		}
	}
	
	if (n_Errors > 0){
		return -1;
	}else{
		if (check_date_validaty(arr_DateParts[0].Trim(), arr_DateParts[1].Trim(), arr_DateParts[2].Trim()) == 1){
			return 1;
		}else{
			return -1;
		}
	}
}
//	convert date to numbers of millisecond since January 1, 1970, 00:00:00 //
function date_ms(d_Date, str_Separator){
	var arr_DateParts	= d_Date.split(str_Separator);
	var n_DateUTC		= Date.UTC((arr_DateParts[2] - 1900), (arr_DateParts[1] - 1), arr_DateParts[0]);
	
	return n_DateUTC;
}
//	get today date in '01.01.2001' format
function get_today_date(n_Separator){
	var obj_Today			= new Date();
	var d_Today				= obj_Today.getDate() + n_Separator + (obj_Today.getMonth() + 1) + n_Separator + obj_Today.getYear()
	
	return d_Today;
}
//	amount digits grouping function
function digit_grouping(n_Amount){
	var str_Amount			= '';
	var str_AmountGrouped	= '';
	var i					= '';
	
	str_Amount	= n_Amount.toString();
	i			= str_Amount.length;
	
	while (i >= 0){
		i -= 3;
		if (i > 0){
			str_AmountGrouped = '.' + str_Amount.substr(i,3) + str_AmountGrouped;
		}else{
			str_AmountGrouped = str_Amount.substr(0,(i + 3)) + str_AmountGrouped;
		}
	}
	
	return str_AmountGrouped;
}
//	check numeric values
function is_Numeric(n_Value){
	if (isNaN(parseInt(n_Value)) == true){
		return -1;
	}else{
		return 1;
	}
}
//	get UserAgent (browser)
function UA(){
	if (navigator.appName.indexOf("Netscape") != -1)
		return 'NN';
	if (navigator.appName.indexOf("Microsoft") != -1)
		return 'IE';
}
//	show hide layers function,
//	where str_LayerID is a layer name, and str_Action is a 'show' or 'hide'
function showhidelayer(str_LayerID, str_Action){
	if (str_LayerID.Trim() != '' && str_Action.Trim() != ''){
		obj_Layer = (UA() == 'NN') ? eval('document.layers.' + str_LayerID) : eval('document.all.' + str_LayerID);
		
		if (str_Action == 'show')
			obj_Layer.style.display = 'block';
		if (str_Action == 'hide')
			obj_Layer.style.display = 'none';
	}
}
// check date validaty, return 1 if date is true or -1 if date is not true //
function check_date_validaty(dp_Day, dp_Month, dp_Year){
	var arr_MonthDays	= new Array(12);
	
	arr_MonthDays[0]	= 31;
	arr_MonthDays[1]	= 28;
	arr_MonthDays[2]	= 31;
	arr_MonthDays[3]	= 30;
	arr_MonthDays[4]	= 31;
	arr_MonthDays[5]	= 30;
	arr_MonthDays[6]	= 31;
	arr_MonthDays[7]	= 31;
	arr_MonthDays[8]	= 30;
	arr_MonthDays[9]	= 31;
	arr_MonthDays[10]	= 30;
	arr_MonthDays[11]	= 31;
	
	if (dp_Day > 0 && dp_Month > 0 && dp_Year > 0){
		if (dp_Month <= 12){
			if (dp_Year/4 == Math.floor(dp_Year/4)){
				arr_MonthDays[1] = 29;
			}
			
			if (dp_Day <= arr_MonthDays[dp_Month - 1]){
				return 1;
			}else{
				return -1;
			}
		}else{
			return -1;
		}
	}
}
//	popup pencere yoket
function destroy_opener(str_WindowName){
	if (opener){
		var obj_PopUpWindow = eval('opener.' + str_WindowName);
		if (obj_PopUpWindow){
			obj_PopUpWindow = null;
		}
	}
}
//****************************************** CONTACTS ******************************************
function Contacts(){
var obiso = document.form1
if (obiso.ad.value == "") {
		alert("Please enter your name.");
		obiso.ad.focus();
		return false;
	}
	if (obiso.soyad.value == "") {
		alert("Please enter your surname.");
		obiso.soyad.focus();
		return false;
	}
	if (obiso.email.value == "") {
		alert("please enter your e-mail address.");
		obiso.email.focus();
		return false;	
	}
	if (chk(/^[a-z0-9\#\+\.\_\!\-]{1,20}\@[a-z0-9\.\_\-]{2,30}\.[a-z]{1,4}$/,obiso.email.value)==null) {
		alert("Please enter your e-mail address complate.");
		obiso.email.focus();
		return false;
	}
	if (obiso.konu.value == "") {
		alert("Please enter your subject.");
		obiso.konu.focus();
		return false;
	}
   if ((obiso.giden[0].checked==false) && (obiso.giden[1].checked==false)){
            alert("Please select the branch.");
            obiso.giden[0].focus();
            return false;
    }
	
    if (obiso.mesaj.value == "") {
		alert("Please enter your requests or comments");
		obiso.mesaj.focus();
		return false;
	}
	if (obiso.mesaj.value.length<7){
         alert("Please enter right your requests or comments .");
         return false;
}

function chk(re,a){
  a=a.replace(/(^\s*)|(\s*$)/g, "");
  a=a.replace(/\s{1,}/g, " ");
  return a.match(re);
		
	}
	return true;
}

	//**************************************** GuestBook **************************************** 
function GuestBook()
	{
	var obiso
	obiso = (document.form1)
	if (obiso.ad.value == "") {
		alert("Please enter your name.");
		obiso.ad.focus();
		return false;
	}
	if (obiso.ad.value.length<3){
         alert("Please enter your right name.");
         return false;
	}
	if (obiso.email.value == "") {
		alert("Please enter your e-mail.");
		obiso.email.focus();
		return false;	
	}
	
	if (chk(/^[a-z0-9\#\+\.\_\!\-]{1,20}\@[a-z0-9\.\_\-]{2,30}\.[a-z]{1,4}$/,obiso.email.value)==null) {
		alert("Please enter your right e-mail.");
		obiso.email.focus();
		return false;
		}
	
	if (obiso.ulke[obiso.ulke.selectedIndex].value == "0") {
		alert("Please select your country.");
		obiso.ulke.focus();
		return false;
	}
	if (obiso.mesaj.value == "") {
		alert("Please enter your comments.");
		obiso.mesaj.focus();
		return false;
	}
	if (obiso.mesaj.value.length<3){
         alert("Please enter your right comments.");
         return false;
	}
    
   
	
function chk(re,a){
  a=a.replace(/(^\s*)|(\s*$)/g, "");
  a=a.replace(/\s{1,}/g, " ");
  return a.match(re);
		
	}
	return true;
}
	//-->
     