﻿// JScript File
var xmlHttpReq,e;

function Map_Display()
{
 // new Ajax.Updater('td1', 'index.aspx?id=1', {parameters:Form.serialize("form1"),onComplete:function(){ loadmap();},asynchronous:true, evalScripts:true});
   xmlhttpPost("searchresults.aspx?id="+Math.random());
//   xmlhttpPost("searchresults.aspx?id="+document.getElementById("drlwhere").value);
   
}
function xmlhttpPost(strURL) {
    //xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
  
try {
self.xmlHttpReq = new XMLHttpRequest();
}
catch(e) {
try {
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e) {
alert("Browser problem");
}
}
    
    self.xmlHttpReq.open('GET', strURL, true);//('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = setdiv;//function() {
//        if (self.xmlHttpReq.readyState == 4) {
//            alertContents(self.xmlHttpReq.responseText);
//        }
//    }
    self.xmlHttpReq.send(strURL);
}
function setdiv()
{

    if (self.xmlHttpReq.readyState == 4)
    {
      var respo = xmlHttpReq.responseText;
      document.getElementById("Panel_Popup").className="panel_window1";
     document.getElementById("Map_panel").className="panel_window_map1";
//       document.getElementById("Image_Replace").innerHTML='&nbsp;';
//       document.getElementById('Image_Replace').className="main1";
      // loadmap(respo);
      loadmap(respo);
      
    }
}

// JScript File
 function loadmap(s) {
   try
     {
 var hotel_Lat_Lng=s.split("|");
 var mytool_array=hotel_Lat_Lng[0].split("&");
 var Name=mytool_array[0];
 var City=mytool_array[1];
 var State=mytool_array[2];
 var Description=mytool_array[3];
 var lng_point=mytool_array[4];//trimAll(mytool_array[0]);//17.50393;//
 var lat_point=mytool_array[5];//trimAll(mytool_array[1]);//78.39921;//
 var zm_point=mytool_array[6];//trimAll(mytool_array[2]);
if(lat_point!="")
{

   var  flag = GBrowserIsCompatible();
       if (flag) {
        var map = new GMap2(document.getElementById("Map_panel"));
        map.addControl(new GMapTypeControl());
        map.addControl(new GLargeMapControl());
        //map.addControl(new google.maps.LocalSearch(),new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(5,-120)));
        var center = new GLatLng(lat_point,lng_point);
        var lat=parseFloat(lat_point);
        var lng=parseFloat(lng_point);
        var zm=parseFloat(zm_point);
        var center = new GLatLng(lat,lng);
        map.setCenter(center,zm);
        geocoder = new GClientGeocoder();
        var marker = new GMarker(center, {draggable: false}) ;
        map.addOverlay(marker);
        
        
        // Create a base icon for all of our markers that specifies the
        // shadow, icon dimensions, etc.
        var baseIcon = new GIcon(G_DEFAULT_ICON);
        baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
        baseIcon.iconSize = new GSize(20, 34);
        baseIcon.shadowSize = new GSize(37, 34);
        baseIcon.iconAnchor = new GPoint(9, 34);
        baseIcon.infoWindowAnchor = new GPoint(9, 2);

        // Creates a marker whose info window displays the letter corresponding
        // to the given index.
        function createMarker(point, index,Name,City,State,Desc) {
          // Create a lettered icon for this point using our icon class
          var letter = String.fromCharCode("A".charCodeAt(0) + index);
          var letteredIcon = new GIcon(baseIcon);
          letteredIcon.image = "http://www.google.com/mapfiles/marker" + letter + ".png";

          // Set up our GMarkerOptions object
         // markerOptions = { icon:letteredIcon };
          var marker = new GMarker(point,{draggable: false});
          GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml("<div class='Marker_Size'><b>"+Name+", "+City+", "+State+",</b><br> "+Desc+"</div>");
          });
//          GEvent.addListener(marker, "click", function() {
//            marker.openInfoWindowHtml("Marker <b>" +name+ "</b><br>"+Desc);
//          });
          return marker;
       }

        // Add 10 markers to the map at random locations
        var bounds = map.getBounds();
        var southWest = bounds.getSouthWest();
        var northEast = bounds.getNorthEast();
        var lngSpan = northEast.lng() - southWest.lng();
        var latSpan = northEast.lat() - southWest.lat();
        for (var i = 0; i < hotel_Lat_Lng.length-1; i++) {
        try
        {
        var lat_lng=hotel_Lat_Lng[i+1].split("&");
        var name=lat_lng[0];
        var point=new GLatLng(parseFloat(lat_lng[5]),parseFloat(lat_lng[4]));
        map.addOverlay(createMarker(point, i,name,lat_lng[1],lat_lng[2],lat_lng[3]));
        }
        catch(e)
        {
        //no map point
        }
         
        }
             
      // marker.openInfoWindowHtml(" <div class='Marker_Size'><b>" +Name+", "+City+", "+State+".</b><br> "+Description+"</div>");
       GEvent.addListener(marker, "click", function() {
            marker.openInfoWindowHtml("<div class='Marker_Size'><b>"+Name+", "+City+", "+State+".</b><br> "+Description+"</div>");

          });
	   GEvent.addListener(marker, "dragend", function() {
       var point = marker.getPoint();
	   map.panTo(point);

        });
       }
    }

     else
        alert("no map");
        }
        catch(e)
        {
        alert("No map");
        }
    }

