function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function toggleElement( sel1, sel2, element1 ){
	try{
		var arrival=document.getElementById(sel1);
		var departure=document.getElementById(sel2);

		if (arrival.value != 'Arrival Date' && arrival.value != ''){
			departure.value=arrival.value;
		}

		try{
			if ( document.getElementById(element1) != null)
			{			
				var element1 = document.getElementById(element1);
				if ((arrival.value != 'Arrival Date' && arrival.value != '') && (departure.value != 'Departure Date' && departure.value != '')){
					element1.style.visibility= 'visible';
				}else{
					element1.value = ''; 
					element1.style.visibility= 'hidden';
				}
			}
		}catch(e){
		}
	}catch(e){		
	}
	return;
}

function checkAvailabilityDate(ID){
	var data = "cmd=checkAvailability"	
	if ( _checkDate(document.getElementById("requested_date").value) && _checkDate(document.getElementById("requested_date2").value))
	{
		data = data + "&Id=" + ID;
		data = data + "&Check_In=" + document.getElementById("requested_date").value;
		data = data + "&Check_Out=" + document.getElementById("requested_date2").value;
		sendRequest( _afterCheckAvailabilityDate, data, "POST", "/vacation-rentals/includes/call-i-advanced-search.asp", true );
	}else{
		if ( !_checkDate(document.getElementById("requested_date").value)){
			document.getElementById("requested_date").select();
		}else{
			document.getElementById("requested_date2").select();
		}
		return false;
	}
}

function _afterCheckAvailabilityDate( oj ) {	
	try{
		var xmlDoc  = oj.responseXML;	
		var result = xmlDoc.getElementsByTagName("result")[0].firstChild.nodeValue;
		if (result =="ok"){
			var Availability = xmlDoc.getElementsByTagName("Availability")[0].firstChild.nodeValue;
			if (Availability == 'True' ) {
				var Id = xmlDoc.getElementsByTagName("Id")[0].firstChild.nodeValue;
				document.location = 'https://www.seapines.com/vacation-rentals/rental-booking.asp?rental=' + Id;
			}else{
				document.location = '/vacation-rentals/advanced-search.asp';
			}
		}
	}catch(e){		
	}
}