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();
}
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 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;";
	}
}
var changeModifyFlag=0;
var changeStarFlag=0;
var changeAdlFlag=0;

function changeModifyImg(){
	if(changeModifyFlag==0){
		changeModifyFlag=1;
		document.getElementById("modifyYourSearch").className="modify-open";
		document.getElementById("tabModifySearch").style.display="none";
	}
	else{
		changeModifyFlag=0;
		document.getElementById("modifyYourSearch").className="modify-close";
		document.getElementById("tabModifySearch").style.display="block";
	}
}
function changeStarImg(){
	if(changeStarFlag==0){
		changeStarFlag=1;
		document.getElementById("chnStrImg").src="http://images1.makemytrip.com/mmtimgs/images/calque-165.gif";
		document.getElementById("starRatingTable").style.display="block";
	}
	else{
		document.getElementById("chnStrImg").src="http://images1.makemytrip.com/mmtimgs/images/calque-165-close.gif";
		document.getElementById("starRatingTable").style.display="none";
		changeStarFlag=0;
	}
}
function changeFilterImg(){
	if(changeAdlFlag==0){
		changeAdlFlag=1;
		document.getElementById("chnAdlImg").src="http://images1.makemytrip.com/mmtimgs/images/calque-165-close.gif";
		document.getElementById("idDivAddl").style.display="block";
	}
	else{
		document.getElementById("chnAdlImg").src="http://images1.makemytrip.com/mmtimgs/images/calque-165.gif";
		document.getElementById("idDivAddl").style.display="none";
		changeAdlFlag=0;
	}
}
function submitModifySearch(){
	if(document.getElementById("cityName").value == "dotedLine"){
		alert("Please Select the Destination");
		return false;
	}
	if(document.getElementById("cityName").selectedIndex==0){
		document.getElementById("cityName").focus();
		alert(enterCity);
		return;
	}
	var checkin=document.forms[0].checkInDate.value;
	var checkout=document.forms[0].checkOutDate.value;
	if(checkin=="" && checkout==""){
		alert(enterDates);
		document.forms[0].checkInDate.focus();
    return;
  }
	if(checkin=="" || checkin=="DD/MM/YYYY" || checkin=="dd/mm/yyyy"){
		alert(enterCheckIn);
		document.forms[0].checkInDate.focus();
		return;
	}
	else if(checkout=="" || checkout=="DD/MM/YYYY" || checkout=="dd/mm/yyyy"){
		alert(enterCheckOut);
		document.forms[0].checkOutDate.focus();
		return;
	}

	if(!isThisDate(document.getElementById("arrDateOway").value, "checkInDate")){
		document.forms[0].checkInDate.focus();
		return false;
	}
	if(!isThisDate(document.getElementById("depDateOway").value,"checkOutDate")){
		document.forms[0].checkOutDate.focus();
		return false;
	}
	if(checkCurrentData(document.getElementById("arrDateOway").value)){
		alert(checkInDate);
		document.forms[0].checkInDate.focus();
		return false;
	}
	if(checkCurrentData(document.getElementById("depDateOway").value)){
		alert(checkOutDate);
		document.forms[0].checkOutDate.focus();
		return false;
	}
	checkinArr = checkin.split("/");
	checkoutArr = checkout.split("/");
	var checkInDateObj = new Date(checkinArr[2], checkinArr[1]-1, checkinArr[0]);
	var checkOutDateObj = new Date(checkoutArr[2], checkoutArr[1]-1, checkoutArr[0]);
	var fromTime = checkInDateObj.getTime();
	var toTime = checkOutDateObj.getTime();
	if(fromTime==toTime) {
		alert(same_check_in_out);
		document.forms[0].checkOutDate.focus();
		return;
	}
	if(fromTime>toTime) {
		alert(checkIn_CheckOut);
		document.forms[0].checkOutDate.focus();
		return;
	}
	if(ValidateForm(checkin,'checkInDate')){
		if(ValidateForm(checkout,'checkOutDate')){
			if(document.forms[0].checkInDate.value=="DD/MM/YYYY" || document.forms[0].checkInDate.value==""){
				alert(enterCheckIn);
				document.forms[0].checkInDate.focus();
			}
			else if(document.forms[0].checkOutDate.value=="DD/MM/YYYY" || document.forms[0].checkOutDate.value==""){
				alert(enterCheckOut);
				document.forms[0].checkOutDate.focus();
			}
			else{
				if(document.getElementById("cityName").selectedIndex>0){
					document.getElementById("hiddenCityName").value = document.getElementById("cityName").options[document.getElementById("cityName").selectedIndex].innerHTML;
					document.forms[0].action = "searchHotelProgress.do?residentOfIndia=Y&method=searchHotels";
					deleteAllCookies();
					window.setTimeout("document.forms[0].submit();" , 500);
				}
				else{
					alert(enterCity);
				}
			}
		}
	}
}
function checkCurrentData(val){
	var curdate=new Date();
	var day=curdate.getDate();
	var month=eval(curdate.getMonth())+1;
	var year=curdate.getFullYear();
	var valarray = val.split("/");
	if(eval(valarray[2])==eval(year)){
		if(eval(valarray[1])==eval(month)){
			if(eval(valarray[0])>=eval(day)){
				return false;
			}
		}
		else if(eval(valarray[1])>eval(month)){
			return false;
		}
	}
	else if(eval(valarray[2])>eval(year)){
		return false;
	}
	return true;
}
function whatIsModi(evt){
	evt = (evt) ? evt : ((window.event) ? window.event : "");
	if (evt) {
		var elem = (evt.target) ? evt.target : evt.srcElement;
		var x = evt.clientX;
		var y = evt.clientY + document.body.scrollTop+8;
		var divObj = document.getElementById("WhatIsX");
		divObj.style.display = "block";
		divObj.style.position = "absolute";
		divObj.style.left = x-50;
		divObj.style.top = y;
		divObj.innerHTML = '<div class="select-free"><table bgcolor=white" cellpadding="0" cellspacing="0" width="200" heigth="100" style="border: 1px solid #3396FF"><tr bgcolor=\'#3396FF\'><td height="20px"><font color="white"><b>What is Modify Search?</td><td style="cursor:pointer" align="right"><span onClick="document.getElementById(\'WhatIsX\').style.display=\'none\'"><font color="white"><b>close[X]&nbsp;&nbsp;</b></span></td></tr><tr><td colspan=2 bgcolor="white"><br/><font size="1" family="verdana">The Modify Search component allows you to modify the search you have made.</font></td></tr></table><!--[if lte IE 6.5]><iframe ></iframe><![endif]--></div>';
	}
}
function whatIsHtlNm(evt){
	evt = (evt) ? evt : ((window.event) ? window.event : "");
	if (evt) {
		var elem = (evt.target) ? evt.target : evt.srcElement;
		var x = evt.clientX;
		var y = evt.clientY + document.body.scrollTop+8;
		var divObj = document.getElementById("WhatIsX");
		divObj.style.display = "block";
		divObj.style.position = "absolute";
		divObj.style.left = x+50;
		divObj.style.top = y-20;
		divObj.innerHTML = '<table bgcolor=white" cellpadding="0" cellspacing="0" width="200" heigth="100" style="border: 1px solid #3396FF"><tr bgcolor=\'#3396FF\'><td height="20px"><font color="white"><b>What is Hotel Name?</td><td style="cursor:pointer" align="right"><span onClick="document.getElementById(\'WhatIsX\').style.display=\'none\'"><font color="white"><b>close[X]&nbsp;&nbsp;</b></span></td></tr><tr><td colspan=2 bgcolor="white"><br/><font size="1"  family="verdana">The Hotel Name text field allows users to enter a minimum of three characters and the system will auto-complete the hotels that contain those characters. The matches will appear for selection in a drop-down overlay.</font></td></tr></table>';
	}
}
function showResults(onSubmit){
	showUR();
	window.setTimeout('showResults1('+onSubmit+')', 1);
}
function showResults1(onSubmit){
	if(!onSubmit)
		groupHotels();
	if (end==0){
		showNoResultsMessage();
		fillPagingInfo();
		hideUR();
		return;
	}
	var hotelsTablesString = "";
	for (var hotelCount=start; hotelCount<end; hotelCount++){
		var key = hDD[hotelCount]['HC'];
		key = key+"k"+hotelCount;
		if (get(key)== null){
			var tempHotelString = "<TABLE><TR><TD WIDTH=100% STYLE='padding-bottom:10px'>" + buildSingleHotelTable(hotelCount) +"</td></tr></table>";
			put(key, tempHotelString);
			hotelsTablesString += tempHotelString;
		}
		else{
			hotelsTablesString += get(key);
		}
  }
	document.getElementById("resultsDiv").innerHTML = hotelsTablesString ;
	if(cleareDistances)
		displayDistancesInKM(mapRequestVar, result);
  showHotelsInCity();
	hideUR();
	fillPagingInfo();
}
function sortByLMD(){
	var LMDHotels = new Array();
	var notLMDHotels = new Array();
	for (var count=0; count<hDD.length; count++ ){
		if (hDD[count]['LMD'] == 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);
}
function groupHotels(){
	var mmtHotels = new Array();
	var gdsHotels = new Array();
	for (var count=0;count<hDD.length ; count++){
		var isGds = hDD[count]['GDS'];
		if (isGds.toUpperCase()=="I"){
			gdsHotels[gdsHotels.length] =  hDD[count];
		}
		else{
			mmtHotels[mmtHotels.length] =  hDD[count];
		}
	}
	hDD = mmtHotels.concat(gdsHotels);
}
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("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 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;

	if (currentPage != 0 && currentPage != 1){
		linksString += "<A style='cursor:pointer' onclick=\"document.getElementById('top').focus();takeToPage("+ (parseInt(currentPage) - 1)+");\"><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 (currentPage != 0 && currentPage!= totalPages ){
		linksString2 += "<A style='cursor:pointer' onclick=\"document.getElementById('top').focus();takeToPage("+ (parseInt(currentPage) + 1)+");\"><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(false);
	setCookie("pageNum", pageNumber, 1);
}
function sortByAttribute(attributeName, onSubmit){
	if (attributeName=='MMTRecom'){
		sortedOrder = "MMTRecom";
		start = 0;
		end = Math.min(hotelsPerPage, hDD.length);
		currentPage =  (hDD.length==0) ? 0: 1;
		setCookie("pageNum",1,1);
		if(!onSubmit){
			sortPriority();
			sortByLMD();
		}
		showResults(onSubmit);
		return;
	}
	else 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(onSubmit);
		return;
	}
	else 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(onSubmit);
		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();
	showFilteredResultAreaPriceGrid(-1,-1,-1,-1,7,1);

	for (var count=0;count<hDD.length ; count++){
		var starRattingVar = hDD[count]['SR'];
		var locaionVarArr = hDD[count]['HL'];
		var lowestAvgPrice = hDD[count]['LAP'];
		var propertyTypeVar = hDD[count]['PT'];
		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);
					} 
					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);
	setCookie("pageNum",1,1);
	showResults(false);
}
function cleareDistancesFun(){
	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(false);
}
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]['HC'];
    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]['HC'];
			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(false);
}
function displayDistancesInKM(areaName, result){
	if(distSortFnFlg){
		for(var hotelArrCount=start; hotelArrCount<end; hotelArrCount++){
			var mmtHotelId = hDD[hotelArrCount]['HC'];
			var distanceAvlFlag = true;
			if(resultVar.length !=0){
				for(var resultCnt=0;resultCnt<resultVar.length;resultCnt++){
					var mapHotelId = resultVar[resultCnt]["id"];

					var idVar = "blueBoxTab"+hotelArrCount;
					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);
	tempstartPriceSlab = startPriceSlab ;
	tempendPriceSlab  =endPriceSlab;
	tempstarRating = starRating;
	tempisPriceflag = isPriceflag;
	firstTimeResultsShowing = false;
	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;
	}
	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;
	}
	var areaPriceGridHotels = new Array();
	var flag = false;
	var filteredAmenityList = getTheAmenityList(givenAmenityName);
	for (var count=0;count<hD.length ; count++){
		var hotel = hD[count];
		var starRatting = hD[count]['SR'];
		var locationVarArr = hD[count]['HL'];
		var lowestAvgPrice = hD[count]['LAP'];
		var propertyType = hD[count]['PT'];
		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;
				}
			}
			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(false);
}

