var firstTimeResultsShowing = true;
var tempstartPriceSlab = 0 ;
var tempendPriceSlab  =0;
var tempstarRating = 0;
var tempisPriceflag = 0;
var rowNumber = 0;
var columnNumber= 0;
var locationArr ;
var distSortFnFlg = false;

var sortedOrder = "";
var listOfTotalAmenities=new Array();
        Array.prototype.removeDuplicates =  f;
        function f()
        {
                  var temp=new Array();
                  this.sort();
                  for(i=0;i<this.length;i++)
                 {
                          if(this[i]==this[i+1]) {continue}
                                  temp[temp.length]=this[i];
                 }
                  return temp;
 }
        var milestoneYear = 2000;

        var     months = new Array();
                                                        months[0] = "JAN";
                                                        months[1] = "FEB";
                                                        months[2] = "MAR";
                                                        months[3] = "APR";
                                                        months[4] = "MAY";
                                                        months[5] = "JUN";
                                                        months[6] = "JUL";
                                                        months[7] = "AUG";
                                                        months[8] = "SEP";
                                                        months[9] = "OCT";
                                                        months[10] = "NOV";
                                                        months[11] = "DEC";
        var reqObj = null;
        var descRequest=null;
        var ajxResponse = null;
        var JSPURL = "jsp/PackageDatesReflecter.jsp"
        try
        {
           reqObj = new window.XMLHttpRequest();
           if (reqObj.overrideMimeType)
           {
                //       reqObj.overrideMimeType('text/xml');
           }
        }
        catch (e)
        {
                  reqObj = new ActiveXObject("Msxml2.XMLHTTP");
        }

function findIt( key )
{
    var result = (-1);
    for( var i = 0; i < this.keyArray.length; i++ )
    {
        if( this.keyArray[ i ] == key )
        {
            result = i;
            break;
        }
    }
    return result;
}

function put( key, val )
{
    var elementIndex = this.findIt( key );

    if( elementIndex == (-1) )
    {
        this.keyArray.push( key );
        this.valArray.push( val );
    }
    else
    {
        this.valArray[ elementIndex ] = val;
    }
}

function get( key )
{
    var result = null;
    var elementIndex = this.findIt( key );

    if( elementIndex != (-1) )
    {
        result = this.valArray[ elementIndex ];
    }

    return result;
}



function showResults()
{
        showUR();
        window.setTimeout('showResults1()' , 1);
}


function showNoResultsMessage()
{
	if(searchForCurrentDate == "false"){
		document.getElementById("resultsDiv").innerHTML = "<br><TABLE WIDTH='97%' border=1 CELLSPACING=0 bordercolor=#FF0000><TR HEIGHT=50 VALIGN=middle><TD ALIGN='center' class='redtext-headings'><span style='font-weight:bold;font-size:10px'>We apologize that bookings for today's check in cannot be made after 6:00 PM (India time). You can search for hotels for check in tomorrow or any other date that you prefer.</SPAN></TD></TR></TABLE>&nbsp;"
	}else{
                        document.getElementById("resultsDiv").innerHTML = "<br><TABLE WIDTH='97%' border=1 CELLSPACING=0 bordercolor=#FF0000><TR HEIGHT=50 VALIGN=middle><TD ALIGN='center' class='redtext-headings'><span style='font-weight:bold;font-size:10px'>Sorry, no hotels were found that matched your search criteria. Please search again.</SPAN></TD></TR></TABLE>&nbsp;"
	}

}
function showResults1()
{
                groupHotels()
                var hotelsTablesString = "";
                if (end==0)
                {
                        showNoResultsMessage();
                        fillPagingInfo();
                        hideUR();
                        return;
                }
                for (var hotelCount=start;hotelCount<end ;hotelCount++ )
                {

			var key = hDD[hotelCount]['HotelCode'];
			key = key+"k"+hotelCount;
			if (get(key)== null)
			{
			//alert("Inside get(key) is null");
				var tempHotelString = "<TABLE><TR><TD WIDTH=100%  STYLE='padding-bottom:10px'>" + buildSingleHotelTable(hotelCount) +"</td></tr></table>";;
			put(key,tempHotelString);
			hotelsTablesString += tempHotelString;
			}
			else
			{
				//alert("key is not null");
				hotelsTablesString += get(key);
			}
                }
		document.getElementById("resultsDiv").innerHTML = hotelsTablesString ;
				if(cleareDistances)
					displayDistancesInKM(mapRequestVar,result);
                showHotelsInCity();
				fillPagingInfo();
                hideUR();
}

function sortByLMD(){
	var LMDHotels = new Array();
	var notLMDHotels = new Array();
	for (var count=0;count<hDD.length ; count++ ){
		var result = isLMDHotel(count);
		if (result == 1){
			LMDHotels[LMDHotels.length] = hDD[count];
		}else {
			notLMDHotels[notLMDHotels.length] = hDD[count];
		}

	}
	LMDHotels.sort(sortByPrice);
	if(notLMDHotels.length >0){
	notLMDHotels=sortOnRequestHotel(notLMDHotels);
	}
	hDD=LMDHotels.concat(notLMDHotels);
	for (var c=0;c<hDD.length;c++){
		var hotel = hDD[c];
		var hotelName = hotel['HotelName'];
		//alert(hotelName);
	}
}

function groupHotels()
{
        var mmtHotels = new Array();
        var gdsHotels = new Array();
        for (var count=0;count<hDD.length ; count++)
        {
                var isGds = hDD[count]['GDSHotel'];
                if (isGds.toUpperCase()=="I")
                {
                        gdsHotels[gdsHotels.length] =  hDD[count];
                }
                else
                {
                        mmtHotels[mmtHotels.length] =  hDD[count];
                }
        }
        hDD = mmtHotels.concat(gdsHotels);
		//sortByLMD();
}
function fillPagingInfo()
        {
                if(totalPages==0)
                {
                        document.getElementById("resultsTable").style.display="none";
                        document.getElementById("PagingTable").style.display="none";
                        document.getElementById("PagingDiv1").style.display="none";
                }
                else
                {
                        document.getElementById("resultsTable").style.display="block";
                        document.getElementById("PagingTable").style.display="block";
                        document.getElementById("PagingDiv1").style.display="block";
                }

                var pageLable = ""
                if(totalPages!=0){
                        pageLable = "<span style='font-size:10px'>Page " + currentPage + " Of "+ totalPages +"</span>";
                }
                var recordLable = ""
                if(hDD.length!=0){
                        document.getElementById("pagingInfoTable").style.display = "block"
                        document.getElementById("sortCell").width = "576"
                        document.getElementById("PagingTable").width = "576"
                        document.getElementById("resultsTable").width = "576"
                        recordLable = "Showing <span style='font-size:10px'>"+(end-start) + " Of " + hDD.length + " Hotels</span>";
                }
                else
                {
                        document.getElementById("pagingInfoTable").style.display = "none"
                }
                var linksString =  getLinksString();
                if(hDD.length==1){
                        linksString="";
                }

                document.getElementById("PageInfo").innerHTML = pageLable
                document.getElementById("RecordInfo").innerHTML = recordLable
                document.getElementById("LinksInfo").innerHTML = linksString

                //document.getElementById("PageInfo_Bottom").innerHTML = pageLable;
                document.getElementById("RecordInfo_Bottom").innerHTML = recordLable;
                document.getElementById("LinksInfo_Bottom").innerHTML =  linksString;
        }
        function getStartPage()
        {
                if (currentPage==0)
                {
                        return 0
                }
                if (currentPage==1 || currentPage==2)
                {
                        return 1;
                }
                if (currentPage==totalPages && currentPage-2 > 0)
                {
                        return currentPage - 2
                }
                else
                {
                        return currentPage-1;
                }
        }
        function getLinksString()
        {

                //var linksString1 = "<B><A style='cursor:pointer' onclick=\"document.getElementById('top').focus();arrowTakeToPage('l');\"><b>First</b></A></B>&nbsp;&nbsp;&nbsp;";
                var linksString = "";
                var startPage = getStartPage();
                if (startPage==0)
                {
                        return linksString;
                }
                var endPage = (currentPage==totalPages) ? totalPages : (currentPage + 1);
                var linkCount =0;
                var totalPageCount = totalPages;
				var pageNumberString = "";
				var linksString2 = "";

				var pageCounter = 0;

				if(currentPage%5 != 0)
					pageCounter = Math.floor(currentPage/5)*5;
				else
					pageCounter = Math.floor((currentPage-1)/5)*5

				//alert(pageCounter + " : " +totalPages );

				 if(pageCounter != 0){
						  linksString += "<A style='cursor:pointer' onclick=\"document.getElementById('top').focus();takeToPage("+ (pageCounter)+");\"><b>Prev</b></A>"
				  }
				for (var pageCount=pageCounter;pageCount<=totalPages -1 && pageCount<=pageCounter + 4; pageCount++) {

							pageNumberString += " <A style='cursor:pointer' onclick=\"document.getElementById('top').focus();takeToPage("+ (pageCount + 1)+");\"><b> " + (pageCount + 1)  + " </b></A> | "
				}

				if(totalPages > pageCounter + 5  ){
						linksString2 += "<A style='cursor:pointer' onclick=\"document.getElementById('top').focus();takeToPage("+ (pageCounter + 6)+");\"><b>Next</b></A>"
				}
			linksString=linksString+ pageNumberString + linksString2
			return linksString;
        }


        function arrowTakeToPage(s){

                if(s=="g"){
                        takeToPage(totalPageCount);
                }else if(s=="l"){
                        takeToPage(1);
                }else{
                        if(currentPage>1){
                                currentPage=(eval(currentPage)-1);
                        }

                        takeToPage(currentPage);
                }
        }
        function takeToPage(pageNumber)
        {
                pageNumber = ( pageNumber > totalPages ? totalPages : pageNumber);
                pageNumber = (pageNumber <=0 ? 1 : pageNumber);
                currentPage=pageNumber;
                start = (pageNumber-1) * hotelsPerPage;
                var nextRecords = (pageNumber * hotelsPerPage);
                end = Math.min(nextRecords , hDD.length);
                currentPage = pageNumber;
                showHotelsInCity();
                showResults();
                setCookie("pageNum",pageNumber,1);
        }
        function sortByAttribute(attributeName)
        {
//              javascript:dlg2.show();(by Venky)
                if (attributeName=='MMTRecom')
                {
                        sortedOrder = "MMTRecom";
                        sortPriority();
                        start = 0;
                        end = Math.min(hotelsPerPage, hDD.length);
                        currentPage =  (hDD.length==0) ? 0: 1
                        setCookie("pageNum",1,1);
						sortByLMD();
						//sortOnRequestHotel();
                        showResults();
                        return;
                }
                if (attributeName=='StarRating')
                {
                        sortedOrder = "StarRating";
                        hDD.sort(sortByStarRating);
                        start = 0;
                        end = Math.min(hotelsPerPage, hDD.length);
                        currentPage =  (hDD.length==0) ? 0: 1
                        setCookie("pageNum",1,1);
                        showResults();
                        return;
                }
                if (attributeName=='LowestAvgPrice')
                {

                        sortedOrder = "LowestAvgPrice";
                        hDD.sort(sortByPrice);
                        start = 0;
                        end = Math.min(hotelsPerPage, hDD.length);
                        currentPage =  (hDD.length==0) ? 0: 1
                        setCookie("pageNum",1,1);
                        showResults();
                        return;
                }
        }
        function dirtypop(result) {
   			var generator = window.open('helo', 'name', 'height=768,width=1024');
  			generator.document.write(result);
   			generator.document.close();
   }

   var tempHotelArr = new Array();
   var flag = false;

   function sortByArea(area){

   	 var areaPriceGridHotels = new Array();
                //var notAreaPriceGridHotels = new Array();
                /*if(!flag){
                	tempHotelArr = hDD;
                }else{
                	hDD = tempHotelArr;
                }*/

   	 		showFilteredResultAreaPriceGrid(-1,-1,-1,-1,7,1);

                //alert("starRatting  ::  "+starRatting+" area :: "+area+" Price :: "+price);
                for (var count=0;count<hDD.length ; count++)
                {
                        var starRattingVar = hDD[count]['StarRating'];
                        var locaionVarArr = hDD[count]['Locations'];
                        var lowestAvgPrice = hDD[count]['LowestAvgPrice'];
                        var propertyTypeVar = hDD[count]['PropertyType'];
                        if(area != ""){
                        if(locaionVarArr.length !=0){
                        for(var k=0;k<locaionVarArr.length;k++){
                        	var locaionVar = locaionVarArr[k];
                        if (locaionVar == area)
                        {

                                areaPriceGridHotels[areaPriceGridHotels.length] =  hDD[count];
                                areaPriceGridHotels.sort(sortByPrice);
                                //areaPriceGridHotels.sort(sortBy)
                        } else if(propertyTypeVar != "" && locaionVar == area && parseInt(lowestAvgPrice) >= parseInt(price))
                        {
                        	areaPriceGridHotels[areaPriceGridHotels.length] =  hDD[count];
                        	areaPriceGridHotels.sort(sortByPrice);
                        }
                        }
                }
                }else{
                	if(locaionVarArr.length ==0){
                		areaPriceGridHotels[areaPriceGridHotels.length] =  hDD[count];
                        areaPriceGridHotels.sort(sortByPrice);
                	}
                }
                }
                flag = true;
                hDD = areaPriceGridHotels;

                start = 0;
				end =  (hDD.length > hotelsPerPage) ? (hotelsPerPage) : (hDD.length);
				currentPage =  (hDD.length==0) ? 0: 1;
				totalPages =  Math.ceil( hDD.length / hotelsPerPage);
                //hDD.sort(sortByStarRating);
                setCookie("pageNum",1,1);
                showResults();
   }

   function cleareDistancesFun(){
//   	 areaArrMap = new Array();
//   	 areaArrMapTemp = new Array();
   	document.getElementById("unableToGetResult").style.display = "none";
    document.getElementById("totalDiv").style.cursor = "default"
    document.getElementById("DialogContentBlocking2").style.display="none";
   	 alternateAreaArr - new Array();
   	 resultVar = new Array();
   	 cleareDistances = false;
   	 showResults();
   }

   function sortByHotelWithDistance(areaName,result){

   	cleareDistances = true;
	distSortFnFlg = true;
   	 var hotelArr = new Array();
   	 var hotelWithDistances = new Array();
     var hotelWithoutDistances = new Array();
     locationArr = new Array();
			sortedOrder = "distance";

            result.sort(sortByDistances);

			for (var count=0;count<hDD.length ; count++)
                {
                	var hotelFoundFlag = true;
                		var hotelName = hDD[count]['HotelCode'];
              for(var resultCount=0; resultCount<result.length;resultCount++){
              	var hotelNameDist = result[resultCount]['id'];

                        if (hotelName == hotelNameDist)
                        {
                        	hotelFoundFlag = false;
                        	hotelArr[hotelArr.length] =  hDD[count];
                        	break;
                        }
                }
                if(hotelFoundFlag){
                	hotelWithoutDistances[hotelWithoutDistances.length]=hDD[count];
                }

                }

                resultVar = new Array();
                for(var resultCount=0; resultCount<result.length;resultCount++){
              		var hotelIDDist = result[resultCount]['id'];
                		for(var hotelArrCount=0; hotelArrCount<hotelArr.length;hotelArrCount++){
                			var hotelArrID = hotelArr[hotelArrCount]["HotelCode"];
                			if(hotelIDDist==hotelArrID){
                				hotelWithDistances[hotelWithDistances.length] = hotelArr[hotelArrCount];
                				resultVar[resultVar.length] = result[resultCount];

                			}
                		}
                }


                for(var withoutDisCount=0; withoutDisCount<hotelWithoutDistances.length;withoutDisCount++){
                	hotelWithDistances[hotelWithDistances.length] = hotelWithoutDistances[withoutDisCount];
                }



                flag = true;
                hDD = hotelWithDistances;

                start = 0;
				end =  (hDD.length > hotelsPerPage) ? (hotelsPerPage) : (hDD.length);
				currentPage =  (hDD.length==0) ? 0: 1;
				totalPages =  Math.ceil( hDD.length / hotelsPerPage);
                setCookie("pageNum",1,1);
                showResults();

   }

   function displayDistancesInKM(areaName,result){

	   	if(distSortFnFlg){

   			for(var hotelArrCount=start; hotelArrCount<end;hotelArrCount++){
			   	var mmtHotelId = hDD[hotelArrCount]["HotelCode"];
			   	var distanceAvlFlag = true;
			   	if(resultVar.length !=0){
   				for(var resultCnt=0;resultCnt<resultVar.length;resultCnt++){
			   		var mapHotelId = resultVar[resultCnt]["id"];

                	var idVar = "blueBoxTab"+hotelArrCount;
                	//alert("idVar" +idVar);
                	if(mapHotelId == mmtHotelId){
	                	document.getElementById(idVar).style.display = "block";
	                	document.getElementById(idVar).className="distancesearch";
	                	document.getElementById("disMetBlueBox"+hotelArrCount).innerHTML="<strong>"+resultVar[resultCnt]['distance']+"</strong> away from the "+areaName+" </span>";
	                	distanceAvlFlag = false;
                	}
   				}
			   	}
   				if(distanceAvlFlag){
   					var idVar = "blueBoxTab"+hotelArrCount;
   					document.getElementById(idVar).className="distanceNotFound";
   					document.getElementById(idVar).style.display = "block";
	                document.getElementById("disMetBlueBox"+hotelArrCount).innerHTML="The aerial distance of this hotel from <u>"+areaName+"</u> is not updated as of now. The hotel details write up would indicate the location of this hotel.</span>";
   				}
                }

   			}
   }

   				function sortHotelWithDistance(){
   						sortedOrder = "distance";
                        resultVar.sort(sortByHotelWithDistance);
                        displayDistancesInKM(mapRequestVar,resultVar);
                        return;
   				}

   function showFilteredResultAreaPriceGrid(startPriceSlab, endPriceSlab, starRating, isPriceflag, rowNum, colNum){
	rowNumber = rowNum;
	columnNumber = colNum;
	highlightAreaPriceCol(rowNum,colNum,0);
	//highlightMouseOver(rowNum,colNum,0);
	 tempstartPriceSlab = startPriceSlab ;
     tempendPriceSlab  =endPriceSlab;
     tempstarRating = starRating;
     tempisPriceflag = isPriceflag;
	firstTimeResultsShowing = false;
	//alert("startPriceSlab  :: "+startPriceSlab+"  endPriceSlab  ::  "+endPriceSlab+"  starRating  ::  "+starRating+"   isPriceflag ::  "+isPriceflag+"  rowNum  ::  "+rowNum+"  colNum  ::  "+colNum);
	var givenHotelSubstring = document.getElementById("hotelNameString").value;
		filterHotelChain();
		var filteredHotelDetails = new Array();
		var amenities = document.getElementsByName("FilterAmenities");
		var count =0;

		for (var hotelCount=0;hotelCount<hD.length ;hotelCount++ )
		{
			if((starRating == -1) && (isPriceflag == -1) && checkForAmenities(hotelCount) && isAllRoomOnReequest(hotelCount) >0){
			filteredHotelDetails[filteredHotelDetails.length] = hD[hotelCount];
		} else {
			if((isPriceflag == -1) && isSameStarRating(hotelCount, starRating) && checkForAmenities(hotelCount) && isAllRoomOnReequest(hotelCount) >0){
				filteredHotelDetails[filteredHotelDetails.length] = hD[hotelCount];
			} else if((starRating == -1) && isSamePriceSlab(hotelCount, startPriceSlab, endPriceSlab) && checkForAmenities(hotelCount) && isAllRoomOnReequest(hotelCount) >0){
				filteredHotelDetails[filteredHotelDetails.length] = hD[hotelCount];
			} else if(isSameStarRating(hotelCount, starRating) && isSamePriceSlab(hotelCount, startPriceSlab, endPriceSlab) && checkForAmenities(hotelCount) && isAllRoomOnReequest(hotelCount) >0){
			filteredHotelDetails[filteredHotelDetails.length] = hD[hotelCount];
		}
		}
		}
		hDD = filteredHotelDetails;
	}


	function checkedTheAminities(count){

		var isCheckBoxChecked = false;

			if(count != 111){
				isCheckBoxChecked = document.getElementById("Amenity"+count).checked;;
			}
		//alert("isCheckBoxChecked   --- "+isCheckBoxChecked);
		if(isCheckBoxChecked){
			if(saveAreaVar != "" || priceRreaVar!= "" || starRattingVar!=""){
				areaGridAmenitySort(count)
			}else if(saveAreaVar == "" && priceRreaVar == "" && starRattingVar ==""){
				filter();
			}
		}else{
			if(saveAreaVar == "" && priceRreaVar == "" && starRattingVar ==""){
				filter();
			}else if(saveAreaVar != "" && priceRreaVar != "" && starRattingVar !=""){
				sortByAreaPriceGrid(starRattingVar,saveAreaVar,priceRreaVar);
			}else if(saveAreaVar != ""){
				sortByArea(saveAreaVar);
			}else if(starRattingVar !=""){
				showFilteredResultAreaGrid(-1,-1,starRattingVar,-1,-1,starRattingVar);
			}
		}
	}

	function areaGridAmenitySort(amenityCount)
        {

			var givenAmenityName
			if(amenityCount != ""){
				givenAmenityName = document.getElementById("Amenity"+amenityCount).value;
			}
			//alert("givenAmenityName   :: "+givenAmenityName+"  starRattingGrd  ::   "+starRattingGrd+"  locationGrd  :::   "+locationGrd+"  propertyTypeGrd  :: "+propertyTypeGrd+"  priceGrd  ::  "+priceGrd);
        	var areaPriceGridHotels = new Array();
        	var flag = false;
               var filteredAmenityList = getTheAmenityList(givenAmenityName);
			   //alert("saveAreaVar   mmm  "+saveAreaVar+"  priceRreaVar  "+priceRreaVar+"  starRattingVar  "+starRattingVar);
                for (var count=0;count<hD.length ; count++)
                {
                var hotel = hD[count];
                var starRatting = hD[count]['StarRating'];
                var locationVarArr = hD[count]['Locations'];
                var lowestAvgPrice = hD[count]['LowestAvgPrice'];
                var propertyType = hD[count]['PropertyType'];
                var locationFlag = false;;
                for(var locationCounter=0; locationCounter<locationVarArr.length;locationCounter++){
                	var locationName = locationVarArr[locationCounter];
                	if(saveAreaVar != "" && locationName == saveAreaVar){
                		locationFlag = true;
                	}
                }


                var amenities = hotel['hA'];

                for (var amenityCount=0;amenityCount<amenities.length ; amenityCount++ )
                {
                        var amenity = amenities[amenityCount];
                        var amenityName = amenity['aN'];
                       for(var filteramenitycount=0;filteramenitycount<filteredAmenityList.length ; filteramenitycount++){
						   var tempFilterAmenity=filteredAmenityList[filteramenitycount];
					   if (amenityName.toUpperCase().indexOf(tempFilterAmenity.toUpperCase()) !=-1)
                        {
                        	if(saveAreaVar != "" && priceRreaVar!= "" && starRattingVar!=""){

                        	if(locationFlag == true && priceRreaVar<=lowestAvgPrice && starRatting==starRattingVar){
                        		areaPriceGridHotels[areaPriceGridHotels.length] =  hD[count];
                        	}else if(locationFlag == true && priceRreaVar<=lowestAvgPrice && starRatting==starRattingVar && propertyTypeVar != ""){
								areaPriceGridHotels[areaPriceGridHotels.length] =  hD[count];
							}
                        	}else{
                        	 if(locationFlag == true){
                        		areaPriceGridHotels[areaPriceGridHotels.length] =  hD[count];
                        	}else if(starRattingVar != "" && starRatting==starRattingVar){
                            	areaPriceGridHotels[areaPriceGridHotels.length] =  hD[count];
                			}else if(starRattingVar != "" && starRatting==starRattingVar){
								areaPriceGridHotels[areaPriceGridHotels.length] =  hD[count];
							}
                        	}

                            flag = true;
                            break;                        	//areaPriceGridHotels.sort(sortByPrice);

                        }
                }
                if(flag){
                	break;
                }
                }


                }
                flag = true;
                hDD = areaPriceGridHotels;

                start = 0;
				end =  (hDD.length > hotelsPerPage) ? (hotelsPerPage) : (hDD.length);
				currentPage =  (hDD.length==0) ? 0: 1;
				totalPages =  Math.ceil( hDD.length / hotelsPerPage);
                hDD.sort(sortByPrice);
                setCookie("pageNum",1,1);
                showResults();
        }


   function sortByAreaPriceGrid(starRatting, area, price)
        {


                //var notAreaPriceGridHotels = new Array();
                showFilteredResultAreaPriceGrid(-1,-1,-1,-1,7,1);
                var areaPriceGridHotels = new Array();

                for (var count=0;count<hDD.length ; count++)
                {
                        var starRattingVar = hDD[count]['StarRating'];
                        var locaionVarArr = hDD[count]['Locations'];
                        var lowestAvgPrice = hDD[count]['LowestAvgPrice'];
                        var propertyTypeVar = hDD[count]['PropertyType'];
                        var hotelNAme = hDD[count]['HotelName'];

                        if(locaionVarArr.length !=0){
                        for(var k=0;k<locaionVarArr.length;k++){

                        	var locaionVar = locaionVarArr[k];
                        if (parseInt(starRattingVar) >= parseInt(starRatting) && locaionVar == area && parseInt(lowestAvgPrice) >= parseInt(price) && propertyTypeVar != "Serviced Apartment")
                        {
                        	//alert("hotel Name :::  "+hotelNAme+" propertyType :::  "+propertyTypeVar);
                                areaPriceGridHotels[areaPriceGridHotels.length] =  hDD[count];
                                //areaPriceGridHotels.sort(sortByPrice);
                                areaPriceGridHotels.sort(sortByStarRating);
                                //areaPriceGridHotels.sort(sortBy)
                        } else if(propertyTypeVar != "" && parseInt(starRatting)>=6  && locaionVar == area && parseInt(lowestAvgPrice) >= parseInt(price))
                        {
                        	//alert("hotel Name 111111 :::  "+hotelNAme+" propertyType :::  "+propertyTypeVar);
                        	areaPriceGridHotels[areaPriceGridHotels.length] =  hDD[count];
                        	areaPriceGridHotels.sort(sortByPrice);
                        	//areaPriceGridHotels.sort(sortByStarRating);
                        }
                        }
                }else{
                	if (parseInt(starRattingVar) >= parseInt(starRatting) && parseInt(lowestAvgPrice) >= parseInt(price) && propertyTypeVar != "Serviced Apartment" && area == "")
                        {
                        	//alert("hotel Name  444444 :::  "+hotelNAme+" propertyType :::  "+propertyTypeVar);
                                areaPriceGridHotels[areaPriceGridHotels.length] =  hDD[count];
                                //areaPriceGridHotels.sort(sortByPrice);
                                areaPriceGridHotels.sort(sortByStarRating);
                        }
						else if(parseInt(starRatting)==6 && parseInt(lowestAvgPrice) >= parseInt(price) && propertyTypeVar != "" && area == ""){
                        	areaPriceGridHotels[areaPriceGridHotels.length] =  hDD[count];
                                //areaPriceGridHotels.sort(sortByPrice);
                            areaPriceGridHotels.sort(sortByStarRating);
                        }
                }

                }
                flag = true;
                hDD = areaPriceGridHotels;

                start = 0;
				end =  (hDD.length > hotelsPerPage) ? (hotelsPerPage) : (hDD.length);
				currentPage =  (hDD.length==0) ? 0: 1;
				totalPages =  Math.ceil( hDD.length / hotelsPerPage);
                //hDD.sort(sortByStarRating);
                setCookie("pageNum",1,1);
                showResults();

        }


        function sortByAttributeLinkAreaPriceGrid(attributeName){
        	//alert("starRatting    :::  "+starRatting);
        	//showFilteredResult(-1,-1,starRatting,-1,-1,starRatting);

        	if (attributeName=='StarRating')
                {

        						hDD.sort(sortByStarRatingAreaPriceGrid);
                                //hDD.reverse();
                                setCookie("order",null,-1)
                                start = 0;
                                end = Math.min(hotelsPerPage, hDD.length);
                                currentPage =  (hDD.length==0) ? 0: 1
                                setCookie("pageNum",1,1);
                                showResults();
                                return;
                }
				 if (attributeName=='LowestAvgPrice')
                {
                	hDD.sort(sortByPrice);
                                //hDD.reverse();
                                start = 0;
                                setCookie("order",null,-1)
                                end = Math.min(hotelsPerPage, hDD.length);
                                currentPage =  (hDD.length==0) ? 0: 1
                                setCookie("pageNum",1,1);
                                showResults();
                                return;
                }


        }


        function sortByStarRatingAreaPriceGrid(a, b) {
                var x = parseInt(a.StarRating);
                var y = parseInt(b.StarRating);
                return ((x < y) ? -1 : ((x > y) ? 1 : sortByPriceAreaPriceGrid(a,b)));
        }

        function sortByPriceAreaPriceGrid(a, b){
        		var x = a.LowestAvgPrice/ 1;
                var y = b.LowestAvgPrice / 1;
                return ((x < y)? -1 : ((x > y)?1 : sortByName(a,b)));
        }

        function sortByAttributeLink(attributeName) {
                if (attributeName=='StarRating')
                {
                                        //javascript:dlg2.show();
                        var oldImg = eval("document.getElementById('StarRatingOrder').src").split("/");
                        var oldImgSrc = oldImg[oldImg.length-1]
                        if(oldImgSrc=="arrow-top.gif") {
                                document.getElementById("StarRatingOrder").src = imgPath+"images/arrow-bottom.gif";
                                hDD.sort(sortByStarRating);
                                hDD.reverse();
                                setCookie("order",null,-1)
                                start = 0;
                                end = Math.min(hotelsPerPage, hDD.length);
                                currentPage =  (hDD.length==0) ? 0: 1
                                setCookie("pageNum",1,1);
                                showResults();
                                return;
                        } else {
                                //javascript:dlg2.show();
                                document.getElementById("StarRatingOrder").src = imgPath+"images/arrow-top.gif";
                                hDD.sort(sortByStarRating);
                                start = 0;
                                setCookie("order",1,1)
                                end = Math.min(hotelsPerPage, hDD.length);
                                currentPage =  (hDD.length==0) ? 0: 1
                                setCookie("pageNum",1,1);
                                showResults();
                                return;
                        }
                }
                if (attributeName=='LowestAvgPrice')
                {
                        //javascript:dlg2.show();
                        var oldImg = eval("document.getElementById('LowestAvgPriceOrder').src").split("/");
                        var oldImgSrc = oldImg[oldImg.length-1]
                        if(oldImgSrc=="arrow-top.gif") {
                                document.getElementById("LowestAvgPriceOrder").src = imgPath+"images/arrow-bottom.gif";
                                hDD.sort(sortByPrice);
                                hDD.reverse();
                                start = 0;
                                setCookie("order",null,-1)
                                end = Math.min(hotelsPerPage, hDD.length);
                                currentPage =  (hDD.length==0) ? 0: 1
                                setCookie("pageNum",1,1);
                                showResults();
                                return;
                        } else {
                                //javascript:dlg2.show();
                                document.getElementById("LowestAvgPriceOrder").src = imgPath+"images/arrow-top.gif";
                                hDD.sort(sortByPrice);
                                start = 0;
                                setCookie("order",1,1)
                                end = Math.min(hotelsPerPage, hDD.length);
                                currentPage =  (hDD.length==0) ? 0: 1
                                setCookie("pageNum",1,1);
                                showResults();
                                return;
                        }
                }
        }
        function sortByRecommendation()
        {
				alert("Sort by Reco");
                var recommendedHotels = new Array();
                var notRecommendedHotels = new Array();
                for (var count=0;count<hDD.length ; count++)
                {
                        var recommendation = hDD[count]['MMTRecom'];
                        if (recommendation.toUpperCase()=="YES" || recommendation.toUpperCase()=="Y")
                        {
                                recommendedHotels[recommendedHotels.length] =  hDD[count];
                        }
                        else
                        {
                                notRecommendedHotels[notRecommendedHotels.length] =  hDD[count];
                        }

                }
                recommendedHotels.sort(sortByName);
                notRecommendedHotels.sort(sortByName);
				alert("sorting");
                hDD = recommendedHotels.concat(notRecommendedHotels);
                start = 0;
                end = Math.min(hotelsPerPage, hDD.length);
                currentPage =  (hDD.length==0) ? 0: 1
                setCookie("pageNum",1,1);
                showResults();
        }

        function sortByDistances(a, b){
        	var x = parseFloat(a.distance);
            var y = parseFloat(b.distance);
            return ((x < y) ? -1 : ((x > y) ? 1 : sortByReco(a,b)));
        }

        function sortByStarRating(a, b) {

                var x = parseInt(a.StarRating);
                var y = parseInt(b.StarRating);
                return ((x < y) ? -1 : ((x > y) ? 1 : sortByPrice(a,b)));
        }
