function write_flash()	{
	document.write("<object width='380' height='238'><param name='movie' value='http://www.youtube.com/v/OxCGhAL2vhU?fs=1&amp;hl=en_US&amp;rel=0'></param><param name='allowFullScreen' value='false'></param><param name='allowscriptaccess' value='always'></param><embed src='http://www.youtube.com/v/OxCGhAL2vhU?fs=1&amp;hl=en_US&amp;rel=0' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='false' width='380' height='238'></embed></object>");
	}

function open_banner_window(which, height, width)	{
	window.open("/banners/" + which,"Banner","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=" + width + ",height=" + height + ",left=30,top=80");
	}

function add_clause(which)	{
	
	document.getElementById('add_clause_' + which).style.display = 'block';
	document.getElementById('add_c_' + which).style.display = 'none';
	document.getElementById('add_c_' + (which + 1)).style.display = 'block';
	}

function show_button()	{

	show = 0;

	if (document.getElementById('one_date').checked || (document.getElementById('multi_date').checked && document.getElementById('num_dates').selectedIndex != 0))	{
		show++;		
		}

	if (show != 0)	{
		document.getElementById('sub').style.display = 'block';
		}
	else	{
		document.getElementById('sub').style.display = 'none';
		}

	}

function get_policy_info()	{

	if (document.getElementById('insurance').value != '')	{

		http = getHTTPObject();

		http.onreadystatechange = function()	{
			
			if (http.readyState == 4) {
				results = http.responseText;
				
				if (results == 1)	{
					message = 'hunter (lessee)';
					document.getElementById('m_info').style.display = 'block';
					document.getElementById('m_is_hunter').checked = true;
					document.getElementById('m_is_owner').disabled = true;
					}
				else	{
					message = 'landowner (lessor)';
					document.getElementById('m_info').style.display = 'block';
					document.getElementById('m_is_owner').checked = true;
					document.getElementById('m_is_hunter').disabled = true;
					}

				show_button();
				} // end if ready state
			
			} // end inner function

		variables = 'policy_id=' + document.getElementById('insurance').value;

		http.open('POST', '/members/functions/get_insurance_info.php', true);
		http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		http.setRequestHeader("Content-length", variables.length);
		http.setRequestHeader("Connection", "close");
		http.send(variables);
		
		}

	}

function get_popup(page)	{
	window.open('popup.php?page=' + page,"Link","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=550,height=450,left=30,top=80");
	}

function get_free_quote_counties()	{

	if (document.getElementById('c_state').value != '')	{

		http = getHTTPObject();

		http.onreadystatechange = function()	{
			
			if (http.readyState == 4) {

				// Split the comma delimited response into an array
				results = http.responseText.split(",");
				
				ClearOptions(document.getElementById('c_county'));

				for (var x = 0; x < results.length; x++)	{
				  results[x].trim();
				  AddToOptionList(document.getElementById('c_county'), results[x], results[x]);
				  }

				} // end if ready state
			
			} // end inner function

		variables = 'st=' + document.getElementById('c_state').value;

		http.open('POST', '/members/functions/get_counties.php', true);
		http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		http.setRequestHeader("Content-length", variables.length);
		http.setRequestHeader("Connection", "close");
		http.send(variables);
		
		}
	else	{
		ClearOptions(document.getElementById('c_county'));
		}
	}

function get_counties()	{

	if (document.getElementById('insured_state').value != '')	{

		http = getHTTPObject();

		http.onreadystatechange = function()	{
			
			if (http.readyState == 4) {

				// Split the comma delimited response into an array
				results = http.responseText.split(",");
				
				ClearOptions(document.getElementById('insured_county'));

				for (var x = 0; x < results.length; x++)	{
				  results[x].trim();
				  AddToOptionList(document.getElementById('insured_county'), results[x], results[x]);
				  }

				//document.getElementById('insured_county').style.visibility = 'visible';

				} // end if ready state
			
			} // end inner function

		variables = 'st=' + document.getElementById('insured_state').value;

		http.open('POST', '/members/functions/get_counties.php', true);
		http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		http.setRequestHeader("Content-length", variables.length);
		http.setRequestHeader("Connection", "close");
		http.send(variables);
		
		}
	else	{
		ClearOptions(document.getElementById('insured_county'));
		}
	}


function ClearOptions(optionList) {
   // Always clear an option list from the last entry to the first
   for (x = optionList.length; x > 0; x = x - 1) {
	  optionList[x] = null;
	  }
	}