function sortByAreaPriceGrid(starRatting, area, price){

	showFilteredResultAreaPriceGrid(-1,-1,-1,-1,7,1);
	var areaPriceGridHotels = new Array();

	for (var count=0;count<hDD.length ; count++){
		var starRattingVar = hDD[count]['SR'];
		var locaionVarArr = hDD[count]['HL'];
		var lowestAvgPrice = hDD[count]['LAP'];
		var propertyTypeVar = hDD[count]['PT'];
		var hotelNAme = hDD[count]['HN'];

		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"){
					areaPriceGridHotels[areaPriceGridHotels.length] =  hDD[count];
					areaPriceGridHotels.sort(sortByStarRating);
				} else if(propertyTypeVar != "" && parseInt(starRatting)>=6  && locaionVar == area && parseInt(lowestAvgPrice) >= parseInt(price)){
					areaPriceGridHotels[areaPriceGridHotels.length] =  hDD[count];
					areaPriceGridHotels.sort(sortByPrice);
				}
			}
		}else{
			if (parseInt(starRattingVar) >= parseInt(starRatting) && parseInt(lowestAvgPrice) >= parseInt(price) && propertyTypeVar != "Serviced Apartment" && area == ""){
				areaPriceGridHotels[areaPriceGridHotels.length] =  hDD[count];
				areaPriceGridHotels.sort(sortByStarRating);
			}
			else if(parseInt(starRatting)==6 && parseInt(lowestAvgPrice) >= parseInt(price) && propertyTypeVar != "" && area == ""){
				areaPriceGridHotels[areaPriceGridHotels.length] =  hDD[count];
        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);
	setCookie("pageNum",1,1);
	showResults(false);
}
function sortByAttributeLinkAreaPriceGrid(attributeName){
	if (attributeName=='StarRating'){
		hDD.sort(sortByStarRatingAreaPriceGrid);
		setCookie("order",null,-1);
		start = 0;
		end = Math.min(hotelsPerPage, hDD.length);
		currentPage =  (hDD.length==0) ? 0: 1;
		setCookie("pageNum",1,1);
		showResults(false);
		return;
	}
	if (attributeName=='LowestAvgPrice'){
		hDD.sort(sortByPrice);
		start = 0;
		setCookie("order",null,-1);
		end = Math.min(hotelsPerPage, hDD.length);
		currentPage =  (hDD.length==0) ? 0: 1
		setCookie("pageNum",1,1);
		showResults(false);
		return;
	}
}
function sortByStarRatingAreaPriceGrid(a, b) {
	var x = parseInt(a.SR);
	var y = parseInt(b.SR);
	return ((x < y) ? -1 : ((x > y) ? 1 : sortByPriceAreaPriceGrid(a,b)));
}
function sortByPriceAreaPriceGrid(a, b){
	var x = a.LAP/ 1;
	var y = b.LAP / 1;
	return ((x < y)? -1 : ((x > y)?1 : sortByName(a,b)));
}
function sortByAttributeLink(attributeName) {
	if (attributeName=='StarRating'){
		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(false);
			return;
		} else {
			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(false);
			return;
		}
	}
  if (attributeName=='LowestAvgPrice'){
		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(false);
			return;
		} else {
			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(false);
			return;
		}
	}
}
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.SR);
	var y = parseInt(b.SR);
	return ((x < y) ? -1 : ((x > y) ? 1 : sortByPrice(a,b)));
}
function sortPriority(){
  hDD.sort(sortByPriority);
}
function sortByName(a,b){
	var x = a.HN;
	var y = b.HN;
	return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}
function sortByPriority(a,b){
	var x = parseInt(a.HP);
	var y = parseInt(b.HP);
	return ((x < y) ? -1 : ((x > y) ? 1 : sortByPrice(a,b)));
}
function sortByReco(a,b){
	var x = a.Rec;
	var y = b.Rec;
	return ((x < y) ? 1 : ((x > y) ? -1 : sortByPrice(a,b)));
}
function sortByPrice(a, b){
	var x = a.LAP/ 1;
	var y = b.LAP / 1;
	return ((x < y)? -1 : ((x > y)?1 : sortByName(a,b)));
}
function popDesc(hotelIndex,event){
	try {
		descRequest = new window.XMLHttpRequest();
		if(descRequest.overrideMimeType) {
		}
	} 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';
	}
}

var fareFrom;
var fareTo;
var hotelPromoText="";