function sortPriority(){
        hDD.sort(sortByPriority);
}
function sortByName(a,b){
        var x = a.HotelName;
        var y = b.HotelName;
        return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}
function sortByPriority(a,b){
        var x = parseInt(a.HtlPriority);
        var y = parseInt(b.HtlPriority);
        return ((x < y) ? -1 : ((x > y) ? 1 : sortByPrice(a,b)));
}
function sortByReco(a,b){
        var x = a.MMTRecom;
        var y = b.MMTRecom;
        return ((x < y) ? 1 : ((x > y) ? -1 : sortByPrice(a,b)));
}
        function sortByPrice(a, b)
        {
                var x = a.LowestAvgPrice/ 1;
                var y = b.LowestAvgPrice / 1;
                return ((x < y)? -1 : ((x > y)?1 : sortByName(a,b)));
        }
        function popDesc(hotelIndex,event)
        {
                try {
                        descRequest = new window.XMLHttpRequest();
                        if(descRequest.overrideMimeType) {
                //              descRequest.overrideMimeType('text/xml');
                        }
                } catch(e) {
                        descRequest = new ActiveXObject("Msxml2.XMLHTTP");
                }
                document.getElementById("explodeDesc").style.position="absolute"
                document.getElementById("explodeDesc").style.left=300
                document.getElementById("explodeDesc").style.top=event.clientY + document.body.scrollTop - 100
                hideDiv("explode1");
                hideDiv("explode");
                descRequest.open("Get" , "jsp/getDescription.jsp?hotelIndex="+hotelIndex+"&Date="+new Date());
                descRequest.send(null);
                if (descRequest.readyState==4){
                        showRetrievedDescription();
                }
                descRequest.onreadystatechange = showRetrievedDescription;
        }
        function showRetrievedDescription()
        {
                if (descRequest.readyState==4){
                        var desc = descRequest.responseText;
                        document.getElementById('giveDescId').innerHTML= "<FONT SIZE='0.9ems'>"+desc+"</font>";
                        document.getElementById('explodeDesc').style.display='block';
                }
        }

        // Modified by Prasad on 25 March 2007 (Starting)

        var fareFrom;
        var fareTo;

        // Modified by Prasad on 25 March 2007 (Ending)
		var hotelPromoText="";
        function buildSingleHotelTable(hotelIndex)
        {
		//alert(hotelIndex);
                var GDSHotelFlag = hDD[hotelIndex]['GDSHotel']
                var hotelTableString = "";
                var hotel = hDD[hotelIndex];
                var hotelCode = hotel['HotelCode'];
                var mmtRecomm = hotel['MMTRecom'];
                var hotelName = hotel['HotelName'];

                var rating = hotel['StarRating'];
                var GDSHotelCode = hotel['GDSHotelCode']
                var description = hotel['HotelDescription'];
				var result = isLMDHotel(hotelIndex);

				var isPayCash=hotel['allowCashPay'];
				//alert("result = " + result);
                /*if(description.length>200){
                        description=description.substring(0,180)+ ".... <a href='#1' onclick='popDesc("+hotelIndex+",event)' style='cursor:pointer'><u>more<img src='"+imgPath+"images/farerule_img.gif' border=0></u></a>"
                }*/
                hotelTableString += "<TABLE WIDTH='98%' style='border:1px solid #7CBCE7' CELLSPACING='0' cellpadding='0' border='0' style='padding:0'> ";
                var headingBackgroundImageSrc;
                var starRatingString = getStarRatingString(rating);
                if(hotel['PropertyType']!=null && hotel['PropertyType']!=""){
                        starRatingString=hotel['PropertyType']
                }
                var hotelNameDisplay = "";
                if (hotelName.length>45)
                {
                        hotelNameDisplay = hotelName.substring(0,42)  + "...";
                }
                else
                {
                        hotelNameDisplay = hotelName
                }
				if (result == 1){
					hotelTableString += '<TR><TD WIDTH=100%><table border=0 width=100%  align=center cellpadding=0 cellspacing=0 class=hotelline-bg><tr><td align=left valign=top class=hotel-lmd-bg><table width=98% border=0 align=right cellpadding=0 cellspacing=0><tr><td  height=25 align=left class=text-bold-10-red style="padding-left:40px">Last Minute Special Rate - Upto 40% discount!</td> <td>&nbsp;</td></tr><tr><td class=whitetext-headings style="padding-left:30px"><span title="'+ hotel['HotelName']+'">'+ hotelNameDisplay+'</span></td><td align=right valign=bottom><table border=0 cellspacing=0 cellpadding=0><tr><td class=text-white colspan=2 >'+starRatingString+'</td></tr></table></td></tr></table></td><td width=1 align=right valign=top><img src='+imgPath+'images/hotel_recommended_line.gif width=1 height=43 alt= /></td></tr></table></td></tr>'+
										"<tr><td width=100% colspan=2><table border=0 width=580px id='blueBoxTab"+hotelIndex+"' style='display: none;' cellspacing=0 cellpadding=0 align=center><tr><td width=450px><span id='disMetBlueBox"+hotelIndex+"'>1.6 km away from the MG Road, Pune</span></td><td width=90px style='color:#00009f;font-size:10px;' ><span align='left'><a href='#' onClick='cleareMapTextBox();' style='color:#00009f;font-size:10px;'>Modify Search</a></span></td><td><a><img border=0 src='images/binocular-image.gif' height='20px' style='display:bolock;'></a></td></tr></table></td></tr>";
                    headingBackgroundImageSrc = imgPath+"images/main_Bg.jpg"
				}else {
                	if (mmtRecomm.toUpperCase()=='Y')
                	{
 	                    hotelTableString += '<TR><TD WIDTH=100%><table border=0 width=100%  align=center cellpadding=0 cellspacing=0 class=hotelline-bg><tr><td align=left valign=top class=hotel-bg><table width=98% border=0 align=right cellpadding=0 cellspacing=0><tr><td  height=25 align=left class=text-bold-10 style="padding-left:19px">Recommended</td> <td>&nbsp;</td></tr><tr><td class=whitetext-headings><span title="'+ hotel['HotelName']+'">'+ hotelNameDisplay+'</span></td><td align=right valign=bottom><table border=0 cellspacing=0 cellpadding=0><tr><td class=text-white colspan=2 >'+starRatingString+'</td></tr></table></td></tr></table></td><td width=1 align=right valign=top><img src='+imgPath+'images/hotel_recommended_line.gif width=1 height=43 alt= />'+
 	                    					"</td></tr></table><tr><td width=100%><table border=0 width=580px id='blueBoxTab"+hotelIndex+"' style='display: none;' cellspacing=0 cellpadding=0 align=center>"+
 	                    					"<tr><td width=450px><span id='disMetBlueBox"+hotelIndex+"'>1.6 km away from the MG Road, Pune</span></td><td width=90px><span align='left'><a href='#' style='color:#00009f;font-size:10px;' onClick='cleareMapTextBox();' style='color:#00009f;font-size:10px;'>Modify Search</a></span></td><td><a><img border=0 src='images/binocular-image.gif' height='20px' style='display:bolock;'></a></td></tr></table></td></tr>";
                        headingBackgroundImageSrc = imgPath+"images/main_Bg.jpg"
                	}
                	else
                	{
                        hotelTableString += "<TR><TD WIDTH='70%' class='whitetext-headings' BGCOLOR='#0099FF'><span title='"+ hotel['HotelName']+"' style='padding: 3px 0px 0px 10px; height:25px'>" + hotelNameDisplay+"</span></TD><TD HEIGHT='100%' WIDTH='50%' ALIGN='RIGHT' BGCOLOR='#0099FF' class='text-white'>" + starRatingString+"</TD></TR>"+
              								"<tr><td width=100% colspan=2><table border=0 width=580px id='blueBoxTab"+hotelIndex+"' style='display: none;' cellspacing=0 cellpadding=0 align=center><tr><td width=450px><span id='disMetBlueBox"+hotelIndex+"'>1.6 km away from the MG Road, Pune</span></td><td width=90px style='color:#00009f;font-size:10px;'><span align='left'><a href='#' onClick='cleareMapTextBox();' style='color:#00009f;font-size:10px;'>Modify Search</a></span></td><td><a><img border=0 src='images/binocular-image.gif' height='20px' style='display:bolock;'></a></td></tr></table></td></tr>";
				}
				}
                hotelTableString += "<TR><TD WIDTH='100%' COLSPAN=2>" + getDescriptionTable(hotelIndex) +"</TD></TR>";

				if(isPayCash=="Y")
                   hotelTableString += "<TR VALIGN='top'><TD WIDTH='100%' COLSPAN=2 style='padding-left:10;padding-bottom:10;'><div style='float:right;padding-top:5px;'><img src='images/pay-at-hotel.gif' /></div><BR>" + description + "<BR><BR><a href='#select' "
                else
                   hotelTableString += "<TR VALIGN='top'><TD WIDTH='100%' COLSPAN=2 style='padding-left:10;padding-bottom:10;padding-right:10px;'><BR>" + description + "<BR><BR><a href='#select' "
                if(hotel['isOpq']!="Y")
                        hotelTableString +="onClick='goToHtlDetails(\""+hotelCode+"\", 1 , "+ hotelIndex+")'"
                hotelTableString +=">More Details <img src="+imgPath+"images/calque_125.gif width='9' height='7' alt='' BORDER=0/></a></TD></TR><tr><td colspan=2 style='padding-bottom:10;'><span id='hotelPromoText'></span></td></tr>";
                var gdsName = hotel['GDSName'];
                var currency = (residentOfIndiaFlag.toUpperCase()=="YES" || residentOfIndiaFlag.toUpperCase()=="Y")?"Rs.": "US $";
                if ((gdsName.toUpperCase()=="PEGASUS") || (gdsName.toUpperCase()=="P"))
                {
                                fareFrom =  hotel['FareFrom']
                                fareTo =  hotel['FareTo'];
                                if( (fareFrom!="" && fareTo!="") &&  (fareFrom!=null && fareTo!=null ) )
                                {
                                        //Modified by Jhansi
                                        hotelTableString += "<TR><TD WIDTH='100%' COLSPAN=2 ALIGN='center'><table cellpadding=0  cellspacing=0 border=0 width='100%' align='center'><tr><td width='25%' align='center' class='text-11-bold' BGCOLOR=#FFFFFF>Price Range</td><td width='45%' align='center' class='text-11-bold' BGCOLOR=#FFFFFF>From: " + currency+" "+  fareFrom+ " &nbsp;&nbsp;&nbsp;To: " +currency+" "+ fareTo+"</td><td width='30%' align='right'><IMG STYLE='cursor:pointer' SRC='"+ selectImageSRC +"' title='Book' "
                                        if(hotel['isOpq']!="Y")
                                                hotelTableString +="onClick='goToHtlDetails(\""+hotelCode+"\", 5 , "+ hotelIndex+")'"
                                        hotelTableString +="></td></tr></table></TD></TR>";
                                }
                                else
                                {
                                        //hotelTableString += "<TR><TD WIDTH='100%' COLSPAN=2  class='text-11-bold' ALIGN='center' id='"+GDSHotelCode+"Table'>No Rooms Available</TD></TR>";
                                        hotelTableString += "<TR><TD WIDTH='100%' COLSPAN=2  class='text-11-bold' ALIGN='center' id='"+GDSHotelCode+"Table'>Sorry, there are no rooms available in this hotel.</TD></TR>";
                                }
                }
                else if(gdsName.toUpperCase()=="HILTON")
                {
                        hotelTableString += "<TR><TD WIDTH='100%' COLSPAN=2 id='"+GDSHotelCode+"Table'></TD></TR>";
                }
                else
                        {
						hotelPromoText="";
                       var roomTypesString = getRoomTypesTable(hotelIndex);
			            if(roomTypesString != null || roomTypesString != ""){
			            hotelTableString += "<TR><TD WIDTH='100%' COLSPAN=2>" + roomTypesString + "</TD></TR>";
			            hotelTableString += "</TABLE>";

						if(hotelPromoText!="")//Set Hotel Promotion Text for Display Purpose
						{
							hotelTableString = hotelTableString.replace(/<span id='hotelPromoText'><\/span>/,hotelPromoText);
						}
			          } else {
				hotelTableString ="";
			}
                }
                hotelTableString += "</TABLE>";
                return hotelTableString;
        }

		function isLMDHotel(hotelIndex){

			var roomTypes = hDD[hotelIndex]['rT'];
			var result = 0;
			if (roomTypes.length==0)
            {
                        return "";
            }
			for (var roomTypeCount=0 ; roomTypeCount<roomTypes.length; roomTypeCount++){
				var roomType = roomTypes[roomTypeCount];
				var tariffs = roomType['tf'];
				for (var tariffCount =0; tariffCount<tariffs.length; tariffCount++){
					var tariff = tariffs[tariffCount];
				    var dayPrices = tariff['dP'];
				for(var dayPriceCnt=0; dayPriceCnt<dayPrices.length; dayPriceCnt++) {
				    var tempDayPrice = dayPrices[0];
				    var tempMealPlan = tempDayPrice['DayPriceMealPlan'];
				if (tempMealPlan == 'Last Minute Special Rate'){
					 result = 1;
					 return result;
				}
				}

					if (tariff['MealPlan'] == 'Last Minute Special Rate'){
						result = 1;
						return result;
					}

					   var tariffInclusions = tariff['Inclusions'];
                        for (var dayPriceInclusionCount = 0; dayPriceInclusionCount<tariffInclusions.length; dayPriceInclusionCount++)
                        {
                                var inclusion = tariffInclusions[dayPriceInclusionCount];
                                if (inclusion == 'Last Minute Special Rate')
                                {
                                result = 1;
						        return result;
                                }
                        }




				}
			}

			return result;
		}

