// JavaScript Document
var http_request = false; 
var divID
var divContent
var divHotID
var jsarray;
var jsarraycount;
var jsarryNo;
var idhotshow;
var mun = 1;
var HotDivCont;
var HOTfeed = new Array();
var HOTnum = 0;
var idsHfeed ;
var totHfeed ;
var HOTcount ;
var feedPlaceID
var feedTot
var timerlen = 5;
var slideAniLen = 250;
var timerID = new Array();
var startTime = new Array();
var obj = new Array();
var endHeight = new Array();
var moving = new Array();
var dir = new Array
var NAobj
var pages
var navpgs
var http_requestPlace = false; 
var divPID
var placeIDn
var placeTYn
var placeSRTn
var placeTOTHn
var placeNAn
var lfirst = 1
var cookPlc
var hwpackdivs

function BDPlaceInit(){
	
	
	feedPlaceID = document.getElementById('IDplace').value;
	feddTot = document.getElementById('TOTfeed').value - 1; 
	placeTYn = document.getElementById('TYplace').value;
	placeTOTHn = document.getElementById('TOThotplace').value; //TOThotplace
	placeNAn = document.getElementById('NAMEplace').value;
	if (feddTot > 0){
		callFeedBacks(feedPlaceID,fedd[1])
	}
	listofHotel(feedPlaceID,placeTYn,'Pick',placeTOTHn,placeNAn)
	cookPlc = readCookie('wFLY')
	if (cookPlc == null){cookPlc = 'True'}
	addFly(cookPlc)
	
}
function BDHWPlaceInit(){
	
	hwpackdivs = document.getElementById('HWpackDiv').value;
	feedPlaceID = document.getElementById('IDplace').value;
	feddTot = document.getElementById('TOTfeed').value - 1; 
	placeTYn = document.getElementById('TYplace').value;
	placeTOTHn = document.getElementById('TOThotplace').value;
	placeNAn = document.getElementById('NAMEplace').value;
	if (feddTot > 0){
		callFeedBacks(feedPlaceID,fedd[1])
	}
	listofHotel(feedPlaceID,placeTYn,'Pick',placeTOTHn,placeNAn)
	initTip()
	
}

function BDInterestInit(){
	
	feedPlaceID = document.getElementById('IDplace').value;
	feddTot = document.getElementById('TOTfeed').value - 1; 
	placeTYn = document.getElementById('TYplace').value;
	placeTOTHn = document.getElementById('TOThotplace').value; //TOThotplace
	placeNAn = document.getElementById('NAMEplace').value;
	if (feddTot > 0){
		callFeedBacks(feedPlaceID,fedd[1])
	}
	if (placeTYn == 1 || placeTYn == 25){
		cookPlc = readCookie('wFLY')
		if (cookPlc == null){cookPlc = 'True'}
		addFly(cookPlc)
	}
}
// ***** AJAX TO SHOW HOTEL FEEDBACKS *****
function HOTcallfeed(hotid,hotna){
	idhotshow = hotid
	jsarray = hotna //'H'+ hotid +'H'
	jsarraycount = jsarray.length
	document.getElementById('div'+ hotid).style.display = 'block';
	//document.getElementById('feedTot'+ idhotshow).innerHTML = jsarraycount ;
	document.getElementById('feedControls'+ hotid).style.display = 'block';
	callHotelFeed(hotid,-1)
}



function callHotelFeed(IDhotel,IDfeed){ 
    //alert(IDhotel+' | '+ IDfeed)
	document.getElementById('cont'+idhotshow).innerHTML = '<img src="/images/wait.gif">';
	url = '/A_Get_HotelFeedBack.aspx?HotelID='+ IDhotel +'&FeedID=' + IDfeed +'&From=HOT'
	//http_request.onreadystatechange = FeedContents;
	Hhttp_request=HotFeedXmlHttpObject(HotFeedContents)
	Hhttp_request.open('GET', url, true); 
	Hhttp_request.send(null); 
} 