function buildSingleHotelTable(hotelIndex){
	var hotel = hDD[hotelIndex];

  var headingBackgroundImageSrc;
	var starRatingString = getStarRatingString(hotel['SR']);
	if(hotel['PT']!=null && hotel['PT']!=""){
		starRatingString = hotel['PT'];
	}
	var hotelName = hotel['HN'];
	var hotelNameDisplay = "";
	if (hotelName.length>45){
		hotelNameDisplay = hotelName.substring(0,42)  + "...";
	}
	else{
		hotelNameDisplay = hotelName;
	}
	var mmtRecommended = hotel['Rec']=='Y'?true:false;
	var cashPayAllowed = hotel['ACP']=='Y'?true:false;
	var isLMD = hotel['LMD']==1?true:false;
	var isGDSHotel = hotel['GDS']=='I'?true:false;
	var hotelTableString = "";
	var hotelString = "HT"+hotelIndex;
	hotelTableString += "<a name='"+hotelString+"' id='"+hotelString+"' href='#'></a><TABLE WIDTH='98%' style='border:1px solid #7CBCE7' CELLSPACING='0' cellpadding='0' border='0' style='padding:0'> ";
		               
  //var hotelTableString = "<TABLE WIDTH='98%' style='border:1px solid #7CBCE7' CELLSPACING='0' cellpadding='0' border='0' style='padding:0'> ";
	if (mmtRecommended){
		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="'+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+"' style='font-family:arial;font-size:12px;'></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 if(isLMD){
		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="'+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+"' style='font-family:arial;font-size:12px;'></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{
		hotelTableString += "<TR><TD WIDTH='70%' class='whitetext-headings' BGCOLOR='#0099FF'><span title='"+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+"' style='font-family:arial;font-size:12px;'></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(hotel, hotelIndex, mmtRecommended, isGDSHotel) +"</TD></TR>";

	if(!cashPayAllowed)
		hotelTableString += "<TR VALIGN='top'><TD WIDTH='100%' COLSPAN=2 style='padding-left:10;padding-bottom:10;padding-right:10px;'><BR>" + hotel['HD'] + "<BR><BR><a href='#select' ";
	else
		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>" + hotel['HD'] + "<BR><BR><a href='#select' ";

	hotelTableString +="onClick='goToHtlDetails(\""+hotel['HC']+"\", 1 , "+ hotelIndex+")'>More Details <img src="+imgPath+"images/calque_125.gif width='9' height='7' BORDER=0/></a></TD></TR><tr><td colspan=2 style='padding-bottom:10;'><span id='hotelPromoText'></span></td></tr>";
	hotelPromoText="";
	var roomTypesString = getRoomTypesTable(hotel, hotelIndex, isLMD);
	if(roomTypesString != null || roomTypesString != ""){
		hotelTableString += "<TR><TD WIDTH='100%' COLSPAN=2>" + roomTypesString + "</TD></TR>";
		hotelTableString += "</TABLE>";

		if(hotelPromoText!=""){
			hotelTableString = hotelTableString.replace(/<span id='hotelPromoText'><\/span>/,hotelPromoText);
		}
	} else {
		hotelTableString ="";
	}
  hotelTableString += "</TABLE>";
  return hotelTableString;
}

 		var onRequestTariffsCount = 0;
		 var hotelCode = ""; 		 
		 var minAvgPriceRateBook = 0;	                
		 var minAvgPriceRateRequest = 0; 
		 var minAvgPriceRatePromotionsBook = 0; 
		 var minAvgPriceRatePromotionsRequest = 0; 
		 var seperatorCell1 = " | ";
		 var checkFlagForRoom = true; 		 
		 function showAllRoomTypes(hotelIndex){		
			 var lowestPriceRTString = "lowestPriceRT"+hotelIndex;
			 var allPriceRTString = "allPriceRT"+hotelIndex;						 
			 var hotelFocusString = "HT"+hotelIndex;			 			 		 
		 	 document.getElementById(lowestPriceRTString).style.display = "none";		 	 
		 	 document.getElementById(allPriceRTString).style.display = "";	 	 
		 	 document.getElementById(hotelFocusString).focus();			  	 
		 }		 
		 function hideAllRoomTypes(hotelIndex){		 
		  	 var lowestPriceRTString = "lowestPriceRT"+hotelIndex;
			 var allPriceRTString = "allPriceRT"+hotelIndex;				
			 var hotelFocusString = "HT"+hotelIndex;			   	
		 	 document.getElementById(lowestPriceRTString).style.display = "";		 	 
		 	 document.getElementById(allPriceRTString).style.display = "none";		 	 
		 	 document.getElementById(hotelFocusString).focus();	 	
		 }
function getRoomTypesTable(hotel, hotelIndex, isLMD){
	var lowestAvgPrice = hotel['LAP'];	
	onRequestTariffsCount = 0;
	hotel['rT'].sort(sortRoomTypes);
	hotelCode = hotel['HC'];
	var emptyRow = "<tr><td width=100% colspan=7 bgcolor=#7CBCE7></td></tr>";
	var lowestPriceRTString = "lowestPriceRT"+hotelIndex; 
	var roomTypesString = "";
	var totalRoomsWithDifferntTariff = 0; var totalRoomOnRequest = 0;	
	minAvgPriceRateBook = 0;	 minAvgPriceRateRequest = 0;	 minAvgPriceRatePromotionsBook = 0;   minAvgPriceRatePromotionsRequest = 0; 	
	var promoImgTag="<img src='images/deal-tag.gif'/>";
	var roomTypes = hotel['rT'];
	var totalRates = 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['AS']=='R' && onRequestHotelStatus == 1) || tariff['AS']=='B'){		
				totalRates += 1;
			}   
		}              
  }	              
	var showRTString = "showRT"+hotelIndex;   	
	if(totalRates == 1)
		roomTypesString = "<table width=100% cellspacing=0 cellpadding='0' border=0><tr><td width=100%> <div id = '"+lowestPriceRTString+"' style = 'display:' ><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;align:left;'   width=490   >Room Type<span style='width:150px;' id = '"+showRTString+"'  > <font size= '1'><span style='margin-bottom: 3px; height: 12px;cursor:pointer;color:#1E90FF'></span></font></span></td> <td colspan = 2 class='table-field-tit'  width=310 align=left> Average Daily Rate</td></tr>";
  else				      
		roomTypesString = "<table width=100% cellspacing=0 cellpadding='0' border=0><tr><td width=100%>  <div id = '"+lowestPriceRTString+"' style = 'display:' ><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;align:left;'   width=490   >Room Type |<span style='width:150px;' id = '"+showRTString+"' onclick= 'showAllRoomTypes("+hotelIndex+");' > <font size= '1'><span style='margin-bottom: 3px; height: 12px;cursor:pointer;color:#1E90FF'><u>Show all room rates ("+totalRates+")</u></span></font><img src="+imgPath+"images/calque_125.gif width='9' height='7' alt='' BORDER=0/></span></td> <td colspan = 2 class='table-field-tit'  width=310 align=left> Average Daily Rate</td></tr>";
  
  calculateMinBookReq(roomTypes);  
  findRoomTypeWithMinReqBook(roomTypes);
	
	for (var roomTypeCount=0; roomTypeCount<roomTypes.length; roomTypeCount++){
		var roomType = roomTypes[roomTypeCount];var tariffs = roomType['tf'];
		var promoImgTagSel="";
		var isPromoHotelTextReqd = false;checkFlagForRoom = true;    
    for (var tariffCount =0; tariffCount<tariffs.length; tariffCount++){
      totalRoomsWithDifferntTariff = totalRoomsWithDifferntTariff +1;
      promoImgTagSel="";
      var tariff = tariffs[tariffCount],			
			promoText=tariff['PText'];
			var bookable = tariff['AS']=='R'?false:true;
			var avgPricePerNight = 1;
			avgPricePerNight=avgPricePerNight*tariff['APN'];
			var discAvgPricePerNight = 1;
			discAvgPricePerNight = discAvgPricePerNight*tariff['DANP'];
			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>";
			}		
               if (tariff['AvailStatus']=='R') {
                    totalRoomOnRequest = totalRoomOnRequest+1;                   
                }   
				if (promoText != null && promoText != ""){		
		                   if (roomTypeWithMinReqBookPromotions  == ""){  		                   
		                    if (minAvgPriceRatePromotionsBook != 0){
						         if (minAvgPriceRatePromotionsBook >= minAvgPriceRatePromotionsRequest)	{
						         if (discAvgPricePerNight == avgPricePerNight){               
					               if ((minAvgPriceRatePromotionsBook == avgPricePerNight) || (minAvgPriceRatePromotionsRequest == avgPricePerNight)){				                       		
					                       	roomTypesString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
			   						        /* Added By Minal For Controlling OnRequest Switch Off Case */
			   					    		if ((onRequestHotelStatus == 1 && !bookable) || bookable) 
			   						        checkFlagForRoom = false;
						            } }
						            else if (discAvgPricePerNight < avgPricePerNight){
						            if ((minAvgPriceRatePromotionsBook == discAvgPricePerNight) || (minAvgPriceRatePromotionsRequest == discAvgPricePerNight)){				                       		
					                       	roomTypesString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
			   						   /* Added By Minal For Controlling OnRequest Switch Off Case */
			   					    	if ((onRequestHotelStatus == 1 && !bookable) || bookable)
			   						      checkFlagForRoom = false;
						            } }   }
						       else {if (discAvgPricePerNight == avgPricePerNight){ 
						            if (minAvgPriceRatePromotionsRequest != avgPricePerNight){				            
						               if (minAvgPriceRatePromotionsBook == avgPricePerNight){				                       		
					                       	roomTypesString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
			   					    	   
			   					    	    /* Added By Minal For Controlling OnRequest Switch Off Case */
			   					    		if ((onRequestHotelStatus == 1 && !bookable) || bookable)
			   					    	    checkFlagForRoom = false; }	}} else  if (discAvgPricePerNight < avgPricePerNight){ 
						        	  	if (minAvgPriceRatePromotionsRequest != discAvgPricePerNight){					            
						               		if (minAvgPriceRatePromotionsBook == discAvgPricePerNight){				                       		
					                       	roomTypesString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
			   					    	 /* Added By Minal For Controlling OnRequest Switch Off Case */
			   					    	 if ((onRequestHotelStatus == 1 && !bookable) || bookable)
			   					    	 checkFlagForRoom = false; }					            
						        	}
						        	} }
						     }
						      else{ if (discAvgPricePerNight == avgPricePerNight){  
						     	    if (minAvgPriceRatePromotionsRequest == avgPricePerNight){		
					                       	roomTypesString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
			   					    	  /* Added By Minal For Controlling OnRequest Switch Off Case */
			   					    	 if ((onRequestHotelStatus == 1 && !bookable) || bookable)				   					    	 
			   					    	 checkFlagForRoom = false; }
						     	  }else  if (discAvgPricePerNight < avgPricePerNight){ 
						     	    if (minAvgPriceRatePromotionsRequest == discAvgPricePerNight){		
					                       	roomTypesString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
			   					     /* Added By Minal For Controlling OnRequest Switch Off Case */
			   					    if ((onRequestHotelStatus == 1 && !bookable) || bookable)			   					    
			   					     checkFlagForRoom = false;	 }
						     	  }  } } else{
					      if (parseInt(roomTypeWithMinReqBookPromotions)  == roomTypeCount){	
					       if (minAvgPriceRatePromotionsBook != 0){
					              if (minAvgPriceRatePromotionsBook >= minAvgPriceRatePromotionsRequest)	{  
					               if (discAvgPricePerNight == avgPricePerNight){                  
					               if ((minAvgPriceRatePromotionsBook == avgPricePerNight) || (minAvgPriceRatePromotionsRequest == avgPricePerNight)){				                       		
					                       	roomTypesString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
			   						   
			   						    /* Added By Minal For Controlling OnRequest Switch Off Case */
			   					    	if ((onRequestHotelStatus == 1 && !bookable) || bookable)	
			   						       checkFlagForRoom = false;  
						            	}
						            }else  if (discAvgPricePerNight < avgPricePerNight){  
						            if ((minAvgPriceRatePromotionsBook == discAvgPricePerNight) || (minAvgPriceRatePromotionsRequest == discAvgPricePerNight)){				                       		
					                       	roomTypesString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
			   						  /* Added By Minal For Controlling OnRequest Switch Off Case */
			   					 	if ((onRequestHotelStatus == 1 && !bookable) || bookable)
			   						     checkFlagForRoom = false;  
						            	}
						            }
						            }
						            else {
						          if (discAvgPricePerNight == avgPricePerNight){    
						            if (minAvgPriceRatePromotionsRequest != avgPricePerNight){		            
						               if (minAvgPriceRatePromotionsBook == avgPricePerNight){				                       		
					                       	roomTypesString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
			   					     /* Added By Minal For Controlling OnRequest Switch Off Case */
			   					    if ((onRequestHotelStatus == 1 && !bookable) || bookable)
			   					     checkFlagForRoom = false;	 }					            
						        	}
						        	}else   if (discAvgPricePerNight < avgPricePerNight){
						        	      if (minAvgPriceRatePromotionsRequest != discAvgPricePerNight){				            
						               if (minAvgPriceRatePromotionsBook == discAvgPricePerNight){				                       		
					                       	roomTypesString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
			   					    	 /* Added By Minal For Controlling OnRequest Switch Off Case */
			   					     if ((onRequestHotelStatus == 1 && !bookable) || bookable)
			   					    	 checkFlagForRoom = false; }// end of Matching price						            
						        	}
						        	} }
					                } else{
						     	   if (discAvgPricePerNight == avgPricePerNight){    
						     	    if (minAvgPriceRatePromotionsRequest == avgPricePerNight){		
					                       	roomTypesString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
			   					    	 /* Added By Minal For Controlling OnRequest Switch Off Case */
			   					    	if ((onRequestHotelStatus == 1 && !bookable) || bookable)	
			   					    	 checkFlagForRoom = false; }
			   					     }else  if (discAvgPricePerNight < avgPricePerNight){    
			   					       if (minAvgPriceRatePromotionsRequest == discAvgPricePerNight){		
					                       	roomTypesString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
			   					    	 /* Added By Minal For Controlling OnRequest Switch Off Case */
			   					    	 if ((onRequestHotelStatus == 1 && !bookable) || bookable)	
			   					    	  checkFlagForRoom = false;}
			   					     } } }
					            } }     else{    
				       if (roomTypeWithMinReqBook  == ""){   
					    if (minAvgPriceRateBook != 0){
				  		     if (minAvgPriceRateBook >= minAvgPriceRateRequest)	{ 
				  		       if (discAvgPricePerNight == avgPricePerNight){ 
				               if ((minAvgPriceRateBook == avgPricePerNight) || (minAvgPriceRateRequest == avgPricePerNight)){				                       		
				                       	roomTypesString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
		   						    /* Added By Minal For Controlling OnRequest Switch Off Case */
			   					   if ((onRequestHotelStatus == 1 && !bookable) || bookable)	
		   						    checkFlagForRoom = false;   
					            }	
					            }else   if (discAvgPricePerNight < avgPricePerNight){
					             if ((minAvgPriceRateBook == discAvgPricePerNight) || (minAvgPriceRateRequest == discAvgPricePerNight)){				                       		
				                       	roomTypesString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
		   						      /* Added By Minal For Controlling OnRequest Switch Off Case */
			   					     if ((onRequestHotelStatus == 1 && !bookable) || bookable)	
		   						      checkFlagForRoom = false; 
					            }}}
					            else { if (discAvgPricePerNight == avgPricePerNight){  
						            if (minAvgPriceRateRequest != avgPricePerNight){				            
						               if (minAvgPriceRateBook == avgPricePerNight){				                       		
					                       	roomTypesString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
			   					    /* Added By Minal For Controlling OnRequest Switch Off Case */
			   					    if ((onRequestHotelStatus == 1 && !bookable) || bookable)	
			   					    checkFlagForRoom = false;  }							            
						            }
						            }else   if (discAvgPricePerNight < avgPricePerNight){  
						             if (minAvgPriceRateRequest != discAvgPricePerNight){			            
						               if (minAvgPriceRateBook == discAvgPricePerNight){				                       		
					                       	roomTypesString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
			   					    /* Added By Minal For Controlling OnRequest Switch Off Case */
			   					    if ((onRequestHotelStatus == 1 && !bookable) || bookable)
			   					    checkFlagForRoom = false;  }						            
						            }  } }
						           }
						      else{
						     	   if (discAvgPricePerNight == avgPricePerNight){    
						     	    if (minAvgPriceRateRequest == avgPricePerNight){		
					                       	roomTypesString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
			   					    	 /* Added By Minal For Controlling OnRequest Switch Off Case */
			   					    	 if ((onRequestHotelStatus == 1 && !bookable) || bookable)
			   					    	 checkFlagForRoom = false; }
			   					    	 }else  if (discAvgPricePerNight < avgPricePerNight){  
			   					    	   if (minAvgPriceRateRequest == discAvgPricePerNight){		
					                       	roomTypesString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
			   					    	 /* Added By Minal For Controlling OnRequest Switch Off Case */
			   					    	 if ((onRequestHotelStatus == 1 && !bookable) || bookable)
			   					    	  checkFlagForRoom = false;}
			   					    	 } 	  }
					            }
					  else{
					  if (parseInt(roomTypeWithMinReqBook)  == roomTypeCount){ 
					     if (minAvgPriceRateBook != 0){   
					      if (minAvgPriceRateBook >= minAvgPriceRateRequest)	{   
					       if (discAvgPricePerNight == avgPricePerNight){  
					       	if (!(minAvgPriceRateBook == avgPricePerNight) && (minAvgPriceRateRequest == minAvgPriceRateBook ))     {         
				               if ((minAvgPriceRateBook == avgPricePerNight) || (minAvgPriceRateRequest == avgPricePerNight)){				                       		
				                       	roomTypesString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
		   						      /* Added By Minal For Controlling OnRequest Switch Off Case */
			   					     if ((onRequestHotelStatus == 1 && !bookable) || bookable)
		   						       checkFlagForRoom = false;
					            }
					            }else{ if (onRequestHotelStatus == 0){
			                        if (tariffs[tariffCount]['AS']=='B'){			                        
					                        if (minAvgPriceRateBook == avgPricePerNight){				                       		
						                       	roomTypesString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
				   						        /* Added By Minal For Controlling OnRequest Switch Off Case */
			   					    	 if ((onRequestHotelStatus == 1 && !bookable) || bookable)
				   						       checkFlagForRoom = false;
							            }
			                        	}  }else{
			                           if (tariffs[tariffCount]['AS']=='B'){			                        
					                        if (minAvgPriceRateBook == avgPricePerNight){				                       		
						                       	roomTypesString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
				   						       /* Added By Minal For Controlling OnRequest Switch Off Case */
			   					    	 if ((onRequestHotelStatus == 1 && !bookable) || bookable)
				   						       checkFlagForRoom = false;
							            }
			                        	} if (tariffs[tariffCount]['AS']=='R'){			                        
					                        if (minAvgPriceRateRequest == avgPricePerNight){				                       		
						                       	roomTypesString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
				   						        /* Added By Minal For Controlling OnRequest Switch Off Case */
			   					    		 	if ((onRequestHotelStatus == 1 && !bookable) || bookable)
				   						       checkFlagForRoom = false;
							            }
			                        	}  } }
					            }else  if (discAvgPricePerNight < avgPricePerNight){  
					            	if (!(minAvgPriceRateBook == avgPricePerNight) && (minAvgPriceRateRequest == minAvgPriceRateBook ))     { 
					               if ((minAvgPriceRateBook == discAvgPricePerNight) || (minAvgPriceRateRequest == discAvgPricePerNight)){				                       		
				                       	roomTypesString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
		   						       /* Added By Minal For Controlling OnRequest Switch Off Case */
			   					     if ((onRequestHotelStatus == 1 && !bookable) || bookable)
		   						       checkFlagForRoom = false;
					            }	
					            }else{
					              if (onRequestHotelStatus == 0){
			                        if (tariffs[tariffCount]['AS']=='B'){			                        
					                        if (minAvgPriceRateBook == discAvgPricePerNight){				                       		
						                       	roomTypesString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
				   						     /* Added By Minal For Controlling OnRequest Switch Off Case */
			   					    	 if ((onRequestHotelStatus == 1 && !bookable) || bookable)
				   						       checkFlagForRoom = false;
							            }
			                        	}}else{
			                           if (tariffs[tariffCount]['AS']=='B'){			                        
					                        if (minAvgPriceRateBook == discAvgPricePerNight){				                       		
						                       	roomTypesString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
				   						      /* Added By Minal For Controlling OnRequest Switch Off Case */
			   					    	 if ((onRequestHotelStatus == 1 && !bookable) || bookable)	
				   						       checkFlagForRoom = false;
							            }
			                        	}  if (tariffs[tariffCount]['AS']=='R'){			                        
					                        if (minAvgPriceRateRequest == discAvgPricePerNight){				                       		
						                       	roomTypesString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
				   						      /* Added By Minal For Controlling OnRequest Switch Off Case */
			   					    		 	if ((onRequestHotelStatus == 1 && !bookable) || bookable)
				   						       checkFlagForRoom = false;
							            }
			                        	}   }  }  }}
					            else {if (discAvgPricePerNight == avgPricePerNight){ 
						            if (minAvgPriceRateRequest != avgPricePerNight){				            
						               if (minAvgPriceRateBook == avgPricePerNight){				                       		
					                       	roomTypesString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
			   					     /* Added By Minal For Controlling OnRequest Switch Off Case */
			   					     if ((onRequestHotelStatus == 1 && !bookable) || bookable)
			   					      checkFlagForRoom = false;}							            
						            }
						            }else  if (discAvgPricePerNight < avgPricePerNight){ 
						              if (minAvgPriceRateRequest != discAvgPricePerNight){		            
						               if (minAvgPriceRateBook == discAvgPricePerNight){				                       		
					                       	roomTypesString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
			   					   /* Added By Minal For Controlling OnRequest Switch Off Case */
			   					    	 if ((onRequestHotelStatus == 1 && !bookable) || bookable)
			   					     checkFlagForRoom = false; }						            
						            }
						            }  }   }
						      else{ if (discAvgPricePerNight == avgPricePerNight){   
						     	    if (minAvgPriceRateRequest == avgPricePerNight){		
					                       	roomTypesString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
			   					     /* Added By Minal For Controlling OnRequest Switch Off Case */
			   					    	if ((onRequestHotelStatus == 1 && !bookable) || bookable)
			   					    	 checkFlagForRoom = false; }
						     	    }else if (discAvgPricePerNight < avgPricePerNight){ 
						     	     if (minAvgPriceRateRequest == discAvgPricePerNight){		
					                       	roomTypesString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
			   					    	 /* Added By Minal For Controlling OnRequest Switch Off Case */
			   					    	 if ((onRequestHotelStatus == 1 && !bookable) || bookable)	
			   					    	 checkFlagForRoom = false; }
						     	    } }
					        }
					       }
					    } 
					        }
					    }
			                  var showRTString1 = "showRT1"+hotelIndex; 
			                  if(totalRates == 1)
				     		  roomTypesString += "<tr><td style='border-right:1px solid #7CBCE7'>&nbsp;</td><td style='padding-left:2px'><span style='width:150px;' id = '"+showRTString1+"'  > <font size= '1'><b><span style='margin-bottom: 3px; height: 12px;cursor:pointer;color:#1E90FF'></span></b></font></span></td><td>&nbsp;</td></tr>"
					    	 else
					    	 roomTypesString += "<tr><td style='border-right:1px solid #7CBCE7'>&nbsp;</td><td style='padding-left:2px'><span style='width:150px;' id = '"+showRTString1+"' onclick= 'showAllRoomTypes("+hotelIndex+");' > <font size= '1'><b><span style='margin-bottom: 3px; height: 12px;cursor:pointer;color:#1E90FF'><u>Show all room rates ("+totalRates+")</u></span></b></font><img src="+imgPath+"images/calque_125.gif width='9' height='7' alt='' BORDER=0/></span></td><td>&nbsp;</td></tr>"
					         var allRoomString = getFullRoomTypesTable(hotel,hotelIndex, isLMD);
									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>";
					                         roomTypesString += emptyRow+ "</div></table>" + onRequestIndication + "</td></tr></table>";
					                }
					                else {
					                        if ((totalRoomOnRequest == totalRoomsWithDifferntTariff) && onRequestHotelStatus == 0){  return ""; } // end of if(totalRoomOnRequest == totalRoomsWithDifferntTariff)
					                        else{ roomTypesString += "</table></div></td></tr></table>"; }// end of else(totalRoomOnRequest == totalRoomsWithDifferntTariff
					                }
					              return  roomTypesString += allRoomString;	
}
	function getFullRoomTypesTable(hotel, hotelIndex, isLMD)
		{
		               onRequestTariffsCount = 0;
		                var lowestAvgPrice =hotel['LAP']
		                hotel['rT'].sort(sortRoomTypes);
		                var roomTypes = hotel['rT'];
		                var hotelCode = hotel['HC'];		                              
		                var emptyRow = "<tr><td width=100% colspan=7 bgcolor=#7CBCE7></td></tr>";
		                var allPriceRTString = "allPriceRT"+hotelIndex; // Hotel Index 
		                var totalRoomsWithDifferntTariff = 0;
		                var totalRoomOnRequest = 0;		             
		                checkFlagForRoom = true;   
		                var totalRates = 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['AS']=='R' && onRequestHotelStatus == 1) || tariff['AS']=='B'){		
								   totalRates += 1;
								}   
							 }              
		                  }
		                   var hideRTString = "hideRT"+hotelIndex; 
		                   var allRoomsString = "";
		                   if (totalRates == 1)
			    		   allRoomsString = "<table width=100% cellspacing=0 cellpadding='0' border=0><tr><td width=100%><div id = '"+allPriceRTString+"' style = 'display:none' ><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 = 490 align=left >Room Type<span  style = 'width:150px;' id = '"+hideRTString+"'  > <font size= '1'><span style='margin-bottom: 3px; height: 12px;cursor:pointer; color:#1E90FF' ></span></font></span></td> <td colspan='2' class='table-field-tit'  width = 310  align=left> Average Daily Rate</td></tr>";
		             		else
		             		allRoomsString = "<table width=100% cellspacing=0 cellpadding='0' border=0><tr><td width=100%><div id = '"+allPriceRTString+"' style = 'display:none' ><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 = 490 align=left >Room Type |<span  style = 'width:150px;' id = '"+hideRTString+"'  onclick= 'hideAllRoomTypes("+hotelIndex+");' > <font size= '1'><span style='margin-bottom: 3px; height: 12px;cursor:pointer; color:#1E90FF' ><u>Hide all room rates ("+totalRates+")</u></span></font><img src="+imgPath+"images/calque_125.gif width='9' height='7' alt='' BORDER=0/></span></td> <td colspan='2' class='table-field-tit'  width = 310  align=left> Average Daily Rate</td></tr>";
		               for (var roomTypeCount=0 ; roomTypeCount<roomTypes.length; roomTypeCount++) {		                  
		                        var roomType = roomTypes[roomTypeCount];
		                        var tariffs = roomType['tf'];								
								var promoImgTag="<img src='images/deal-tag.gif'/>";
								var promoImgTagSel="&nbsp;";
								var isPromoHotelTextReqd = false;
								checkFlagForRoom = true;   
		                     for (var tariffCount =0; tariffCount<tariffs.length; tariffCount++){		                      
		                                promoImgTagSel="&nbsp;";
										totalRoomsWithDifferntTariff =totalRoomsWithDifferntTariff +1;										
		                                var tariff = tariffs[tariffCount],  availStatus = tariff['AS'] ,roomTypeRowString = "<TR VALIGN='middle'>" ,
		                                           roomTypeNameCell = "" ,multipleTariffs = tariff['MT'] ,viewAll = tariff['ViewAll'] ,
		                                           packageAvailable = tariff['PA'] , packageFrom = tariff['PF'] ,packageTo = tariff['PT'] ,
		                                           packageNights = tariff['PN'] , displayTaxesSeperately = tariff['DTS'] ,
		                                           baseAdultNum = tariff['BAN'] ,baseAdultTax = tariff['BAT'],
		                                           accomodate=tariff['Acc'], promoText=tariff['PText'];	 
										 		   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['AS']=='R') 
		                                           { 
			                                           totalRoomOnRequest = totalRoomOnRequest+1; 
			                                           tempStatus =1; 
		                                           }	
		                                        	if ((tariff['AS']=='R' && onRequestHotelStatus == 1) || tempStatus == 0){													 
																									
													  	allRoomsString += getLowestAvgPriceData(roomTypes, roomTypeCount , hotelIndex, tariffCount,isLMD);
			   					    				 }
			   					    	/* Added By Minal For Controlling OnRequest Switch Off Case */
			   					    	 	if ((onRequestHotelStatus == 1 && tariff['AS']=='R') ||  tariff['AS']=='B' )	 
		                      					checkFlagForRoom = false; 	                    
		                       }		                      
		                      }
		                var hideRTString1 = "hideRT1"+hotelIndex; 
		                 if (totalRates == 1)
					    allRoomsString += "<tr><td style='border-right:1px solid #7CBCE7'>&nbsp;</td><td  style='padding-left:2px'><span style='width:150px;' id = '"+hideRTString1+"' ><font size= '1'><b><span style='margin-bottom: 3px; height: 12px;cursor:pointer;color:#1E90FF'></span></b></font></span></td><td>&nbsp;</td></tr>"
						else
						 allRoomsString += "<tr><td style='border-right:1px solid #7CBCE7'>&nbsp;</td><td  style='padding-left:2px'><span style='width:150px;' id = '"+hideRTString1+"' onclick= 'hideAllRoomTypes("+hotelIndex+");' ><font size= '1'><b><span style='margin-bottom: 3px; height: 12px;cursor:pointer;color:#1E90FF'><u>Hide all room rates ("+totalRates+")</u></span></b></font><img src="+imgPath+"images/calque_125.gif width='9' height='7' alt='' BORDER=0/></span></td><td>&nbsp;</td></tr>"
						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 allRoomsString +emptyRow+ "</table>" + onRequestIndication + "</td></tr></table>"; }
		                else   {
		                        if((totalRoomOnRequest == totalRoomsWithDifferntTariff) && onRequestHotelStatus == 0){
		                                return "";
		                        } else {
		                        return allRoomsString + "</table></td></tr></table>";
		                        }  } 
		        }
					        
		   function getLowestAvgPriceData(roomTypes , roomTypeCount , hotelIndex, tariffCount, isLMD){  
		   			 var roomType = roomTypes[roomTypeCount]; var tariffs = roomType['tf'];		                   
						   var promoImgTag="<img src='images/deal-tag.gif'/>";   var promoImgTagSel="";		  var tariff = tariffs[tariffCount],		                               
	                       availStatus = tariff['AS'] , roomTypeRowString = "<TR VALIGN='middle'>" ,roomTypeNameCell = "" ,multipleTariffs = tariff['MT'] ,
	                       viewAll = tariff['ViewAll'] , packageAvailable = tariff['PA'] , packageFrom = tariff['PF'] ,packageTo = tariff['PT'] ,
	                       packageNights = tariff['PN'] ,   displayTaxesSeperately = tariff['DTS'] , baseAdultNum = tariff['BAN'] ,
	                       baseAdultTax = tariff['BAT'],  accomodate=tariff['Acc'], promoText=tariff['PText'];		     
		     	 		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['AS']=='R') { tempStatus = 1;  }
                        if ((tariff['AS']=='R' && onRequestHotelStatus == 1) || tempStatus == 0){
                              	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; }// end of if (package From)
                                    else    {
                                             displayYearFrom = "0" + (packageFromDate.getFullYear() - milestoneYear);   }// end of else(package From)
                                    displayPackageFrom = packageFromDate.getDate() + " " + months[packageFromDate.getMonth()] + " " +  displayYearFrom;
                                    var displayYearTo ;
                                    if ( (packageToDate.getFullYear() - milestoneYear) > 10)   {
                                            displayYearTo = packageToDate.getFullYear() - milestoneYear; }// end of if(package to)		                   
                                    else      {
                                            displayYearTo = "0" + (packageToDate.getFullYear() - milestoneYear); }// end of else(package to)
                                    displayPackageTo =  packageToDate.getDate() + " " + months[packageToDate.getMonth()] + " " +  displayYearTo;         }// end of if(package Available)
	                            	var displayTaxesSeperately = tariff['DTS'];	                            	
	                                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 = "<BR/>" + getInclusions(roomType , roomTypeCount , hotelIndex, tariff, tariffCount, isLMD) ;
	                                var selectImg = (tariff['AS']=='B')? selectImageSRC :onRequestImageSRC
	                                var roomTypeCodeDisplay = roomTypes[roomTypeCount]['rTC']
	                                var tariffTypeCodeDisplay = roomTypes[roomTypeCount]['tf'][tariffCount]['TC']
	                                var packageFunction = "changeToPackageDates(\""+ packageFrom+"\" , \""+ packageTo+"\")";
                			if (!(accomodate!="Y" && accomodate!="YES")){
                                if (selectImg==selectImageSRC){
                                        if (packageAvailable=="Y" || packageAvailable=="y")
                                        {if (checkFlagForRoom) var selectImageCell = "<td ALIGN='center' BGCOLOR=#FFFFFF style='padding-left:1px;padding-top:2px;padding-bottom:2px; 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:1px;padding-top:2px;padding-bottom:2px; border-top:1px solid #e5e5e5'><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
                                        {if (checkFlagForRoom)     var selectImageCell = "<td ALIGN='center' BGCOLOR=#FFFFFF style='padding-left:1px;padding-top:2px;padding-bottom:2px; 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
                                           var selectImageCell = "<td ALIGN='center' BGCOLOR=#FFFFFF style='padding-left:1px;padding-top:2px;padding-bottom:2px; border-top:1px solid #e5e5e5'><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")
                                        {if (checkFlagForRoom)  var selectImageCell = "<td ALIGN='center' BGCOLOR=#FFFFFF style='padding-left:1px;padding-top:2px;padding-bottom:2px; 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>";
                                          else
                                           	var selectImageCell = "<td ALIGN='center' BGCOLOR=#FFFFFF style='padding-left:1px;padding-top:2px;padding-bottom:2px; border-top:1px solid #e5e5e5'><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
                                        {	if (checkFlagForRoom) var selectImageCell = "<td ALIGN='center' BGCOLOR=#FFFFFF style='padding-left:1px;padding-top:2px;padding-bottom:2px; 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>";
                                            else
                                              var selectImageCell = "<td ALIGN='center' BGCOLOR=#FFFFFF style='padding-left:1px;padding-top:2px;padding-bottom:2px; border-top:1px solid #e5e5e5'><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)
			                {if (checkFlagForRoom)    var selectImageCell = "<td ALIGN='center' BGCOLOR=#FFFFFF style='padding-left:1px;padding-top:2px;padding-bottom:2px; border-top:1px solid #7CBCE7'>Exceeds number of <br> guests</td>";
			              	else
			              		   var selectImageCell = "<td ALIGN='center' BGCOLOR=#FFFFFF style='padding-left:1px;padding-top:2px;padding-bottom:2px; border-top:1px solid #e5e5e5'>Exceeds number of <br> guests</td>";
			                }
                        	var avgPricePerNight = 1; avgPricePerNight=avgPricePerNight*tariff['APN'];		
            				var discAvgPricePerNight = 1;discAvgPricePerNight=discAvgPricePerNight*tariff['DANP'];
                            var priceCel = "";
                                if (discAvgPricePerNight<avgPricePerNight)
                                {   if (displayTaxesSeperately!="Y")
                                        {		roomTypeNameCell = "<TD ALIGN='left' BGCOLOR=#FFFFFF";
                                        		if (checkFlagForRoom){roomTypeNameCell += " style='border-right:1px solid #7CBCE7;padding-left:10px;padding-top:10px; border-top:1px solid #7CBCE7'><a href='#select' class='text-11-bold' "
                                             	 roomTypeNameCell +="onClick='goToHtlDetails(\""+hotelCode+"\", 5 , "+hotelIndex+")'"
                                             	roomTypeNameCell +=" alt='"+roomType['rTN']+"'>" + roomType['rTN'] + "</A> &nbsp;&nbsp;&nbsp; <font class='orangetext-bold-9'><B>Limited time discount!</B></font> <BR/>" ;
                                       			}else{roomTypeNameCell += "  style='border-right:1px solid #7CBCE7;padding-left:10px;padding-top:10px; border-top:1px solid #e5e5e5 '>";}
                                       			roomTypeNameCell += getInclusions(roomType , roomTypeCount , hotelIndex, tariff, tariffCount, isLMD)+"</TD>";
                                        }
                                        else   {
                                        		roomTypeNameCell = "<TD ALIGN='left' BGCOLOR=#FFFFFF";
                                        		if (checkFlagForRoom){roomTypeNameCell += " style='border-right:1px solid #7CBCE7;padding-left:10px;padding-top:10px; border-top:1px solid #7CBCE7'><a href='#select' class='text-11-bold' "
                                                roomTypeNameCell +="onClick='goToHtlDetails(\""+hotelCode+"\", 5 , "+hotelIndex+")'"
                                               roomTypeNameCell +=" alt='"+roomType['rTN']+"'>" + roomType['rTN'] + "</A>&nbsp;&nbsp;&nbsp;<font class='orangetext-bold-9'><B>Limited time discount!</B></font> <BR/>" ;
                                        	}else{
                                       			roomTypeNameCell += "  style='border-right:1px solid #7CBCE7;padding-left:10px;padding-top:10px; border-top:1px solid #e5e5e5 '>";
                                       			}
                                        roomTypeNameCell += getInclusions(roomType , roomTypeCount , hotelIndex, tariff, tariffCount, isLMD)+"</TD>"; }// end of else(displayTaxesSeperately)
                                }
                                else 
                                {
                                        if (displayTaxesSeperately=="Y")
                                        {		roomTypeNameCell = "<TD ALIGN='left' BGCOLOR=#FFFFFF";
                                        		if (checkFlagForRoom){
                                                        roomTypeNameCell += " style='border-right:1px solid #7CBCE7;padding-left:10px;padding-top:10px; border-top:1px solid #7CBCE7'><a href='#select' class='text-11-bold' "
                                                        roomTypeNameCell +="onClick='goToHtlDetails(\""+hotelCode+"\", 5 , "+hotelIndex+")'"
                                                       roomTypeNameCell +=" alt='"+roomType['rTN']+"'>" + roomType['rTN'] + "</A><BR/>";
                                       				}else{
                                       				roomTypeNameCell += "  style='border-right:1px solid #7CBCE7;padding-left:10px;padding-top:10px; border-top:1px solid #e5e5e5 '>";	}
                                        roomTypeNameCell += getInclusions(roomType , roomTypeCount , hotelIndex, tariff, tariffCount, isLMD)+"</TD>";
                                        }
                                        else   {		roomTypeNameCell = "<TD ALIGN='left' BGCOLOR=#FFFFFF";
                                        		if (checkFlagForRoom){
	                                                roomTypeNameCell += " style='border-right:1px solid #7CBCE7;padding-left:10px;padding-top:10px; border-top:1px solid #7CBCE7'><a href='#select' class='text-11-bold' "
	                                                 roomTypeNameCell +="onClick='goToHtlDetails(\""+hotelCode+"\", 5 , "+hotelIndex+")'"
	                                                roomTypeNameCell +=" alt='"+roomType['rTN']+"'>" + roomType['rTN'] + "</A><BR/>";
                                       			}else{	roomTypeNameCell += "  style='border-right:1px solid #7CBCE7;padding-left:10px;padding-top:10px; border-top:1px solid #e5e5e5 '>";	}
                                        roomTypeNameCell += getInclusions(roomType , roomTypeCount , hotelIndex, tariff, tariffCount, isLMD)+"</TD>";
                                        }
                                }
			                if (discAvgPricePerNight<avgPricePerNight)
			                {  if(promoImgTagSel=="")
			                      {  promoImgTagSel="&nbsp;"}
                                    if (tariff['AS']=='R') {
                                                onRequestTariffsCount += 1;  }
                                        if (packageAvailable=="Y" || packageAvailable=="y")
                                        {			if (checkFlagForRoom)    priceCell = (tariff['AS']=='R')?"<TD width = 210 align='center' class='text-11-bold' BGCOLOR=#FFFFFF style='border-top:1px solid #7CBCE7;padding-top:2px;padding-bottom:2px;'><div style='margin-left:10px;float:left;width:43px'>"+ 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['DANP'])+"</font></B><br><font color='red'>*</FONT></span></center>"+packageMessage+"<BR></div></TD>": "<TD width = 210 align='center' class='text-11-bold' BGCOLOR=#FFFFFF style='border-top:1px solid #7CBCE7;padding-top:2px;padding-bottom:2px;'><div style='margin-left:10px;float:left;width:43px'>"+ promoImgTagSel+"</div><div style='padding-left:10px;float:left;'><span style='font-weight:normal'><B><DEL> " + currency+" "+format(tariff['APN'])+"</DEL></B></SPAN><span class='orangetext-bold-11'><B><br>"+ currency+ " " + format(tariff['DANP'])+"</B></span></center>"+packageMessage+"<BR></div></TD>";
                                       				else
                                       				priceCell = (tariff['AS']=='R')?"<TD  width = 210 align='center' class='text-11-bold' BGCOLOR=#FFFFFF style='border-top:1px solid #e5e5e5;padding-top:2px;padding-bottom:2px;'><div style='margin-left:10px;float:left;width:43px'>"+ 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['DANP'])+"</font></B><br><font color='red'>*</FONT></span></center>"+packageMessage+"<BR></div></TD>": "<TD width = 210 align='center' class='text-11-bold' BGCOLOR=#FFFFFF style='border-top:1px solid #e5e5e5;padding-top:2px;padding-bottom:2px;'><div style='margin-left:10px;float:left;width:43px'>"+ promoImgTagSel+"</div><div style='padding-left:10px;float:left;'><span style='font-weight:normal'><B><DEL> " + currency+" "+format(tariff['APN'])+"</DEL></B></SPAN><span class='orangetext-bold-11'><B><br>"+ currency+ " " + format(tariff['DANP'])+"</B></span></center>"+packageMessage+"<BR></div></TD>";
                                        }
                                        else
                                        {		if (checkFlagForRoom)	priceCell = (tariff['AS']=='R')?"<TD width = 210 align='center' class='text-11-bold' BGCOLOR=#FFFFFF style='border-top:1px solid #7CBCE7;padding-top:2px;padding-bottom:2px;'><div style='margin-left:10px;float:left;width:43px'>"+ 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['DANP'])+"</font></B><br><font color='red'>*</font></span><BR></div></TD>": "<TD width = 210 align='center' class='text-11-bold' BGCOLOR=#FFFFFF style='border-top:1px solid #7CBCE7;padding-top:2px;padding-bottom:2px;'><div style='margin-left:10px;float:left;width:43px'>"+ promoImgTagSel+"</div><div style='padding-left:10px;float:left;'><span style='font-weight:normal'><B><DEL> " +currency+" "+format(tariff['APN']) +"</DEL></B></SPAN><span class='orangetext-bold-11'><B><br>"+ currency+ " " +format(tariff['DANP'])+"</B></span><BR></div></TD>";
                                        		else
                                        			priceCell = (tariff['AS']=='R')?"<TD width = 210 align='center' class='text-11-bold' BGCOLOR=#FFFFFF style='border-top:1px solid #e5e5e5;padding-top:2px;padding-bottom:2px;'><div style='margin-left:10px;float:left;width:43px'>"+ 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['DANP'])+"</font></B><br><font color='red'>*</font></span><BR></div></TD>": "<TD width = 210 align='center' class='text-11-bold' BGCOLOR=#FFFFFF style='border-top:1px solid #e5e5e5;padding-top:2px;padding-bottom:2px;'><div style='margin-left:10px;float:left;width:43px'>"+ promoImgTagSel+"</div><div style='padding-left:10px;float:left;'><span style='font-weight:normal'><B><DEL> " +currency+" "+format(tariff['APN']) +"</DEL></B></SPAN><span class='orangetext-bold-11'><B><br>"+ currency+ " " +format(tariff['DANP'])+"</B></span><BR></div></TD>";
                                        }
			                 }
			                 else   { if(promoImgTagSel=="")
			                      {  promoImgTagSel="&nbsp;"}
		                                         if (packageAvailable=="Y" || packageAvailable=="y")
		                                         {		if (checkFlagForRoom) priceCell = (tariff['AS']=='R')?"<TD width = 210 ALIGN='center'class='text-11-bold' BGCOLOR=#FFFFFF style='border-top:1px solid #7CBCE7;padding-top:2px;padding-bottom:2px;'><div style='margin-left:10px;float:left;width:43px'>"+ promoImgTagSel+"</div><div style='padding-left:10px;float:left;'> " + currency+" "+format(tariff['APN']) +"<br> <font color='red'>*</font></span>" + packageMessage + "</div></TD>": "<TD width = 210 align='center'class='text-11-bold' BGCOLOR=#FFFFFF style='border-top:1px solid #7CBCE7;padding-top:2px;padding-bottom:2px;'><div style='margin-left:10px;float:left;width:43px'>"+ promoImgTagSel+"</div><div style='padding-left:10px;float:left;'>  " +currency+" "+format(tariff['APN']) +"" + packageMessage+"<BR></div></TD>";
		                                       			else
		                                       				priceCell = (tariff['AS']=='R')?"<TD width = 210 ALIGN='center'class='text-11-bold' BGCOLOR=#FFFFFF style='border-top:1px solid #e5e5e5;padding-top:2px;padding-bottom:2px;'><div style='margin-left:10px;float:left;width:43px'>"+ promoImgTagSel+"</div><div style='padding-left:10px;float:left;'> " + currency+" "+format(tariff['APN']) +"<br> <font color='red'>*</font></span>" + packageMessage + "</div></TD>": "<TD width = 210  align='center'class='text-11-bold' BGCOLOR=#FFFFFF style='border-top:1px solid #e5e5e5;padding-top:2px;padding-bottom:2px;'><div style='margin-left:10px;float:left;width:43px'>"+ promoImgTagSel+"</div><div style='padding-left:10px;float:left;'>  " +currency+" "+format(tariff['APN']) +"" + packageMessage+"<BR></div></TD>";
		                                         }
		                                         else
		                                         {	if (checkFlagForRoom)  priceCell = (tariff['AS']=='R')?"<TD width = 210 ALIGN='center' class='text-11-bold' BGCOLOR=#FFFFFF style='border-top:1px solid #7CBCE7;padding-top:2px;padding-bottom:2px;'> <div style='margin-left:10px;float:left;width:43px'>"+ promoImgTagSel+"</div><div style='padding-left:10px;float:left;'>" + currency+" "+format(tariff['APN']) +"<br> <font color='red'>*</span></div></TD>": "<TD width = 210 ALIGN='center' class='text-11-bold' BGCOLOR=#FFFFFF style='border-top:1px solid #7CBCE7;padding-top:2px;padding-bottom:2px;'> <div style='margin-left:10px;float:left;width:43px'>"+ promoImgTagSel+"</div><div style='padding-left:10px;float:left;'>" +currency+" "+format(tariff['APN']) +"<BR></div></TD>";
		                                       		else
		                                       			priceCell = (tariff['AS']=='R')?"<TD width = 210 ALIGN='center' class='text-11-bold' BGCOLOR=#FFFFFF style='border-top:1px solid #e5e5e5;padding-top:2px;padding-bottom:2px;'> <div style='margin-left:10px;float:left;width:43px'>"+ promoImgTagSel+"</div><div style='padding-left:10px;float:left;'>" + currency+" "+format(tariff['APN']) +"<br> <font color='red'>*</span></div></TD>": "<TD width = 210 ALIGN='center' class='text-11-bold' BGCOLOR=#FFFFFF style='border-top:1px solid #e5e5e5;padding-top:2px;padding-bottom:2px;'> <div style='margin-left:10px;float:left;width:43px'>"+ promoImgTagSel+"</div><div style='padding-left:10px;float:left;'>" +currency+" "+format(tariff['APN']) +"<BR></div></TD>";
		                                         }
		                 }
		                     roomTypeRowString +=  roomTypeNameCell  +   priceCell +  selectImageCell + "</TR>";
                   }
		     return roomTypeRowString;
		      }

		  var trackCount = 0;
		  var roomTypeWithMinReqBook = "";
		  var trackCountPromotions = 0;
		  var roomTypeWithMinReqBookPromotions = "";

		  function findRoomTypeWithMinReqBook(roomTypes)
		  {			    	  
				trackCount = 0;
				roomTypeWithMinReqBook = "";
				trackCountPromotions = 0;
		        roomTypeWithMinReqBookPromotions = "";		 	  
		      for (var roomTypeCount=0 ; roomTypeCount<roomTypes.length; roomTypeCount++){
	                	   var roomType = roomTypes[roomTypeCount];
	                       var tariffs = roomType['tf']; 
	                       trackCount = 0;trackCountPromotions= 0;
		               if (roomTypeWithMinReqBook == ""){
				     		 for (var tariffCount =0; tariffCount<tariffs.length; tariffCount++) {			
								 var tariffForComp = tariffs[tariffCount];
				                        var avgPricePerNightForCompLowestPrice = 1;avgPricePerNightForCompLowestPrice = avgPricePerNightForCompLowestPrice*tariffForComp['APN'];
				                     	var discAvgNightPrice = 1; discAvgNightPrice = discAvgNightPrice*tariffForComp['DANP'];
				                    if (trackCount != 2) {	 if (discAvgNightPrice == avgPricePerNightForCompLowestPrice){				                    	                       
					                       if (avgPricePerNightForCompLowestPrice == minAvgPriceRateRequest)
					                       		trackCount = trackCount + 1;
					                       if (avgPricePerNightForCompLowestPrice == minAvgPriceRateBook)
					                       		trackCount = trackCount + 1; }  
				                     else if (discAvgNightPrice < avgPricePerNightForCompLowestPrice){		
				                       		if (discAvgNightPrice == minAvgPriceRateRequest)
					                       		trackCount = trackCount + 1;
					                       if (discAvgNightPrice == minAvgPriceRateBook)
					                       		trackCount = trackCount + 1;				                       		
				                       }	    } 	}
				               	if (trackCount == 2){
				               		roomTypeWithMinReqBook = roomTypeCount+"";	}  	}
				       if (roomTypeWithMinReqBookPromotions == ""){
				     		 for (var tariffCount =0; tariffCount<tariffs.length; tariffCount++)
				    		  {		                       
				                        var tariffForComp = tariffs[tariffCount];
				                        var avgPricePerNightForCompLowestPrice = 1;avgPricePerNightForCompLowestPrice = avgPricePerNightForCompLowestPrice*tariffForComp['APN'];
				                    	var discAvgNightPrice = 1; discAvgNightPrice = discAvgNightPrice*tariffForComp['DANP'];
				                 		var promoText=tariffForComp['PText'];
				               if (promoText!=null && promoText!="")
								{	
				                    if (trackCountPromotions != 2) {	
				                     if (discAvgNightPrice == avgPricePerNightForCompLowestPrice){						                       
				                       if (avgPricePerNightForCompLowestPrice == minAvgPriceRatePromotionsRequest)
				                       		trackCountPromotions = trackCountPromotions + 1;
				                       if (avgPricePerNightForCompLowestPrice == minAvgPriceRatePromotionsBook)
				                       		trackCountPromotions = trackCountPromotions + 1;   }  
				                     else if (discAvgNightPrice < avgPricePerNightForCompLowestPrice){
				                      if (discAvgNightPrice == minAvgPriceRatePromotionsRequest)
				                       		trackCountPromotions = trackCountPromotions + 1;
				                       if (discAvgNightPrice == minAvgPriceRatePromotionsBook)
				                       		trackCountPromotions = trackCountPromotions + 1; } }		
				                  }		   }		 
			               	if (trackCountPromotions == 2){
			               		roomTypeWithMinReqBookPromotions = roomTypeCount+"";	 	} 
				  			}	
		   			  }
		     }		     
		   			   	
		  function calculateMinBookReq(roomTypes)
		  {			
		      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 tariffForComp = tariffs[tariffCount];var promoText=tariffForComp['PText'];
				                        var avgPricePerNightForCompLowestPrice = 1;   avgPricePerNightForCompLowestPrice = avgPricePerNightForCompLowestPrice*tariffForComp['APN'];
				                     	 var discAvgNightPrice = 1; discAvgNightPrice = discAvgNightPrice*tariffForComp['DANP'];
		                               if(tariffForComp['AS']=='B'){   
		                              	if (discAvgNightPrice == avgPricePerNightForCompLowestPrice){		                               			                            
		                               			if (minAvgPriceRateBook == 0)
		                                         	minAvgPriceRateBook = avgPricePerNightForCompLowestPrice;
		                                         else{if(minAvgPriceRateBook > avgPricePerNightForCompLowestPrice){
		                                         		minAvgPriceRateBook = avgPricePerNightForCompLowestPrice;}
		                               			} 
				                               	if (promoText!=null && promoText!="")
											   	{	if (minAvgPriceRatePromotionsBook == 0)
			                                         	minAvgPriceRatePromotionsBook = avgPricePerNightForCompLowestPrice;
			                                         else{
			                                         	if(minAvgPriceRatePromotionsBook > avgPricePerNightForCompLowestPrice){
			                                         	    minAvgPriceRatePromotionsBook = avgPricePerNightForCompLowestPrice;	}
			                               				}			                               			
			                               			}
		                               		}
		                               		else if (discAvgNightPrice < avgPricePerNightForCompLowestPrice){
		                               			if (minAvgPriceRateBook == 0)
		                                         	minAvgPriceRateBook = discAvgNightPrice;
		                                         else{if(minAvgPriceRateBook > discAvgNightPrice){
		                                         		minAvgPriceRateBook = discAvgNightPrice;}
		                               			}  
				                               	if (promoText!=null && promoText!="") 	{		   		
													if (minAvgPriceRatePromotionsBook == 0)
			                                         	minAvgPriceRatePromotionsBook = discAvgNightPrice;
			                                         else{if(minAvgPriceRatePromotionsBook > discAvgNightPrice){
			                                         	    minAvgPriceRatePromotionsBook = discAvgNightPrice;}
			                               				} 			                               			
			                               			}
		                               		}
				                       	 }
					                   if(onRequestHotelStatus != 0){
			                               if(tariffForComp['AS']=='R'){  
			                               	if (discAvgNightPrice == avgPricePerNightForCompLowestPrice){
			                               			if (minAvgPriceRateRequest == 0) minAvgPriceRateRequest = avgPricePerNightForCompLowestPrice;
			                                         else{if(minAvgPriceRateRequest > avgPricePerNightForCompLowestPrice){	minAvgPriceRateRequest = avgPricePerNightForCompLowestPrice;}
			                                         	}
						                           	if (promoText!=null && promoText!="") {		   		
													if (minAvgPriceRatePromotionsRequest == 0)minAvgPriceRatePromotionsRequest = avgPricePerNightForCompLowestPrice;
			                                         else{
			                                         	if(minAvgPriceRatePromotionsRequest > avgPricePerNightForCompLowestPrice)  	{
			                                         	    minAvgPriceRatePromotionsRequest = avgPricePerNightForCompLowestPrice;  	}
			                               			}	}}
		                               		else if (discAvgNightPrice < avgPricePerNightForCompLowestPrice){
		                               			if(minAvgPriceRateRequest == 0)
			                                         	minAvgPriceRateRequest = discAvgNightPrice;
			                                         else{
			                                         	if(minAvgPriceRateRequest > discAvgNightPrice){
			                                         		minAvgPriceRateRequest = discAvgNightPrice;}//end of if
			                               			} 
						                           	if (promoText!=null && promoText!="")   {		   		
													if (minAvgPriceRatePromotionsRequest == 0)
			                                         	minAvgPriceRatePromotionsRequest = discAvgNightPrice;
			                                         else{if(minAvgPriceRatePromotionsRequest > discAvgNightPrice){
			                                         	    minAvgPriceRatePromotionsRequest = discAvgNightPrice;}//end of if
			                               			}
			                               		}
		                               		}}
				                       	 }
				               	} }
							}
		     
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'><div><ul class='lowerrateG'><li>The \"<strong>Lowest Hotel Rate Guarantee</strong>\" 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>This offer is valid for all hotels marked with the <strong>LOWEST RATE GUARANTEE</strong> stamp.</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. The minimum per night difference should be of Rs. 200 or more in order to qualify for the claim.</li><li>MakeMyTrip 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 normally 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><li>If an individual makes multiple bookings under the same or different guest names, all the bookings will be considered as one booking. In such cases, only one free night will be given to the individual on the multiple bookings made.</li><li>The first night free will be given on bookings for stay of two nights or more. If the stay is for one night then 50% refund for the booking will be given.</li><li>This offer can not be combined with any other offer or promotion.</li><li>MakeMyTrip\'s decisions on all claims under this offer shall be final and binding.</li><li>All disputes shall be subject to Delhi jurisdiction only.</li><li>MakeMyTrip reserves the right to terminate this offer at any time without notice.</li></ul> </div></td></tr></table></td></tr></table>";
	}
}
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]['HC'];
		if (code==hotelCode){
			return hotelCount;
		}
	}
	return -1;
}
function takeToReviewPage(hotelDisplayIndex , roomTypeCode , tariffTypeCodeDisplay , multipleTariffs , checkInDate , checkoutDate , DisplayTaxesSeperately , availStatus,tariffIndex){

	var gdsHotel = hDD[hotelDisplayIndex]['GDS'];
	var gdsHotelCode = hD[hotelDisplayIndex]['GDSC'];
	var gdsName = hD[hotelDisplayIndex]['GDSN'];
	var hotelCode = hDD[hotelDisplayIndex]['HC'];
	var hotelName =  hDD[hotelDisplayIndex]['HN'];
	var starRating =  hDD[hotelDisplayIndex]['SR'];
	var MMTRecom =  hDD[hotelDisplayIndex]['Rec'];

	var tariffCode = tariffTypeCodeDisplay;
	var htlDesc = hDD[hotelDisplayIndex]['HD'];
	var htlArea = hDD[hotelDisplayIndex]['A'];
	document.hotelsListingForm.HtlDesc.value = htlDesc;
	document.hotelsListingForm.HtlArea.value = htlArea;
	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]['HI'];
	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]['HPI'] ;
	document.hotelsListingForm.ImgURL.value = img;
	var chkIn =  hDD[hotelDisplayIndex]['CIT'];
	var chkOut =  hDD[hotelDisplayIndex]['COT'];
	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, tariff, tariffCount, isLMD){



		
	var inclusionString = "<table width = '100%' cellpadding=5 cellspacing=0 valign='middle'>";
		                
						var tariffs = roomType['tf'];
		                var shownInclusionCount = 0;
		                var tariff = tariffs[tariffCount];
		                var dayPrices = tariff['dP'];
		                var multipleTariff = tariff['MT'];
		                var viewAll = tariff['ViewAll'];
						var result = 0;
						
						var hotelCode = roomType['HC'];
						
						inclusionString = inclusionString + "<tr><td width= 138 valign = 'top'><font color= '#342D7E' size = '1'> >> <b>  Inclusions: </b><font></td><td>&nbsp;</td>";
		 				inclusionString = inclusionString + "<td  width= 352>";
		 				
		 				
		 				var inclusionStringCopy = inclusionString ;
		 			if(isLMD){
						for (var dayPriceCnt=0; dayPriceCnt<dayPrices.length; dayPriceCnt++) {						
					
						
						 var tempDayPrice = dayPrices[0];
						 var tempMealPlan = tempDayPrice['DPMP'];
						
												
						 if (tempMealPlan == 'Last Minute Special Rate'){
							if (dayPrices.length>=1 && dayPrices[0]['DayPriceInclusions'].length>0)
		                	{
		                        inclusionString += "<font color='red'>" + tempMealPlan+"!"+"</font>";
		                	}
		                	else
		                	{
		                        inclusionString += "<font color='red'>" + tempMealPlan+"!"+"</font>";
		                	}
							result = 1;
							 break;		
							}						
						}					
				
						if (tariff['MP'] == 'Last Minute Special Rate'){
							result = 1;
						}
						}
						if (result == 0){						
							
		                	if (dayPrices.length>=1 && dayPrices[0]['DPI'].length>0)
		                	{
		                			if (inclusionStringCopy != inclusionString){		                					                			
		                              		inclusionString = inclusionString + ", ";
		                              	}
		                                inclusionString +=  ""+tariff['MP'];
		                             
		                	}
		                	else
		                	{
		                		if (inclusionStringCopy != inclusionString)
		                			inclusionString = inclusionString + ", ";
		                       		inclusionString += tariff['MP'];		                       	
		                	}
		           
		       			}
		       				       		
		       			
		       			if (dayPrices.length< 1)
							inclusionString = inclusionString +".";	
		       			
		       			
		              if(dayPrices.length>=1)
		                {
		                        var dayPrice = dayPrices[0];
		                        var dayPriceInclusions = tariff['Inc'];
		                       for (var dayPriceInclusionCount = 0; dayPriceInclusionCount<dayPriceInclusions.length; dayPriceInclusionCount++)
		                        {		
		                                shownInclusionCount += 1;
		                               if (shownInclusionCount<= maximumInclusionsToShow)
		                                { 		
		                                        var inclusion = ""+dayPriceInclusions[dayPriceInclusionCount];
		                                        if ((result == 0 || result == 1) &&(inclusion != '.') &&(inclusion != '..'))
		                                        {
		                                			inclusionString = inclusionString + ", ";
		                                       		 inclusionString += inclusion ;
		                                       	 }
		                                }
		                        }
		                }
		                		                
		          
		                
		                inclusionString = inclusionString + ".";		                
		                inclusionString = inclusionString + "</td></tr>";
		                  if (shownInclusionCount > maximumInclusionsToShow)
		                {
		                        var togglerId = hotelIndex +":"+roomTypeCount;
		                        roomTypeCount=roomType['rTI'];
		                     
		                       inclusionString += '<tr valign="top"><td  width= 138 valign = "top">&nbsp;</td><td>&nbsp;</td><td width= 352 style="padding: 4px;"><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  width= 138 valign = "top">&nbsp;</td><td>&nbsp;</td><td width= 352 style="padding: 4px;"><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>"
		                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]['HC']
	hotelIndex = getHotelIndex(hotelCode);

	try {
		reqObj = new window.XMLHttpRequest();
		if(reqObj.overrideMimeType) {
		}
	} catch(e) {
		reqObj = new ActiveXObject("Msxml2.XMLHTTP");
	}
	var timeInc=new Date();
	reqObj.open("Get" , "jsp/getInclusions.jsp?hotelIndex="+hotelIndex+"&ROOM_TYPE_COUNT="+roomTypeCount+"&TARIFF_COUNT="+tariffCount+"&time="+timeInc, false);
	reqObj.send(null);
	while (reqObj.readyState!=4)    {}
	var ajxResponse= reqObj.responseText;	
	var myObject = eval('(' + ajxResponse + ')');
	var tableData = myObject.bindings;	
	var sessionResult = tableData[0].SessionExpired;
	if(sessionResult == true){	
		document.hotelsListingForm.action="sessionExpired.do";
		document.hotelsListingForm.method = "Post";
		document.hotelsListingForm.submit();
	}
	
	
  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] = formatAsNumber(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] = formatAsNumber(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) {
		}
	} catch(e) {
		inclusionsRequest = new ActiveXObject("Msxml2.XMLHTTP");
	}
	var hotelCode = hDD[hotelIndex]['HC'];
	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 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['P'];
			dayInclusionArray[len][1] = dayPrice['DPMP'];
			var dayPriceInclusions = dayPrice['DPI'];
			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){

	var hotelName = hDD[hotelIndex]['HN'];
	var chkIn =  hDD[hotelIndex]['CIT'];
	var chkOut =  hDD[hotelIndex]['COT'];
	document.hotelsListingForm.ChkInTime.value = chkIn;
	document.hotelsListingForm.ChkOutTime.value = chkOut;
	var GDSHotelCode = hDD[hotelIndex]['GDSC'];
	var GDSName = hDD[hotelIndex]['GDSN'];
	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]['HI'];
	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]['SR']);
	}
	catch (e){}
	var starRating5 = starRatingBoxes[0];
	var starRating4 = starRatingBoxes[1];
	var starRatingBelow3 = starRatingBoxes[2];

	if (starRating5.checked==true && rating==5){
		return true;
	}
	else if (starRating4.checked==true && rating==4){
		return true;
	}
	else if (starRatingBelow3.checked==true && 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){
	var hotelName = hD[hotelIndex]['HN'];
	var hotelNameString = document.getElementById("hotelNameString").value.toUpperCase();
	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 filterOnSubmit(srFlag, hnFlag){
	var filteredHotelDetails = new Array();
	var givenHotelSubstring = document.getElementById("hotelNameString").value;

	for (var hotelCount=0; hotelCount<hD.length; hotelCount++){
		if (hnFlag==false && srFlag==false){
			filteredHotelDetails[filteredHotelDetails.length] = hD[hotelCount];
		}
		else if (hnFlag==true && srFlag==true){
			setCookie("htlName",document.getElementById("hotelNameString").value,1);
			if (checkStarRating(hotelCount) && filterHotelName(hotelCount)){
				filteredHotelDetails[filteredHotelDetails.length] = hD[hotelCount];
			}
		}
		else if (hnFlag==true){
			setCookie("htlName",document.getElementById("hotelNameString").value,1);
			if (filterHotelName(hotelCount)){
				filteredHotelDetails[filteredHotelDetails.length] = hD[hotelCount];
			}
		}
		else if (srFlag==true){
			if (checkStarRating(hotelCount)){
				filteredHotelDetails[filteredHotelDetails.length] = hD[hotelCount];
			}
		}
	}

	hDD = filteredHotelDetails;
	totalPages =  Math.ceil( hDD.length / hotelsPerPage);
	sortByAttribute("MMTRecom", true);
}
function filter(){
	var filteredHotelDetails = new Array();
	var givenHotelSubstring = document.getElementById("hotelNameString").value;

	if(firstTimeResultsShowing == false){
		showFilteredResult(tempstartPriceSlab, tempendPriceSlab, tempstarRating, tempisPriceflag,rowNumber, columnNumber);
	}
	else{
		filterHotelChain();
		var amenities = document.getElementsByName("FilterAmenities");
		for (var hotelCount=0; hotelCount<hD.length; hotelCount++){
			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.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", false);
		}
		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'/>";
	}
	for (var ratingCount=(rating/1+1); ratingCount<=maxRating; ratingCount++){
		starRatingString += "<IMG SRC="+imgPath+"images/star_off.gif width='13' height='12'/>";
	}
	starRatingString += "";
	return starRatingString;
}
function getDescriptionTable(hotel, hotelIndex, mmtRecommended, isGDSHotel){
	var hotelPrimImg = HotelPath + hotel['HPI'];
	var gdsHotel = hotel['GDS'];
	var gdsHotelCode = hotel['GDSC'];
	if(isGDSHotel)
		hotelPrimImg=PegasusPath+gdsHotelCode.replace(";","/")+"/"+hotel['HPI'];
	var lowestAvgPrice = hotel['LAP'];
	var hotelName =  hotel['HN'];
	var hotelCode = hotel['HC'];
	var areaCell = "<TD width='98px' valign='top'>";
	var area = hotel['A'];
	if(area!="")
		areaCell+="<B> Area:<BR> " + area + "</B>";

	var mapLinkRow = "";
	if (hotel['La']!="" && hotel['Lo']!=""){
		mapLinkRow = "<TR valign='top'><TD><IMG SRC="+imgPath+"images/map_icon.gif align='top'></TD><td><a href='#select' onClick='goToHtlDetails(\""+hotelCode+"\", 3, " +hotelIndex+")'>Map This Property</a></TD></tr>";
	}
	else if(!isGDSHotel){
		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+"<TR  valign='top'><TD><img src="+imgPath+"images/morephotos-icon.gif align='top' width='20' height='12' alt='' /></TD><TD><a href='#select' onClick='goToHtlDetails(\""+hotelCode+"\", 2 , "+ hotelIndex+")'>More Photos</a></TD></TR>";
	if(hotel['HVC']>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' onClick='setDefaultTab(\""+hotelCode+"\", 2 , "+ hotelIndex+",1)'><strong>Video Tour</strong></a></TD></TR>";
	}
	areaCell+="</TABLE></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>";
	if(!isGDSHotel) {
		var displayLowestAvgPrice = formatAsNumber(lowestAvgPrice);
		if(displayLowestAvgPrice.length<=5){
			if(mmtRecommended){
        var cell4 = "<TD align='right' bgcolor='white'> <table width='140' class=blue-border id='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'><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(mmtRecommended){
				var cell4 = "<TD align='right' bgcolor='white'> <table width='135' height=100% class=blue-border id='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'><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>";
			}
		}
	} else 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['FF'];
		fareTo=hotel['FT'];
		if (fareFrom!=null && fareTo!=null){
			var cell4 = "<TD> <table width='135' height=100% class=blue-border id='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>";
		}
	}
	var amenityString = "<TD valign='top'>" + getAmenityString(hotel, hotelIndex, isGDSHotel) + "</TD>";
	var travellerRatingCell = "<TD ALIGN='center' width='65px' VALIGN='top'>" + getTravellerRating(hotel, hotelIndex, isGDSHotel) + "</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 descriptionTableString = "<TABLE WIDTH='100%' CELLSPACING=0 cellpadding=0 BORDER=0><TR VALIGN=TOP><TD><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>" +cell4+ "</TR></TABLE>";
	return descriptionTableString;
}
function getTravellerRating(hotel, hotelIndex, isGDSHotel){
	var hotelCode = hotel['HC'];
	var travellerRatingString = "";
	var travellerRating = hotel['TR'];
	if (travellerRating.length==0 && !isGDSHotel){
		travellerRatingString = "<b><SPAN STYLE='font-size:9px'>No Reviews Available</span></b>";
	}
	else if(!isGDSHotel || travellerRating!="0"){
		var totalReviews =  hotel['RC'];
		travellerRatingString += "<b>Traveler<br>Rating:<br><span class=text-bold-19>"+travellerRating+"</span><br/>out of 5</b><br/><a href='#select' onClick='goToHtlDetails(\""+hotelCode+"\", 4 , "+ hotelIndex+")'>"+ totalReviews+" User<br/> Reviews</a>";
	}
	return travellerRatingString;
}
function getAmenityString(hotel, hotelIndex, isGDSHotel){
	var hotelAmenities = hotel['hA'];

	var amenitiesShown = 0;
	var amenityString ="<div><Table width='131px'>";
	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>" + 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' onClick='goToHtlDetails(\""+hotel['HC']+"\", 1 , "+ hotelIndex+" , \"Amenities\")'>View All Amenities</a></td></tr>";
	}
	if(amenitiesShown==0){
		amenityString += "<TR valign=top style='vertical-align:top'><TD colspan=2 nowrap valign=top>";
		if(!isGDSHotel)
			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 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='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>";
	if(propertyTypeSpan!=null)
		propertyTypeSpan.innerHTML = propertyTypeString;
}
function filterProperties(hotelCount){
	var hotelsToShow = new Array();
	var propertyTypes = document.getElementsByName("FilterProperties");
	var propertyType = hD[hotelCount]['PT'];
	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]['HL'];
	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 += "</TABLE>";
	filterAmenitiesSpan.innerHTML = filterAmenitiesString;
}
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);
}