function getRoomTypesTable(hotelIndex)
{
                var onRequestTariffsCount = 0;
                var lowestAvgPrice = hDD[hotelIndex]['LowestAvgPrice']
                hDD[hotelIndex]['rT'].sort(sortRoomTypes);
                var roomTypes = hDD[hotelIndex]['rT'];
                var hotelCode = hDD[hotelIndex]['HotelCode'];
                if (roomTypes.length==0)
                {
                        return "";
                }
                var emptyRow = "<tr><td width=100% colspan=7 bgcolor=#7CBCE7></td></tr>";
                var roomTypesString = "<table width=100% cellspacing=0 cellpadding='0' border=0><tr><td width=100%><table width='100%'  style='height:100%; width:100%;'  border='0' cellpadding='0' cellspacing='0' >"+emptyRow+"<tr style='width:100%'><td class='table-field-tit' style='border-right:1px solid #7CBCE7' width='245' align=left>Room Type</td> <td class='table-field-tit' style='border-right:1px solid #7CBCE7' width='245' align=left> Inclusions</td><td class='table-field-tit' style='border-right:1px solid #7CBCE7' width='210' align=left> Average Daily Rate</td><td class='table-field-tit' width='100'>&nbsp;</td></tr>";

                var totalRoomsWithDifferntTariff = 0;
                var totalRoomOnRequest = 0;
                for (var roomTypeCount=0 ; roomTypeCount<roomTypes.length; roomTypeCount++)
                {

                        var roomType = roomTypes[roomTypeCount];
                        var tariffs = roomType['tf'];


                        var tariffRowLength =0;
                        if(onRequestHotelStatus == 0){
                                for (var tariffCount =0; tariffCount<tariffs.length; tariffCount++)
                                {
                                 if(tariffs[tariffCount]['AvailStatus']=='B') {
                                                tariffRowLength = tariffRowLength+1;
                                        }
                               }
                        }else {
                                tariffRowLength = tariffs.length;
                        }
                        var   tempActualtariffCount =0;
						var promoImgTag="<img src='images/deal-tag.gif'/>";
						var promoImgTagSel="";
						var isPromoHotelTextReqd = false;
                        for (var tariffCount =0; tariffCount<tariffs.length; tariffCount++)
                        {
                                promoImgTagSel="";
								totalRoomsWithDifferntTariff =totalRoomsWithDifferntTariff +1;
                                var tariff = tariffs[tariffCount],
                                           availStatus = tariff['AvailStatus'] ,
                                           roomTypeRowString = "<TR VALIGN='middle'>" ,
                                           roomTypeNameCell = "" ,
                                           multipleTariffs = tariff['MultipleTariffs'] ,
                                           viewAll = tariff['ViewAll'] ,
                                           packageAvailable = tariff['PackageAvailable'] ,
                                           packageFrom = tariff['PackageFrom'] ,
                                           packageTo = tariff['PackageTo'] ,
                                           packageNights = tariff['PackageNights'] ,
                                           displayTaxesSeperately = tariff['DisplayTaxesSeperately'] ,
                                           baseAdultNum = tariff['BaseAdultNum'] ,
                                           baseAdultTax = tariff['BaseAdultTax'],
                                           accomodate=tariff['Accomodate'],
                                           promoText=tariff['PromoText'];

										   //Added to Show PromoImage Per Tariff
										   if(promoText!=null && promoText!="")
										   {
										   		promoImgTagSel=promoImgTag;
												hotelPromoText = "<div style='height:15px;font-size:11px;padding:5px 0px 7px 10px;border-top:1px solid #eee98a;border-bottom:1px solid #eee98a;background:#fffeea'><img src='images/deal-tag.gif' style='float:left;'/><div style='float:left;margin-top:2px;padding-left:5px;color:#be1616;'><span id='hotelPromoText'>" + promoText + "</span></div></div>";
										   }

                                           var tempStatus = 0;

                                           if(tariff['AvailStatus']=='R') {
                                                totalRoomOnRequest = totalRoomOnRequest+1;
                                                tempStatus =1;
                                        }
                                        if((tariff['AvailStatus']=='R' && onRequestHotelStatus == 1) || tempStatus == 0){
                                                tempActualtariffCount = tempActualtariffCount +1;
                                        var packageFromDate ,
                                                   packageToDate ,
                                                   displayPackageFrom ,
                                                   displayPackageTo;
                                        if (packageAvailable=="Y" || packageAvailable=="y")
                                        {
                                                var dateParts = packageFrom.split("-");

                                                packageFromDate = new Date(dateParts[0] + "/" + dateParts[1] + "/" + dateParts[2]);

                                                dateParts = packageTo.split("-");

                                                packageToDate = new Date(dateParts[0] + "/" + dateParts[1] + "/" + dateParts[2]);

                                                var displayYearFrom;
                                                if ( (packageFromDate.getFullYear() - milestoneYear) > 10 )
                                                {
                                                        displayYearFrom = packageFromDate.getFullYear() - milestoneYear;
                                                }
                                                else
                                                {
                                                                displayYearFrom = "0" + (packageFromDate.getFullYear() - milestoneYear);
                                                }
                                                displayPackageFrom = packageFromDate.getDate() + " " + months[packageFromDate.getMonth()] + " " +  displayYearFrom;


                                                var displayYearTo ;
                                                if ( (packageToDate.getFullYear() - milestoneYear) > 10 )
                                                {
                                                        displayYearTo = packageToDate.getFullYear() - milestoneYear;
                                                }
                                                else
                                                {
                                                        displayYearTo = "0" + (packageToDate.getFullYear() - milestoneYear);
                                                }


                                                displayPackageTo =  packageToDate.getDate() + " " + months[packageToDate.getMonth()] + " " +  displayYearTo;

                                        }

                            var displayTaxesSeperately = tariff['DisplayTaxesSeperately'];
                                var packageMessage = "<BR><FONT COLOR='orange'>Special  "+ packageNights + " night package available. <BR> Check in date:<BR><I>" + displayPackageFrom + "</I> <BR> Check out Date:<BR><I>" + displayPackageTo+"</I><br>To book, please click on book</FONT>";
                                var inclusionsCell = "<TD BGCOLOR=#FFFFFF  style='border-right:1px solid #7CBCE7;padding-left:5px;border-top:1px solid #7CBCE7' valign='middle'>" + getInclusions(roomType , roomTypeCount , hotelIndex, tariffCount) + "</TD>";
                                var selectImg = (tariff['AvailStatus']=='B')?selectImageSRC:onRequestImageSRC
                                var roomTypeCodeDisplay = roomTypes[roomTypeCount]['rTC']
                                var tariffTypeCodeDisplay = roomTypes[roomTypeCount]['tf'][tariffCount]['TariffCode']
                                var packageFunction = "changeToPackageDates(\""+ packageFrom+"\" , \""+ packageTo+"\")";

                if(!(accomodate!="Y" && accomodate!="YES")){
                                if(selectImg==selectImageSRC)
                                {
                                        if (packageAvailable=="Y" || packageAvailable=="y")
                                        {
                                                var selectImageCell = "<td ALIGN='center' BGCOLOR=#FFFFFF style='padding-left:5px; border-top:1px solid #7CBCE7'><a name='givenname' href='#Select' alt='Select Booking'><IMG STYLE='cursor:pointer' SRC='" + selectImg + "' onClick='takeToReviewPage("+hotelIndex+"," + roomTypeCodeDisplay+" , " + tariffTypeCodeDisplay+",\""+ multipleTariffs+"\", \""+packageFrom+"\",\""+ packageTo+"\" , \""+displayTaxesSeperately+"\",null,\""+tariffCount+"\")' style='cursor:pointer' title='Book' border='0' ></a></td>";
                                        }
                                        else
                                        {
                                                var selectImageCell = "<td ALIGN='center' BGCOLOR=#FFFFFF style='padding-left:5px; border-top:1px solid #7CBCE7'><a name='givenname' href='#select' alt='Select Booking'><IMG STYLE='cursor:pointer' SRC='" + selectImg + "'  onClick='takeToReviewPage("+hotelIndex+"," + roomTypeCodeDisplay+" , " + tariffTypeCodeDisplay+",\""+ multipleTariffs+"\", "+null+","+ null+" , \""+displayTaxesSeperately+"\",null,\""+tariffCount+"\")'  style='cursor:pointer' title='Book' border='0' ></a></td>";
                                        }
                                }
                                else
                                {
                                        if (packageAvailable=="Y" || packageAvailable=="y")
                                        {
                                                        var selectImageCell = "<td ALIGN='center' BGCOLOR=#FFFFFF style='padding-left:5px; border-top:1px solid #7CBCE7'><a name='givenname' href='#select' alt='Request Booking'><IMG STYLE='cursor:pointer' SRC='" + selectImg + "'  onClick='takeToReviewPage("+hotelIndex+"," + roomTypeCodeDisplay+" , " + tariffTypeCodeDisplay+",\""+ multipleTariffs+"\", \""+packageFrom+"\",\""+ packageTo+"\" , \""+displayTaxesSeperately+"\",null,\""+tariffCount+"\")' style='cursor:pointer' title='On Request' border='0'></a></td>";
                                                        onRequestTariffsCount++;
                                        }
                                        else
                                        {
                                                        var selectImageCell = "<td ALIGN='center' BGCOLOR=#FFFFFF style='padding-left:5px; border-top:1px solid #7CBCE7'><a name='givenname' href='#select' alt='Request Booking'><IMG STYLE='cursor:pointer' SRC='" + selectImg + "'  onClick='takeToReviewPage("+hotelIndex+"," + roomTypeCodeDisplay+" , " + tariffTypeCodeDisplay+",\""+ multipleTariffs+"\", "+null+","+ null+", \""+displayTaxesSeperately+"\",null,\""+tariffCount+"\") '  style='cursor:pointer' title='On Request' border='0'></a></td>";
                                                        onRequestTariffsCount++;
                                        }
                                }
                }else if(trim(accomodate).length>0)
                {
                        var selectImageCell = "<td ALIGN='center' BGCOLOR=#FFFFFF style='padding-left:5px; border-top:1px solid #7CBCE7'>Exceeds number of <br> guests</td>";
                }
                                var currency = (residentOfIndiaFlag.toUpperCase()=="YES" || residentOfIndiaFlag.toUpperCase()=="Y") ?"Rs.": "US$";
                                var gdsHotel = hDD[hotelIndex]['GDSHotel'];
                            var avgPricePerNight = 1;
                                avgPricePerNight=avgPricePerNight*tariff['AvgPriceNight'];
                var discAvgPricePerNight = 1
                                        discAvgPricePerNight=discAvgPricePerNight*tariff['DiscAvgNightPrice'];
                            var priceCel = "";
                                if(tempActualtariffCount==1 && discAvgPricePerNight<avgPricePerNight)
                                {
                                        if (displayTaxesSeperately!="Y")
                                        {
                                                roomTypeNameCell = "<TD ALIGN='left' BGCOLOR=#FFFFFF rowspan="+tariffRowLength+" style='border-right:1px solid #7CBCE7;padding-left:5px; border-top:1px solid #7CBCE7'><a href='#select' class='text-11-bold' "
                                                if(hDD[hotelIndex]['isOpq']!="Y")
                                                        roomTypeNameCell +="onClick='goToHtlDetails(\""+hotelCode+"\", 5 , "+hotelIndex+")'"
                                                roomTypeNameCell +=" alt='"+roomType['rTN']+"'>" + roomType['rTN'] + "</A><BR/><font class='orangetext-bold-9'><B>Limited time discount!</B></font></TD>";
                                        }
                                        else
                                        {
                                                roomTypeNameCell = "<TD ALIGN='left' BGCOLOR=#FFFFFF rowspan="+tariffRowLength+" style='border-right:1px solid #7CBCE7;padding-left:5px; border-top:1px solid #7CBCE7'><a href='#select' class='text-11-bold' "
                                                if(hDD[hotelIndex]['isOpq']!="Y")
                                                        roomTypeNameCell +="onClick='goToHtlDetails(\""+hotelCode+"\", 5 , "+hotelIndex+")'"
                                                roomTypeNameCell +=" alt='"+roomType['rTN']+"'>" + roomType['rTN'] + "</A><BR><font class='orangetext-bold-9'><B>Limited time discount!</B></font></TD>";
                                        }
                                }
                                else if (tempActualtariffCount==1 )
                                {
                                        if (displayTaxesSeperately=="Y")
                                        {
                                                        roomTypeNameCell = "<TD ALIGN='left' BGCOLOR=#FFFFFF rowspan="+tariffRowLength+" style='border-right:1px solid #7CBCE7;padding-left:5px; border-top:1px solid #7CBCE7'><a href='#select' class='text-11-bold' "
                                                        if(hDD[hotelIndex]['isOpq']!="Y")
                                                                roomTypeNameCell +="onClick='goToHtlDetails(\""+hotelCode+"\", 5 , "+hotelIndex+")'"
                                                        roomTypeNameCell +=" alt='"+roomType['rTN']+"'>" + roomType['rTN'] + "</A></TD>";
                                        }
                                        else
                                        {
                                                roomTypeNameCell = "<TD ALIGN='left' BGCOLOR=#FFFFFF rowspan="+tariffRowLength+" style='border-right:1px solid #7CBCE7;padding-left:5px; border-top:1px solid #7CBCE7'><a href='#select' class='text-11-bold' "
                                                if(hDD[hotelIndex]['isOpq']!="Y")
                                                        roomTypeNameCell +="onClick='goToHtlDetails(\""+hotelCode+"\", 5 , "+hotelIndex+")'"
                                                roomTypeNameCell +=" alt='"+roomType['rTN']+"'>" + roomType['rTN'] + "</A></TD>";
                                        }
                                }
                if (discAvgPricePerNight<avgPricePerNight)
                {

                                        if (tariff['AvailStatus']=='R')
                                        {
                                                onRequestTariffsCount += 1;
                                        }
                                        if (packageAvailable=="Y" || packageAvailable=="y")
                                        {
                                                         priceCell = (tariff['AvailStatus']=='R')?"<TD align='center' class='text-11-bold' BGCOLOR=#FFFFFF style='border-right:1px solid #7CBCE7;border-top:1px solid #7CBCE7'><div style='margin-left:10px;float:left;'>"+ promoImgTagSel+"</div><div style='padding-left:10px;float:left;'><span style='font-weight:normal'><B><del> " + currency+" "+format(avgPricePerNight)+"</del></B></span><br> <span class='orangetext-bold-11'><B>" + currency+" "+ format(tariff['DiscAvgNightPrice'])+"</font></B><br><font color='red'>*</FONT></span></center>"+packageMessage+"<BR></div></TD>": "<TD  align='center' class='text-11-bold' BGCOLOR=#FFFFFF style='border-right:1px solid #7CBCE7;border-top:1px solid #7CBCE7'><div style='margin-left:10px;float:left;'>"+ promoImgTagSel+"</div><div style='padding-left:10px;float:left;'><span style='font-weight:normal'><B><DEL> " +currency+" "+format(tariff['AvgPriceNight'])+"</DEL></B></SPAN><span class='orangetext-bold-11'><B><br>"+ currency+ " " + format(tariff['DiscAvgNightPrice'])+"</B></span></center>"+packageMessage+"<BR></div></TD>";
                                        }
                                        else
                                        {
                                                 priceCell = (tariff['AvailStatus']=='R')?"<TD  align='center' class='text-11-bold' BGCOLOR=#FFFFFF style='border-right:1px solid #7CBCE7;border-top:1px solid #7CBCE7'><div style='margin-left:10px;float:left;'>"+ promoImgTagSel+"</div><div style='padding-left:10px;float:left;'><span style='font-weight:normal'><B><del> " + currency+" "+format(avgPricePerNight)+"</del></B></span><br> <span class='orangetext-bold-11'><B>" + currency+" "+ format(tariff['DiscAvgNightPrice'])+"</font></B><br><font color='red'>*</font></span><BR></div></TD>": "<TD align='center' class='text-11-bold' BGCOLOR=#FFFFFF style='border-right:1px solid #7CBCE7;border-top:1px solid #7CBCE7'><div style='margin-left:10px;float:left;'>"+ promoImgTagSel+"</div><div style='padding-left:10px;float:left;'><span style='font-weight:normal'><B><DEL> " +currency+" "+format(tariff['AvgPriceNight']) +"</DEL></B></SPAN><span class='orangetext-bold-11'><B><br>"+ currency+ " " +format(tariff['DiscAvgNightPrice'])+"</B></span><BR></div></TD>";
                                        }
                 }
                 else
                 {
                                         if (packageAvailable=="Y" || packageAvailable=="y")
                                         {
                                                  priceCell = (tariff['AvailStatus']=='R')?"<TD ALIGN='center'class='text-11-bold' BGCOLOR=#FFFFFF style='border-right:1px solid #7CBCE7;border-top:1px solid #7CBCE7'><div style='margin-left:10px;float:left;'>"+ promoImgTagSel+"</div><div style='padding-left:10px;float:left;'> " + currency+" "+format(tariff['AvgPriceNight']) +"<br> <font color='red'>*</font></span>" + packageMessage + "</div></TD>": "<TD align='center'class='text-11-bold' BGCOLOR=#FFFFFF style='border-right:1px solid #7CBCE7;border-top:1px solid #7CBCE7'><div style='margin-left:10px;float:left;'>"+ promoImgTagSel+"</div><div style='padding-left:10px;float:left;'>  " +currency+" "+format(tariff['AvgPriceNight']) +"" + packageMessage+"<BR></div></TD>";
                                         }
                                         else
                                         {
                                                priceCell = (tariff['AvailStatus']=='R')?"<TD ALIGN='center' class='text-11-bold' BGCOLOR=#FFFFFF style='border-right:1px solid #7CBCE7;border-top:1px solid #7CBCE7'> <div style='margin-left:10px;float:left;'>"+ promoImgTagSel+"</div><div style='padding-left:10px;float:left;'>" + currency+" "+format(tariff['AvgPriceNight']) +"<br> <font color='red'>*</span></div></TD>": "<TD ALIGN='center' class='text-11-bold' BGCOLOR=#FFFFFF style='border-right:1px solid #7CBCE7;border-top:1px solid #7CBCE7'> <div style='margin-left:10px;float:left;'>"+ promoImgTagSel+"</div><div style='padding-left:10px;float:left;'>" +currency+" "+format(tariff['AvgPriceNight']) +"<BR></div></TD>";
                                         }
                 }
                                roomTypeRowString +=  roomTypeNameCell +   inclusionsCell +   priceCell +  selectImageCell + "</TR>";
                                roomTypesString += roomTypeRowString;
                                        }
                        }
                }

				if (onRequestTariffsCount>0)
                {
                        var onRequestIndication = "<div style='background-color:white;width:100%; cellspacing=0 cellpadding=0 style='border:1px solid #3396FF''><table width='100%'><tr><td width='400' style='padding-left:5px'><font color='red'><b>*</b></font> indicates that rooms are unavailable online.Bookings can be made on request. Call <b>1800 103 3000 (Airtel)</b> and <b>1800 11 3000 (MTNL/BSNL)</b> to Book Now.</td><td align='right' valign='top'><a  onClick=\"javascript:whatIsThis(event);\" style=\"cursor:pointer; text-decoration:underline;\">What is this</a><img src='"+imgPath+"images/farerule_img.gif' border=\"0\" onClick=\"javascript:whatIsThis(event);\" style=\"cursor:pointer\"/></a></td></tr></table></div>";
                        return roomTypesString +emptyRow+ "</table>" + onRequestIndication + "</td></tr></table>";
                }
                else
                {
                        if((totalRoomOnRequest == totalRoomsWithDifferntTariff) && onRequestHotelStatus == 0){
                                return "";
                        } else {
                        return roomTypesString + "</table></td></tr></table>";
                        }
                }
        }//getRoomTypesTable()::End
        function whatIsThis(evt)
	{
		 evt = (evt) ? evt : ((window.event) ? window.event : "")
	 	if (evt) {
			var elem = (evt.target) ? evt.target : evt.srcElement
			var x = evt.clientX - 30;
			var y = evt.clientY + document.body.scrollTop+4;
			var divObj = document.getElementById("WhatIsX");
			divObj.style.display = "block";
			divObj.style.position = "absolute";
			divObj.style.left = x-150;
			divObj.style.top = y;
			divObj.innerHTML = "<table width='301' height='26' bgcolor='#3396FF' cellspacing=0 cellpadding=0 style='border:1px solid #3396FF'><tr><td><table width='300' height='25' cellspacing='0' border=0 cellpading='0' bgcolor='#FFFFFF'><tr bgcolor='#3396FF'><td align='left'><font color='white'><B>What is On Request?</B></font></td><td align='right'><a href='javascript:divclose(\"WhatIsX\")' title='Close' style='font-size:12'><b><font color='white'><b>close[X]</b></font></b></a></td></tr><tr><td align='left' colspan='2'>Currently, there are no rooms available in this hotel. You may send us a booking request and our travel specialist will try to get your booking confirmed.<br><br><b>MakeMyTrip.com Service Guarantee.</b><br>If we do not revert to you on the status of your booking within 3 business hours, MakeMyTrip.com will give you Rs. 1,000 off your next reservation.<BR><br><B>Business Hours:</B><table width='100%'><tr><td>Monday to Friday </td><td>Saturday</td></tr><tr><td>9:30 AM to 5:30 PM</td><td>9:30 AM to 1:00 PM</td></tr></table><br></td></tr></table></td></tr></table>"
		}
	}

 function whatIsThisGuarantee(evt)
	{
		 evt = (evt) ? evt : ((window.event) ? window.event : "")
	 	if (evt) {
			var elem = (evt.target) ? evt.target : evt.srcElement
			var x = evt.clientX - 30;
			var y = evt.clientY + document.body.scrollTop+4;
			var divObj = document.getElementById("WhatIsX");
			divObj.style.display = "block";
			divObj.style.position = "absolute";
			divObj.style.left = x-150;
			divObj.style.top = y;
			divObj.innerHTML = "<table width='301' height='26' bgcolor='#3396FF' cellspacing=0 cellpadding=0 style='border:1px solid #3396FF'><tr><td><table width='300' height='25' cellspacing='0' border=0 cellpading='0' bgcolor='#FFFFFF'><tr bgcolor='#3396FF'><td align='left'><font color='white'><B>What is Lowest Hotel Rate Guarantee?</B></font></td><td align='right'><a href='javascript:divclose(\"WhatIsX\")' title='Close' style='font-size:12'><b><font color='white'><b>close[X]</b></font></b></a></td></tr><tr><td align='left' colspan='2'><br><ul ><li>The 'Lowest Hotel Rate Guarantee' offer is valid for hotel bookings made online on www.makemytrip.com or through the MakeMyTrip call centre. This offer is for hotels available in India only.</li><li>The lower tariff quote (if you find any) must be for the same hotel on the same dates, same room category and same inclusions as the booking made on MakeMyTrip.</li><li>If a lower tariff is found anywhere else other than MakeMyTrip.com, then an email with the tariff quote/screen print must be sent to hotelservice@makemytrip.com within 24 hours of making the booking on MakemMyTrip.com. The lower rate must be available to verify at the time of receipt of the claim.</li><li>MakeMyTrip.com will refund one night's tariff if the rate booked on MakeMyTrip.com is higher. </li><li>The refund of the one night's tariff will be credited back to the credit card used for making the booking within one week of completion of the stay. </li><li>The Lowest Hotel Rate Guarantee is applicable on standard tariffs offered publicly on another travel website or directly by the hotel. </li></ul><div style='padding:2px;font-weight:bold;'> - This offer is valid for all hotels marked with the <span style='color:#CC0000;'>LOWEST RATE GUARANTEE</span> stamp.</div><div style='padding-top:5px;'> - MakeMyTrip's decisions on all claims under this offer shall be final and binding.</div><div style='padding-top:5px;'> - The first night free will be given on bookings for stay of 2 nights or more. If the stay is for 1 night then 50% refund for the booking will be given.</div><div style='padding-top:5px;'> - The minimum per night difference should be of Rs. 200 or more in order to qualify for the claim.</div></td></tr></table></td></tr></table>"
		}
	}

	function divclose(name){
        var divObj;
        divObj= document.getElementById(name);
        divObj.style.display = "none";
    }

        function divclose(name){
        var divObj;
        divObj= document.getElementById(name);
        divObj.style.display = "none";
    }


        function getHotelIndex(hotelCode)
        {
                        for (var hotelCount=0; hotelCount<hD.length; hotelCount++ )
                        {
                                var code = hD[hotelCount]['HotelCode']
                                if (code==hotelCode)
                                {
                                        return hotelCount;
                                }
                        }
                        return -1;
        }

        function takeToReviewPage(hotelDisplayIndex , roomTypeCode , tariffTypeCodeDisplay , multipleTariffs , checkInDate , checkoutDate , DisplayTaxesSeperately , availStatus,tariffIndex)
        {
						var gdsHotel = hDD[hotelDisplayIndex]['GDSHotel'];
                        var gdsHotelCode = hD[hotelDisplayIndex]['GDSHotelCode'];
                        var gdsName = hD[hotelDisplayIndex]['GDSName'];
                        var hotelCode = hDD[hotelDisplayIndex]['HotelCode'];
                        var hotelName =  hDD[hotelDisplayIndex]['HotelName']
                        var starRating =  hDD[hotelDisplayIndex]['StarRating']
                        var MMTRecom =  hDD[hotelDisplayIndex]['MMTRecom'];

                        var tariffCode = tariffTypeCodeDisplay
                        var htlDesc = hDD[hotelDisplayIndex]['HotelDescription'];
                        var htlArea = hDD[hotelDisplayIndex]['Area'];
                    document.hotelsListingForm.HtlDesc.value = htlDesc;
                        document.hotelsListingForm.HtlArea.value = htlArea;
                        if (gdsName.toUpperCase()=="PEGASUS")
                        {
                                gdsName =  "P";
                        }
                        else if (gdsName.toUpperCase()=="HILTON")
                        {
                                gdsName = "H"
                        }
                        document.hotelsListingForm.GDSHotel.value = gdsHotel;
                        document.hotelsListingForm.GDSHotelCode.value = gdsHotelCode;
                        document.hotelsListingForm.GDSName.value = gdsName;
                        document.hotelsListingForm.MMTHotelCode.value = hotelCode;
                        document.hotelsListingForm.RoomTypeCode.value = roomTypeCode;
                        document.hotelsListingForm.HotelName.value = hotelName;
                        document.hotelsListingForm.StarRating.value = starRating;
                        document.hotelsListingForm.MMTRecom.value = MMTRecom;
                        document.hotelsListingForm.HotelIndex.value = hDD[hotelDisplayIndex]['HotelIndex'];
                        var roomTypeIndex = getRoomTypeIndex(getHotelIndex(hotelCode), roomTypeCode);
                        document.hotelsListingForm.RoomTypeIndex.value = roomTypeIndex;
                        document.hotelsListingForm.TariffIndex.value = tariffIndex;
                        document.hotelsListingForm.TariffCode.value = tariffCode;
                        document.hotelsListingForm.MultipleTariffs.value = multipleTariffs;
                        document.hotelsListingForm.DisplayTaxesSeperately.value = DisplayTaxesSeperately
                        var img = hDD[hotelDisplayIndex]['HotelPrimImg'] ;
                        document.hotelsListingForm.ImgURL.value = img;
                        var chkIn =  hDD[hotelDisplayIndex]['ChkInTime'];
                var chkOut =  hDD[hotelDisplayIndex]['ChkOutTime'];
                document.hotelsListingForm.ChkInTime.value = chkIn;
                        document.hotelsListingForm.ChkOutTime.value = chkOut;
                        if ( checkInDate!=null  && checkoutDate!=null)
                        {
                                        document.hotelsListingForm.action =  "hotelReview?PackageFrom="+ checkInDate+"&PackageTo="+checkoutDate+"&AvailStatus="+ availStatus+"&DisplayTaxesSeperately="+DisplayTaxesSeperately + "&CurrentPage="+currentPage ;
                        }
                        else
                        {
                                        document.hotelsListingForm.action =  "hotelReview?AvailStatus="+ availStatus+"&DisplayTaxesSeperately="+DisplayTaxesSeperately + "&CurrentPage="+currentPage;
                        }
                        setAmenCookie()
                        document.hotelsListingForm.method = "Post"
                        document.hotelsListingForm.submit();
        }



        function getInclusions(roomType , roomTypeCount , hotelIndex, tariffCount)
        {
                var inclusionString = "&nbsp;<br/><table width100% cellpadding=0 cellspacing=0 valign='middle'>";
				var tariffs = roomType['tf'];
                var shownInclusionCount = 0;
                var tariff = tariffs[tariffCount];
                var dayPrices = tariff['dP'];
                var multipleTariff = tariff['MultipleTariffs'];
                var viewAll = tariff['ViewAll'];
				var result = 0;


				for(var dayPriceCnt=0; dayPriceCnt<dayPrices.length; dayPriceCnt++) {
				 var tempDayPrice = dayPrices[0];
				 var tempMealPlan = tempDayPrice['DayPriceMealPlan'];
				 if (tempMealPlan == 'Last Minute Special Rate'){
					if (dayPrices.length>=1 && dayPrices[0]['DayPriceInclusions'].length>0)
                	{
                                inclusionString += "<tr valign='top'><td><B><SUP>.</SUP></B></TD><TD><font color='red'>" + tempMealPlan+"!"+"</font></TD></TR>";
                	}
                	else
                	{
                        inclusionString += "<tr valign='top'><td>&nbsp;</TD><TD><font color='red'>" + tempMealPlan+"!"+"</font></TD></TR>";
                	}
					result = 1;
					 break;
				}
				}
				if (tariff['MealPlan'] == 'Last Minute Special Rate'){
					result = 1;
				}
				if (result == 0){
                	if (dayPrices.length>=1 && dayPrices[0]['DayPriceInclusions'].length>0)
                	{
                                inclusionString += "<tr valign='top'><td><B><SUP>.</SUP></B></TD><TD>" + tariff['MealPlan']+"</TD></TR>";
                	}
                	else
                	{
                        inclusionString += "<tr valign='top'><td>&nbsp;</TD><TD>" + tariff['MealPlan']+"</TD></TR>";
                	}
       			}
                if(dayPrices.length>=1)
                {
                        var dayPrice = dayPrices[0];
                        var dayPriceInclusions = tariff['Inclusions'];
                        for (var dayPriceInclusionCount = 0; dayPriceInclusionCount<dayPriceInclusions.length; dayPriceInclusionCount++)
                        {
                                shownInclusionCount += 1;
                                if (shownInclusionCount<= maximumInclusionsToShow)
                                {
                                        var inclusion = dayPriceInclusions[dayPriceInclusionCount];
                                        var displayInclusion = inclusion
                                        inclusionString += "<tR valign='top'><TD><B><SUP>.</SUP></B></td><td title='"+inclusion+"'>" + displayInclusion+"</td></tr>";
                                }
                        }
                }
                inclusionsPanes += 1;
                if (shownInclusionCount > maximumInclusionsToShow)
                {
                        var togglerId = hotelIndex +":"+roomTypeCount;
                        roomTypeCount=roomType['rTI']
                        inclusionString += '<tr valign="top"><td colspan=2 style="padding: 8px;"><A name=\'#2\' onClick="retrieveInclusionsDojo(event, '+hotelIndex+', '+roomTypeCount+', '+tariffCount+')" style="cursor:pointer" alt=\'All Inclusions\'><u>View All Inclusions</u> <IMG SRC='+imgPath+'images/farerule_img.gif BORDER=0></A></td></tr>';
                }
                else if (((multipleTariff=='y' || multipleTariff=='Y') && viewAll=='Y'))
                {
                        var togglerId = hotelIndex +":"+roomTypeCount;
                        roomTypeCount=roomType['rTI']
                        inclusionString += '<tr valign="top"><td colspan=2 style="padding: 8px;"><A name=\'#2\' onClick="retrieveInclusionsDojo(event, '+hotelIndex+', '+roomTypeCount+', '+tariffCount+')" style="cursor:pointer" alt=\'All Inclusions\'><u>View All Inclusions</u> <IMG SRC='+imgPath+'images/farerule_img.gif BORDER=0></A></td></tr>';
                }
                /*
                if (shownInclusionCount >= maximumInclusionsToShow && ((multipleTariff=='y' || multipleTariff=='Y') && viewAll=='Y'))//|| dayPrices.length>1)
                {
                                var togglerId = hotelIndex +":"+roomTypeCount;
                                roomTypeCount=roomType['rTI']
                                inclusionString += '<tr valign="top"><td colspan=2 style="padding: 8px;"><A name=\'#2\' onClick="retrieveInclusionsDojo(event, '+hotelIndex+', '+roomTypeCount+', '+tariffCount+')" style="cursor:pointer" alt=\'All Inclusions\'><u>View All Inclusions</u> <IMG SRC='+imgPath+'images/farerule_img.gif BORDER=0></A></td></tr>';
                }
                */
                inclusionString += "</TABLE><br/>&nbsp;"
                return inclusionString;
        }


        function retrieveInclusionsDojo(e, hotelIndex, roomTypeCount, tariffCount)
        {
                var element = e.srcElement
                        if(!e) {
                                 var e = window.event;
                        }
                        mouseX = e.clientX;
                        mouseY = e.clientY;
                        if(navigator.appName=="Netscape") {
                                mouseX = e.pageX;
                                mouseY = e.pageY;
                        }
                        var hotelCode = hDD[hotelIndex]['HotelCode']
                        hotelIndex = getHotelIndex(hotelCode);

                        try {
                                reqObj = new window.XMLHttpRequest();
                                if(reqObj.overrideMimeType) {
                                //              ajxRequest.overrideMimeType('text/xml');
                                }
                        } catch(e) {
                                reqObj = new ActiveXObject("Msxml2.XMLHTTP");
                        }
                        reqObj.open("Get" , "jsp/getInclusions.jsp?hotelIndex="+hotelIndex+"&ROOM_TYPE_COUNT="+roomTypeCount+"&TARIFF_COUNT="+tariffCount, false);
                        reqObj.send(null);
                        while (reqObj.readyState!=4)    {}
                        var ajxResponse= reqObj.responseText;
                        var myObject = eval('(' + ajxResponse + ')');

                        var tableData = myObject.bindings;



         populateTable(null,tableData,e,null);
}

        var inclusionsRequest;
        var mouseX , mouseY;
        function populateTable(type, data, evt, e) {


                tableData = data;
                dataSize = data.length;
                var dayInclusionArray = new Array();
                for(var j=0;j<dataSize;j++)
                {
                  if(typeof(data[j])== "object")
                        {
                          var len = dayInclusionArray.length;
                          dayInclusionArray[len] = new Array();
                          var discPrice = data[j].DiscPrice;
                          dayInclusionArray[len][0] = format(data[j].Price);
                          dayInclusionArray[len][1] = data[j].MealPlan;
                      dayInclusionArray[len][2] = format();
                          var inclusions =  data[j].Inclusions.split("#");
                          for(var i=0; i<inclusions.length-1; i++)
                                {
                                  dayInclusionArray[len][i+2] = inclusions[i];
                          }
                          dayInclusionArray[len][inclusions.length+1] = format(discPrice);
                  }
                }
                var div = document.getElementById("explodeIncDiv");
                        var inclusionExplode = document.getElementById("explodeInclusion")
                        inclusionExplode.style.display="block"
                        div.style.position = "absolute" ;
                        var divWidth = parseInt(  (inclusionExplode.style.width).split("px")[0] , 10);
                        var targetLeft = parseInt(mouseX,10) + document.body.scrollLeft;

                        var scrollTop = (navigator.appName=="Netscape")?0:document.body.scrollTop;
                        var targetTop = parseInt(mouseY) + scrollTop;

                        if (targetLeft + divWidth > window.screen.width)
                        {
                                div.style.left = window.screen.width - divWidth - (window.screen.width/16);
                        }
                        else
                        {
                                div.style.left = parseInt(mouseX,10) + document.body.scrollLeft + "px"
                        }
                        div.style.top = parseInt(mouseY) + scrollTop+ "px"
                        var inclusionTableStr = buildInclusionsTable(dayInclusionArray);
                        document.getElementById("explodeInclusionText").innerHTML='<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%"><tr><td bgcolor="#0099FF">'+inclusionTableStr+'</td><tr></table>';
        }

        function retrieveInclusions(e, hotelIndex, roomTypeCount, tariffCount) {
                if(!e) {
                         var e = window.event;
                }
                mouseX = e.clientX;
                mouseY = e.clientY;
                if(navigator.appName=="Netscape") {
                        mouseX = e.pageX;
                        mouseY = e.pageY;
                }
                try {
                        inclusionsRequest = new window.XMLHttpRequest();
                        if(inclusionsRequest.overrideMimeType) {
                //              inclusionsRequest.overrideMimeType('text/xml');
                        }
                } catch(e) {
                        inclusionsRequest = new ActiveXObject("Msxml2.XMLHTTP");
                }
                var hotelCode = hDD[hotelIndex]['HotelCode'];
                var roomtypeCode = hDD[hotelIndex]['rT'][roomTypeCount]['rTC'];
                inclusionsRequest.open("Get" , "searchHotels.do?method=getInclusions&hotelIndex="+hotelIndex+"&ROOM_TYPE_COUNT="+roomTypeCount+"&TARIFF_COUNT="+tariffCount);
                inclusionsRequest.send(null);
                inclusionsRequest.onreadystatechange = showRetrievedInclusions;
        }

        function showRetrievedInclusions() {
                if(inclusionsRequest.readyState==4) {
                        var dayInclusionArray = new Array();
                        var responseDoc = inclusionsRequest.responseText;
                        var totalList = responseDoc.split("<Tariff-Inclusions>")[1].split("</Tariff-Inclusions>")[0];
                        var dayPricesList = totalList.split("<DayPrice>");
                        var remainingStr = "";
                        for(var p=1; p<dayPricesList.length; p++) {
                                var dayPriceList = dayPricesList[p].split("</DayPrice>")[0];
                                remainingStr = dayPriceList.split("<Price>")[1].split("</Price>");
                                var price = remainingStr[0];
                                var len = dayInclusionArray.length;
                                dayInclusionArray[len] = new Array();
                                dayInclusionArray[len][0] = price;
                                remainingStr = remainingStr[1].split("<Meal-Plan>")[1].split("</Meal-Plan>");
                                var mealPlan = remainingStr[0];
                                dayInclusionArray[len][1] = mealPlan;
                                var inclusionList = remainingStr[1].split("<Inclusion>");
                                for(var i=1; i<inclusionList.length; i++) {
                                        var inclusionName = inclusionList[i].split("</Inclusion>")[0];
                                        dayInclusionArray[len][i/1+1] = inclusionName;
                                }
                        }
                        var div = document.getElementById("explodeIncDiv");
                        div.style.position = "absolute" ;
                        div.style.left = (document.body.scrollLeft + mouseX) + "px"
                        div.style.top = (document.body.scrollTop  + mouseY) + "px"
                        var inclusionTableStr = buildInclusionsTable(dayInclusionArray);
                        document.getElementById("explodeInclusionText").innerHTML='<table border="0" cellpadding="0" cellspacing="0" width="97%" height="100%"><tr><td bgcolor="#0099FF">'+inclusionTableStr+'</td><tr></table>';
                }
        }


