function resetResults(){
        setResults("Grading",'0','999999');
        for(var i=0; i < document.forms[""+fName][chkbox].length; i++){
                document.forms[""+fName][chkbox][i].checked=true;
        }
}

function sendRoomDetail(search_id,hotelId,roomId)
{
        document.roomDetailForm.hotel_id.value = hotelId;
        document.roomDetailForm.room_id.value = roomId;
        document.roomDetailForm.search_id.value = search_id;	
        document.roomDetailForm.submit();
}

function sendHotelDetail(search_id,hotelId)
{
        document.hotelDetailForm.hotel_id.value = hotelId;
	document.hotelDetailForm.search_id.value = search_id;
        document.hotelDetailForm.submit();
}

function roompop(url){
        window.open(url,'','top=45, left=45, height=420, width=385, scrollbars=no,vscroll=no,hscroll=no, toolbars=no, resizable=no');
}

var count=0;
var hotelId='';
function addHotelComp(hotel_id)
{
        count++;
}

function compareHotel()
{
        if(count<2){
                location.href="#";
                alert("Please check at least three hotels to compare.")
        }else if(count>3){
                location.href="#";
                alert("Please check only three hotels to compare.")
        }else{
                location.href="compareHotel.html?hotel_id="+hotelId+"&analytics_param="+gparam;
        }
}

function get_check_value()
{
        hotelId = '';
        for (var i=0; i < document.chkForm.chotel.length; i++){
                if (document.chkForm.chotel[i].checked){
                        if(hotelId.length > 0){
                        hotelId = hotelId +'|'+document.chkForm.chotel[i].value;
                        }else{
                        hotelId = document.chkForm.chotel[i].value;
                        }
                }
        }
        if(count<2){
                alert("Please check at least two hotels to compare.")
        }else if(count>3){
                alert("Please check only three hotels to compare.")
        }else{
                location.href="compareHotel.html?hotel_id="+hotelId+"&analytics_param="+gparam;
        }
}

function showResult(){
        var min;
        var max;
        var ctr=0;
	isPrange=2;
        for(var i=0; i < document.forms[""+fName][chkbox].length; i++){
                if(document.forms[""+fName][chkbox][i].checked){
                        val = document.forms[""+fName][chkbox][i].value.split('-');
                        if(ctr == 0){   min=val[0];     max=val[1];     }
                        ctr++;
                        if(min>val[0]){ min = val[0];   }
                        if(max<val[1]){ max = val[1];   }
                }
        }
        var sortType = 'Price';
		//alert('Sorting '+min +' : '+ max)
        if(window.document.chkForm.sortType[0].checked){        sortType='Price';       }
        if(window.document.chkForm.sortType[1].checked){        sortType='HotelName';   }
        setResults(sortType,min,max);
}

function showImage(divid,ino){
        for(i=1;i<ino;i++){
                window.document.getElementById('idiv'+i).style.display='none';
        }
        window.document.getElementById(divid).style.display='block';
}

function setDest(f,o,d){
	var f=document.forms[""+f];
	f.type[1].checked=true;
}

function showAgeBlock(val,f){
  var f=document.forms[""+f];
  if(val<1){
        window.document.getElementById('cha1').style.display='none';
        window.document.getElementById('cha2').style.display='none';
		window.document.getElementById('cha_c1').style.display='none';
		window.document.getElementById('cha_c2').style.display='none';
        f.age1.value='';
        f.age2.value='';
  }
  if(val == 1){
        window.document.getElementById('cha1').style.display='block';
        window.document.getElementById('cha2').style.display='none';
		window.document.getElementById('cha_c1').style.display='block';
		window.document.getElementById('cha_c2').style.display='none';
        f.age2.value='';
  }
  if(val == 2){
        window.document.getElementById('cha1').style.display='block';
        window.document.getElementById('cha2').style.display='block';
		window.document.getElementById('cha_c1').style.display='block';
		window.document.getElementById('cha_c2').style.display='block';

  }
}

function submitForm(){
	if(!document.paxDetailForm.tc.checked){
        	alert('Please check the terms and conditions')
                return false;
      	}else{
        	return true;
       	}
}

function ascii_value(c){
        var i;
        for(i = 0; i < 256; ++ i){
                var h = i.toString (16);
                if (h.length == 1)
                        h = "0" + h;
                h="%"+h;
                h=unescape (h);
                if(h==c)
                        break;
        }
        return i;
}

function CommaFormatted(amount)
{
        var delimiter = ","; // replace comma if desired
        var d = '';
        var i = amount;
        if(isNaN(i)) { return ''; }
        var minus = '';
        if(i < 0) { minus = '-'; }
        i = Math.abs(i);
        var n = new String(i);
        var a = [];
        while(n.length > 3)
        {
                var nn = n.substr(n.length-3);
                a.unshift(nn);
                n = n.substr(0,n.length-3);
        }
        if(n.length > 0) { a.unshift(n); }
        n = a.join(delimiter);
        if(d.length < 1) { amount = n; }
        else { amount = n + '.' + d; }
        amount = minus + amount;
        return amount;
}

 var map = null;
 var geocoder = null;
 /*function load() {
 	if (GBrowserIsCompatible()) {
        	map = new GMap2(document.getElementById("map"));
        	map.addControl(new GLargeMapControl());
        	geocoder = new GClientGeocoder();
        	showAddress(city, address);
      	}
 }

 function createMarker(point, address, info) {
 	var marker = new GMarker(point);
  	GEvent.addListener(marker, "click", function() {
    		map.setCenter(point, 6);
    		marker.openInfoWindowHtml(info);
  	});
 	return marker;
 }

 function showAddress(address, info) {
	if (geocoder) {
        	geocoder.getLatLng(
          	address,
          	function(point) {
            		if (!point) {
              		alert(address + " not found");
            		} else {
              		map.setCenter(point, 5);
              		var marker = new GMarker(point);
//              	map.addOverlay(marker);
               		map.addOverlay(createMarker(point, address, info));
              		marker.openInfoWindowHtml(address);
            		}
          	}
        	);
      }
 }*/

/*******************************************************************************
 * Function Name : Trim
 * Description   : trim the spaces
 * Arguments     : fld
 * Return values :
 ********************************************************************************/
function Trim(fld)
{
        while(''+fld.charAt(0)==' ')
                fld=fld.substring(1,fld.length);
        while(''+fld.charAt(fld.length-1)==' ')
                fld=fld.substring(0,fld.length-1);
        while(''+fld.charCodeAt(0)==13 || ''+fld.charCodeAt(0)==10)
                fld=fld.substring(1,fld.length);
        while(''+fld.charCodeAt(fld.length-1)==13 || ''+fld.charCodeAt(fld.length-1)==10)
                fld=fld.substring(0,fld.length-1);
        return fld;
}
