var hotelPerPage = 40;
var dataLength = 1;
var priceRateArray = new Array('1550', '770', '390', '190', '0', '0');
var priceRateTo = new Array('99999', '1550', '770', '390', '190', '99999');
var hotelArray = new Array();
var starRateArray = new Array('5', '4', '3', '2', 'All');
var starTabArray =  new Array();
var hotelFilterArray = new Array();
var hotelPriceArray = new Array(0, 0, 0, 0, 0, 0, 0);
var hotelSortArray = new Array();

function selectSortBy(sortType) {
	location.href = sortType;
}

function clearVariable() {
	top.page = 1;
	top.alphabet = 'All';
	top.price = 0;
	top.star = 0;
	top.area = 'All';
}

function hotelList(url) {
	top.url = url;
	var xmlHttp;
	try { 
		xmlHttp=new XMLHttpRequest();
	} catch (e) { 
		try	{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			if (xmlHttp.status < 400) {
				httext = xmlHttp.responseText;

				tempArray=xmlHttp.responseText.split("\n");
				top.dataLength = tempArray.length;
				for (index = 0; index < top.dataLength; index++) {
					top.hotelArray[index] = tempArray[index].split("\t");
				}
				for (index = 0; index < hotelArray[0].length; index++) {
					top.hotelArray[top.dataLength - 1][index] = CRates(5, top.hotelArray[8][index], top.hotelArray[7][index], 0);
				}
				
			}
			try {
				top.hotelArray[0][0];
			}
			catch (e) {
				top.hotelArray[0] = new Array();
			}
			
			var hotelTotal = top.hotelArray[0].length;
				
			for (index = 0; index < priceRateArray.length; index++) {
				var priceFrom = parseFloat(priceRateArray[index]);
				var priceTo = parseFloat(priceRateTo[index]);
				var hasHotel = 0;
				
				var indexHotel = hotelTotal;
				for (subIndex = 0; subIndex < indexHotel; subIndex++) {
					var hotelMinRate = parseFloat(top.hotelArray[top.dataLength - 1][subIndex]);
					
					if (hotelMinRate > priceFrom && hotelMinRate <= priceTo) {
						hasHotel = 1;
						indexHotel = subIndex;
					}
				}
				hotelPriceArray[index] = hasHotel;
			}
			
			setTimeout("hotelPage(top.sortBy)", 0);
		}
	}
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

function tabAlphabet() {
	var indexAlphabet = 0;
	var alphabetArray = new Array();
	hotelTotal = top.hotelArray[0].length;
	var displayByAlphabet = '';
	displayByAlphabet = '<div ID="sortby_menuBottom" CLASS="clearfix"><div class="red11">';
	if (hotelTotal != 0) {
		alphabetArray[0] = top.hotelArray[0][0].charAt(0).toUpperCase();
		
		for (index = 1; index < top.hotelArray[0].length; index++) {
			if (top.hotelArray[0][index].charAt(0).toUpperCase() != alphabetArray[indexAlphabet]) {
				indexAlphabet++;
				alphabetArray[indexAlphabet] = top.hotelArray[0][index].charAt(0).toUpperCase();
			}
		}
		for (index = 0; index < alphabetArray.length; index++) {
			if (alphabet != alphabetArray[index]) {	
										displayByAlphabet += '<a class="lgray11_33cc33"  href="javascript:divideByAlphabet(\'' + alphabetArray[index] + '\')">';
			} else {				displayByAlphabet += '<b>';	}
										displayByAlphabet += alphabetArray[index];
			if (alphabet != alphabetArray[index]) {
										displayByAlphabet += '</a>';
			} else {				displayByAlphabet += '</b>';	}
										displayByAlphabet += '&nbsp; ';
			if (index != (alphabetArray.length - 1)) {
										displayByAlphabet += '<span style="color:#000000">| &nbsp;</span>';
			}
		}
		displayByAlphabet += '<span style="color:#000000">|</span>&nbsp;';
		if (alphabet != 'All') {	displayByAlphabet += '<a class="lgray11_33cc33" href="javascript:divideByAlphabet(\'All\')">'; }
		else {						displayByAlphabet += '<b>';	
		}
										displayByAlphabet += 'All Name';
		if (alphabet != 'All') {	displayByAlphabet += '</a>';	}
		else {						displayByAlphabet += '</b>';	}
	}
	else{displayByAlphabet += '&nbsp;';}
	displayByAlphabet += '</div></div>';
	return displayByAlphabet;
}

function printStarRating(starRating) {
	var text = '';
	
	for (i = 1; i <= Math.ceil(starRating); i++) {
		text += '<img src="/images/icon/';
		if (i > starRating) {
			text += 'halfstar.gif';
		} else {
			text += 'fullstar.gif';
		}
		text += '">';
	}

	return text;
}

function printHead() {
	var text = '';
	text += '<div CLASS="city_Topline">';
	text += '		<div STYLE="width:730px; float:left; padding:6px; " class="gray12_33">';
	text += '			<img alt="popular hotel" src="/images/icon/pop03.gif" border="0" > : Popular';
	text += '			<img alt="special promotion" src="/images/icon/promo02.gif" border="0" > : Special Promotion';
	text += '			<img alt="Instant Confirmation" src="/images/icon/instantconfirm.gif" border="0" > : Instant Confirmation';
	text += '			<img alt="New Hotel" src="/images/icon/ic_new-hotel.gif" border="0" > : New Hotel';
	text += '		</div>';
	text += '</div>';
	
	return text;
}

function printTitle() {
	var text = '';
	/*text += '<div ID="list_title" CLASS="clearfix">';
	text += '	<div CLASS="list_hotelname">Hotel Name</div>';
	text += '	<div CLASS="list_120">&nbsp;</div>';
	text += '	<div CLASS="list_100">Rates</div>';
	text += '	<div CLASS="list_100">Rating</div>';
	text += '</div>';*/
	
	return text;
}

function printTable(table, index) {
	var text = '';
	
	text += '			<li>';
	text += '				<div CLASS="citylist-hotelL">';
	text +='<img src="/Images/Icon/icon_arrow.gif"width="7" height="9" alt="">'
	text += '					<a href="' + eval('top.' + table + '[1][' + index + ']') + '"  class="black12-red_none" title="' + eval('top.' + table + '[0][' + index + ']') + ', ' + cityName + '"' + '>' + eval('top.' + table + '[0][' + index + ']').substring(0, 30);
	if(eval('top.' + table + '[0][' + index + ']').length > 30){text +='...';}
	text += '					</a>';
	if (eval('top.' + table + '[3][' + index + ']') == 1) {
		text += '&nbsp;<img src="/images/icon/pop03.gif" width="16" border="0" style="border-color:DDDDDD" alt="' + eval('top.' + table + '[0][' + index + ']') + ' is popular hotel">'
	}	else {
		text += '&nbsp;';
	}
	if (eval('top.' + table + '[4][' + index + ']') == 1) {
		text += '&nbsp;<img src="/images/icon/promo02.gif" width="16" border="0" style="border-color:DDDDDD" alt="Special Promotions">';
	}	else {
		text += '&nbsp;';
	}
	if (eval('top.' + table + '[5][' + index + ']') == 1) {
		text += '&nbsp;<img src="/images/icon/instantconfirm.gif" width="15" border="0" style="border-color:DDDDDD" alt="Instant Confirmation">';
	}	else {
		text += '&nbsp;';
	}
	if (eval('top.' + table + '[6][' + index + ']') == 1) {
		text += '&nbsp;<img src="/images/icon/ic_new-hotel.gif" alt="New Hotel" align="absmiddle">';
	}	else {
		text += '&nbsp;';
	}
	text += '				</div>';
	text += '				<div CLASS="citylist-hotelR">';
	if (eval('top.' + table + '[7][' + index + ']') != 1) {
		text += 					CRates(getCurr(), eval('top.' + table + '[8][' + index + ']'), eval('top.' + table + '[7][' + index + ']'), 1);
	} else {
		text += '';
	}
	text += '				</div>';
	text += '			</li>';

	return text;
}
function divideByAlphabet(text) {
	var hotelTotal = top.hotelArray[0].length;
	
	top.alphabet = text;

	if (text != 'All') {
		var hotelListArray = new Array(1);
		var countIndex = 0;
		
		for (subIndex = 0; subIndex < top.dataLength; subIndex++) {
			hotelListArray[subIndex] = '';
		}

		for (index = 0; index < hotelTotal; index++) {
			if (top.hotelArray[0][index].charAt(0).toUpperCase() == text) {
				for (subIndex = 0; subIndex < top.dataLength; subIndex++) {
					hotelListArray[subIndex] += top.hotelArray[subIndex][index] + '\t';
				}
				countIndex++;
			}
		}
		
		for (subIndex = 0; subIndex < top.dataLength; subIndex++) {
			top.hotelFilterArray[subIndex] = hotelListArray[subIndex].split('\t');
			top.hotelFilterArray[subIndex].length = countIndex;
		}
	}
	divideByPageNo(1);
}

function tabPageNo(itemTotal, pageTotal, itemFrom, itemTo) {
	if (itemTotal == 0) {
		itemFrom = 0;
		itemTo = 0;
	}
	var displayByPageNo = '';
	displayByPageNo += '<div STYLE=" clear:both"></div>';
	displayByPageNo += '<div ID="bgLightRed">';
	displayByPageNo += '		<div STYLE="float:left; " CLASS="txtBlack11">';
	displayByPageNo += '		<b>&nbsp;Result : </b> ' +'<SPAN class="red11">'+ itemTotal+ '</SPAN>'+ ' &nbsp;<B>Hotels Found</B>';
	displayByPageNo += '		</div>';
	displayByPageNo += '		<div STYLE="float:right; text-align:right; " CLASS="txtBlack11">';

	displayByPageNo += '			Display hotels&nbsp;' + itemFrom + ' - ' + itemTo + ' of ' + itemTotal;
	if (page != 1) {
		displayByPageNo += '			&nbsp;&nbsp;';
		displayByPageNo += '		<a href="javascript:divideByPageNo(' + (page - 1) + ')" CLASS="txtbrown11">&lt; Previous</a>';
	}
	if (page != pageTotal && itemTotal != 0) {
		displayByPageNo += '			&nbsp;&nbsp;';
		displayByPageNo += '		<a href="javascript:divideByPageNo(' + (page + 1) + ')" CLASS="txtbrown11">Next &gt;</a>';
	}
	displayByPageNo += '			&nbsp;&nbsp;';
	displayByPageNo += '		</div>';
	displayByPageNo += '</div>';
	
	return displayByPageNo;
}

function divideByPageNo(page) {
	top.page = page;
	
	var table = '';
	var tab = '';	
	var type = 0;

	switch(sortBy) {
		case 1 :	table = (alphabet != 'All') ? 'hotelFilterArray': 'hotelArray';
						tab = tabAlphabet();
						type = 0;
						break;
		case 2 :	table = 'hotelFilterArray';
						tab = tabPrice();
						type = 1;
						break;
		case 3 :	table = (starRateArray[top.star] != 'All') ? 'hotelFilterArray': 'hotelArray';
						tab = tabStar();
						type = 2;
						break;
		case 4 :	table = (area != 'All') ? 'hotelFilterArray' : 'hotelArray';
						tab = tabArea();
						type = 0;
						break;
		case 5 :	table = 'hotelFilterArray';
						tab = tabPromotion();
						type = 0;
						break;
	}
	
	sortProcess(table, type);
	
	var hotelTotal = eval('top.' + table + '[0].length');
	
	var pageTotal = Math.ceil(hotelTotal / hotelPerPage);
	var pageMod = hotelTotal % hotelPerPage;
	
	var hotelFrom = (top.page - 1) * hotelPerPage;
	var hotelTo = hotelFrom + hotelPerPage;
	
	if (top.page == pageTotal && hotelTotal != hotelPerPage && hotelTotal != hotelTo) {
		hotelTo = hotelFrom + pageMod;
	}
	
	var displayHotelList = printHead() + tabPageNo(hotelTotal, pageTotal, hotelFrom + 1, hotelTo) + printTitle();
	if (hotelTotal != 0) {
		displayHotelList += '<div class="city_Topline">';
		
		if(hotelFrom < Math.ceil((hotelFrom+hotelTo)/2)){
			displayHotelList += '	<DIV class="citylist-hotel"><ul>';
			for (index = hotelFrom; index < Math.ceil((hotelFrom+hotelTo)/2); index++) {
				displayHotelList += printTable(table, top.hotelSortArray[type][index]);
			}
			displayHotelList += '	</ul></DIV>';
		}
			displayHotelList += '	<DIV class="citylist-hotel"><ul>';
			for (index = Math.floor((hotelFrom + 1 + hotelTo)/2); index < hotelTo; index++) {
				displayHotelList += printTable(table, top.hotelSortArray[type][index]);
			}
			if(hotelTo%2 == 1){
				displayHotelList += '<li><div CLASS="citylist-hotelR"></DIV></li>';
			}
			displayHotelList += '	</ul></DIV>';
			
		displayHotelList += '</div>';
	}
	tabSortBy();
	if (hotelTotal != 0){
		document.getElementById('ListHotel').innerHTML= tab + '' + displayHotelList + tabPageNo(hotelTotal, pageTotal, hotelFrom + 1, hotelTo);
	}
	else{
		document.getElementById('ListHotel').innerHTML= tab + '' + displayHotelList;
	}
}

function tabPrice() {
	var priceTitleArray = new Array('<B>1,550</B> HKD up', '<B>770-1,550</B> HKD', '<B>390-770</B> HKD', '<B>190-390</B> HKD', 'Under <B>190</B> HKD', 'All Price');
	
	var divideByPrice = '<div ID="sortby_menuBottom" CLASS="clearfix">																							<div class="red11">';
	for (index = 0; index < priceTitleArray.length; index++) {
		if (top.hotelPriceArray[index] == 1) {		
			if (top.price != index) {	
					divideByPrice += '<a class="lgray11_33cc33"  href="javascript:divideByPrice(' + index + ')">';
			}
			else{divideByPrice += ''}
					divideByPrice += priceTitleArray[index];
			if (top.price != index) {
					divideByPrice += '</a>';	
			}
			else{divideByPrice += ''}
					divideByPrice += '&nbsp; ';
			if (index != (priceTitleArray.length - 1)) {
					divideByPrice += '<span style="color:#000000">| &nbsp</span>';
			}
		}
	}
	divideByPrice += '</div></div>';
	
	return divideByPrice;
}

function divideByPrice(price) {
	top.price = price;
	var priceFrom = parseFloat(priceRateArray[price]);
	var priceTo = parseFloat(priceRateTo[price]);
	
	var hotelTotal = top.hotelArray[0].length;
	
	var hotelListArray = new Array();
	var countIndex = 0;
	
	for (subIndex = 0; subIndex < top.dataLength; subIndex++) {
		hotelListArray[subIndex] = '';
	}
	for (index = 0; index < hotelTotal; index++) {
		var hotelMinRate = parseFloat(top.hotelArray[top.dataLength - 1][index]);
		if (hotelMinRate > priceFrom && hotelMinRate <= priceTo) {
			for (subIndex = 0; subIndex < top.dataLength; subIndex++) {
				hotelListArray[subIndex] += top.hotelArray[subIndex][index] + '\t';
			}
			countIndex++;
		}
	}
	for (subIndex = 0; subIndex < top.dataLength; subIndex++) {
		top.hotelFilterArray[subIndex] = hotelListArray[subIndex].split('\t');
		top.hotelFilterArray[subIndex].length = countIndex;
	}

		divideByPageNo(1);
}
function tabStar()  {
	var starTitleArray = new Array('5 Stars', '4 Stars', '3 Stars', '2 Stars', 'All Stars');
	var divideByStar = '<div ID="sortby_menuBottom" CLASS="clearfix"><div class="red11">';
	for (index = 0; index < starRateArray.length; index++) {
		if (starTabArray[index] != 0) {
			if (star != index) {		divideByStar += '<a class="lgray11_33cc33"  href="javascript:divideByStar(\'' + starRateArray[index] + '\')">'; 	}
			else {						divideByStar += '<b>';		}
											divideByStar += starTitleArray[index];
			if (star != index) {		divideByStar += '</a>';		}
			else {						divideByStar += '</b>';		}
											divideByStar += '&nbsp; ';
											divideByStar += '<span style="color:#000000" id="star' + index + '">'
				if(index != starRateArray.length-1){
					divideByStar += '|';
				}
				divideByStar += '</span> &nbsp;';
		}
	}
	divideByStar += '</div></div>';
	
	return divideByStar;
}

function divideByStar(star) {
	var indexStar = 0;
	var index = 0;
	var isFound = 0;
	while (index < starRateArray.length && isFound == 0) {
		if (starRateArray[index] == star) {
			indexStar = index;
			isFound = 1;
		}
		index++;
	}
	star = indexStar;
	top.star = indexStar;
	
	if (star != starRateArray[star]) {
		var starFrom = Math.floor(starRateArray[star]);
		var starTo = starFrom + 1;
		
		var hotelTotal = top.hotelArray[0].length;
		var hotelListArray = new Array(1);
		var countIndex = 0;
		
		for (subIndex = 0; subIndex < top.dataLength; subIndex++) {
			hotelListArray[subIndex] = '';
		}
	
		for (index = 0; index < hotelTotal; index++) {
			var hotelStar = top.hotelArray[9][index];
			if (hotelStar >= starFrom && hotelStar < starTo) {
				for (subIndex = 0; subIndex < top.dataLength; subIndex++) {
					hotelListArray[subIndex] += top.hotelArray[subIndex][index] + '\t';
				}
				countIndex++;
			}
		}
		
		for (subIndex = 0; subIndex < top.dataLength; subIndex++) {
			top.hotelFilterArray[subIndex] = hotelListArray[subIndex].split('\t');
			top.hotelFilterArray[subIndex].length = countIndex;
		}
	}
	divideByPageNo(1);
}

function tabPromotion() {
	var divideByPromotion = '<div ID="sortby_menuBottom" CLASS="clearfix"><div class="red11">&nbsp;</div></div>';

	return divideByPromotion;	
}

function divideByPromotion() {
	var hotelTotal = top.hotelArray[0].length;
	
	var hotelListArray = new Array(1);
	var countIndex = 0;
	
	for (subIndex = 0; subIndex < top.dataLength; subIndex++) {
		hotelListArray[subIndex] = '';
	}

	for (index = 0; index < hotelTotal; index++) {
		var hotelPromotion = top.hotelArray[4][index];
		if (hotelPromotion == 1) {
			for (subIndex = 0; subIndex < top.dataLength; subIndex++) {
				hotelListArray[subIndex] += top.hotelArray[subIndex][index] + '\t';
			}
			countIndex++;
		}
	}
	
	for (subIndex = 0; subIndex < top.dataLength; subIndex++) {
		top.hotelFilterArray[subIndex] = hotelListArray[subIndex].split('\t');
		top.hotelFilterArray[subIndex].length = countIndex;
	}
	divideByPageNo(1);
}

function tabArea() {
	var indexArea = 0;
	var areaArray = new Array(1);
	var sortArray = new Array(top.hotelArray[0].length);
	
	for (index = 0; index < top.hotelArray[0].length; index++) {
		sortArray[index] = top.hotelArray[2][index];
	}
	
	sortArray.sort();
	
	areaArray[0] = '!';
	for (index = 1; index < sortArray.length; index++) {
		var areaName = sortArray[index];
		if (areaName != areaArray[indexArea]) {
			indexArea++;
			areaArray[indexArea] = areaName;
		}
	}
	
	var displayByArea = '<div ID="sortby_menuBottom" CLASS="clearfix"><div class="red11">';
	if (area != 'All') {		displayByArea += '<a class="lgray11_33cc33" href="javascript:divideByArea(\'All\')">'; }
	else{displayByArea += '<B>'}
									displayByArea += 'All';
	if (area != 'All') {		displayByArea += '</a>';	}
	else{displayByArea += '</B>'}
									displayByArea += '<span style="color:#000000"> | </span> ';
	for (index = 1; index < areaArray.length; index++) {
		if (area != areaArray[index]) {	
									displayByArea += '<a class="lgray11_33cc33"  href="javascript:divideByArea(\'' + areaArray[index] + '\')">';	}
		else{displayByArea += '<B>'}
									displayByArea += areaArray[index];
		if (area != areaArray[index]) {
									displayByArea += '</a>';
		} 							
		else{displayByArea += '</B>'}
									displayByArea += ' <span style="color:#000000"> | </span> ';
	}
	if (area != 'Other') {	displayByArea += '<a class="lgray11_33cc33" href="javascript:divideByArea(\'Other\')">'; }
	else{displayByArea += '<B>'}
									displayByArea += 'Other';
	if (area != 'Other') {	displayByArea += '</a>';	}
	else{displayByArea += '</B>'}
	displayByArea += ' </div></div>';

	return displayByArea;
}

function divideByArea(area) {
	top.area = area;
	if (area == 'Other') {		area = '!';		}
	

	var hotelTotal = top.hotelArray[0].length;
	var hotelListArray = new Array(1);
	var countIndex = 0;
	
	for (subIndex = 0; subIndex < top.dataLength; subIndex++) {
		hotelListArray[subIndex] = '';
	}
	
	for (index = 0; index < hotelTotal; index++) {
		var hotelArea = top.hotelArray[2][index];
		if (area == hotelArea) {
			for (subIndex = 0; subIndex < top.dataLength; subIndex++) {
				hotelListArray[subIndex] += top.hotelArray[subIndex][index] + '\t';
			}
			
			countIndex++;
		}
	}
	
	for (subIndex = 0; subIndex < top.dataLength; subIndex++) {
		top.hotelFilterArray[subIndex] = hotelListArray[subIndex].split('\t');
		top.hotelFilterArray[subIndex].length = countIndex;
	}
	divideByPageNo(1);
}

function hotelPage(sortNo) {
	clearVariable();
	switch(sortNo) {
		case 1 : 	top.sortBy = 1;				// Sort By Name
						divideByAlphabet('All');
						break;
		case 2 :	top.sortBy = 2;				// Sort By Price
						divideByPrice(5);
						break;
		case 3 : 	top.sortBy = 3;				// Sort By Star Rating
						divideByStar('All');
						break;
		case 4 :	top.sortBy = 4;				// Sort By Area
						divideByArea('All');
						break;
		case 5 : 	top.sortBy = 5;				// Sort By Promotion Only
						divideByPromotion();
						break;
	}
}

function sortProcess(table, type) {
	
	top.hotelSortArray[type] = new Array();

	if (type == 0) {
		for (index = 0; index < eval(table + '[0].length'); index++) {
			top.hotelSortArray[0][index] = index + '@' + eval(table + '[0][' + index + ']');
		}
	} else if (type == 1) {
		for (index = 0; index < eval(table + '[0].length'); index++) {
			top.hotelSortArray[1][index] = index + '@' + CRates(5, eval(table + '[8][' + index + ']'), eval(table + '[7][' + index + ']'), 0);
		}
	} else if (type == 2) {
		for (index = 0; index < eval(table + '[0].length'); index++) {
			top.hotelSortArray[2][index] = index + '@' + eval(table + '[9][' + index + ']');
		}
	}

	switch (type) {
		/*case 0	:	hotelSortArray[type].sort(sortByAlphabet);			// Sort by Hotel name
						break;*/
		case 1	: 	hotelSortArray[type].sort(sortByNumber);			//	Sort by Price
						break;
		case 2	: 	hotelSortArray[type].sort(sortByNumber);			// Sort by Star rating
						break;
	}

	for (index = 0; index < hotelSortArray[type].length; index++) {
		top.hotelSortArray[type][index] = top.hotelSortArray[type][index].substring(0, top.hotelSortArray[type][index].indexOf('@'));
	}
}

function sortByNumber(first, second) {
	
	first = parseFloat(first.substring(first.indexOf('@') + 1));
	second = parseFloat(second.substring(second.indexOf('@') + 1));

	return (first - second);
}

function sortByAlphabet(first, second) {
	first += '';
	second += '';
	
	first = first.substring(first.indexOf('@') + 1);
	second = second.substring(second.indexOf('@') + 1);
	
	return (first>second)?1:(first<second)?-1:0;
}
/*
 *		'Most Popular'
 */
function tabSortBy() {
	var sortByTitle = new Array('Name', 'Price', 'Star Rating', 'Location', 'Promotions Only');
	var sortByText = '';
	for (index = 1; index <= sortByTitle.length; index++) {
		sortByText += '<DIV style="float:left">';
		if (top.sortBy != index) {
			if (index == 4){
				if(chkareapage != 0){
				sortByText += '<A class=l12b_blackc30 href="'+urlallarea+'">';}
			}
			else{sortByText += '<A class=l12b_blackc30 href="javascript:hotelPage(' + index + ');">';}
		} else {
			sortByText += '<font class=cc3300_12>'
		}
		if(index != 4 || chkareapage != 0){sortByText += '<B>&nbsp;' + sortByTitle[index - 1] + '</B>';}
		if (top.sortBy != index) {
			if (index != 4 || chkareapage != 0){sortByText += '</A>';}
		} else {
			sortByText += '</font>';
		}
		if(index != sortByTitle.length){
			if (index != 4 || chkareapage != 0){sortByText += '&nbsp; | &nbsp;';}
		}
		sortByText += '</DIV>';
	}
	
	document.getElementById('sortByTab').innerHTML = sortByText;
}