function buildInclusionsTable(dayInclusionArray)
       {
              var currency = (residentOfIndiaFlag.toUpperCase()=="YES" || residentOfIndiaFlag.toUpperCase()=="Y")?"Rs.": "US$";
              var inclusionString = '<table border="0" cellpadding="0" cellspacing="1" width="100%" height="100%">';
              var noOfDaysLeft = travelDuration;
              var noOfRows = ((travelDuration%7)==0 ? parseInt(travelDuration/7, 10) : parseInt(travelDuration/7, 10) + 1);
              var headerRow = "";
              for(var rowCount = 0; rowCount<noOfRows; rowCount++)
                         {
                    inclusionString+= '<tr bgcolor="#FFFFFF">'
                     if(rowCount=="0")
                                        {
                         inclusionString+= '<td>&nbsp;</td>';
                         if(noOfRows>1)
                               inclusionString+= '<td>&nbsp;</td>';
                     }
                                         else if(rowCount>0)
                                         {
                          inclusionString+= '<td>&nbsp;</td><td>&nbsp;</td>';
                     }
                     var rowCells;
                     if(noOfDaysLeft>=7)
                                        {
                         rowCells = 7;
                         noOfDaysLeft = noOfDaysLeft-7;
                    }
                                        else
                                        {
                          rowCells = noOfDaysLeft;
                    }
                    var wkDay = jsCheckInDate.getDay();
                    for(var colCount=0; colCount<rowCells; colCount++)
                                        {
                          inclusionString+= '<td class="table-field-tit">' +weekDayNames[wkDay]+'</td>';
                          wkDay = (wkDay>=6)?0:(wkDay+1);
                    }
                    inclusionString+=fillEmptyCells(noOfRows, rowCells);
                    inclusionString+= '</tr><tr bgcolor="#FFFFFF">'
                    inclusionString+= (noOfRows>1)?'<td class="table-field-tit"> Wk '+(rowCount/1+1)+'</td>' : '';
                    inclusionString+= '<td class="table-field-tit"> Price </td>';
                    for(var colCount=0; colCount<rowCells; colCount++)
                    {
                                                if(dayInclusionArray[colCount+ (rowCount *7)][dayInclusionArray[colCount+ (rowCount *7)].length-1]!="")
                                                        inclusionString+= '<td align="center"> <del>'+currency +' '+dayInclusionArray[colCount+ (rowCount *7)][0]+'</del><br/> <font color="#FE7D01">'+currency + dayInclusionArray[colCount+ (rowCount *7)][dayInclusionArray[colCount+ (rowCount *7)].length-1]+'</td>';
                                                else
                                inclusionString+= '<td align="center"> '+currency +' '+dayInclusionArray[colCount+ (rowCount *7)][0]+'</td>';
                     }
                     inclusionString+=fillEmptyCells(noOfRows, rowCells);
                     inclusionString+= (noOfRows>1)?'</tr><tr bgcolor="#FFFFFF"><td class="table-field-tit">&nbsp;</td><td class="table-field-tit"> Inclusions </td>':'</tr><tr bgcolor="#FFFFFF"><td class="table-field-tit" style="padding: 8px;"> Inclusions </td>'
                     for(var colCount=0; colCount<rowCells; colCount++)
                     {
                           inclusionString+= '<td align="left" style="padding: 8px;"><table cellspacing="0" cellpadding="0"><tr><td  valign="top"><img src='+imgPath+'images/bullet1.gif ></td><td>'+dayInclusionArray[colCount+ (rowCount *7)][1]+'</td></tr></table>';
                           for(var j=2; j<dayInclusionArray[colCount+ (rowCount *7)].length-1; j++)
                           {
                                 if(dayInclusionArray[colCount+ (rowCount *7)][j]!=null && dayInclusionArray[colCount+ (rowCount *7)][j]!='un,de,fi,ned')
                                         inclusionString+= '<table cellspacing="0" cellpadding="0"><tr><td  valign="top"><img src='+imgPath+'images/bullet1.gif ></td><td>'+dayInclusionArray[colCount+ (rowCount *7)][j]+'</td></tr></table>';
                           }
                           inclusionString+= '</td>';
                     }
                     inclusionString+=fillEmptyCells(noOfRows, rowCells);
                     inclusionString+= '</tr>'
              }
              inclusionString+= '</table>'
              return inclusionString;
       }



        function fillEmptyCells(noOfRows, rowCells) {
                var str = "";
                if(noOfRows>1 && rowCells<7) {
                        for(var cnt=rowCells; cnt<7; cnt++) {
                                str+= '<td>&nbsp;</td>';
                        }
                }
                return str;
        }

        function buildIncTable(roomTypeCount , hotelIndex)
        {
                var hotel = hDD[hotelIndex];
                var roomTypes = hDD[hotelIndex]['rT'];
                var roomType = roomTypes[roomTypeCount];
                var shownInclusionCount = 0;
                var tariffs = roomType['tf'];
                var noOfRows = ((travelDuration%7)==0 ? parseInt(travelDuration/7, 10) : parseInt(travelDuration/7, 10) + 1);
                var inclusionString = '<table border="0" cellpadding="0" cellspacing="1" width="100%" height="110%">';
                var dayInclusionArray = new Array();
                for (var tariffCount =0; tariffCount<tariffs.length; tariffCount++)
                {
                        var tariff = tariffs[tariffCount];
                        var dayPrices = tariff['dP'];
                        for (var dayPriceCount=0; dayPriceCount < dayPrices.length; dayPriceCount++)
                        {
                                var len = dayInclusionArray.length;
                                dayInclusionArray[len] = new Array();
                                var dayPrice = dayPrices[dayPriceCount];
                                dayInclusionArray[len][0] = dayPrice['Price'];
                                dayInclusionArray[len][1] = dayPrice['DayPriceMealPlan'];
                                var dayPriceInclusions = dayPrice['DayPriceInclusions'];
                                var incCnt = 2;
                                for (var dayPriceInclusionCount = 0; dayPriceInclusionCount<dayPriceInclusions.length; dayPriceInclusionCount++)
                                {
                                        shownInclusionCount += 1;
                                        var inclusion = dayPriceInclusions[dayPriceInclusionCount];
                                        dayInclusionArray[len][incCnt] = inclusion;
                                        incCnt++;
                                }
                        }
                }
                var noOfDaysLeft = travelDuration;
                var headerRow = "";
                for(var rowCount = 0; rowCount<noOfRows; rowCount++) {
                        inclusionString+= '<tr bgcolor="#FFFFFF">'
                        if(rowCount=="0") {
                                inclusionString+= '<td>&nbsp;</td>';
                                if(noOfRows>1)
                                        inclusionString+= '<td>&nbsp;</td>';
                        }
                        var rowCells;
                        if(noOfDaysLeft>=7) {
                                rowCells = 7;
                                noOfDaysLeft = noOfDaysLeft-7;
                        } else {
                                rowCells = noOfDaysLeft;
                        }
                        var wkDay = jsCheckInDate.getDay();
                        for(var colCount=0; colCount<rowCells; colCount++) {
                                inclusionString+= '<td class="table-field-tit">' +weekDayNames[wkDay]+'</td>';
                                wkDay = (wkDay>=6)?0:(wkDay+1);
                        }
                        inclusionString+= '</tr><tr bgcolor="#FFFFFF">'
                        //for Price
                        inclusionString+= (noOfRows>1)?'<td class="table-field-tit"> Wk '+(rowCount/1+1)+'</td>' : '';
                        inclusionString+= '<td class="table-field-tit"> Price </td>';
                        for(var colCount=0; colCount<rowCells; colCount++) {
                                inclusionString+= '<td align="center">'+dayInclusionArray[colCount][0]+'</td>';
                        }
                        //for Inclusions
                        inclusionString+= '</tr><tr bgcolor="#FFFFFF"><td class="table-field-tit"> Inclusions </td>'
                        for(var colCount=0; colCount<rowCells; colCount++) {
                                inclusionString+= '<td>. '+dayInclusionArray[colCount][1]+'<br>';
                                for(var j=2; j<dayInclusionArray[colCount].length; j++) {
                                        inclusionString+= '. '+dayInclusionArray[colCount][j]+'<br>';
                                }
                                inclusionString+= '</td>';
                        }
                        inclusionString+= '</tr>'
                }
                return inclusionString;
        }


        function goToHtlDetails(hotelCode, tabNo , hotelIndex , anchorName)
        {
			//if(mapCityGridFlagVar){
			//	document.getElementById("statesautocomplete").className ="zIndexInput";
			//}

                var hotelName = hDD[hotelIndex]['HotelName']
                var chkIn =  hDD[hotelIndex]['ChkInTime'];
        var chkOut =  hDD[hotelIndex]['ChkOutTime'];
                document.hotelsListingForm.ChkInTime.value = chkIn;
                document.hotelsListingForm.ChkOutTime.value = chkOut;
                var GDSHotelCode = hDD[hotelIndex]['GDSHotelCode']
                var GDSName = hDD[hotelIndex]['GDSName']
                if (GDSName.toUpperCase()=="PEGASUS")
                {
                        GDSName =  "P";
                }
                else if (GDSName.toUpperCase()=="HILTON")
                {
                        GDSName = "H"
                }
                document.hotelsListingForm.hidHotelSeqNo.value = hotelCode;
                document.hotelsListingForm.GDSHotelCode.value = GDSHotelCode;
                document.hotelsListingForm.GDSName.value = GDSName;
                var roomTypes = hDD[hotelIndex]['rT'];
                var roomTypeCodesString = "";
                for (var count=0;count<roomTypes.length ;count++ )
                {
                                var roomTypeCode = roomTypes[count]['rTC'];
                                roomTypeCodesString += roomTypeCode + "!";
                }
                document.hotelsListingForm.RoomTypeCodesString.value=roomTypeCodesString;
                var roomTypeNamesString = ""
                for (var count=0;count<roomTypes.length ;count++ )
                {
                                var roomTypeCode = roomTypes[count]['rTN'];
                                roomTypeNamesString += roomTypeCode + "!";
                }
                document.hotelsListingForm.RoomTypeNamesString.value=roomTypeNamesString;
                document.hotelsListingForm.hidTargetTab.value=tabNo;
                document.hotelsListingForm.hotelName.value=hotelName;
                hotelIndex=hDD[hotelIndex]['HotelIndex'];
                var displayHotelIndex = hotelIndex;
                try{
                        document.getElementById("idModifyDtls").style.display="none";
                        document.getElementById("locationCell").style.display="none";
                }catch(e){
                }
                setAmenCookie();


          		var cityCode = document.getElementById("hidCityCode").value;
          		var url = "hotelDetails.do?method=displayHtlDetails&hidCityCode="+cityCode+"&hidHotelSeqNo="+ hotelCode+"&hotelName="+ hotelName+"&RoomTypeCodesString="+ roomTypeCodesString + "&RoomTypeNamesString=" + roomTypeNamesString + "&HotelIndex=" + hotelIndex+"&AnchorName=" + anchorName+"&CurrentPage="+currentPage+"&isHotelVideo="+globalIsVideo+"&hidTargetTab="+tabNo;
				getHotelDetails(url, tabNo);

        }

        function isAmenityPresent( givenAmenityName , hotelIndex)
        {
               var filteredAmenityList = getTheAmenityList(givenAmenityName);
                var hotel = hD[hotelIndex];
                var amenities = hotel['hA']
                for (var amenityCount=0;amenityCount<amenities.length ; amenityCount++ )
                {
                        var amenity = amenities[amenityCount];
                        var amenityName = amenity['aN'];
                       for(var filteramenitycount=0;filteramenitycount<filteredAmenityList.length ; filteramenitycount++){
						   var tempFilterAmenity=filteredAmenityList[filteramenitycount];
					   if (amenityName.toUpperCase().indexOf(tempFilterAmenity.toUpperCase()) !=-1)
                        {
                                return true;
                        }
                }
                }
                return false;
        }

		function getTheAmenityList(givenAmenityName)
		{

			    var filteredAmenityList = new Array();
				if(givenAmenityName =="Travel Desk/Assistance"){

				 filteredAmenityList[filteredAmenityList.length]="Travel Desk";
				 filteredAmenityList[filteredAmenityList.length]="Travel agency facilities";
				 filteredAmenityList[filteredAmenityList.length]="Sightseeing";

				}else if(givenAmenityName =="Internet"){
				  filteredAmenityList[filteredAmenityList.length]="Chargeable Wi Fi Internet Connectivity";
				  filteredAmenityList[filteredAmenityList.length]="Free Wi Fi Internet Connectivity";
				  filteredAmenityList[filteredAmenityList.length]="Free WiFi Internet";
                  filteredAmenityList[filteredAmenityList.length]="Free WiFi Internet Connectivity";
                  filteredAmenityList[filteredAmenityList.length]="Chargeable Wi Fi Internet Connectivity";
                  filteredAmenityList[filteredAmenityList.length]="Chargeable WiFi Internet";
                  filteredAmenityList[filteredAmenityList.length]="Chargeable WiFi Internet Connectivity";
                  filteredAmenityList[filteredAmenityList.length]="WiFi at a charge";
                  filteredAmenityList[filteredAmenityList.length]="Internet Facility";
                  filteredAmenityList[filteredAmenityList.length]="Wifi Enabled";


				}else if(givenAmenityName =="Golf"){
					filteredAmenityList[filteredAmenityList.length]="18-hole Golf Course";
                  filteredAmenityList[filteredAmenityList.length]="Golf";
                  filteredAmenityList[filteredAmenityList.length]="9-hole Golf Course";

				}else if(givenAmenityName =="Transport Facility"){
					filteredAmenityList[filteredAmenityList.length]="Airport/Railway Station Transfer";
					filteredAmenityList[filteredAmenityList.length]="Airport/Rlwy Stn Transfer";


				}else if(givenAmenityName =="Laundry/Dry Cleaning Service"){
					filteredAmenityList[filteredAmenityList.length]="Laundry Service";
					filteredAmenityList[filteredAmenityList.length]="Dry Cleaning Service";

				}else if(givenAmenityName =="Outdoor Activities"){
					filteredAmenityList[filteredAmenityList.length]="Outdoor Activities";
                    filteredAmenityList[filteredAmenityList.length]="Miniature Golf Course";
                    filteredAmenityList[filteredAmenityList.length]="Skiing";
                    filteredAmenityList[filteredAmenityList.length]="Jungle Safari";
                    filteredAmenityList[filteredAmenityList.length]="Jogging Track";

				}else if(givenAmenityName =="Swimming Pool"){

					filteredAmenityList[filteredAmenityList.length]="Outdoor Swimming Pool";
                    filteredAmenityList[filteredAmenityList.length]="Swimming Pool";



				}else if(givenAmenityName =="Restaurant/Coffee Shop"){
					filteredAmenityList[filteredAmenityList.length]="24-hour Coffee Shop";
                    filteredAmenityList[filteredAmenityList.length]="24-hr Coffee Shop";
					filteredAmenityList[filteredAmenityList.length]="Coffee Shop";


				}else if(givenAmenityName =="Entertainment Center"){
					filteredAmenityList[filteredAmenityList.length]="Activity Centre";
                    filteredAmenityList[filteredAmenityList.length]="Entertainment Centre";



				}else if(givenAmenityName =="Business Services"){
					filteredAmenityList[filteredAmenityList.length]="Board Room";
                    filteredAmenityList[filteredAmenityList.length]="Boardroom";
					filteredAmenityList[filteredAmenityList.length]="Business Centre";


				}else if(givenAmenityName =="Fitness Centre/Gym"){
					filteredAmenityList[filteredAmenityList.length]="Massage Centre";
                    filteredAmenityList[filteredAmenityList.length]="Gymnasium";
					filteredAmenityList[filteredAmenityList.length]="Gymnasium/Health Club";


				}

				return filteredAmenityList;
		}
        function checkStarRating(hotelIndex)
        {
                var starRatingBoxes = document.getElementsByName("StarRatingBox");
                try
                {
                                var rating = parseInt(hD[hotelIndex]['StarRating']);
                }
                catch (e)
                {
//                      alert("hotelIndex::"+ hotelIndex +" and the total are :: "+ hD.length);
                }
                var starRating5 = starRatingBoxes[0];
                var starRating4 = starRatingBoxes[1];
                var starRatingBelow3 = starRatingBoxes[2];

                if (starRating5.checked==true )
                {
                        if (rating==5)
                        {
                                return true;
                        }
                }
                if (starRating4.checked==true )
                {
                        if (rating==4)
                        {
                                return true;
                        }
                }
                if (starRatingBelow3.checked==true )
                {
                        if (rating<=3)
                        {
                                return true;
                        }
                }
                if (starRating5.checked==false && starRating4.checked==false && starRatingBelow3.checked==false)
                {
                        return false;
                }
                return false;
        }