function AddToOptionList(optionList, optionValue, optionText) {
   // Add option to the bottom of the list
   optionList[optionList.length] = new Option(optionText, optionValue);
	}

String.prototype.inspect = function() {
	return this.replace(
		/[\x00-\x20]/g, function($0) {
			return "\\x" + 
				(0x100|$0.charCodeAt(0)).toString(16).substr(1);
	})
}

String.prototype.trim = function trim(str) {
	return (str || this).
		replace(/^\s+/g, '').
		replace(/\s+$/g, '');
}


function show_forms()	{
	document.getElementById('p_info').style.display= 'block';
	document.getElementById('l_info').style.display= 'block';
	document.getElementById('i_info').style.display= 'block';
	document.getElementById('c_button').style.display= 'block';

	get_member_info('ins');

	}
	
function get_member_info(which)	{
	
	http = getHTTPObject();

	http.onreadystatechange = function()	{
		
		if (http.readyState == 4) {
			fill_form(http.responseText, which);			
			} // end if ready state
		
		} // end inner function

	variables = 'nothing';

	http.open('POST', '/members/functions/get_member_data.php', true);
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", variables.length);
	http.setRequestHeader("Connection", "close");
	http.send(variables);
	
	}

function fill_form(JSONdata, which)	{
	eval(JSONdata);

	if (which == 'cc')	{
		document.getElementById('x_First_Name').value = info.f_name;
		document.getElementById('x_Last_Name').value = info.l_name;
		document.getElementById('x_Address').value = info.addy;
		document.getElementById('x_City').value = info.city;
		document.getElementById('x_Zipcode').value = info.zipcode;
		document.getElementById('x_Phone').value = info.phone;

		for (x = 0; x < document.getElementById('x_State').options.length ; x++)	{
			if (document.getElementById('x_State')[x].value == info.state)	{
				document.getElementById('x_State').selectedIndex = x;
				}
			}
		
		}
	else	{

		if (document.getElementById('purchased_as_member_type_l').checked)	{

			document.getElementById('landowner_name').value = info.f_name + ' ' + info.l_name;
			document.getElementById('landowner_mailing_address').value = info.addy;
			document.getElementById('landowner_city').value = info.city;
			document.getElementById('landowner_zipcode').value = info.zipcode;
			document.getElementById('landowner_home_phone').value = info.phone;
			document.getElementById('landowner_email_addy').value = info.email;

			for (x = 0; x < document.getElementById('landowner_state').options.length ; x++)	{
				if (document.getElementById('landowner_state')[x].value == info.state)	{
					document.getElementById('landowner_state').selectedIndex = x;
					}
				}

			// clear out the other section of the form
			document.getElementById('contact_name').value = '';
			document.getElementById('contact_mailing_addy').value = '';
			document.getElementById('contact_city').value = '';
			document.getElementById('contact_zipcode').value = '';
			document.getElementById('contact_home_phone').value = '';
			document.getElementById('contact_state').selectedIndex = 0;
			document.getElementById('contact_email_addy').value = '';

			}
		else	{

			document.getElementById('contact_name').value = info.f_name + ' ' + info.l_name;
			document.getElementById('contact_mailing_addy').value = info.addy;
			document.getElementById('contact_city').value = info.city;
			document.getElementById('contact_zipcode').value = info.zipcode;
			document.getElementById('contact_home_phone').value = info.phone;
			document.getElementById('contact_email_addy').value = info.email;

			for (x = 0; x < document.getElementById('contact_state').options.length ; x++)	{
				if (document.getElementById('contact_state')[x].value == info.state)	{
					document.getElementById('contact_state').selectedIndex = x;
					}
				}

			// clear out the other section of the form
			document.getElementById('landowner_name').value = '';
			document.getElementById('landowner_mailing_address').value = '';
			document.getElementById('landowner_city').value = '';
			document.getElementById('landowner_zipcode').value = '';
			document.getElementById('landowner_home_phone').value = '';
			document.getElementById('landowner_email_addy').value = '';
			document.getElementById('landowner_state').selectedIndex = 0;
			}
		
		}
	
	}

function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}

function trim(str)	{  
	while(str.charAt(0) == " ")	{  
		str = str.substring(1);
		}
	while(str.charAt(str.length-1) == " " )	{  
		str = str.substring(0,str.length-1);
		}
  return str;
}

