

var newWin = null;
function openNewWindow(url){

var width = 1200; 
var height = 900;
var XOffset = (screen.availWidth - width)/2;
var YOffset = (screen.availHeight - height)/2;

var parameters = 'WIDTH='+width+',HEIGHT='+height+',SCROLLBARS=yes,RESIZABLE=yes'+
                 ",screenX=" + XOffset + ",screenY=" + YOffset + ",top=" + YOffset +
                  ",left=" + XOffset;
var windowName='healthinpsectreport';
newWin = window.open(url, windowName, parameters );

newWin.focus();

}


function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 

var list=xmlHttp.responseText.split("*");

var frm = document.searchForm;
with(frm){
var commLength = (list.length -1)/2; // we cut of the last element because it is the community id previously selected.
community.length = commLength + 1;
community.selectedIndex =-1;
var selectedCommunityId = list[list.length-1];
community.options[0].value = ""; 
  community.options[0].text ="     ";
for(var i=0; i <commLength; i++){
  community.options[i+1].value = list[i*2].replace(/^\s+|\s+$/g, ''); //trim string
  community.options[i+1].text = list[2*i + 1].replace(/^\s+|\s+$/g, '');//trim string
  if(!isEmpty(selectedCommunityId) 
  && selectedCommunityId == community.options[i+1].value){
    community.selectedIndex = i+1;
  }
}
}
}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

function emptyFields(frm){
with(frm){
  reset();
  name.value="";
  address.value="";
  municipality.selectedIndex = 0;
  community.length = 0;
}
}

//check for cookies
function getCookie( cookieNameParam ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var allCookies = document.cookie.split( ';' );
	//alert(allCookies);
	var tempCookie = '';
	var cookieName = '';
	var cookieValue = '';
	var cookieFound = false; // set boolean t/f default f
	
	for ( var i = 0; i < allCookies.length; i++ ){
		// now we'll split apart each name=value pair
		tempCookie = allCookies[i].split( '=' );
		
		// and trim left/right whitespace while we're at it
		cookieName = tempCookie[0].replace(/^\s+|\s+$/g, '');
	
		// if the extracted name matches passed check_name
		if ( cookieName == cookieNameParam ){
			cookieFound = true;	
		}
	}
	return cookieFound;
}	

function checkCookie(param){
 if(!getCookie(param)){
 alert("Please enable cookies for this web site.\n" +
       "Cookies are currently disabled by your browser. The Environmental Health Inspections website requires that cookies be enabled.\n" + 
       "If you are using Microsoft Internet Explorer 6 or later, open Internet Options from the Tools menu. \n" +
       "Click the Privacy tab, and then click Sites. Type the address for Environmental Health Inspections \n" +
       " into the field, click Allow, and then click OK to save your changes.");
 return;
 }
}

//register the function
  document.captureEnter = 'validateForm()';
  
  function validateForm(){
    document.searchForm.submit();
   
  }