function trim(str)
{
        return lTrim(rTrim(str));
}
function lTrim(str)
{
        var s = "";
        var count;
        for (count=0; (count<str.length && str.charAt(count)==" " ); count++)
        {
        }
        while (count<str.length)
        {
                        s += str.charAt(count++);
        }
        return s;
}
function rTrim(str)
{
         str = str + "";
        var s = "";
        var count;
        for (count=str.length-1; (count>=0 && str.charAt(count)==" " ); count--)
        {
        }
        for (var count2=0; count2<=count;count2++ )
        {
                s += str.charAt(count2);
        }
        return s;
}
        function filterHotelName(hotelIndex)
        {
//              alert("here");
                var hotelName = hD[hotelIndex]['HotelName'];
                var hotelNameString = document.getElementById("hotelNameString").value.toUpperCase();
        //      alert("hotelNameString : "+hotelNameString)
                if (hotelNameString=='NAME CONTAINS...' || hotelNameString=="Hotel Name contains...")
                {
                        return true;
                }
                if (trim(hotelNameString)==0)
                {
                        return true;
                }
                if (hotelName.toUpperCase().indexOf(hotelNameString)!=-1)
                {
                        return true;
                }
                else
                {
                        return false;
                }
        }
       function filter()
	{

		var givenHotelSubstring = document.getElementById("hotelNameString").value;
		if(firstTimeResultsShowing == false){
		//	alert("bbbbbbbbb");
			showFilteredResult(tempstartPriceSlab, tempendPriceSlab, tempstarRating, tempisPriceflag,rowNumber, columnNumber);
			//alert("nnnnnnnnn");
		} else {

			document.getElementsByName("top")[0].focus();
			if(document.getElementById("AdditionalFilterOptionTable1").style.display=="block"){
				if(document.getElementsByName('HotelChain1')[0].value!="" && document.getElementsByName('HotelChain2')[0].value != "" && document.getElementsByName('HotelChain3')[0].value!=  ""){
					if(document.getElementsByName('HotelChain1')[0].value==document.getElementsByName('HotelChain2')[0].value){
						if(document.getElementsByName('HotelChain1')[0].value!='Select' && document.getElementsByName('HotelChain2')[0].value!='Select'){
							alert("Duplicate hotel chain is selected.");
							document.getElementsByName('HotelChain2')[0].value='Select';
								document.getElementsByName('HotelChain2')[0].focus();
						}
					}
					if(document.getElementsByName('HotelChain2')[0].value==document.getElementsByName('HotelChain3')[0].value){
						if(document.getElementsByName('HotelChain2')[0].value!='Select' && document.getElementsByName('HotelChain3')[0].value!='Select'){
							alert("Duplicate hotel chain is selected.");
							document.getElementsByName('HotelChain3')[0].value='Select';
							document.getElementsByName('HotelChain3')[0].focus();
						}
					}
					if(document.getElementsByName('HotelChain1')[0].value==document.getElementsByName('HotelChain3')[0].value){
						if(document.getElementsByName('HotelChain1')[0].value!='Select' && document.getElementsByName('HotelChain3')[0].value!='Select'){
							alert("Duplicate hotel chain is selected.");
							document.getElementsByName('HotelChain3')[0].value='Select';
							document.getElementsByName('HotelChain3')[0].focus();
						}
					}
				}
			}
			var filteredHotelDetails = new Array();
			var amenities = document.getElementsByName("FilterAmenities");
			//alert("length of the hotel == ::  "+hD.length);
			for (var hotelCount=0;hotelCount<hD.length ;hotelCount++ )
			{
				var amenityMatchCount = 0;
				for (var amenityCount=0; amenityCount<amenities.length; amenityCount++)
				{
					var amenity = amenities[amenityCount];
					var amin
					if ((amenity.checked==false || isAmenityPresent( amenity.value , hotelCount) ) )
					{
							amenityMatchCount += 1;
					}
				}
				if (givenHotelSubstring.toUpperCase()!="NAME CONTAINS..." && givenHotelSubstring.toUpperCase()!="HOTEL NAME CONTAINS...")
				{

					if (amenityMatchCount==amenities.length &&  checkStarRating(hotelCount)  && filterHotelName(hotelCount)  && filterProperties(hotelCount) && filterByLocation(hotelCount) && filterChains(hotelCount) && isAllRoomOnReequest(hotelCount) > 0)
					{
						filteredHotelDetails[filteredHotelDetails.length] = hD[hotelCount];
					}
					setCookie("htlName",document.getElementById("hotelNameString").value,1);
				}
				else
				{

					setCookie("htlName",document.getElementById("hotelNameString").value,-1);
					if (amenityMatchCount==amenities.length &&  checkStarRating(hotelCount)    && filterProperties(hotelCount) && filterByLocation(hotelCount) && filterChains(hotelCount) && isAllRoomOnReequest(hotelCount) > 0)
					{
						filteredHotelDetails[filteredHotelDetails.length] = hD[hotelCount];
					}
				}
			}

			hDD = filteredHotelDetails
			start = 0;
			end =  (hDD.length > hotelsPerPage) ? (hotelsPerPage) : (hDD.length)
			currentPage =  (hDD.length==0) ? 0: 1
			totalPages =  Math.ceil( hDD.length / hotelsPerPage);
			if(document.forms[1].sort[0].checked){
				sortByAttribute("MMTRecom");
			}
			else if(document.forms[1].sort[1].checked){
				sortByAttributeLink("StarRating");
			}
			else if(document.forms[1].sort[2].checked){
				sortByAttributeLink("LowestAvgPrice");
			}
		}
	}


        function getStarRatingString(rating)
        {
                var starRatingString = "<span style='height: 12px; margin: 0px 0px 3px 10px; '><font color='#FFFFFF'>Star Rating: </font></span>";
                for (var ratingCount=1; ratingCount<=rating; ratingCount++)
                {
                        starRatingString += "<IMG SRC="+imgPath+"images/star_on.gif width='13' height='12' alt=''/>";
                }
                for (var ratingCount=(rating/1+1); ratingCount<=maxRating; ratingCount++)
                {
                        starRatingString += "<IMG SRC="+imgPath+"images/star_off.gif width='13' height='12' alt=''/>";
                }
                starRatingString += "";
                return starRatingString;
        }
        function getDescriptionTable(hotelIndex)
        {
                var descriptionTableString = "<TABLE WIDTH='100%' CELLSPACING=0 cellpadding=0 BORDER=0>";
                var hotel = hDD[hotelIndex];
				var isrecommended = hDD[hotelIndex]['MMTRecom'];
                var hotelPrimImg = HotelPath + hotel['HotelPrimImg'];
                if(hotel['GDSHotel']!='E')
                        hotelPrimImg=PegasusPath+hotel['GDSHotelCode'].replace(";","/")+"/"+hotel['HotelPrimImg'];
                var area = hotel['Area'];
                var lowestAvgPrice = hotel['LowestAvgPrice']
                var gds = hotel['GDSHotel']
                var displayLowestAvgPrice = lowestAvgPrice
                if (gds!="I")
                        displayLowestAvgPrice = format(lowestAvgPrice)
                var hotelName =  hotel['HotelName']
                var hotelCode = hDD[hotelIndex]['HotelCode'];
                var travellerRatingCell = "<TD ALIGN='center' width='65px' VALIGN='top'>" + getTravellerRating(hotelIndex) + "</TD>";
                var amenityString = "<TD valign='top'>" + getAmenityString(hotelIndex) + "</TD>";
                var primImgCell = "<TD width='128' style='padding: 0px 7px 0px 6px;'><img src='" + hotelPrimImg + "' width='128' height='96' alt='"+hotelName+"' title='"+hotelName+"' style='cursor:pointer' onClick='goToHtlDetails(\""+hotelCode+"\", 1 , " + hotelIndex+")'></TD>";

                                var areaCell = "<TD width='98px' valign='top'>"
                if(area!="")
                        areaCell+="<B> Area:<BR> " + area + "</B>"
                if(hotel['isOpq']!="Y")
                {
                        var mapLinkRow = "";
                        if (hotel['Latitude']!=""  &hotel['Longitude']!="")
                        {
                        //      alert("here");
                          mapLinkRow = "<TR valign='top'><TD><IMG SRC="+imgPath+"images/map_icon.gif align='top'></TD><td><a href='#select'" ;
                          mapLinkRow += " onClick='goToHtlDetails(\""+hotelCode+"\", 3 , " + hotelIndex+")'"
                          mapLinkRow += ">Map This Property</a></TD></tr>"
                        }
                        else if(hDD[hotelIndex]['GDSHotel']=='E')
                        {
                //              alert("in else");
                                mapLinkRow = "<TR> <TD COLSPAN=2 style='padding-bottom:8px'><b><SPAN STYLE='font-size:9px;' >No map Available</SPAN></B></TD></TR>";
                        }
                        areaCell+="<TABLE>" + mapLinkRow;
                        areaCell+="<TR  valign='top'><TD><img src="+imgPath+"images/morephotos-icon.gif align='top' width='20' height='12' alt='' /></TD><TD><a href='#select' "
                        areaCell+="onClick='goToHtlDetails(\""+hotelCode+"\", 2 , "+ hotelIndex+")'"
                        areaCell+=">More Photos</a></TD></TR>";
						//alert("vik"+hDD[hotelIndex]['NoOfVirtualVideos']);
						if(hDD[hotelIndex]['NoOfVirtualVideos']>0){
						areaCell+="<TR  valign='top'><TD><img src="+imgPath+"images/video-tour-icon.gif align='top' width='20' height='12' alt='' /></TD><TD><a href='#select' style='color:#ff0000'" ;
                        areaCell+="onClick='setDefaultTab(\""+hotelCode+"\", 2 , "+ hotelIndex+",1)'";
                        areaCell+="><strong>Video Tour</strong></a></TD></TR>";
						}
						 areaCell+="</TABLE>";
                }
                areaCell+="</TD>";
                var seperatorCell1 = " <td width='16'><table border='0' cellspacing='0' cellpadding='0' style='margin: 8px 0px 3px 0px'><tr><td width='1' height='96' bgcolor='#CCCCCC'></td></tr></table></td>";
                var gdsHotel = hotel['GDSHotel'];
                var gdsHotelCode = hotel['GDSHotelCode'];
                var currency = (residentOfIndiaFlag.toUpperCase()=="YES" || residentOfIndiaFlag.toUpperCase()=="Y")?"Rs.": "US$";
                if(gdsHotel.toUpperCase()=="I") {
                if(lowestAvgPrice=="" || lowestAvgPrice==null)
                        {
                                var cell4 = "<TD id='"+gdsHotelCode+"FareTable' align='left'><TABLE WIDTH=135 CELLPADDING=0 CELLSPACING=0 bgcolor=#0099FF  height='3px'><tr><td></td></tr></table></TD>";
                        }
                        else
                        {
                                fareFrom=hotel['FareFrom'];
                                fareTo=hotel['FareTo'];
                                if (fareFrom!=null && fareTo!=null)
                                {
                                        var cell4 = "<TD> <table width='135' height=100% class=blue-border id='table1' name='table1'><tr valign='top'><td width=100% height=100% class='text-11'  align='CENTER'>Price Range <BR> From: <BR> <span class='text-bold-21'>" + currency+" "+ fareFrom + "</span> &nbsp;&nbsp;&nbsp;To: <BR> <span class='text-bold-21'>" +currency+" "+ fareTo +"</span></td></tr><TR HEIGHT='30'><td width=100%>&nbsp;</td></TR></table></TD>";
                                }
                                else
                                {
                                                var cell4 = "<TD><div style='width:135;height:3px;background-color:#0099FF' >&nbsp;</div></TD>";
                                }


                        }
                } else {
                       if(displayLowestAvgPrice.length<=5){

						   if(isrecommended.toUpperCase()=="YES" || isrecommended.toUpperCase()=="Y")
                        {

                         var cell4 = "<TD align='right' bgcolor='white'> <table width='140' class=blue-border id='table1' name='table1'><tr valign='top'><td width=100% class='text-11' align='CENTER'>Lowest Average <BR> Daily Rate :<BR><BR><span class='text-bold-21'>" + currency+" "+displayLowestAvgPrice+"</span></td></tr><TR><td ><div style='float:left;'><img src='images/lowest-rate-guarantee.gif'></div><div style='margin-top:35px;float:right;'><a onClick='whatIsThisGuarantee(event)'style='text-weight:bold;cursor:pointer;text-decoration:underline;'>What is this?</a></div></td></TR></table></TD>";
                        }else{

						var cell4 = "<TD align='right' bgcolor='white'> <table width='140' class=blue-border id='table1' name='table1'><tr valign='top'><td width=100% class='text-11' align='CENTER'>Lowest Average <BR> Daily Rate :<BR><BR><span class='text-bold-21'>" + currency+" "+displayLowestAvgPrice+"</span></td></tr><TR HEIGHT='30'><td width=100%>&nbsp;</td></TR></table></TD>";
                             }
					  }
					   else
					   {

					            if(isrecommended.toUpperCase()=="YES" || isrecommended.toUpperCase()=="Y")
                        {
                                var cell4 = "<TD align='right' bgcolor='white'> <table width='135' height=100% class=blue-border id='table1' name='table1'><tr valign='top'><td width=100% height=100% class='text-11' align='CENTER'>Lowest Average <BR> Daily Rate :<BR><BR><span class='text-bold-19'>" + currency+" "+displayLowestAvgPrice+"</span></td></tr><TR><td ><div style='float:left;'><img src='images/lowest-rate-guarantee.gif'></div><div style='margin-top:35px;float:right;'><a onClick='whatIsThisGuarantee(event)' style='text-weight:bold;cursor:pointer;text-decoration:underline;'>What is this?</a></div></td></TR></table></TD>";
                        } else{
						var cell4 = "<TD align='right' bgcolor='white'> <table width='135' height=100% class=blue-border id='table1' name='table1'><tr valign='top'><td width=100% height=100% class='text-11' align='CENTER'>Lowest Average <BR> Daily Rate :<BR><BR><span class='text-bold-19'>" + currency+" "+displayLowestAvgPrice+"</span></td></tr><TR HEIGHT='30'><td width=100%>&nbsp;</td></TR></table></TD>";


						}

						}
                }
                descriptionTableString += "<TR VALIGN=TOP><TD>";
                descriptionTableString += "<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0><TR HEIGHT=3PX><TD COLSPAN=6  BGCOLOR=#0099FF></TD></tr><TR HEIGHT=10PX><TD COLSPAN=6></TD></tr><tr>" +  primImgCell + areaCell + seperatorCell1+ travellerRatingCell+  seperatorCell1 + amenityString + "</TR></TABLE></td>"
                descriptionTableString += cell4+  "</TR></TABLE>";
                return descriptionTableString ;
        }
        function getTravellerRating(hotelIndex)
        {
                        var hotelCode = hDD[hotelIndex]['HotelCode'];
                        var travellerRatingString = "";
                        var travellerRating = hDD[hotelIndex]['TravellerRating'];
                        if (travellerRating.length==0)
                        {
                                if(hDD[hotelIndex]['GDSHotel']=='E')
                                        travellerRatingString = "<b><SPAN STYLE='font-size:9px'>No Reviews Available</span></b>"
                        }
                        else
                        {
                                var totalReviews =  hDD[hotelIndex]['TotalReviews'];
                                if(hDD[hotelIndex]['GDSHotel']=='E'){
                                        travellerRatingString += "<b>Traveler<br>Rating:<br><span class=text-bold-19>"+ travellerRating+"</span><br />out of 5</b><br /> <a href='#select' "
                                        if(hDD[hotelIndex]['isOpq']!="Y")
                                                travellerRatingString +="onClick='goToHtlDetails(\""+hotelCode+"\", 4 , "+ hotelIndex+")'"
                                        travellerRatingString +=">"+ totalReviews+" User<br /> Reviews</a>";
                                }else if(travellerRating!="0"){
                                        travellerRatingString += "<b>Traveler<br>Rating:<br><span class=text-bold-19>"+ travellerRating+"</span><br />out of 5</b><br /> <a href='#select' "
                                        if(hDD[hotelIndex]['isOpq']!="Y")
                                                travellerRatingString +="onClick='goToHtlDetails(\""+hotelCode+"\", 4 , "+ hotelIndex+")'"
                                        travellerRatingString +=">"+ totalReviews+" User<br /> Reviews</a>";
                                }
                        }

                        return travellerRatingString;
        }
        function getAmenityString(hotelIndex)
        {
                var hotel = hDD[hotelIndex];
                var hotelCode = hDD[hotelIndex]['HotelCode'];
                var amenityString ="<div><Table width='131px' >";

                var hotelAmenities = hotel['hA'];
                var amenitiesShown = 0;

                for (var amenityCount=0 ; amenityCount<hotelAmenities.length; amenityCount++)
                {
                        amenitiesShown += 1;
                        if (amenitiesShown <= maximumAmenitiesToShow)
                        {
                                var amenity = hotelAmenities[amenityCount];
                                var amenityName = amenity['aN'];
                                var amenityImage = uploadDir+amenity['aI'];
                                if (amenity['aI'].length ==0)
                                {
                                        amenityImage = uploadDir + defaultAmenityImage;
                                }

                                var displayAmenityName = amenityName + "";

                                if (amenityName.length>17  && amenityName.indexOf(" ") ==-1)
                                {
                                        displayAmenityName = amenityName.substring( 0 ,15) + "...";
                                }
                                amenityString += "<TR valign='top'><TD><IMG SRC='"+ amenityImage + "' style='float:left' width='14' height='10' ALT='"+amenityName+"'></TD><TD TITLE='"+amenityName+"'>" + displayAmenityName+ "</TD></TR>";
                        }
                }
                if (amenitiesShown >= maximumAmenitiesToShow)
                {
                        amenityString += "<TR><TD colspan=2 nowrap><img src="+imgPath+"images/viewall_icon.gif width='17' height='17' alt='' STYLE='float:left' />";
                        amenityString += "<A NAME='amenityLink' HREF='#select' "
                        if(hotel['isOpq']!="Y")
                                amenityString += "onClick='goToHtlDetails(\""+hotelCode+"\", 1 , "+ hotelIndex+" , \"Amenities\")'"
                        amenityString += ">View All Amenities</A>";
                        amenityString += "</TD></TR>"
                }
                if(amenitiesShown==0){
                        amenityString += "<TR valign=top style='vertical-align:top'><TD colspan=2 nowrap valign=top>";
                        if(hDD[hotelIndex]['GDSHotel']=='E')
                                amenityString += "<b>No Amenities</b>";
                        amenityString += "</TD></TR>"
                }
                amenityString += "</TABLE></div>";
                return amenityString;
        }
        function getOptionsString(maximumCount, selectedCount , startCount)
        {
                var str = "";
                for (var count=startCount;count<=maximumCount; count++)
                {
                        if (count==selectedCount)
                        {
                                str+= "<OPTION selected VALUE=" + count + ">" + count+"</OPTION>";
                        }
                        else
                        {
                                str+= "<OPTION VALUE=" + count + ">" + count+"</OPTION>";
                        }
                }
                return str;
        }
        function adjust()
        {
                var tables = getElementsById("table1");
                for (var count=0;count<tables.length ; count++ )
                {
                        tables[count].style.position = "relative";
                        tables[count].style.top = "-10px";
                        tables[count].className = "blue-border"
                }
        }
        function getElementsById(id)
        {
                var ids =  new Array();
                for (var count=0;count<document.all.length ;count++ )
                {
                        if (document.all[count].id==id)
                        {
                                ids[ids.length] = document.all[count];
                        }
                }
                return  ids;
  }
        function getDistinctInclusions()
        {
                aF = aF.removeDuplicates();
                return;
        }
        function getDistinctLocations()
        {
                lF = lF.removeDuplicates();
        }
        function showFilterChains()
        {
                var showthis=false;
                for(var i=1;i<=3;i++){
                        var ele=document.getElementsByName("HotelChain"+i)[0];
                        for(var j=0;j<hCF.length;j++)
                        {
                                if (hCF[j]!='')
                                {
                                        ele.options[j+1]=new Option(hCF[j],hCF[j],false,false);
                                        showthis=true;
                                }
                        }
                }
                if(showthis)
                {
                        document.getElementById("hotelChainDetails").style.display="block";
                }
        }

        function showFilterLocationName()
        {
        	alert("inside showFilterLocationName ");
                var ele = document.getElementById("locationName");
                lF = lF.removeDuplicates();
                ele.length=lF.length;
                var tdOfLocation = "<tr>";

               for (var count=0; count<lF.length ;count++ ){
               	tdOfLocation+="<td align='center' bordercolor='#6666FF' class='brdrgt brdtop coltxt'><b>"+lF[count]+"</b></td>";
               }
                tdOfLocation += "</tr>";
                alert("tdOfLocation    "+tdOfLocation);
                ele.innerHTML=tdOfLocation;
        }

        function showFilterLocations()
        {

                var ele = document.getElementById("locationSelect");

                lF = lF.removeDuplicates();
                ele.length=lF.length;
                ele.options[0]=new Option("All Areas",0,true,true);
                for (var count=0; count<lF.length ;count++ )
                {
                	ele.options[count+1]=new Option(lF[count],lF[count],false,false);
                }
                if(lF.length==0){
                        ele.style.display="none";
                }
        }
        function filterPropertyTypes()
        {
                 pTF = pTF.removeDuplicates();

                 var propertyTypeSpan = document.getElementById("FilterPropertyTypesSpan");
                 var propertyTypeString = "<table width='100%' border='0' cellspacing='0' cellpadding='0'>";
                 try{
                 for (var propertyTypeCount=0; propertyTypeCount<pTF.length; propertyTypeCount++)
                {
                        var propertyType = pTF[propertyTypeCount]
                        if (trim(propertyType).length!=0)
                        {
                                        //propertyTypeString +="<tr><td width='20' height='20' ><input  type='checkbox' NAME='FilterProperties'  value='"+propertyType+"' name='f' onclick='filter();' ID='FilterProperties" +propertyTypeCount+"'  /></td><td height='20'><LABEL Title='"+propertyType+"' style='cursor:pointer' FOR='FilterProperties" +propertyTypeCount+"''>" +propertyType+"</LABEL></td></tr>";
propertyTypeString +="<tr><td width='20' height='20' ><input  type='checkbox' NAME='FilterProperties'  value='"+propertyType+"' name='f' onclick='checkedTheAminities("+blankVar+");' ID='FilterProperties"+propertyTypeCount+"'/></td><td height='20'><LABEL Title='"+propertyType+"' style='cursor:pointer' FOR='FilterProperties" +propertyTypeCount+"''>" +propertyType+"</LABEL></td></tr>";
                        }
                }
                 }catch(e){
                 }
                propertyTypeString += "</TABLE>";
                propertyTypeSpan.innerHTML = propertyTypeString;
        }
        function filterProperties(hotelCount)
        {
                var hotelsToShow = new Array();
                var propertyTypes = document.getElementsByName("FilterProperties");
                var propertyType = hD[hotelCount]['PropertyType'];
                var present = 0;
                var falseCount = 0;
                for (var propTypeCount=0; propTypeCount<propertyTypes.length;propTypeCount++ )
                {
                        if (propertyTypes[propTypeCount].checked==true && propertyTypes[propTypeCount].value==propertyType )
                        {
                                present = 1;
                        }
                        if (propertyTypes[propTypeCount].checked== false)
                        {
                                falseCount += 1;
                        }
                }
                if(propertyTypes.length==0){
                        if(document.getElementById("FilterProperties")==null){
                                return true;
                        }
                        var propertyGiven=document.getElementById("FilterProperties");
                                if (propertyGiven.checked==true && propertyGiven.value==propertyType )
                                        {
                                                present = 1;
                                        }
                                        if (propertyGiven.checked== false)
                                        {
                                                present = 1;
                                                falseCount += 1;
                                        }
                }
                if (present==1 || (falseCount==propertyTypes.length && propertyTypes.length!=0)|| (falseCount==1 && propertyTypes.length==0))
                {
                        return true;
                }
                else
                {
                        return false;
                }
        }
        function filterByLocation(count)
        {
                var loc = document.getElementById("locationSelect").value;
                if (loc=="0")
                {
                        setCookie("location",null,-1);
                        return true;
                }
                setCookie("location",loc,1);
                var locations = hD[count]['Locations'];
                var present = 0;
                for (var locCount=0;locCount<locations.length ;locCount++ )
                {
                        var locOfHotel = locations[locCount];
                        if (locOfHotel==loc)
                        {
                                        present = 1;
                        }
                }
                if (present==1)
                {
                        return true;
                }
                else
                {
                        return false;
                }
        }
 function showFilterAmenities()
 {

         var filterAmenitiesSpan = document.getElementById("FilterAmenitiesSpan");
         var filterAmenitiesString = "<table width='100%' border='0' cellspacing='0' cellpadding='0'>";
         if(aF.length==0){
                 document.getElementById("amenitiesHead").style.display='none';
                 return;
         }

		  if(listOfTotalAmenities.length ==0){
			 var isTravelDeskAvailable=false;
			 var isInternetAvail=false;
			 var isResturantAvail=false;
			 var isBusinessServiceAvail=false;
			 var isSwimmingPoolAvail=false;
			 var isFitnessCenterAvail=false;
		    for (var amenityCount=0; amenityCount<aF.length; amenityCount++)
        {
                        var amenity = aF[amenityCount]
                        if (trim(amenity).length!=0)
                        {

                               if((amenity=="Travel Desk"||amenity=="Travel agency facilities"||amenity=="Sightseeing")&&isTravelDeskAvailable==false){
                               isTravelDeskAvailable=true;
							   listOfTotalAmenities[listOfTotalAmenities.length]="Travel Desk/Assistance";
							   }
							   else if ((amenity=="Chargeable Wi Fi Internet Connectivity"||amenity=="Free Wi Fi Internet Connectivity"||amenity=="Free WiFi Internet"||amenity=="Free WiFi Internet Connectivity"||amenity=="Chargeable Wi Fi Internet Connectivity"||amenity=="Chargeable WiFi Internet"||amenity=="Chargeable WiFi Internet Connectivity"||amenity=="WiFi at a charge"||amenity=="Internet Facility"||amenity=="Wifi Enabled")&&isInternetAvail==false){
							   isInternetAvail=true;
							   listOfTotalAmenities[listOfTotalAmenities.length]="Internet";
							   }
							   else if ((amenity=="Outdoor Swimming Pool"||amenity=="Swimming Pool")&&isSwimmingPoolAvail==false){
							   isSwimmingPoolAvail=true;
							   listOfTotalAmenities[listOfTotalAmenities.length]="Swimming Pool";
							   }
							   else if ((amenity=="Board Room"||amenity=="Boardroom"||amenity=="Business Centre")&&isBusinessServiceAvail==false){
							   isBusinessServiceAvail=true;
							   listOfTotalAmenities[listOfTotalAmenities.length]="Business Services";
							   }
							   else if ((amenity=="Indoor Multi Cuisine Restaurant"||amenity=="24-hour Coffee Shop"||amenity=="24-hr Coffee Shop"||amenity=="Coffee Shop")&&isResturantAvail==false){
							   isResturantAvail=true;
							   listOfTotalAmenities[listOfTotalAmenities.length]="Business Services";
							   }else if ((amenity=="Gymnasium"||amenity=="Gymnasium/Health Club"||amenity=="Massage Centre")&&isFitnessCenterAvail==false){
							   isFitnessCenterAvail=true;
							   listOfTotalAmenities[listOfTotalAmenities.length]="Fitness Centre/Gym";
							   }
                        }

        }



		  }

			for (var amenityCount=0; amenityCount<listOfTotalAmenities.length; amenityCount++)
        {
                        var amenity = listOfTotalAmenities[amenityCount]
                        if (trim(amenity).length!=0)
                        {

                                var amenityDisplay = amenity+ "";
                           filterAmenitiesString +="<tr><td width='20' height='20'><input  type='checkbox' id='Amenity"+amenityCount+"' value='"+amenity+"' name='FilterAmenities' onclick='checkedTheAminities("+amenityCount+");'/></td><td height='20'><LABEL Title='"+amenity+"' style='cursor:pointer'  FOR='Amenity"+amenityCount+"'>" +amenityDisplay+"</LABEL></td></tr>";
//filterAmenitiesString +="<tr><td width='20' height='20'><input  type='checkbox' id='Amenity"+amenityCount+"' value='"+amenity+"' name='FilterAmenities' onclick='filter();' /></td><td height='20'><LABEL Title='"+amenity+"' style='cursor:pointer'  FOR='Amenity"+amenityCount+"'>" +amenityDisplay+"</LABEL></td></tr>";
                        }

        }
        filterAmenitiesString += "</TABLE>";
        filterAmenitiesSpan.innerHTML = filterAmenitiesString;
 }
        function displaySearchResults()
        {
                var resultsTable = document.getElementById("resultsTable");
        }
        function getTotalHeight(element)
        {
                if (element.tagName.toUpperCase()=="BODY")
                {
                        return 0;
                }
                var parentNode = element.parentNode
                return element.offsetTop + getTotalHeight(parentNode)
        }
        function getTotalLeft(element)
        {
                if (element.tagName.toUpperCase()=="BODY")
                {
                        return 0;
                }
                var parentNode = element.parentNode
                return element.offsetLeft+ getTotalLeft(parentNode)
        }
