	function createCookie(name,value,days) {
		
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	}

	function readCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}

	function eraseCookie(name) {
		createCookie(name,"",-1);
	}
var buttonTracking = new Array();

function PageButton(disabled,className){
    this.disabled = disabled;
    this.className = className;
}

function already_disableButtons(){

  var buttons = document.getElementsByTagName("input");
  buttonTracking = new Array(buttons.length);
  var track = new Array();
 // alert(buttonTracking);
	for (var i=0;i<buttons.length;i++){
    if (buttons[i].type == 'image'){
					//buttons[i].disabled = true;					trackdisable
					//alert(buttons[i].disabled);
					//track[buttons[i].name] = buttons[i].disabled;
					createCookie(buttons[i].name,buttons[i].disabled,1);					
    }
  }
}


function disableButtons(){

  var buttons = document.getElementsByTagName("input");
  buttonTracking = new Array(buttons.length);
 
	for (var i=0;i<buttons.length;i++){
    if (buttons[i].type == 'image'){
		var s = buttons[i].src; 	
		var d = s.lastIndexOf('.');
		//alert(s.substring(s.lastIndexOf('/') + 1, d < 0 ? s.length : d));
		if(s.substring(s.lastIndexOf('/') + 1, d < 0 ? s.length : d)=='date_icon') {
			//alert('abc');		
		} else {
			buttonTracking[i] = new PageButton(buttons[i].disabled,buttons[i].className);
			buttons[i].disabled = true;
			buttons[i].src = 'images/book_it_btn.jpg';
		}
    }
  }
}


