var SELECTEDCITY = '';
function $(i){return document.getElementById(i)}
function turnoffDestinationContent(){
	$('destinationContentOn').checked = false;
	$('destinationcontentParent').innerHTML = '';
	}

function addDestinationContent(c){
	var where = $('destinationcontentParent');
	if(!c.checked){
		turnoffDestinationContent();
		where.style.display = 'none';
		return;
		}
	where.style.display = '';
	try{x=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{x=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){try{x=new XMLHttpRequest();}catch(e){x=null;}}}
	x.onreadystatechange = function(){
		if(x.readyState == 4){
			var r = x.responseText;
			where.innerHTML = r;
			}
		else{
			}
		}
	x.open("POST", '/us/hi/destinationcontent/' + SELECTEDCITY + '/', true);
	try{
		x.send(encode('id_arrivalDate') + '&' + encode('id_nights'));
		}
	catch(e){x.send();}
	}

function checkSingleCity(){
	var city = $('id_city');
	var destinationTable = $('destinationcontentTable');
	destinationTable.style.display = 'none';
	var s = 0;
	for(var i = 0; i < city.options.length; i++)
		if(city.options[i].selected) s += 1
	if(s == 1 && HASGUIDE[city.value] == 1){
		destinationTable.style.display = '';
		SELECTEDCITY = city.value;
		}
	else{
		turnoffDestinationContent();
		}
	}

function selectAll(s){
	var div = s.parentNode.parentNode;
	var inputs = div.getElementsByTagName('input');
	for(var i = 0; i < inputs.length; i++) inputs[i].checked = s.checked;
	}

function encode(id){
	var o = $(id);
	return encodeURIComponent(o.name) + '=' + encodeURIComponent(o.value)
	}

function update(){
	try{x=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{x=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){try{x=new XMLHttpRequest();}catch(e){x=null;}}}
	x.onreadystatechange = function(){
		if(x.readyState == 4){
			var r = x.responseText;
			var div = $('destinationcontent');
			div.parentNode.innerHTML = r;
			}
		else{
			}
		}
	x.open("POST", '/us/hi/destinationcontent/' + SELECTEDCITY + '/', true);
	x.send(encode('dateFrom') + '&' + encode('dateTo'));
	}
