﻿<!--
var ts = '';
var bastar = '';
var bittar = '';
var siradakiodano = 0;//ajaxsrcden oku
//var hotid = displayItem("id");
var _root = ''; //'/demo';

/////////////////////////////////////////////////////////////////////////
function proomNum(odasayi)
{
	if(odasayi == "1")
	{
		document.getElementById("spOda1").style.display = 'none' ;
		proomShowHide("8","none");
	}
	else
	{
		document.getElementById("spOda1").style.display = '' ;
		proomShowHide(odasayi,"");
	}
}
function proomShowHide(lastindex,display)
{

	for(i=2;i<=parseInt(lastindex);i++)
	{
		document.getElementById("trOda" + i).style.display = display ;
	}
	if(parseInt(lastindex)<8)
	{
		for(i=parseInt(lastindex)+1;i<=8;i++)
		{
			document.getElementById("trOda" + i).style.display = (display == "none") ? "" : "none" ;
		}
	}
}
function pageNum(odasayi,cocsayi)
{
	if(cocsayi == 0)
	{
		pageShowHide("3",odasayi,"none");
	}
	else
	{
		pageShowHide(cocsayi,odasayi,"");
	}
}
function pageShowHide(lastindex,odasayi,display)
{

	for(i=1;i<=parseInt(lastindex);i++)
	{
		document.getElementById("spYas" + odasayi + i).style.display = display ;
	}
	if(parseInt(lastindex)<3)
	{
		for(i=parseInt(lastindex)+1;i<=3;i++)
		{
			document.getElementById("spYas" + odasayi + i).style.display = (display == "none") ? "" : "none" ;
		}
	}
}
/////////////////////////////////////////////////////////////////////////
function pstrAdultNum(odasayi)
{
	tmp = "";
	var tmpObj = null;
	for(i=1;i<=parseInt(odasayi);i++)
	{
		tmpObj = document.getElementById("ddAdult" + i);
		tmp += tmpObj.options[tmpObj.selectedIndex].value + ",";
	}
	if(tmp != "")tmp = tmp.substring(0,tmp.length-1);
	return tmp;
}
function pstrChildNum(odasayi)
{
	tmp = "";
	var tmpObj = null;
	for(i=1;i<=parseInt(odasayi);i++)
	{
		tmpObj = document.getElementById("ddChild" + i);
		tmp += tmpObj.options[tmpObj.selectedIndex].value + ",";
	}
	if(tmp != "")tmp = tmp.substring(0,tmp.length-1);
	return tmp;
}
function pstrAgeNum(odasayi)
{
	var tmp = "";
	var tmpObj = null;
	var tmpObj2 = null;
	var cocsayi = 0;
	for(i=1;i<=parseInt(odasayi);i++)
	{	
		tmpObj = document.getElementById("ddChild" + i);
		cocsayi = tmpObj.options[tmpObj.selectedIndex].value;
		for(j=1;j<=parseInt(cocsayi);j++)
		{
			tmpObj2 = document.getElementById("ddYas" + i + j);
			tmp += i + "," + j + "," + tmpObj2.options[tmpObj2.selectedIndex].value + "|";
		}
	}
	if(tmp != "")tmp = tmp.substring(0,tmp.length-1);
	return tmp;
}