function f1()
{
var qPos = document.URL.indexOf('?');
var pos1 = document.URL.substr(qPos+1);
alert(pos1);
return pos1;
}

function Individual_Map(hotelid)
{

   xmlhttpPostID2("searchresults.aspx?hotelid="+hotelid);
}
function xmlhttpPostID2(strURL1)
{
 var self = this;
    if (window.XMLHttpRequest) 
    {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) 
    {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    
    self.xmlHttpReq.open('GET', strURL1, true);//('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = setdiv1;
    self.xmlHttpReq.send(strURL1);
   // document.getElementById('Image_Replace').style.backgroundColor='#E5E3DF';
}
function setdiv1()
{
    if (self.xmlHttpReq.readyState == 4)
    {
   
       var respo = xmlHttpReq.responseText;
       document.getElementById("Panel_Ind_Map").className="panel_window1";
     document.getElementById("Panel_Ind_SubMap").className="panel_window_map1";
       loadIndividualmap(respo)
    }
}
function loadIndividualmap(s) {
   try
     {
 var hotel_Lat_Lng=s.split("|");
 var mytool_array=hotel_Lat_Lng[0].split("&");
 var Name=mytool_array[0];
 var City=mytool_array[1];
 var State=mytool_array[2];
 var Description=mytool_array[3];
 var lng_point=mytool_array[4];//trimAll(mytool_array[0]);//17.50393;//
 var lat_point=mytool_array[5];//trimAll(mytool_array[1]);//78.39921;//
 var zm_point=mytool_array[6];//trimAll(mytool_array[2]);

if(lat_point!="")
{
   var  flag = GBrowserIsCompatible();
       if (flag) {
        var map = new GMap2(document.getElementById("Panel_Ind_SubMap"));
        map.addControl(new GMapTypeControl());
        map.addControl(new GLargeMapControl());
        //map.addControl(new google.maps.LocalSearch(),new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(5,-120)));
        var center = new GLatLng(lat_point,lng_point);
        var lat=parseFloat(lat_point);
        var lng=parseFloat(lng_point);
        var zm=parseFloat(zm_point);
        var center = new GLatLng(lat,lng);
        map.setCenter(center,zm);
        geocoder = new GClientGeocoder();
        var marker = new GMarker(center, {draggable: false}) ;
        map.addOverlay(marker);
                    
       marker.openInfoWindowHtml(" <div class='Marker_Size'><b>" +Name+", "+City+", "+State+".</b><br> "+Description+"</div>");
       GEvent.addListener(marker, "click", function() {
            marker.openInfoWindowHtml("<div class='Marker_Size'><b>"+Name+", "+City+", "+State+".</b><br> "+Description+"</div>");

          });
	   GEvent.addListener(marker, "dragend", function() {
       var point = marker.getPoint();
	   map.panTo(point);

        });
       }
    } 
     else
        alert("no map");
        }
        catch(e)
        {
        alert("No map");
        }
    }
    
    var hotelid;
    function Desc(hotelid)
    {
    var dd = document.getElementById(hotelid).style.display;
    if (dd == 'none'||dd=="")
    {
    
        document.getElementById(hotelid).style.display = 'block';
        //document.getElementById("l1").innerHTML='Hide';
    }
    else        
    { 
        document.getElementById(hotelid).style.display = 'none';
       // document.getElementById("l1").innerHTML='Show';
    }
    if(document.getElementById(hotelid).style.display == 'block')
    xmlhttpPostID3("searchresults.aspx?hotelid_des="+hotelid);
    
   } 
 
function xmlhttpPostID3(strURL1)
{
 var self = this;
    if (window.XMLHttpRequest) 
    {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) 
    {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    
    self.xmlHttpReq.open('GET', strURL1, true);//('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = setdivacordyn;
    self.xmlHttpReq.send(strURL1);
   // document.getElementById('Image_Replace').style.backgroundColor='#E5E3DF';
}
function setdivacordyn()
{
    if (self.xmlHttpReq.readyState == 4)
    {
    
       var respo = xmlHttpReq.responseText;
       var response=respo.split("|");
       var hotel_id=response[0];
       var desciption=response[1];
       document.getElementById(hotel_id).innerHTML=desciption;
   
       
    }
}
function datagrid_display(roominfo_id)
{
var room="Room_info"+roominfo_id;
 var room_div = document.getElementById(room).style.display;
    if (room_div == 'none')
    {
    
        document.getElementById(room).style.display = 'block';
        //document.getElementById("l1").innerHTML='Hide';
    }
    else        
    { 
        document.getElementById(room).style.display = 'none';
       // document.getElementById("l1").innerHTML='Show';
    }


return false;
}
function show_images(hotelid)
{
var pic_id="Hotel_Pic_div"+hotelid;
//var Hotel_Picture_div=document.getElementById(pic_id).style.display;
//if(Hotel_Picture_div=='none'||Hotel_Picture_div=="")
//{
 xmlhttpPostID_images("searchresults.aspx?hotelid_pictures="+hotelid);
// }
// else
// {
// document.getElementById(pic_id).style.display="none";
// }
}
function xmlhttpPostID_images(strurl)
  {
 var self = this;
    if (window.XMLHttpRequest) 
    {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) 
    {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    
    self.xmlHttpReq.open('GET',strurl, true);//('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange =showimages;
    self.xmlHttpReq.send(strurl);
   // document.getElementById('Image_Replace').style.backgroundColor='#E5E3DF';
}




 function showimages()
{

    if (self.xmlHttpReq.readyState == 4)
    {
   //var JScript = "javascript: ShowPhotoLocal(\"Images/HotelPics/" + hotel_id + "/" + image + "\" + dtImages.Rows[i][2].ToString() + " \")";
    var image_script="";
       var respo = xmlHttpReq.responseText;
       var response=respo.split("|");
       var hotel_id=response[0];
       var image1=response[1];
       var imagecell="Imagecell";
       var pic_id="Hotel_Pic_div";
       var hotel_big_img='ImageHotel';
       if(response[1]!="")
       {
        
        Popup.showModal('PreviewImg');
        window.document.images[hotel_big_img].src ="Images/HotelPics/"+hotel_id+"/"+response[1];
       //document.getElementById(imagecell).innerHTML="Images/HotelPics/"+hotel_id+"/"+response[1];
        document.getElementById(pic_id).style.display="block";
       }
      // var arr = new Array();
       	//arr = {"images":['test','test1']};
	for(var i=0;i<response.length-1;i++)
	{
		
	var image=response[i+1];
	var onmouse_Script = "javascript: ShowPhotoLocal1(\"Images/HotelPics/" + hotel_id + "/" + image + "\","+hotel_id+")";
	 image_script+="<img src=\"Images/HotelPics/" + hotel_id + "/" + image + "\" width='57' height='57'  border=0 hspace = '1' vspace = '1' onMouseOver = '" +onmouse_Script + "'/>";
	}
	
	  // window.document.images[hotel_big_img].src ="Images/HotelPics/"+hotel_id+"/"+response[1];
       document.getElementById(imagecell).innerHTML=image_script;
    return false;
       
    }
}


function ShowPhotoLocal1(strHttpAdr,hotel_id)
{
  divid="ImageHotel";
   //RotateImages = false;
    //document.getElementById(divid).src=strHttpAdr;
  window.document.images[divid].src = strHttpAdr;
}
function Show_roomImages(room_id,hotel_id)
{
 xmlhttpPostID_room_images("searchresults.aspx?room_pictures="+room_id+"|"+hotel_id);
}
function  xmlhttpPostID_room_images(strurl)
{
var self = this;
    if (window.XMLHttpRequest) 
    {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) 
    {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    
    self.xmlHttpReq.open('GET',strurl, true);//('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange =show_room_images;
    self.xmlHttpReq.send(strurl);

}
function show_room_images()
{
 if (self.xmlHttpReq.readyState == 4)
    {
   //var JScript = "javascript: ShowPhotoLocal(\"Images/HotelPics/" + hotel_id + "/" + image + "\" + dtImages.Rows[i][2].ToString() + " \")";
       var image_script="";
       var respo = xmlHttpReq.responseText;
       var response=respo.split("|");
       var room_id=response[0];
       var hotel_id=response[1];
        var hotel_big_img="ImageHotel"+hotel_id;
    //  var image1=response[1];
       var imagecell="Imagecell"+hotel_id;
       var pic_id="Hotel_Pic_div"+hotel_id;
       if(response[2]!="")
       {
       document.getElementById(pic_id).style.display="block";
       }
       else
       {
       document.getElementById(pic_id).style.display="none";
       }
      // var arr = new Array();
       	//arr = {"images":['test','test1']};
	for(var i=0;i<response.length-2;i++)
	{
		
	 var image=response[i+2];
	var onmouse_Script = "javascript: ShowPhotoLocal1(\"Images/HotelPics/" + hotel_id + "/"+room_id+"/"+ image + "\","+hotel_id+")";
	 image_script+="<img src=\"Images/HotelPics/" + hotel_id + "/"+room_id+"/" + image + "\" width='57' height='57'  border=0 hspace = '1' vspace = '1' onMouseOver = '" +onmouse_Script + "'/>";
	}
	   window.document.images[hotel_big_img].src ="Images/HotelPics/"+hotel_id+"/"+room_id+"/"+response[2];
       document.getElementById(imagecell).innerHTML=image_script;
       return false;
   
       
    }
}

function guest_reviews(hotel_id)
{
  //var path = 'customerreviews.aspx?id='+hotel_id;
   var path = 'guestreviews.aspx?id='+hotel_id;
    window.open(path,'HotelFinder','fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=yes,directories=no,location=yes');
    
}
function guestreviewclose()
{
    window.close();
}

// To Hide the Popup window


function  HideImgDiv() 
{
    Popup.hide('PreviewImg');
}




// ****** prasad *****//





 function showimages()
{

    if (self.xmlHttpReq.readyState == 4)
    {
   //var JScript = "javascript: ShowPhotoLocal(\"Images/HotelPics/" + hotel_id + "/" + image + "\" + dtImages.Rows[i][2].ToString() + " \")";
    var image_script="";
       var respo = xmlHttpReq.responseText;
       var response=respo.split("|");
       var hotel_id=response[0];
       var image1=response[1];
       var imagecell="Imagecell";
       var pic_id="Hotel_Pic_div";
       var hotel_big_img='ImageHotel';
       if(response[1]!="")
       {
        
        Popup.showModal('PreviewImg');
        window.document.images[hotel_big_img].src ="Images/HotelPics/"+hotel_id+"/"+response[1];
       //document.getElementById(imagecell).innerHTML="Images/HotelPics/"+hotel_id+"/"+response[1];
        document.getElementById(pic_id).style.display="block";
       }
      // var arr = new Array();
       	//arr = {"images":['test','test1']};
	for(var i=0;i<response.length-1;i++)
	{
		
	var image=response[i+1];
	var onmouse_Script = "javascript: ShowPhotoLocal1(\"Images/HotelPics/" + hotel_id + "/" + image + "\","+hotel_id+")";
	 image_script+="<img src=\"Images/HotelPics/" + hotel_id + "/" + image + "\" width='57' height='57'  border=0 hspace = '1' vspace = '1' onMouseOver = '" +onmouse_Script + "'/>";
	}
	
	  // window.document.images[hotel_big_img].src ="Images/HotelPics/"+hotel_id+"/"+response[1];
       document.getElementById(imagecell).innerHTML=image_script;
    return false;
       
    }
}


// displaying the Room Images in Popup Window

var hid,hpicname;

function DisplayHotelImages(hid,hpicname)
{ 
var imageid = "hidd"+hid;
var imagepath = document.getElementById(imageid).value;
var arrimagepath = imagepath.split("|");
var imagecell="Imagecell";
var pic_id="Hotel_Pic_div";
var hotel_big_img='ImageHotel';
var image_script="";    

if(arrimagepath[0]!="")
{
    if(arrimagepath.length>0)
    { 
     Popup.showModal('PreviewImg'); 
     document.getElementById(pic_id).style.display="block";     
	        for(var i=0;i<arrimagepath.length-1;i++)
	        {		
	           if(arrimagepath[i] != "")
	            {	
	            var image=arrimagepath[i];	 
                var onmouse_Script = "javascript: ShowPhotoLocal1(\"http://book.chobs.in/HotelData/H"+hid+"/RoomTypeImages/"+image+"\","+hid+")";
                image_script+="<img src=\"http://book.chobs.in/HotelData/H"+hid+"/RoomTypeImages/"+image+"\" width='57' height='57'  border=0 hspace = '1' vspace = '1' onMouseOver = '" +onmouse_Script + "'/>";
	            }
	        }
	window.document.images[hotel_big_img].src ="http://book.chobs.in/HotelData/H"+hid+"/RoomTypeImages/"+arrimagepath[0];   
    document.getElementById(imagecell).innerHTML=image_script;    
    }
 }
 else
  { 
	    if(hpicname!="")
	    {   
	        Popup.showModal('PreviewImg'); 
	        document.getElementById(pic_id).style.display="block";	    	 
			var onmouse_Script = "javascript: ShowPhotoLocal1(\"Images/HotelPics/" + hid + "/" + hpicname + "\","+hid+")";
	        image_script+="<img src=\"Images/HotelPics/" + hid + "/" + hpicname + "\" width='57' height='57'  border=0 hspace = '1' vspace = '1' onMouseOver = '" +onmouse_Script + "'/>";
	    }
	    window.document.images[hotel_big_img].src ="Images/HotelPics/"+hid+"/"+hpicname;
        document.getElementById(imagecell).innerHTML=image_script;    
  }
}


var hotelpicname;
function DisplayHotelImages(hotelid)
//function DisplayHotelImages(hotelid,hotelpicname)
{
    var pic_id="Hotel_Pic_div"+hotelid;
    var Hotel_Picture_div=document.getElementById(pic_id).style.display;
    if(Hotel_Picture_div=='none'||Hotel_Picture_div=="")
    {
     //GetImages(hotelid,hotelpicname);
     document.getElementById(pic_id).style.display="Block";
     }
     else
     {
     document.getElementById(pic_id).style.display="none";
     }
}

function show_amenitites(hotelid)
{
var amID="amenities"+hotelid;
var HotelAmenitydiv=document.getElementById(amID).style.display;
if(HotelAmenitydiv=='none'||HotelAmenitydiv=="")
{
 document.getElementById(amID).style.display="block";
 }
 else
 {
 document.getElementById(amID).style.display="none";
 }
}