var gdsreq=null;
try {
                gdsreq = new window.XMLHttpRequest();
        } catch(e) {
                gdsreq = new ActiveXObject("Msxml2.XMLHTTP");
        }
function getGDSResults()
{
        var url="jsp/gds_hotel_results.jsp?id=0";
        var gdsCnt = 0;
        for (var hotelCount=0;hotelCount<hD.length ;hotelCount++ )
        {
                var gdsHotel = hD[hotelCount]['GDSHotel'];
                if (gdsHotel=="I")
                {
                        var gdsHotelCode = hD[hotelCount]['GDSHotelCode'];
                        var gdsName =  hD[hotelCount]['GDSName'];
                        if (gdsName.toUpperCase()=="PEGASUS")
                        {
                                gdsName =  "P"
                        }
                        else if (gdsName=="HILTON")
                        {
                                gdsName = "H"
                        }
                        url += "&GdsHotelCode="+gdsHotelCode+"&GdsName="+gdsName;
                        gdsCnt++;
                }
        }

         if (gdsCnt>0)
         {
                gdsreq.open("Get" , url, false);
                gdsreq.send(null);
                while (gdsreq.readyState!=4){}
                var ajxResponse= gdsreq.responseText;
                var myObject = eval('(' + ajxResponse + ')');
                var tableData = myObject.bindings;
                showGDSSearchResults(null,tableData,null);
         }

}
function showGDSSearchResults(type, data, evt)
{
        var tableData = data;
        var dataSize = data.length;
        var GDSHotelsArray = new Array();
        for(var j=0;j<dataSize;j++) {
          if(typeof(data[j])== "object") {
                  var len = GDSHotelsArray.length;
                  GDSHotelsArray[len] = new Array();
                  GDSHotelsArray[len]['GDSHotelCode'] = data[j].HtlCodeGDS;
                  GDSHotelsArray[len]['GDSName'] = data[j].GDSName;
                  GDSHotelsArray[len]['Status'] =  data[j].Status;
                  GDSHotelsArray[len]['Currency'] = (residentOfIndiaFlag.toUpperCase()=="YES" || residentOfIndiaFlag.toUpperCase()=="Y")?"Rs.": "US$";//data[j].Currency;
                  if((data[j].GDSName.toUpperCase()=='PEGASUS') ||(data[j].GDSName.toUpperCase()=='P'))
                  {
                          GDSHotelsArray[len]['FareFrom'] = data[j].PriceFrom;
                          GDSHotelsArray[len]['FareTo'] = data[j].Priceto;
                  }
                  else if(data[j].GDSName.toUpperCase()=='HILTON')
                 {
                                var roomTypeFound = true;
                                var rtCnt = 0;
                                GDSHotelsArray[len]['LowestAvgPrice'] = data[j].LowestAvgPrice;
                                GDSHotelsArray[len]['RoomTypes'] = new Array();
                                while(roomTypeFound==true) {
                                        var roomTypesObj = eval("data["+j+"].roomType"+(rtCnt/1+1));
                                        if((roomTypesObj!=null) && typeof(roomTypesObj)=="object") {
                                                 GDSHotelsArray[len]['RoomTypes'][rtCnt] = new Array();
                                                 GDSHotelsArray[len]['RoomTypes'][rtCnt]['RoomTypeCode'] = roomTypesObj.RoomTypeCode;
                                                 GDSHotelsArray[len]['RoomTypes'][rtCnt]['rTN'] = roomTypesObj.rTN;
                                                 var tariffFound = true;
                                                 var tarCnt = 1;
                                                 GDSHotelsArray[len]['RoomTypes'][rtCnt]['tf'] = new Array();
                                                 while(tariffFound==true) {
                                                         var tariffObj = eval("roomTypesObj.Tariff"+tarCnt);
                                                         if((tariffObj!=null) && typeof(tariffObj)=="object") {
                                                                 GDSHotelsArray[len]['RoomTypes'][rtCnt]['tf'][tarCnt-1] = new Array();
                                                                 GDSHotelsArray[len]['RoomTypes'][rtCnt]['tf'][tarCnt-1]['TariffCode'] = tariffObj.TariffCode;
                                                                 GDSHotelsArray[len]['RoomTypes'][rtCnt]['tf'][tarCnt-1]['Fare'] = tariffObj.Fare;
                                                                 GDSHotelsArray[len]['RoomTypes'][rtCnt]['tf'][tarCnt-1]['CancelPolicy'] = tariffObj.CancelPolicy;
                                                         }
                                                         else {
                                                                 tariffFound = false;
                                                         }
                                                         tarCnt++;
                                                 }
                                         }
                                         else {
                                                 roomTypeFound=false;
                                         }
                                         rtCnt++;
                          }
                  }
           }
        }
        addGDSResultsContent(GDSHotelsArray);
}
function addGDSResultsContent(GDSHotelsArray)
{
        for(var i=0; i<GDSHotelsArray.length; i++)
        {
                var GDSHotelCode = GDSHotelsArray[i]['GDSHotelCode'];
                var GDSName = GDSHotelsArray[i]['GDSName'];
                var status = GDSHotelsArray[i]['Status'];
                var lowestPriceId = GDSHotelCode+"FareTable";
                var fareTableObj = document.getElementById(GDSHotelCode+"FareTable");
                var tdId = GDSHotelCode+"Table";
                status = status.toUpperCase();
                try
                {
                if (status=="F" )
                {
                        document.getElementById(tdId).innerHTML  = "Sorry! could not retrieve data";
                        continue;
                }
                else if (status=="NA" )
                {
                        document.getElementById(tdId).innerHTML  = "Sorry! no rooms available in this hotel";
                        continue;
                }
                }
                catch(e)
                {
                }
                var currCode = GDSHotelsArray[i]['Currency'];
                var currency = (residentOfIndiaFlag.toUpperCase()=="YES" || residentOfIndiaFlag.toUpperCase()=="Y")?"Rs.": "US$";
                if((GDSName.toUpperCase()=="PEGASUS") ||(GDSName.toUpperCase()=="P")) {
                        var tdId = GDSHotelCode+"Table";
                        var fareFrom = format(GDSHotelsArray[i]['FareFrom']);
                        var fareTo =  format(GDSHotelsArray[i]['FareTo']);
//                      fareFrom = null;
//                      fareTo = null;
                        var pegsLowestAvgPrice =  fareFrom;
                        for(var m=0; m<hDD.length; m++)
                        {
                                if(GDSHotelCode==hDD[m]['GDSHotelCode']) {
                                        hDD[m]['FareFrom'] = fareFrom;
                                        hDD[m]['FareTo'] = fareTo;
                                        hDD[m]['LowestAvgPrice'] = fareFrom;
                                        break;
                                }
                        }
                        var cellObj = document.getElementById(tdId);
                        var hotelIndex;
                        var hotelCode;
                        for(var htlCnt=0; htlCnt<hDD.length; htlCnt++) {
                                if(GDSHotelCode==hDD[htlCnt]['GDSHotelCode']) {
                                        hotelCode = hDD[htlCnt]['HotelCode'];
                                        hotelIndex = htlCnt;
                                }
                        }
                        if(cellObj!=null) {
                                var varinnerHtml="<table cellpadding=0  cellspacing=0 border=0 width='575' align='center'><tr><td width='25%' align='center' class='text-11-bold' BGCOLOR=#FFFFFF>Price Range</td><td width='45%' align='center' class='text-11-bold' BGCOLOR=#FFFFFF>From: " + currency+" "+  fareFrom+ " &nbsp;&nbsp;&nbsp;To: " +currency+" "+ fareTo+"</td><td width='30%' align='right'><a name='givenname' href='#Select'"
                                if(hDD[hotelIndex]['isOpq']!="Y")
                                        varinnerHtml+=" onClick='goToHtlDetails(\""+hotelCode+"\", 5 , "+ hotelIndex+")'"
                                varinnerHtml+="><IMG STYLE='cursor:pointer' BORDER=0 SRC='"+ selectImageSRC +"' title='Book' "
                                if(hDD[hotelIndex]['isOpq']!="Y")
                                        varinnerHtml+="onClick='goToHtlDetails(\""+hotelCode+"\", 5 , "+ hotelIndex+")"
                                varinnerHtml+="'></a></td></tr></table>";
                                cellObj.innerHTML = varinnerHtml
                        }
                        var lowestPriceId = GDSHotelCode+"FareTable";
                        var fareCellObj = document.getElementById(lowestPriceId);
                        if(fareCellObj!=null) {
                                fareCellObj.innerHTML="<table width='122' height=100% class=blue-border id='table1' name='table1'><tr valign='top'><td width=100% height=100% class='text-11'  align='CENTER'>Lowest Average Daily Rate :<BR><span class='text-bold-21'>" + currency+" "+pegsLowestAvgPrice+"</span></td></tr></table>";
                        }
                } else if(GDSName.toUpperCase()=="HILTON"){
                        var gdsHotelIndex = i;
                        var hiltonStr = getHiltonRoomTypesTable(GDSHotelsArray, gdsHotelIndex)
                        var currCode = GDSHotelsArray[i]['Currency'];
                        var currency = (currCode.toUpperCase()=="INR")?"Rs.":"US$";
                        var tdId = GDSHotelCode+"Table";
                        var cellObj = document.getElementById(tdId);
                        if(cellObj!=null) {
                                cellObj.innerHTML = hiltonStr;
                        }
                        var lowestAvgPrice =  format(GDSHotelsArray[i]['LowestAvgPrice']);
                        if(fareTableObj!=null) {
                                fareTableObj.innerHTML = "<table width='122' height=100% class=blue-border id='table1' name='table1'><tr valign='top'><td width=100% height=100% class='text-11'  align='CENTER'>Lowest Average Daily Rate :<BR><span class='text-bold-21'>" + currency+" "+format(lowestAvgPrice)+"</span></td></tr></table>";
                        }
                }
        }
}
function getHiltonRoomTypesTable(GDSHotelsArray, gdsHotelIndex)
{
        var roomTypesString = "<table width=100% cellspacing='0' cellpadding='0' border='1'><tr><td width=100%><table width='100%' style='height:100%;width:100%;' border='0'  cellpadding='0' cellspacing='1' ><tr style='width:100%'><td class='table-field-tit' style='border-right:1px solid #7CBCE7'>Room Type</td> <td class='table-field-tit' style='border-right:1px solid #7CBCE7'> Inclusions</td><td class='table-field-tit' style='border-right:1px solid #7CBCE7'> Average Daily Rate</td><td class='table-field-tit'>&nbsp;</td></tr>";
        var roomTypes = GDSHotelsArray[gdsHotelIndex]['RoomTypes'];
        var gdsHotelCode = GDSHotelsArray[gdsHotelIndex]['GDSHotelCode'];
        var hotelIndex;
        var hotelCode;
        var currCode = GDSHotelsArray[gdsHotelIndex]['Currency'];
        var currency = (currCode.toUpperCase()=="INR")?"Rs.":"US$";
        for(var i=0; i<hDD.length; i++) {
                if(gdsHotelCode==hDD[i]['GDSHotelCode']) {
                        hotelCode = hDD[i]['HotelCode'];
                        hotelIndex = i;
                        hDD[i]['rT'] = new Array();
                        for (var rtCnt=0 ; rtCnt<roomTypes.length; rtCnt++) {
                                var rmType = roomTypes[rtCnt];
                                hDD[i]['rT'][rtCnt] = new Array();
                                hDD[i]['rT'][rtCnt]['rTC'] =  rmType['rTC'];
                                hDD[i]['rT'][rtCnt]['rTN'] =  rmType['rTN'];
                                hDD[i]['rT'][rtCnt]['tf'] = new Array();
                                var trfs = rmType['tf'];
                                for(var tarCnt=0; tarCnt<trfs.length; tarCnt++) {
                                        hDD[i]['rT'][rtCnt]['tf'][tarCnt] = new Array();
                                        hDD[i]['rT'][rtCnt]['tf'][tarCnt]['TariffCode'] = trfs[tarCnt]['TariffCode'];
                                        hDD[i]['rT'][rtCnt]['tf'][tarCnt]['AvgPriceNight'] = trfs[tarCnt]['Fare'];
                                        hDD[i]['rT'][rtCnt]['tf'][tarCnt]['AvailStatus'] = "B";
                                        hDD[i]['rT'][rtCnt]['tf'][tarCnt]['CancelPolicy'] = trfs[tarCnt]['CancelPolicy'];
                                }
                        }
                        break;
                }
        }
        for (var roomTypeCount=0 ; roomTypeCount<roomTypes.length; roomTypeCount++)
        {
                var roomType = roomTypes[roomTypeCount];
                var tariffs = roomType['tf'];
                for (var tariffCount =0; tariffCount<tariffs.length; tariffCount++)
                {
                        var tariff = tariffs[tariffCount];
                        var fare = tariffs[tariffCount]['Fare'];
                        var roomTypeRowString = "<TR VALIGN='middle'>";
                        var roomTypeNameCell = "";
                        if(tariffCount==0) {
                                roomTypeNameCell = "<TD ALIGN='left' BGCOLOR=#FFFFFF  style='padding:5px' rowspan="+tariffs.length+"  style='border-right:1px solid #7CBCE7'><a href='#select' class='text-11-bold' "
                                roomTypeNameCell+="onClick='goToHtlDetails(\""+hotelCode+"\", 5, "+ hotelIndex+")'"
                                roomTypeNameCell+=">" + roomType['rTN'] + "</A></TD>";
                        }
                        var inclusionsCell = "<TD BGCOLOR=#FFFFFF>&nbsp;</TD>";
                        var selectImageCell = "<td ALIGN='center' BGCOLOR=#FFFFFF><a name='givenname' href='#Select' onClick='takeToReviewPage("+hotelIndex+"," + roomTypeCount+" , " + tariffCount+")'><IMG STYLE='cursor:pointer' SRC='" + selectImageSRC + "' alt='Book' onClick='takeToReviewPage("+hotelIndex+"," + roomTypeCount+" , " + tariffCount+")' style='cursor:pointer' border='0'></a></td>";
                        var priceCell = "<TD ALIGN='center' class='text-11-bold' BGCOLOR=#FFFFFF> " + currency+" "+fare +" </TD>";
                        roomTypeRowString +=  roomTypeNameCell +   inclusionsCell +   priceCell +  selectImageCell + "</TR>";
                        roomTypesString += roomTypeRowString;
                }
        }
        return roomTypesString+= "</table></td></tr></table>";
}
        function getDistinctChains()
        {
                if(hCF.length>1)
                        hCF = hCF.removeDuplicates();
                return;
        }