/////////////////////////////////////////////////////////////////////////
function paraSbmt1(reqodasira,bookodaid,reqodaids)
{
	if(!validDate())
	{
		alert('Check-in date must be further than today.');
		return false;
	}
	else if(Trim(document.getElementById('BaslaTarih').value)== '')
	{
		alert('Please select check-in date.');
		return false;
	}
	else if(Trim(document.getElementById('BitisTarih').value)== '')
	{
		alert('Please select check-out date.');
		return false;
	}
	else
	{
		siradakiodano = reqodasira;
		bastar = document.getElementById('BaslaTarih').value;
		bittar = document.getElementById('BitisTarih').value;
		odasayi = document.getElementById('ddOdaSayi').value;
		
		ads = "&an=" + pstrAdultNum(odasayi); //adults
		chs = "&cn=" + pstrChildNum(odasayi); //childs
		ags = "&ag=" + pstrAgeNum(odasayi); //ages
		reqodasira = "&rqos=" + reqodasira;//requested oda sira
		bookodaid = "&boid=" + bookodaid;//book edilmek istenen oda id
		reqodaids = "&rqoids=" + reqodaids;//requested book ids > 13,14 ..
		pg = "&pg=" + document.getElementById('hidPg').value;
		hname = ''; //"&hname=" + document.getElementById('txtHotelName').value;
	    hclass = ''; //"&hclass=" + (document.getElementById('ddHotelClass') ? document.getElementById('ddHotelClass').value : displayItem('hclass'));
	    hloc = ''; //"&hloc=" + (document.getElementById('ddHotelLocation') ? document.getElementById('ddHotelLocation').value : displayItem('hloc'));
		
		ts = 'bt='+document.getElementById('BaslaTarih').value+'&st='+document.getElementById('BitisTarih').value;
		document.getElementById('tbOda').style.display = '';
		document.getElementById('spOdaBekle').innerHTML = '<IMG src=\"'+_root+'/admin/images/loading.gif\" border=\"0\">&nbsp;Loading rooms. Please wait...</SPAN> </SPAN>';
		document.getElementById('spOdaBekle').style.display = '';
		location.href = '#home';
		//document.getElementById('spOdaTable').style.display = '';
		//document.getElementById('tbKisi').style.display = 'none';
		//document.getElementById('tbFiyat').style.display = 'none';
		//alert(ts+ads+chs+ags+reqodasira+bookodaid+reqodaids);
		call_async('spOdaBekle',ts+ads+chs+ags+reqodasira+bookodaid+reqodaids+pg+hname+hclass+hloc,'1',odasayi);
	}
}
function pprepQuery()
{
	bastar = document.getElementById('BaslaTarih').value;
	bittar = document.getElementById('BitisTarih').value;
	odasayi = document.getElementById('ddOdaSayi').value;
	ads = "&an=" + pstrAdultNum(odasayi); //adults
	chs = "&cn=" + pstrChildNum(odasayi); //childs
	ags = "&ag=" + pstrAgeNum(odasayi); //ages
	reqodasira = "&rqos=";//requested oda sira
	bookodaid = "&boid=";//book edilmek istenen oda id
	reqodaids = "&rqoids=";//requested book ids > 13,14 ..
	pg = "&pg=" + document.getElementById('hidPg').value;
	hname = ''; //"&hname=" + document.getElementById('txtHotelName').value;
	hclass = ''; //"&hclass=" + document.getElementById('ddHotelClass').value;
	hloc = ''; //"&hloc=" + document.getElementById('ddHotelLocation').value;
	
	ts = 'bt='+document.getElementById('BaslaTarih').value+'&st='+document.getElementById('BitisTarih').value;

	return ts+ads+chs+ags+reqodasira+bookodaid+reqodaids+pg+hname+hclass+hloc;
}
function pprepQuery_ic()
{
	bastar = document.getElementById('BaslaTarih_ic').value;
	bittar = document.getElementById('BitisTarih_ic').value;
	odasayi = document.getElementById('ddOdaSayi_ic').value;
	ads = "&an=1";// + pstrAdultNum(odasayi); //adults
	chs = "&cn=0";// + pstrChildNum(odasayi); //childs
	ags = "&ag=0,0,0";// + pstrAgeNum(odasayi); //ages
	reqodasira = "&rqos=";//requested oda sira
	bookodaid = "&boid=";//book edilmek istenen oda id
	reqodaids = "&rqoids=";//requested book ids > 13,14 ..
	pg = "&pg=" + document.getElementById('hidPg').value;
	hname = ''; //"&hname=" + document.getElementById('txtHotelName').value;
	hclass = ''; //"&hclass=" + document.getElementById('ddHotelClass').value;
	hloc = ''; //"&hloc=" + document.getElementById('ddHotelLocation').value;
	
	ts = 'bt='+document.getElementById('BaslaTarih_ic').value+'&st='+document.getElementById('BitisTarih_ic').value;
	
	return ts+ads+chs+ags+reqodasira+bookodaid+reqodaids+pg+hname+hclass+hloc;
}
function premoteStart(bastar,bittar,odasayi,adultsayi,childsayi,childyas)
{
    call_async2('spHotelClass',_root+'/ajaxsrv.aspx?t=hc&slc='+displayItem('hclass'),'1');
    call_async2('spHotelLocation',_root+'/ajaxsrv.aspx?t=hl&slc='+displayItem('hloc'),'2');
    
	document.getElementById('BaslaTarih').value = bastar;
	document.getElementById('BitisTarih').value = bittar;
	
	//document.getElementById('txtHotelName').value = displayItem('hname');
	
	document.getElementById('ddOdaSayi').selectedIndex = odasayi - 1;
	proomNum(odasayi);
	
	var anum = new Array();
	anum = adultsayi.split(',');
	for(i=0;i<anum.length;i++)
		document.getElementById('ddAdult' + (i+1)).selectedIndex = anum[i] - 1;
	
	var agnum = new Array();
	var cnum = new Array();
	cnum = childsayi.split(',');
	var bas = 0,bit = 0;
	for(j=0;j<cnum.length;j++)
	{
		document.getElementById('ddChild' + (j+1)).selectedIndex = cnum[j];
		pageNum((j+1),cnum[j]);
		
		if(childyas != ''){
		    bas += j==0 ? 0 : parseInt(cnum[j-1]);
		    bit += parseInt(cnum[j]);
			for(k=bas;k<bit;k++)
			{
				agnum = childyas.split('|')[k];
				
				if(parseInt(cnum[j]) > 0)
					document.getElementById('ddYas' + agnum.split(',')[0] + agnum.split(',')[1]).selectedIndex = agnum.split(',')[2];
			}
		}
	}
	if(bastar != "" & bittar != "")
		paraSbmt1('1','0','');
}