function HotFeedContents() { 
	if (Hhttp_request.readyState == 4) { 
	   if (Hhttp_request.status != '') { 
		 divHFeedContent =  Hhttp_request.responseText;
		  setTimeout ("document.getElementById('cont'+idhotshow).innerHTML =  divHFeedContent", 0 );
		  setTimeout ("Hpassval()", 100);
		  	  
 } 
	   else { 
		   alert('There was a problem with the request.'); 
		   document.getElementById('cont'+idhotshow).innerHTML =  '';
		} 
	} 

}
function HotFeedXmlHttpObject(handler){
	if (navigator.userAgent.indexOf("Opera")>=0){
		alert("This City selector doesn't work in Opera")
		return
	}
	if (navigator.userAgent.indexOf("MSIE")>=0){
		var HstrName="Msxml2.XMLHTTP"
			if (navigator.appVersion.indexOf("MSIE 5.5")>=0){
				HstrName="Microsoft.XMLHTTP"
			}
			try{
				HobjXmlHttp=new ActiveXObject(HstrName)
				HobjXmlHttp.onreadystatechange=handler
				return HobjXmlHttp
			}
			catch(e){
				alert("Error. Scripting for ActiveX might be disabled")
				return
			}
	}
	if (navigator.userAgent.indexOf("Firefox")>=0){
	HobjXmlHttp=new XMLHttpRequest()
	HobjXmlHttp.onload=handler
	HobjXmlHttp.onerror=handler
	return HobjXmlHttp
	}
	if (navigator.userAgent.indexOf("Safari")>=0){
	HobjXmlHttp=new XMLHttpRequest()
	HobjXmlHttp.onload=handler
	HobjXmlHttp.onerror=handler
	return HobjXmlHttp
	}
}

function Hpassval(){
		
	if (document.getElementById('totIDsFeed') != null){
		//alert('Hpassval')
		HOTnum = 0
		idsHfeed = document.getElementById('totIDsFeed').value;
		totHfeed = document.getElementById('totHotFeed').value;
		//alert(idsHfeed +" | "+ totHfeed)
		//document.getElementById('feedTot'+ idhotshow).innerHTML = totHfeed
		var idsPart = idsHfeed.split('|');
		//alert(idsPart.length)
		for (i=0;i<=idsPart.length;i++){
			f = i 
			HOTfeed[f] = idsPart[i];
		}
		//alert(HOTfeed[0])
		//alert(HOTnum +' = HOTnum')
		callHotelFeed(idhotshow,HOTfeed[0])
		document.getElementById('feedTot'+ idhotshow).innerHTML = totHfeed
		
	}
}

