
function fmPropertyBasicAdd_chk(){
	
	var hasError=0;
	
	elocationid2 = document.getElementById('elocationid');
	if (elocationid2.selectedIndex == 0){alert("Island is required.");hasError=1;}
	
	if (hasError==1){return false;}
	else {return true;}
}	

function fmPropertyDetail_chk(etypeid){
	
	var hasError=0;
	
	if (etypeid == 11){
		regionid2 = document.getElementById('eregionid');
		if (regionid2.selectedIndex == 0){alert("City/Region is required.");hasError=1;}
	}
	
	propertytypeid2 = document.getElementById('propertytypeid');
	if (propertytypeid2.selectedIndex == 0){alert("Property Type is required.");hasError=1;}
	
	bedid2 = document.getElementById('Bed');
	if (bedid2.selectedIndex == 0){alert("Bedroom total is required.");hasError=1;}
	
	bathid2 = document.getElementById('Bath');
	if (bathid2.selectedIndex == 0){alert("Bathroom total is required.");hasError=1;}
	
	//sleepid2 = document.getElementById('Sleep');
	//if (sleepid2.selectedIndex == 0){alert("Sleep Max is required.");}
	
	if (hasError==1){return false;}
	else {return true;}
}	

function clearText(field){
	if (field.defaultValue == field.value){field.value = '';}
    else if (field.value == ''){field.value = field.defaultValue;}
}

function deleteinfo (form_id)
{
	if ( confirm ('Are you sure you want to DELETE?'))
	{		
		document.forms[form_id].submit();
	}	
}

function flightinfo_get(location_id,flightid,travelmonth,tmonth,tyear){
	view_url(location_id,'CalendarFlight.cfm?flightid=' + flightid + '&travelmonth=' + travelmonth + '&tmonth=' + tmonth + '&tyear=' + tyear, 'html');	
}


function fieldfocus(inputid) {
	document.getElementById(inputid).focus();
}

// switch the show/hide state of two IDs
function toggle_switch(show_id,hide_id) {
	document.getElementById(show_id).style.display = 'none';
	document.getElementById(hide_id).style.display = '';
}

// Simple show/hide
function toggle_simple(id)
{
	var obj = document.getElementById(id);
	if (obj.style.display == '')
	{
		obj.style.display='none';
	}
	else
	{
		obj.style.display='';
	}
}

function toggle_show(id)
{
	var obj = document.getElementById(id);
	obj.style.display='';
}

function toggle_hide(id)
{
	var obj = document.getElementById(id);
	obj.style.display='none';
}

// ?
function toggle(id,status)
{
	var obj = document.getElementById(id);
	if (obj.style.display == '' && status == 'off')
	{
		obj.style.display='none';
	}
	else if (obj.style.display == 'none' && status == 'on')
	{
		obj.style.display='';
	}
}

/*========================================================*/
/* AJAX HTTP GET VIEW FUNCTION
/*========================================================*/

/* GET URL */
function view_url(form_id,get_view,view_type)
{
	var get_view_http_request = false;

	// branch for native XMLHttpRequest object
	if (window.XMLHttpRequest)
	{
		var get_view_http_request = new XMLHttpRequest();
		
		get_view_http_request.onreadystatechange = function() { get_view_http_response(get_view_http_request, form_id, view_type); };
		get_view_http_request.open("GET", get_view, true);
		get_view_http_request.send(null);
	}
	// branch for IE/Windows ActiveX version
	else if (window.ActiveXObject)
	{
		get_view_http_request = new ActiveXObject("Microsoft.XMLHTTP");

		if (get_view_http_request)
		{
			get_view_http_request.onreadystatechange = function() { get_view_http_response(get_view_http_request, form_id, view_type); };
			get_view_http_request.open("GET", get_view, true);
			get_view_http_request.send(null);
		}
	}
}

/* GET URL RESPONSE */
function get_view_http_response(get_view_http_request, form_id, view_type)
{
	// only if req shows "loaded"
	if (get_view_http_request.readyState == 4)
	{
		// only if "OK"
		if (get_view_http_request.status == 200)
		{
			var view_content = get_view_http_request.responseText;

			if ( view_type == 'text' )
				document.getElementById(form_id).innerText=view_content;
			else if ( view_type == 'text_area') 
					document.getElementById(form_id).value=view_content;	
			else if ( view_type == 'html' )
				document.getElementById(form_id).innerHTML=view_content;
		}
		else
		{
			/* Error Message */
			alert("There was a problem retrieving the data:\n" + get_view_http_response.statusText + get_view_http_request.responseText);
		}
	}
}

/* GET URL */
function action_url(post_get_msg)
{
	// branch for native XMLHttpRequest object
	if (window.XMLHttpRequest)
	{
		post_get_msg_http_request = new XMLHttpRequest();
		post_get_msg_http_request.onreadystatechange = post_get_msg_http_response;
		post_get_msg_http_request.open("GET", post_get_msg, true);
		post_get_msg_http_request.send(null);
	}
	// branch for IE/Windows ActiveX version
	else if (window.ActiveXObject)
	{
		post_get_msg_http_request = new ActiveXObject("Microsoft.XMLHTTP");
		if (post_get_msg_http_request)
		{
			post_get_msg_http_request.onreadystatechange = post_get_msg_http_response;
			post_get_msg_http_request.open("GET", post_get_msg, true);
			post_get_msg_http_request.send();
		}
	}
}

/* GET URL RESPONSE */
function post_get_msg_http_response()
{
	// only if req shows "loaded"
	if (post_get_msg_http_request.readyState == 4)
	{
		// only if "OK"
		if (post_get_msg_http_request.status == 200)
		{
			/* Set popup content with response */
			msg_pop_content = post_get_msg_http_request.responseText;
			document.getElementById("dialog-msg").innerHTML=msg_pop_content;
			/* Call popup */
			msg_pop(post_get_msg_http_response.responseText);
		}
		else
		{
			/* Error Message */
			alert("There was a problem retrieving the data:\n" + post_get_msg_http_response.statusText);
		}
	}
}