function popRoomDet(oid)
{
	window.open('PopRoomDet.aspx?id='+oid,'','width=400,height=460,scrollbars=2');
}

function validDate()
{
	bastar = document.getElementById('BaslaTarih').value;
	
	var l_dt = new Date();
	var today = Date.UTC( l_dt.getFullYear(), l_dt.getMonth()+1, l_dt.getDate());
	var secondDate1 = new Date(bastar.split('/')[2],bastar.split('/')[1]-1,bastar.split('/')[0]);
	var secondDate = Date.UTC( secondDate1.getFullYear(), secondDate1.getMonth()+1, secondDate1.getDate());
	
	if(today>secondDate)return false;
	else return true;
}

function validDate1()
{
	bastar = document.getElementById('BaslaTarih').value;
	bittar = document.getElementById('BitisTarih').value;
	
	var firstDate1 = new Date(bastar.split('/')[2],bastar.split('/')[1]-1,bastar.split('/')[0]);
	//var firstDate = Date.UTC( firstDate1.getFullYear(), firstDate1.getMonth()+1, firstDate1.getDate());
	var firstDate = Date.parse( (firstDate1.getMonth()+1)+"/"+firstDate1.getDate()+"/"+ firstDate1.getFullYear());
	//alert(firstDate);
	var secondDate1 = new Date(bittar.split('/')[2],bittar.split('/')[1]-1,bittar.split('/')[0]);
	//var secondDate = Date.UTC( secondDate1.getFullYear(), secondDate1.getMonth()+1, secondDate1.getDate());
	var secondDate = Date.parse( (secondDate1.getMonth()+1)+"/"+secondDate1.getDate()+"/"+ secondDate1.getFullYear());
	//alert(secondDate);
	if(firstDate>=secondDate)return false;
	else return true;
}

function validDate_ic()
{
	bastar = document.getElementById('BaslaTarih_ic').value;
	
	var l_dt = new Date();
	var today = Date.UTC( l_dt.getFullYear(), l_dt.getMonth()+1, l_dt.getDate());
	var secondDate1 = new Date(bastar.split('/')[2],bastar.split('/')[1]-1,bastar.split('/')[0]);
	var secondDate = Date.UTC( secondDate1.getFullYear(), secondDate1.getMonth()+1, secondDate1.getDate());
	
	if(today>secondDate)return false;
	else return true;
}

function validDate1_ic()
{
	bastar = document.getElementById('BaslaTarih_ic').value;
	bittar = document.getElementById('BitisTarih_ic').value;
	
	var firstDate1 = new Date(bastar.split('/')[2],bastar.split('/')[1]-1,bastar.split('/')[0]);
	//var firstDate = Date.UTC( firstDate1.getFullYear(), firstDate1.getMonth()+1, firstDate1.getDate());
	var firstDate = Date.parse( (firstDate1.getMonth()+1)+"/"+firstDate1.getDate()+"/"+ firstDate1.getFullYear());
	//alert(firstDate);
	var secondDate1 = new Date(bittar.split('/')[2],bittar.split('/')[1]-1,bittar.split('/')[0]);
	//var secondDate = Date.UTC( secondDate1.getFullYear(), secondDate1.getMonth()+1, secondDate1.getDate());
	var secondDate = Date.parse( (secondDate1.getMonth()+1)+"/"+secondDate1.getDate()+"/"+ secondDate1.getFullYear());
	//alert(secondDate);
	if(firstDate>=secondDate)return false;
	else return true;
}
//-->