function Hfeedbackward(){
	//alert(HOTnum +' 1st')
	if (HOTnum>0){
		window.status=''
		HOTnum--
		//if (HOTnum==0){
			//HOTnum = 1
		//}
		//alert(HOTnum +' 2nd')
		callHotelFeed(idhotshow,HOTfeed[HOTnum])
		HOTcount = HOTcount - 1
		//var fcomm = FeedComm[fnum]
		//eval("document.getElementById('eachFeed').innerHTML=fcomm");
		eval("document.getElementById('HfeedNo'+idhotshow).innerHTML=HOTcount");
		//eval("document.getElementById('feedNoUp').innerHTML=[fnum]+'/'+ feddTot");
	}
}
function Hfeedforward(){
	//alert(HOTnum)
	//if (HOTnum == 0){
		//alert(HOTcount)
	//}
	if (HOTnum<totHfeed-1){
		HOTnum++
		callHotelFeed(idhotshow,HOTfeed[HOTnum])
		HOTcount = HOTnum + 1
		//var comm = FeedComm[fnum]
		//eval("document.getElementById('eachFeed').innerHTML=comm");
		eval("document.getElementById('HfeedNo'+idhotshow).innerHTML=HOTcount");
		//eval("document.getElementById('feedNoUp').innerHTML=[fnum]+'/'+ feddTot");
	}
	
	
	else window.status='End of Customer Feed backs'
}
//
//
//
// ***** AJAX TO SHOW PLACE HOTEL FEEDBACKS *****
function callFeedBacks(IDplace,IDfeed){ 
    document.getElementById('eachFeed').innerHTML = '<img src="/images/wait.gif">';
	url = '/A_Get_PlaceFeedBack.aspx?PlaceID='+ IDplace +'&FeedID=' + IDfeed
	//alert(url)
	//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", 50 );
 } 
	   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
	}
}
// ***** FEEDBACKS NAAVEGATE 
function feedbackward(){
//alert(fnum)
	if (fnum>0){
		window.status=''
		fnum--
		if (fnum==0){
			fnum = 1
		}
		callFeedBacks(feedPlaceID,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(feedPlaceID,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'
}
// AJAX TO SHOW HOTEL INFO ******

function moreinfoHotel(hotID){ //hotNA,
	   divID = 'cont'+hotID //cont<%=HotID%>
	   divHotID = hotID
	   document.getElementById('feedControls'+ hotID).style.display = 'none';
	    document.getElementById('div'+ divHotID).style.display = 'block';
	   document.getElementById(divID).innerHTML = '<img src="images/wait.gif">'
	   		//slidedown(divID)
       if (window.XMLHttpRequest) { // Mozilla, Safari,... 
           http_request = new XMLHttpRequest(); 
       } else if (window.ActiveXObject) { // IE 
           http_request = new ActiveXObject("Microsoft.XMLHTTP"); 
       } 
	   url = '/A_Get_HotelInfo.aspx?hotID='+ hotID
       http_request.onreadystatechange = alertContents; 
       http_request.open('GET', url, true); 
       http_request.send(null); 
   } 

   function alertContents() { 
		var divIDC = "'"+ divID +"'"
       if (http_request.readyState == 4) { 
           if (http_request.status != '') { 
               //alert(http_request.responseText); 
			  // document.getElementById('thisHotel').value = http_request.responseText;
			  divContent =  http_request.responseText;
			  document.getElementById(divID).innerHTML =  divContent;
			  document.getElementById('div'+ divHotID).style.display = 'block';
			
			  // document.getElementById('thisHotel').style.display='block';
			  // COshowHotel()
			  //
           } else { 
               alert('There was a problem with the request.'); 
           } 
       } 

   }
  
// AJAX TO SHOW HOTEL LIST ******
// **** hotel on place functions
function sortHOT(srtVal){
	
	listofHotel(feedPlaceID,placeTYn,srtVal,placeTOTHn,placeNAn)
}

function hotONplc(){
lfirst == 2
pages = document.getElementById('hotNopg').value; 
 	for (pg=1;pg<=pages;pg++){
		if (pg == 1){
			navpgs = 'Page: <span id="as'+ pg +'" onclick="pgnation('+pg+');" style="cursor:hand;" class="Arial11BlueBold text-high">'+ pg +'</span>&nbsp;&nbsp;&nbsp;'
			navpgsB = 'Page: <span id="asB'+ pg +'" onclick="pgnation('+pg+');" style="cursor:hand;" class="Arial11BlueBold text-high">'+ pg +'</span>&nbsp;&nbsp;&nbsp;'
		}
		else {
			navpgs = navpgs + '<span id="as'+ pg +'" onclick="pgnation('+pg+');" style="cursor:hand;">'+ pg +'</span>&nbsp;&nbsp;&nbsp;'
			navpgsB = navpgsB + '<span id="asB'+ pg +'" onclick="pgnation('+pg+');" style="cursor:hand;">'+ pg +'</span>&nbsp;&nbsp;&nbsp;'
		}
	document.getElementById('pag').innerHTML = navpgs
	document.getElementById('pagB').innerHTML = navpgsB
	}
	
}

function pgnation(pno){
	location.hash = 'paginas';
	for (p=1;p<=pages;p++){
		if (p==pno){
			document.getElementById('dvpg'+p).style.display = 'block'
			if (document.getElementById('as'+p)!=null){
				document.getElementById('as'+p).className= 'Arial11BlueBold text-high'
			}
			if (document.getElementById('asB'+p)!=null){
				document.getElementById('asB'+p).className= 'Arial11BlueBold text-high'
			}
		}
		else{
			document.getElementById('dvpg'+p).style.display = 'none'
			if (document.getElementById('as'+p)!=null){
				document.getElementById('as'+p).className= 'Arial11_Black'
			}
			if (document.getElementById('asB'+p)!=null){
				document.getElementById('asB'+p).className= 'Arial11_Black'
			}
		}
	}
}




	
function listofHotel(placeIDn,placeTYn,placeSRTn,placeTOTHn,placeNAn){ 
//alert(placeIDn+'|'+placeTYn+'|'+placeSRTn+'|'+placeTOTHn+'|'+placeNAn)
		divPID = 'listHOTELS' 
		placeID = placeIDn
		placeTY = placeTYn
		placeSRT = placeSRTn
		placeTOTH = placeTOTHn
		placeNAME = placeNAn
		//document.getElementById(divPID).innerHTML = '<img src="images/wait.gif">'
		//slidedown(divID)
       if (window.XMLHttpRequest) { // Mozilla, Safari,... 
           http_requestPlace = new XMLHttpRequest(); 
       } else if (window.ActiveXObject) { // IE 
           http_requestPlace = new ActiveXObject("Microsoft.XMLHTTP"); 
       } 
	   url = '/A_Get_HotelOnPlace.aspx?plcID='+ placeID +'&plcTY='+ placeTY +'&plcSRT='+ placeSRT +'&plcTOT='+ placeTOTH +'&plcNAME='+ placeNAME
       http_requestPlace.onreadystatechange = alertPlaceContents; 
       http_requestPlace.open('GET', url, true); 
       http_requestPlace.send(null); 

   } 

   function alertPlaceContents() { 
	   //var divIDC = "'"+ divID +"'"
       if (http_requestPlace.readyState == 4) { 
           if (http_requestPlace.status != '') { 
               //alert(http_request.responseText); 
			  // document.getElementById('thisHotel').value = http_request.responseText;
			  divPlaceContent =  http_requestPlace.responseText;
			  document.getElementById(divPID).innerHTML =  divPlaceContent;
			  document.getElementById(divPID).style.display = 'block';
			  if(lfirst == 1 ){
				hotONplc()
			  }
			  
			  // document.getElementById('thisHotel').style.display='block';
			  // COshowHotel()
			  //
           } else { 
               alert('There was a problem with the request.'); 
           } 
       } 

   }

// **********************************************************************

function AshowPopup(divID){
	
	document.getElementById(divID).style.display = 'block';
	
}
function AhidePopup(divID){
	
	document.getElementById(divID).style.display = 'none';
	
}
// *********************************************************************



function toggleSlide(objname,objNA){

  if(document.getElementById(objname).style.display == "none"){
    // div is hidden, so let's slide down
    slidedown(objname);
	document.getElementById(objNA).className = 'HotdivOut';
  }else{
    // div is not hidden, so slide up
    slideup(objname);
	document.getElementById(objNA).className = 'HotdivOver';
  }
}

function slidedown(objname){
	
        if(moving[objname])
                return;

        if(document.getElementById(objname).style.display != "none")
                return; // cannot slide down something that is already visible

        moving[objname] = true;
        dir[objname] = "down";
        startslide(objname);
		
}

function slideup(objname){
	
        if(moving[objname])
                return;
		
        if(document.getElementById(objname).style.display == "none")
		       return; // cannot slide up something that is already hidden

        moving[objname] = true;
        dir[objname] = "up";
        startslide(objname);
		//document.getElementById(objname).innerHTML = ''
}

function startslide(objname){
        obj[objname] = document.getElementById(objname);

        endHeight[objname] = parseInt(obj[objname].style.height);
        startTime[objname] = (new Date()).getTime();

        if(dir[objname] == "down"){
                obj[objname].style.height = "1px";
        }

        obj[objname].style.display = "block";

        timerID[objname] = setInterval('slidetick(\'' + objname + '\');',timerlen);
}

function slidetick(objname){
        var elapsed = (new Date()).getTime() - startTime[objname];

        if (elapsed > slideAniLen)
                endSlide(objname)
        else {
                var d =Math.round(elapsed / slideAniLen * endHeight[objname]);
                if(dir[objname] == "up")
                        d = endHeight[objname] - d;

                obj[objname].style.height = 'auto'; //d + "px";
        }

        return;
}

function endSlide(objname){
        clearInterval(timerID[objname]);

        if(dir[objname] == "up")
                obj[objname].style.display = "none";

        obj[objname].style.height = 'auto' //endHeight[objname] + "px";

        delete(moving[objname]);
        delete(timerID[objname]);
        delete(startTime[objname]);
        delete(endHeight[objname]);
        delete(obj[objname]);
        delete(dir[objname]);

        return;
}
function changediv(classNA,objNA){
	switch(classNA){

		case 'Hotdiv':
		document.getElementById(objNA).className = 'HotdivOver';
		break;
		
		case 'HotdivOver':
		document.getElementById(objNA).className = 'Hotdiv';
		break;
		
	}
}

function hidePopup(hiddid){
	document.getElementById('feedControls'+ hiddid).style.display = 'none';
	document.getElementById('div'+ hiddid).style.display = 'none';
	if (divID!=null){
		document.getElementById(divID).innerHTML = ""
	}
	//document.getElementById('feedTot'+ hiddid).innerHTML = '' ;
}
function setImage(imgSrc,imgTtl){
	document.getElementById('SlideShow').src = imgSrc;
	document.getElementById('imgTitle').innerHTML = imgTtl;

}
// SHOW PLACE GUIDE
	function showGuide(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)
}

function divOvOt(NAclass,idclass){
	switch(NAclass){
		case 'packDIV':
		for (i=1;i<=hwpackdivs;i++){
			if (i == idclass){
				document.getElementById('div'+idclass).style.display = 'block';
				document.getElementById('ttl'+idclass).className = 'bgpackDIV';
			}
			if (i != idclass){
				document.getElementById('div'+i).style.display = 'none';
				document.getElementById('ttl'+i).className = 'packDIV';
			}
		}
		break;
		
		case 'bgpackDIV':
		
		break;
		
	}
}
// SHOW INTEREST
	function showINT(a,b){
		document.lookINT.IDint.value = b
		document.lookINT.action = a
		document.lookINT.submit()
	}
// SHOW PLACE GUIDE
	function showGuide(a){
		document.IDplaceGuide.action = a
		document.IDplaceGuide.submit()
	}
	
function openInfo(proid,pic){
	if (pic == ''){
		var pic1 = document.getElementById('pic'+proid).src
		idxpic = pic1.indexOf('Plus')
	}
	else{
		idxpic = pic.indexOf('Plus')
	}
	
	divPro = 'divv'+proid
	thisimg = 'pic'+proid
	//idxpic = pic.indexOf('Plus')
	if (idxpic > 0){
		
		if (document.getElementById(divPro) != null){
			document.getElementById(divPro).style.display = 'block'
			document.getElementById(thisimg).src = '/images/Minus.jpg' //id="pic<%=prodID%>" src="/images/Plus.jpg"
		}
		else{
			alert("Not description available")
		}
	}
	else{
		document.getElementById(divPro).style.display = 'none'
		document.getElementById(thisimg).src = '/images/Plus.jpg'
	}

}