// JavaScript Document
///////////////////////////////////////////////////////
//          ***** AJAX FUNCTIONS *****               //
///////////////////////////////////////////////////////
var divToShow
var divpicAjax
var divAjaxContent 
// ***** AJAX TO SHOW HOTEL PICTURES *****
function picHotel(htID){ 
	//alert(htID) //picHotAll, divmorePics
	divAjaxContent = ""
	divToShow = "divmorePics"
	divpicAjax = 'picHotAll'
	document.getElementById(divToShow).style.display = 'block';
	document.getElementById(divpicAjax).innerHTML = '<span class="Arial12_Bold_ORA">Loading photos...</spam> <img src="/images/wait.gif">';
  	url = '/A_Get_PicsToPopup.aspx?hotID='+ htID
  //alert(url)
   http_request=GetXmlHttpObject(showpicHotel)
   http_request.open('GET', url, true); 
   http_request.send(null); 
} 
function showpicHotel() { 
	if (http_request.readyState == 4 || http_request.readyState=="complete") { 
	   if (http_request.status != '') { 
	  		divAjaxContent =  http_request.responseText;
			//alert(divAjaxContent)
			//setTimeout ("document.getElementById(divCombAjax).innerHTML  =  divCombineON", 100);
			document.getElementById(divpicAjax).innerHTML  = http_request.responseText; // divAjaxContent;
			//setTimeout("replaceChecks()", 100);
			//document.getElementById(divSimilar).style.display = 'block';
			
	  } 
	   else { 
		    alert('There was a problem with the request.'); 
		   // document.getElementById(divSimilar).innerHTML =  '';
			
		} 
	} 
}
// ***** AJAX TO SHOW HOTEL FEEDBACKS *****
function callFeedBacks(HotelID,HwMy){ 
	document.getElementById('eachFeed').innerHTML = '<img src="/images/wait.gif">';
	 
	url = '/A_Get_HotelFeedBack.aspx?HotelID='+ HotelID +'&HowMany=' + HwMy
	//http_request.onreadystatechange = FeedContents;
	Fhttp_request=FeedXmlHttpObject(FeedContents)
	Fhttp_request.open('GET', url, true); 
	Fhttp_request.send(null); 
} 

function FeedContents() { 
	if (Fhttp_request.readyState == 4) { 
	   if (Fhttp_request.status != '') { 
		 divFeedContent =  Fhttp_request.responseText;
		  setTimeout ("document.getElementById('eachFeed').innerHTML =  divFeedContent", 500 );
 } 
	   else { 
		   alert('There was a problem with the request.'); 
		   document.getElementById('eachFeed').innerHTML =  '';
		} 
	} 

}
function FeedXmlHttpObject(handler){
	if (navigator.userAgent.indexOf("Opera")>=0){
		alert("This City selector doesn't work in Opera")
		return
	}
	if (navigator.userAgent.indexOf("MSIE")>=0){
		var FstrName="Msxml2.XMLHTTP"
			if (navigator.appVersion.indexOf("MSIE 5.5")>=0){
				FstrName="Microsoft.XMLHTTP"
			}
			try{
				FobjXmlHttp=new ActiveXObject(FstrName)
				FobjXmlHttp.onreadystatechange=handler
				return FobjXmlHttp
			}
			catch(e){
				alert("Error. Scripting for ActiveX might be disabled")
				return
			}
	}
	if (navigator.userAgent.indexOf("Firefox")>=0){
	FobjXmlHttp=new XMLHttpRequest()
	FobjXmlHttp.onload=handler
	FobjXmlHttp.onerror=handler
	return FobjXmlHttp
	}
	if (navigator.userAgent.indexOf("Safari")>=0){
	FobjXmlHttp=new XMLHttpRequest()
	FobjXmlHttp.onload=handler
	FobjXmlHttp.onerror=handler
	return FobjXmlHttp
	}
}
// ***** AJAX TO SHOW HOTEL RECENTLY PRICES *****
var loadpg
function recentlyPrice(HotelID,airPortID,nav,plcid,ratID,pgld){ 
	//alert(portID +'|'+ pgld)
	loadpg = pgld // variable to change calendar
	document.getElementById('eachPrice').innerHTML = '<img src="/images/wait.gif">';
	 
   url = '/A_Get_HotelRecentlyPrices.aspx?HotelID='+ HotelID +'&PortID=' + airPortID +'&navL='+ nav +'&plcID='+ plcid +'&idrat='+ ratID
   //http_request.onreadystatechange = FeedContents;
   http_request=GetXmlHttpObject(pricesContents)
   http_request.open('GET', url, true); 
   http_request.send(null); 
} 