function getDistinctChains(){
	if(hCF.length>1)
		hCF = hCF.removeDuplicates();
	return;
}
function filterChains(hotelIndex){
	var hotelChain = hD[hotelIndex]['Chain'];
	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.DANP);
	var y = parseFloat(b.DANP);
	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 sortTariffsByPackage(a , b){
	var package1 = a.PA;
	var package2 = b.PA;
	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 formatAsNumber(number){
	number = number + "";
	x = number.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}
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";
}
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 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;
	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", false);
	}
	else if(document.forms[1].sort[1].checked){
		sortByAttribute("StarRating", false);
	}
	else if(document.forms[1].sort[2].checked){
		sortByAttribute("LowestAvgPrice", false);
	}
}

var flagFilter = false;
var tempHdArr = new Array();

function showFilteredResultAreaGrid(startPriceSlab, endPriceSlab, starRating, isPriceflag, rowNum, colNum){
	rowNumber = rowNum;
	columnNumber = colNum;
	tempstartPriceSlab = startPriceSlab ;
	tempendPriceSlab  =endPriceSlab;
	tempstarRating = starRating;
	tempisPriceflag = isPriceflag;
	firstTimeResultsShowing = false;

	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]['PT'];
			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", false);
	}
	else if(document.forms[1].sort[1].checked){
		sortByAttribute("StarRating", false);
	}
	else if(document.forms[1].sort[2].checked){
		sortByAttribute("LowestAvgPrice", false);
	}
}
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]['SR']);
	if (starRating == rating ) return true;
	else return false;
}
function isSamePriceSlab(hotelIndex, startPriceSlab, endPriceSlab){
	var isSameSlab =false;
	var price = parseInt(hD[hotelIndex]['LAP']);
	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['AS']=='R'){
				// do nothing.
			} else {
				availableRoomsWithTariff = availableRoomsWithTariff +1;
			}
		}
	}
	if(onRequestHotelStatus == 1) {
		availableRoomsWithTariff =1;
	}
	return availableRoomsWithTariff;
}
function highlightAreaPriceCol(var1,var2,var3){
	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';
		}
	}
	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++ ){
		if(temphotelList[count]['OR'] == 1){
			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);
  }
}