function restoreButtons(buttonName){
	//alert(buttonName);
  var buttons = document.getElementsByTagName("input");
  for (var i=0;i<buttons.length;i++){
    if (buttons[i].type == 'image'){
			if(buttons[i].name==buttonName){
					//var checkDis = readCookie(buttons[i].name)
					//if(checkDis=='false')
					//{
						buttons[i].disabled = false;
						buttons[i].src = 'css/images/book_btn.jpg';
					//}
			}else{
				continue;
			}
    }
  }  
}
	
	if (document.getElementById('ProgBar')){							
			//document.getElementById('commonframework').style.visibility ='hidden';
			//document.getElementById('ProgBar').style.display = 'none';
			//document.getElementById('commonframework').style.display = 'none';
	}						
		function write_data(source_type,room_type,hotel_id,source_hotel_id,roomtype_code,valuation,contract,boardtype_code,incoming_contract,destination_code,display_price,record_key,keyIndex) {				
				document.getElementById('loading'+keyIndex).style.display = 'block';																					
				//alert(valuation);
				document.frm_booking.hotel_id.value = hotel_id ;				
				document.frm_booking.source_hotel_id.value = source_hotel_id ;								
				document.frm_booking.sourceType.value = source_type ;			
				document.frm_booking.valuation_file.value = valuation ;
				document.frm_booking.contract_number.value = contract ;									
				document.frm_booking.incoming_contract.value = incoming_contract ;									
				document.frm_booking.boardtype_code.value = boardtype_code;									
				document.frm_booking.destination_code.value = destination_code;										
				document.frm_booking.keyIndex.value = keyIndex;
				ajax.requestFile = 'write_cache.php?destination_code='+destination_code+'&boardtype_code='+boardtype_code+'&incoming_contract='+incoming_contract+'&contract_number='+contract+'&source_type='+source_type+'&room_type='+room_type+'&hotel_id='+hotel_id+'&record_key='+record_key+'&source_hotel_id='+source_hotel_id+'&valuation_file='+valuation;
				// Specifying which file to get										
				
				ajax.onCompletion = hideme;

				ajax.runAJAX();		// Execute AJAX function
				
				//document.getElementById('write_loading_div').style.display = 'none';
				//alert(write_loading_div.style.display);
				
		}
		function hideme(){									
			//alert(ajax.response);
			//alert(document.frm_booking.keyIndex.value);
			keyIndex = document.frm_booking.keyIndex.value;			
			if(ajax.response=='good'){
				
				restoreButtons('book'+keyIndex);
			}else{
				//disableButtons();
			}
			document.getElementById('loading'+keyIndex).style.display = 'none';
			document.frm_booking.isValidSelection.value = ajax.response;
			//document.getElementById(write_loading_div).style.display='none';		
		}



	function show_hotel_details(id,source_type,hotel_name) {
		winx = window.open('hotel_details.php?id='+id+'&source_type='+source_type,'hotel','width=850,height=800,resizable=1,scrollbars=1');
		winx.title = hotel_name;
	}

	function go(formObj) {
		document.forms["go_frm"].submit();
		return false;
	}

	function book_now(display_curr,can_book,source_type,hotel_id,room_loop_key,roomtype_code,valuation,contract,boardtype_code,incoming_contract,destination_code,price){	
		//if(can_book == "1"){
			//alert("You can book. But you have to wait till we test the system and get it live.");									
			//alert(display_curr);
			//alert('nikhil');
			//document.frm_booking.hotel_id.value = hotel_id ;					
			//document.frm_booking.room_loop_key.value = room_loop_key ;														
			//document.frm_booking.sourceType.value = source_type ;														
			//document.frm_booking.roomtype_code.value = roomtype_code ;
			//document.frm_booking.valuation_file.value = valuation ;
			//document.frm_booking.contract_number.value = contract ;									
			//document.frm_booking.incoming_contract.value = incoming_contract ;									
			//document.frm_booking.boardtype_code.value = boardtype_code;									
			//document.frm_booking.destination_code.value = destination_code;
			//document.frm_booking.price.value = price ;
			document.frm_booking.display_curr.value = display_curr ;
			document.frm_booking.submit();
		//} else {
		//	alert("You are not allowed to make a booking. You can just check the prices.");
		//}
	}				
	
	function restrict_booking() {																		
		alert('You can not proceed with this booking.');
		return false;
	}

	function show_plus(id) {																		
		if(document.getElementById('record_'+id).style.display == 'block'){
			document.getElementById('record_'+id).style.display = 'none';								
			document.getElementById('minus_'+id).style.display = 'none';								
			document.getElementById('plus_'+id).style.display = 'block';									
		} else {									
			document.getElementById('record_'+id).style.display = 'block';								
			document.getElementById('minus_'+id).style.display = 'block';								
			document.getElementById('plus_'+id).style.display = 'none';
			
		}
		
		return false;
	}
	
	function show_minus(id) {
		document.getElementById('minus_'+id).style.display = 'none';
		document.getElementById('record_'+id).style.display = 'none';
		document.getElementById('plus_'+id).style.display = 'block';
		return false;
	}
	function cancel_show_plus(id) {																		
		if(document.getElementById('cancel_record_'+id).style.display == 'block'){
			document.getElementById('cancel_record_'+id).style.display = 'none';								
			document.getElementById('cancel_minus_'+id).style.display = 'none';								
			document.getElementById('cancel_plus_'+id).style.display = 'block';									
		} else {									
			document.getElementById('cancel_record_'+id).style.display = 'block';								
			document.getElementById('cancel_minus_'+id).style.display = 'block';								
			document.getElementById('cancel_plus_'+id).style.display = 'none';
			
		}
		
		return false;
	}
	
	function cancel_show_minus(id) {
		document.getElementById('cancel_minus_'+id).style.display = 'none';
		document.getElementById('cancel_record_'+id).style.display = 'none';
		document.getElementById('cancel_plus_'+id).style.display = 'block';
		return false;
	}
	function callAdvancedFilters(value, frmObj)
	{
		frmObj.page.value=1;
		frmObj.sort_data.value=1;
		if(value=='price' || value=='alphabet' || value=='rating' || value=='availability'){
			frmObj.sorting.value=value;
			frmObj.filter.value='';
		}else{
			frmObj.sorting.value='price';
			frmObj.filter.value=value;
		}
		frmObj.submit();

	}