function pricesContents() { 

	if (http_request.readyState == 4) { 
	   if (http_request.status != '') { 
		 divPriceContent =  http_request.responseText;
		 setTimeout ( "document.getElementById('eachPrice').innerHTML =  divPriceContent", 500 );
		 if (loadpg != 1){
		 setTimeout ("passValues()",700);
		 }
 	   } 
	   else { 
		   alert('There was a problem with the request.'); 
		    document.getElementById('eachPrice').innerHTML =  '';
		} 
	} 
}
function GetXmlHttpObject(handler){
	if (navigator.userAgent.indexOf("Opera")>=0){
		alert("This City selector doesn't work in Opera")
		return
	}
	if (navigator.userAgent.indexOf("MSIE")>=0){
		var strName="Msxml2.XMLHTTP"
			if (navigator.appVersion.indexOf("MSIE 5.5")>=0){
				strName="Microsoft.XMLHTTP"
			}
			try{
				objXmlHttp=new ActiveXObject(strName)
				objXmlHttp.onreadystatechange=handler
				return objXmlHttp
			}
			catch(e){
				alert("Error. Scripting for ActiveX might be disabled")
				return
			}
	}
	if (navigator.userAgent.indexOf("Firefox")>=0){
	objXmlHttp=new XMLHttpRequest()
	objXmlHttp.onload=handler
	objXmlHttp.onerror=handler
	return objXmlHttp
	}
	if (navigator.userAgent.indexOf("Safari")>=0){
	objXmlHttp=new XMLHttpRequest()
	objXmlHttp.onload=handler
	objXmlHttp.onerror=handler
	return objXmlHttp
	}
}
function passValues(){
	//alert('Helooo')
	var tit = document.dealsForm.calTitle.value;
	//alert(tit)BsDepCity
	//alert(document.BfrmListQry.BsDepCity.value);
	backsel = document.BfrmListQry.BsDepCity.value;
	
	if (backsel == 'type here'){
	
		if (tit == ''){
			var dep = document.dealsForm.calDepDay.value;
			var ret = document.dealsForm.calRetDay.value;
			var nact = document.dealsForm.calPartNA.value;
			var idct = document.dealsForm.selAirport.value;
			var tit = document.dealsForm.calTitle.value;
			//document.BfrmListQry.BInDate1.value = dep;
			//document.BfrmListQry.BOutDate1.value = ret;
			var len = document.BfrmListQry.BiDepCity.length
			for (i=0;i<=len;i++){
				
				if (document.BfrmListQry.BiDepCity.options[i].value == idct){
				eval("document.BfrmListQry.BiDepCity.options[i]").selected = true;
				break;
				}
				
			}
		}
		else{
			if (document.getElementById('priceTitle') != null){
			document.getElementById('priceTitle').innerHTML  = tit
			}
		}
	
	}
	else{
		document.BfrmListQry.BsDepCity.value = 'type here'
		
	}
	
}