function filterChains(hotelIndex)
        {
                var hotelChain = hD[hotelIndex]['HotelChainName'];
                var returnVal=true;
                for(var i=1;i<=3;i++){
                        var ele=document.getElementsByName("HotelChain"+i)[0];
                        if(ele.value!="Select"){
                                returnVal=false;
                                setCookie("chain"+i,ele.value,1)
                        }else{
                                setCookie("chain"+i,null,-1)
                        }
                        if(hotelChain.toUpperCase()==ele.value.toUpperCase()){
                                return true;
                        }
                }
                return returnVal;
        }
         function sortTariffsByAvgPrice()
     {
       for (var count=0;count<hD.length; count++)
       {
         hDD[count]['rT'].sort(sortRoomTypes);
          for (var roomTypeCount=0;roomTypeCount<hD[count]['rT'].length ;roomTypeCount++ )
          {
               var tariffs = hDD[count]['rT'][roomTypeCount]['tf'];
               tariffs.sort(sortTariffs);
          }
        }
    }
  function sortRoomTypes(a, b)
  {
       var x = parseFloat(a.rTAP);
       var y = parseFloat(b.rTAP);
       return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  }
  function sortTariffs(a, b)
  {
      var x = parseFloat(a.DiscAvgNightPrice);
      var y = parseFloat(b.DiscAvgNightPrice);
      return ((x < y) ? -1 : ((x > y) ? 1 : 0));
 }
function getRoomTypeIndex(OrgHtlIndex, givenRoomTypeCode)
{
        var roomTypes = hD[OrgHtlIndex]['rT'];
        for (var count=0;count<roomTypes.length ;count++ )
        {
                var roomTypeCode = roomTypes[count]['rTC'];
                if (roomTypeCode==givenRoomTypeCode)
                {
                        return roomTypes[count]['rTI'];
                }
        }
        return -1;
}
function getTariffIndex(hotelIndex, givenRoomTypeCode , givenTariffCode)
{
        var roomTypes = hDD[hotelIndex]['rT'];
        var roomTypeIndex=0;
        for (var count=0;count<roomTypes.length ;count++ )
        {
                var roomTypeCode = roomTypes[count]['rTC'];
                if (roomTypeCode==givenRoomTypeCode)
                {
                        roomTypeIndex=count;
                        break;
                }
        }
                var roomType = hDD[hotelIndex]['rT'][roomTypeIndex];
                var tariffs = roomType['tf'];
                for (var count=0 ;count<tariffs.length ;count++ )
                {
                        var tariffCode = tariffs[count]['TariffCode'];
                        if (givenTariffCode==tariffCode)
                        {
                                return count;
                        }
                }
}
function sortTariffsByPackage(a , b)
{
        var package1 = a.packageAvailable;
        var package2 = b.packageAvailable;
        if (package1=='Y' && package2=='N')
        {
                return -1;
        }
        else if (package1=='N' && package2=='Y')
        {
                return 1;
        }
        else
                return 0;
}
function changeToPackageDates(checkinDate , checkoutDate)
{
        reqObj.open("Get" , JSPURL+"?CheckInDate=" + checkinDate + "&CheckOutDate=" + checkoutDate);
        reqObj.send(null);
}
function pause(millisecondi)
{
    var now = new Date();
    var exitTime = now.getTime() + millisecondi;
    while(true)
    {
        now = new Date();
        if(now.getTime() > exitTime) return;
    }
}
function Comma(number)
{
        number = '' + number;
        if (number.length > 2)
        {
                var mod = number.length % 2;
                var output = (mod > 0 ? (number.substring(0,mod)) : '');
                for (i=0 ; i < Math.floor(number.length / 2); i++)
                {
                        if ((mod == 0) && (i == 0))
                        output += number.substring(mod+ 2 * i, mod + 2 * i + 2);
                        else
                        output+= ',' + number.substring(mod + 2 * i, mod + 2 * i + 2);
                }
                return (output);
        }
        else
                return number;
}
function format(number)
{
                number = number + "";
                var dupNum=number;
            var retNum=number.split(".");
                number=retNum[0];
                if (number.length>3)
                {
                        var v = number.substring(0 , number.length-3);
                        var x = number.substring(number.length-3 , number.length);
                        var formattedNumber = Comma(v) + "," + x
                        if(dupNum.indexOf(".")>0)
                                return formattedNumber+"."+retNum[1];
                        else
                                return formattedNumber
                }
                else{
                        if(dupNum.indexOf(".")>0)
                                return number+"."+retNum[1];
                        else
                                return number;
                }
}
        function hideDiv(divId)
        {
                var div = document.getElementById(divId);
                if (div!=null && div.style!=null && div.style.display!=null)
                {
                        div.style.display = "none"
                }
        }


        function showUR()
        {

                if (firstTimeResultsShowing==false)
                {
                        document.getElementById("StatusMsg").innerHTML = "Updating results";
                }

                document.getElementById("totalDiv").style.cursor = "wait";
                document.getElementById("DialogContentBlocking2").style.display="block";
                if (navigator.appName.indexOf("Explorer")==-1)
                {
                        document.getElementById("DialogContentBlocking2").style.left =( (window.screen.width /  4) - 100) + "px"
                }
        }
        function hideUR(){
                        document.getElementById("totalDiv").style.cursor = "default"
                document.getElementById("DialogContentBlocking2").style.display="none";
        }