///////////////////////////////////////////////////////
//          ***** PAGE FUNCTIONS *****               //
///////////////////////////////////////////////////////
function showComment(refObj)
{
	var layer = document.getElementById('comments');
	var x = findPosX(refObj);
	var y = findPosY(refObj);
	
	var x1 = x - 10;
	var y1 = y - 20;
	layer.style.left = x1;
	layer.style.top = y1;
	layer.style.display = "block";
	var height = document.getElementById('comments').clientHeight;
	var width = document.getElementById('comments').clientWidth;
	var x2 = x1 + width;
	var y2 = y1 + height;
	
	// solve IE select over div bug
	var all = document.getElementsByTagName('*'); 
	for(var k=0, elm; elm=all[k++];) 
	{ 
		var o = elm;
		if (o.type == 'select-one' || o.type == 'select-multiple') 
		{
			if (findPosY(o)	> y1 && findPosY(o) < y2)
			{
				if (findPosX(o) > x1 && findPosX(o) < x2)
				{
					if (o.style)
						o.style.visibility = 'hidden';
				}
			} 
		}
	}
}
function hideComment(refObj)
{
	var all = document.getElementsByTagName('*'); 
	for(var k=0, elm; elm=all[k++];) 
	{ 
		var o = elm;
		if (o.type == 'select-one' || o.type == 'select-multiple') 
		{
		if (o.style) o.style.visibility = 'visible';
		}
	}

	var layer = document.getElementById('comments');
	layer.style.display = "none";
}
function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function SubmitForm()
{
	var selObj = document.getElementById("selAirport");
	val = selObj.options[selObj.selectedIndex].value;
	alert(val)
	document.getElementById("selectedAirport").value = val;
	//alert(document.getElementById("selectedAirport").value)
	document.forms['dealsForm'].submit();
}
// ***** FEEDBACKS NAAVEGATE 
function feedbackward(){
//alert(fnum)
	if (fnum>0){
		window.status=''
		fnum--
		if (fnum==0){
			fnum = 1
		}
		callFeedBacks(feddHotel,fedd[fnum])
		//var fcomm = FeedComm[fnum]
		//eval("document.getElementById('eachFeed').innerHTML=fcomm");
		eval("document.getElementById('feedNo').innerHTML=[fnum]+'/'+ feddTot");
		//eval("document.getElementById('feedNoUp').innerHTML=[fnum]+'/'+ feddTot");
	}
}
function feedforward(){
	if (fnum == 0){
		fnum = 1
	}
	if (fnum<fedd.length-1){
		fnum++
		callFeedBacks(feddHotel,fedd[fnum])
		//var comm = FeedComm[fnum]
		//eval("document.getElementById('eachFeed').innerHTML=comm");
		eval("document.getElementById('feedNo').innerHTML=[fnum]+'/'+ feddTot");
		//eval("document.getElementById('feedNoUp').innerHTML=[fnum]+'/'+ feddTot");
	}
	else window.status='End of Customer Feed backs'
}

// ***** PICTURES NAVEGATE
	function fixward(idNum){
		//alert(idNum)
		eval("document.all[idNum].className = 'BG_red'");
	
		for(i=0;i<totP;i++){
			picM = 'IDpic' + i
			//alert(picM)
			if (picM != idNum){
				eval("document.all[picM].className=''");
			}
			else{
				num = i 
				//alert(i)
				picn = i+1
				document.images.pictureshow.src=picture[num];
				eval("document.all['picNo'].value=[picn]");
			}
		}
	}	
	
	function backward(){
		if (num>=0){
			window.status=''
			num--
			if (num==-1){
				num = 0
			}
			document.images.pictureshow.src=picture[num];
			//eval("document.all['PicName'].value=picname[num]");
			eval("document.all['picNo'].value=[num]");
			numid = 'IDpic' + num
			fixward(numid);
		}
	}
	function forward(){
		if (num == 0){
		//num = 1
		}
		if (num<picture.length-1){
		num++
		document.images.pictureshow.src=picture[num];
		//eval("document.all['PicName'].value=picname[num]");
		eval("document.all['picNo'].value=[num]");
		numid = 'IDpic' + num
		fixward(numid);
		}
		else window.status='End of gallery'
	}
// SHOW INTEREST
	function showINT(a,b){
		document.lookINT.IDint.value = b
		document.lookINT.action = a
		document.lookINT.submit()
	}
// SHOW PLACE GUIDE
	function showGuide(a){
		//alert(a)
		document.IDplaceGuide.action = a
		document.IDplaceGuide.submit()
	}
// EMAIL SUSCRIBE	
	var win = true;	
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		 
		// NewWindowGO('/Mail_Forms/RecordTableMail.asp','1','600','250','yes');
 		 //return true					
	}

function ValidateForm(){
	var emailID=document.SiteEmialList.email
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	
	NewWindowGO('/Mail_Forms/RecordTableMail.asp','1','650','250','yes');return false
	//return true
 }

function NewWindowGO(mypage,myname,w,h,scroll){
//alert(myname)
if (myname==1)
{
eval("a=document.SiteEmialList.email.value");
eval("b=document.SiteEmialList.userID.value");
mypage = mypage+"?email="+a+"&userID="+b
//alert(mypage)
}
if (myname==2)
{
eval("c=window.location.href")
mypage = mypage+c
//alert(mypage)
}
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
}