/*var loadedobjects=""


        function loadobjs()
        {
                if (!document.getElementById)
                        return
                for (i=0; i<arguments.length; i++)
                {
                        alert("Loading a js file.....");
                                                var file=arguments[i];
                                                var fileref=""
//                      if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
                        if (file.indexOf(".js")!=-1){

                        //alert("one");//If object is a js file
                        fileref=document.createElement('script')
                        fileref.setAttribute("type","text/javascript");
                        fileref.setAttribute("src", file);
                        //alert("two");
                        }
                        else if (file.indexOf(".css")!=-1){ //If object is a css file
                        fileref=document.createElement("link")
                        fileref.setAttribute("rel", "stylesheet");
                        fileref.setAttribute("type", "text/css");
                        fileref.setAttribute("href", file);
                        }

                        if (fileref!=""){
                        //alert("four");
                        //document.getElementById("txtdeptDateRtrip").focus();

                        document.getElementsByTagName("head").item(0).appendChild(fileref);
                        //setTimeout('Checkvalue();',1000);
                        loadedobjects+=file+" " //Remember this object as being already added to page
                        }
}
}
*/
function setAmenCookie(){
                                var amenities = document.getElementsByName("FilterAmenities");
                                var amenityMatchCount = 0;
                                var amin=""
                                for (var amenityCount=0; amenityCount<amenities.length; amenityCount++)
                                {
                                                var amenity = amenities[amenityCount];
                                                if (amenity.checked)
                                                {
                                                        amin += amenity.value+",";
                                                }
                                }
                setCookie("amenity",amin,1);
}



function checkAmenities()
{
        try{
                var amenities = document.getElementsByName("FilterAmenities");
                var amenString = getCookie("amenity");
                if (!amenString)
                {
                        return;
                }
                var checkedAmenities = amenString.split(",");
                for (var checkedAmenCount=0;checkedAmenCount<checkedAmenities.length ;checkedAmenCount++ )
                {
                        for (var amenityCount=0; amenityCount<amenities.length; amenityCount++)
                                {
                                                var amenity = amenities[amenityCount];
                                                if (amenity.value==checkedAmenities[checkedAmenCount])
                                                {
                                                        amenity.checked = true
                                                }
                                }
                }
        }catch(e){}
}
function setPropCookie(){
        try{
                var propertyTypes = document.getElementsByName("FilterProperties");
                var propertyType = hD[hotelCount]['PropertyType'];
                var prop=""
                for (var propTypeCount=0; propTypeCount<propertyTypes.length;propTypeCount++ )
                {
                        if (propertyTypes[propTypeCount].checked==true )
                        {
                                prop += propertyTypes[propTypeCount].value+",";
                        }
                }
                setCookie("property",prop,1);
        }catch(e){}
}

function setPropCookie(){
        try{
                var propertyTypes = document.getElementsByName("FilterProperties");
                var propString = getCookie("property");
                var checkedProps = propString.split(",");
                var propertyType = hD[hotelCount]['PropertyType'];
                var prop=""
                for (var checkedPropCount=0;checkedPropCount<checkedProps.length ;checkedPropCount++ )
                {
                        for (var propTypeCount=0; propTypeCount<propertyTypes.length;propTypeCount++ )
                        {
                                var property = propertyTypes[propTypeCount];
                                if (propertyTypes[propTypeCount].value==checkedProps[checkedPropCount] )
                                {
                                        propertyTypes[propTypeCount].checked=true
                                }
                        }
                }
        }catch(e){}
}
function showFilteredResult(startPriceSlab, endPriceSlab, starRating, isPriceflag, rowNum, colNum){
rowNumber = rowNum;
columnNumber = colNum;
highlightMouseOver(rowNum,colNum,0);
	 tempstartPriceSlab = startPriceSlab ;
     tempendPriceSlab  =endPriceSlab;
     tempstarRating = starRating;
     tempisPriceflag = isPriceflag;
	firstTimeResultsShowing = false;
	//alert("startPriceSlab  :: "+startPriceSlab+"  endPriceSlab  ::  "+endPriceSlab+"  starRating  ::  "+starRating+"   isPriceflag ::  "+isPriceflag+"  rowNum  ::  "+rowNum+"  colNum  ::  "+colNum);
	var givenHotelSubstring = document.getElementById("hotelNameString").value;
		filterHotelChain();
		var filteredHotelDetails = new Array();
		var amenities = document.getElementsByName("FilterAmenities");
		var count =0;

		for (var hotelCount=0;hotelCount<hD.length ;hotelCount++ )
		{
			if((starRating == -1) && (isPriceflag == -1) && checkForAmenities(hotelCount) && isAllRoomOnReequest(hotelCount) >0){
			filteredHotelDetails[filteredHotelDetails.length] = hD[hotelCount];
		} else {
			if((isPriceflag == -1) && isSameStarRating(hotelCount, starRating) && checkForAmenities(hotelCount) && isAllRoomOnReequest(hotelCount) >0){
				filteredHotelDetails[filteredHotelDetails.length] = hD[hotelCount];
			} else if((starRating == -1) && isSamePriceSlab(hotelCount, startPriceSlab, endPriceSlab) && checkForAmenities(hotelCount) && isAllRoomOnReequest(hotelCount) >0){
				filteredHotelDetails[filteredHotelDetails.length] = hD[hotelCount];
			} else if(isSameStarRating(hotelCount, starRating) && isSamePriceSlab(hotelCount, startPriceSlab, endPriceSlab) && checkForAmenities(hotelCount) && isAllRoomOnReequest(hotelCount) >0){
			filteredHotelDetails[filteredHotelDetails.length] = hD[hotelCount];
		}
		}
		}
		hDD = filteredHotelDetails;
		start = 0;
		end =  (hDD.length > hotelsPerPage) ? (hotelsPerPage) : (hDD.length);
		currentPage =  (hDD.length==0) ? 0: 1;
		totalPages =  Math.ceil( hDD.length / hotelsPerPage);
		if(document.forms[1].sort[0].checked){
			sortByAttribute("MMTRecom");
		}
		else if(document.forms[1].sort[1].checked){
			sortByAttribute("StarRating");
		}
		else if(document.forms[1].sort[2].checked){
			sortByAttribute("LowestAvgPrice");
		}
	}
	var flagFilter = false;
	var tempHdArr = new Array();

	function showFilteredResultAreaGrid(startPriceSlab, endPriceSlab, starRating, isPriceflag, rowNum, colNum){
		rowNumber = rowNum;
		columnNumber = colNum;
		//highlightAreaPriceCol(rowNum,colNum,0);
		tempstartPriceSlab = startPriceSlab ;
		tempendPriceSlab  =endPriceSlab;
		tempstarRating = starRating;
		tempisPriceflag = isPriceflag;
		firstTimeResultsShowing = false;
	//alert("startPriceSlab  :: "+startPriceSlab+"  endPriceSlab  ::  "+endPriceSlab+"  starRating  ::  "+starRating+"   isPriceflag ::  "+isPriceflag+"  rowNum  ::  "+rowNum+"  colNum  ::  "+colNum);

	var givenHotelSubstring = document.getElementById("hotelNameString").value;
		filterHotelChain();
		var filteredHotelDetails = new Array();
		var amenities = document.getElementsByName("FilterAmenities");
		var count =0;

		for (var hotelCount=0;hotelCount<hD.length ;hotelCount++ )
		{
			if(rowNum !=7){
			var propertyTypeVar = hD[hotelCount]['PropertyType'];
			if((starRating == -1) && (isPriceflag == -1) && checkForAmenities(hotelCount) && isAllRoomOnReequest(hotelCount) >0 && propertyTypeVar == ""){
			filteredHotelDetails[filteredHotelDetails.length] = hD[hotelCount];
		} else {
			if((isPriceflag == -1) && isSameStarRating(hotelCount, starRating) && checkForAmenities(hotelCount) && isAllRoomOnReequest(hotelCount) >0 && propertyTypeVar == ""){
				filteredHotelDetails[filteredHotelDetails.length] = hD[hotelCount];
			} else if((starRating == -1) && isSamePriceSlab(hotelCount, startPriceSlab, endPriceSlab) && checkForAmenities(hotelCount) && isAllRoomOnReequest(hotelCount) >0 && propertyTypeVar == ""){
				filteredHotelDetails[filteredHotelDetails.length] = hD[hotelCount];
			} else if(isSameStarRating(hotelCount, starRating) && isSamePriceSlab(hotelCount, startPriceSlab, endPriceSlab) && checkForAmenities(hotelCount) && isAllRoomOnReequest(hotelCount) >0 &&  propertyTypeVar == ""){
			filteredHotelDetails[filteredHotelDetails.length] = hD[hotelCount];
		}else if(parseInt(starRating) == 6 && propertyTypeVar != ""){
			filteredHotelDetails[filteredHotelDetails.length] =  hD[hotelCount];
		}
		}
			}else if(rowNum ==7){

		if((starRating == -1) && (isPriceflag == -1) && checkForAmenities(hotelCount) && isAllRoomOnReequest(hotelCount) >0){
			filteredHotelDetails[filteredHotelDetails.length] = hD[hotelCount];
		} else {
			if((isPriceflag == -1) && isSameStarRating(hotelCount, starRating) && checkForAmenities(hotelCount) && isAllRoomOnReequest(hotelCount) >0){
				filteredHotelDetails[filteredHotelDetails.length] = hD[hotelCount];
			} else if((starRating == -1) && isSamePriceSlab(hotelCount, startPriceSlab, endPriceSlab) && checkForAmenities(hotelCount) && isAllRoomOnReequest(hotelCount) >0){
				filteredHotelDetails[filteredHotelDetails.length] = hD[hotelCount];
			} else if(isSameStarRating(hotelCount, starRating) && isSamePriceSlab(hotelCount, startPriceSlab, endPriceSlab) && checkForAmenities(hotelCount) && isAllRoomOnReequest(hotelCount) >0){
			filteredHotelDetails[filteredHotelDetails.length] = hD[hotelCount];
		}else if(parseInt(starRating) == 6 && propertyTypeVar != ""){
			filteredHotelDetails[filteredHotelDetails.length] =  hD[hotelCount];
		}
		}
			}
		}
		hDD = filteredHotelDetails;
		start = 0;
		end =  (hDD.length > hotelsPerPage) ? (hotelsPerPage) : (hDD.length);
		currentPage =  (hDD.length==0) ? 0: 1;
		totalPages =  Math.ceil( hDD.length / hotelsPerPage);
		if(document.forms[1].sort[0].checked){
			sortByAttribute("MMTRecom");
		}
		else if(document.forms[1].sort[1].checked){
			sortByAttribute("StarRating");
		}
		else if(document.forms[1].sort[2].checked){
			sortByAttribute("LowestAvgPrice");
		}
	}

function filterHotelChain(){
	document.getElementsByName("top")[0].focus();
		if(document.getElementById("AdditionalFilterOptionTable1").style.display=="block"){
			if(document.getElementsByName('HotelChain1')[0].value!="" && document.getElementsByName('HotelChain2')[0].value != "" && document.getElementsByName('HotelChain3')[0].value!=  ""){
				if(document.getElementsByName('HotelChain1')[0].value==document.getElementsByName('HotelChain2')[0].value){
					if(document.getElementsByName('HotelChain1')[0].value!='Select' && document.getElementsByName('HotelChain2')[0].value!='Select'){
						alert("Duplicate hotel chain is selected");
						document.getElementsByName('HotelChain2')[0].value='Select';
						document.getElementsByName('HotelChain2')[0].focus();
					}
				}
				if(document.getElementsByName('HotelChain2')[0].value==document.getElementsByName('HotelChain3')[0].value){
					if(document.getElementsByName('HotelChain2')[0].value!='Select' && document.getElementsByName('HotelChain3')[0].value!='Select'){
						alert("Duplicate hotel chain is selected");
						document.getElementsByName('HotelChain3')[0].value='Select';
						document.getElementsByName('HotelChain3')[0].focus();
					}
				}
				if(document.getElementsByName('HotelChain1')[0].value==document.getElementsByName('HotelChain3')[0].value){
					if(document.getElementsByName('HotelChain1')[0].value!='Select' && document.getElementsByName('HotelChain3')[0].value!='Select'){
						alert("Duplicate hotel chain is selected");
						document.getElementsByName('HotelChain3')[0].value='Select';
						document.getElementsByName('HotelChain3')[0].focus();
					}
				}
			}
		}
}

function isSameStarRating(hotelIndex, starRating)
   {
    var rating = parseInt(hD[hotelIndex]['StarRating']);
    if (starRating == rating ) return true;
	  else return false;
    }

 function isSamePriceSlab(hotelIndex, startPriceSlab, endPriceSlab)
	{
	var isSameSlab =false;
	var price = parseInt(hD[hotelIndex]['LowestAvgPrice']);
	if ((price > startPriceSlab) && (price <= endPriceSlab) ){
		isSameSlab =true;
	       }
	        return isSameSlab;
	 }

	function checkForAmenities(hotelCount)
	{
		var givenHotelSubstring = document.getElementById("hotelNameString").value;
		var amenities = document.getElementsByName("FilterAmenities");
		var amenityMatchCount = 0;
        for (var amenityCount=0; amenityCount<amenities.length; amenityCount++)
              {
		       var amenity = amenities[amenityCount];
		if ( (amenity.checked==false || isAmenityPresent( amenity.value , hotelCount) ) )
		       {
			amenityMatchCount += 1;
		        }
              }
         if (givenHotelSubstring!="NAME CONTAINS..." && givenHotelSubstring!="Hotel Name contains...")
                {
	  if (amenityMatchCount==amenities.length &&  checkStarRating(hotelCount)  && filterHotelName(hotelCount)  && filterProperties(hotelCount) && filterByLocation(hotelCount) && filterChains(hotelCount) && isAllRoomOnReequest(hotelCount)>0)
	               {
		         return true;
	                 }
              }
           else
                 {
	if (amenityMatchCount==amenities.length &&  checkStarRating(hotelCount)    && filterProperties(hotelCount) && filterByLocation(hotelCount) && filterChains(hotelCount) && isAllRoomOnReequest(hotelCount)>0)
	             {
		     return true;
	                }
              }
         return false;
	  }

	    function isAllRoomOnReequest(hotelIndex)
    {
		var onRequestTariffsCount = 0;
		var allRommsWithTariff = 0;
		var availableRoomsWithTariff = 0;
		var roomTypes = hD[hotelIndex]['rT'];
		if (roomTypes.length==0)
		{
			availableRoomsWithTariff = 0;
		}

		for (var roomTypeCount=0 ; roomTypeCount<roomTypes.length; roomTypeCount++)
		{

			var roomType = roomTypes[roomTypeCount];
			var tariffs = roomType['tf'];
			for (var tariffCount =0; tariffCount<tariffs.length; tariffCount++)
			{
				var tariff = tariffs[tariffCount];
			if(tariff['AvailStatus']=='R'){
				// do nothing.
			} else {
					availableRoomsWithTariff = availableRoomsWithTariff +1;
				}
			}
		}
		if(onRequestHotelStatus == 1) {
			availableRoomsWithTariff =1;
		}

		return availableRoomsWithTariff;

	}

	function highlightAreaPriceCol(var1,var2,var3){
		//alert("searchForCurrentDate   ::::  "+(searchForCurrentDate=="true"));

	if(searchForCurrentDate=="true"){
	mouseOutAreaGrid(var3);
	if(var1 == -1){
		var1 =0;
	}



   if(var2 =="888"){
	   for(var i =0; i<parseInt(var3);i++){
	    document.getElementById("row"+var1+"col"+i).style.backgroundColor='#bfe3f9';
		document.getElementById("row"+var1+"col"+i).style.color='#FFF';
	   }
   } else if(var1 == -1){
		    document.getElementById("row0col"+var2).style.backgroundColor='#bfe3f9';
		document.getElementById("row0col"+var2).style.color='#FFF';
   }else{
        document.getElementById("row"+var1+"col"+var2).style.backgroundColor='#bfe3f9';
		document.getElementById("row"+var1+"col"+var2).style.color='#FFF';
   }
   document.getElementById("row7col1").style.backgroundColor='#FFF';
   document.getElementById("row7col1").style.color='#FFF';

	}
	window.status = '';
		return true;
      }

      function mouseOutAreaGrid(var3){

		for(var j=0;j<6;j++){
		for(var i =0; i<parseInt(var3);i++){
	    document.getElementById("row"+j+"col"+i).style.backgroundColor='#FFF';
		document.getElementById("row"+j+"col"+i).style.color='#FFF';
		}
		}
		return true;
	}

	function highlightMouseOver(var1,var2,var3){
		if(cityAreaGridFlagVar == "false"){
	mouseOut();
	if(var1 == -1){
		var1 =0;
	}
   if(var2 ==0){
	   for(var i =0; i<=5;i++){
	    document.getElementById("row"+var1+"col"+i).style.backgroundColor='#bfe3f9';
		document.getElementById("row"+var1+"col"+i).style.color='#FFF';

	   }
   } else if(var1 == -1){

		    document.getElementById("row0col"+var2).style.backgroundColor='#bfe3f9';
		document.getElementById("row0col"+var2).style.color='#FFF';


   }else{
        document.getElementById("row"+var1+"col"+var2).style.backgroundColor='#bfe3f9';
		document.getElementById("row"+var1+"col"+var2).style.color='#FFF';
	//	document.getElementById("row"+var1+"col0").style.backgroundColor='#bfe3f9';
	//	document.getElementById("row"+var1+"col0").style.color='#FFF';
   }

		}
		window.status = '';
		return true;
      }

	function mouseOut(){
		for(var j=0;j<=4;j++){
		for(var i =0; i<=5;i++){
	    document.getElementById("row"+j+"col"+i).style.backgroundColor='#FFF';
		document.getElementById("row"+j+"col"+i).style.color='#FFF';
		}
		}
		return true;
	}
	function sortOnRequestHotel(temphotelList){

		var onRequestHotels = new Array();
		var hotelNotOnRequest = new Array();
		for (var count=0;count<temphotelList.length ; count++ ){
		var onRequestTariffsCount = 0;
		var allRommsWithTariff = 0;
		var availableRoomsWithTariff = 0;
		var roomTypes = temphotelList[count]['rT'];
		if (roomTypes.length==0)
		{
			availableRoomsWithTariff = 0;
		}
		for (var roomTypeCount=0 ; roomTypeCount<roomTypes.length; roomTypeCount++)
		{
			var roomType = roomTypes[roomTypeCount];
			var tariffs = roomType['tf'];
			for (var tariffCount =0; tariffCount<tariffs.length; tariffCount++)
			{
				allRommsWithTariff=allRommsWithTariff+1;
				var tariff = tariffs[tariffCount];
			if(tariff['AvailStatus']=='R'){

				onRequestTariffsCount=onRequestTariffsCount+1;
			} else {
					availableRoomsWithTariff = availableRoomsWithTariff +1;
				}
			}
		}
		if(onRequestTariffsCount == allRommsWithTariff){
			onRequestHotels[onRequestHotels.length] = temphotelList[count];
		}else {
			hotelNotOnRequest[hotelNotOnRequest.length] = temphotelList[count];

		}
		}

		if(onRequestHotels.length!=temphotelList.length){

		temphotelList=hotelNotOnRequest.concat(onRequestHotels);
		}
		return temphotelList;

	}

	var globalIsVideo = 0;
function setDefaultTab(hotelCode,tabIndex,hotelIndex,isVideo){
	globalIsVideo=0;

    if(isVideo==1){
     globalIsVideo=1;
     goToHtlDetails(hotelCode, tabIndex ,hotelIndex);
   }
   }
