function selectAll(isSelected) 
{
	var frm = document.forms[0];
	var ctrls = frm.elements.length;
	
	for(i=0; i<ctrls; i++)
	{
		if(frm.elements[i].type == "checkbox")
		{
			frm.elements[i].checked = isSelected;
		}
	}
}

function showMap(newWinURL) 
{
   var winStats;
   
   var winW = screen.width-50;
   var winH = screen.height-60;
   
   winStats+='toolbar=0,location=0,directories=0,menubar=0,scrollbars=,resizable=1,dependent=1,';
   winStats+='width='+winW+',height='+winH;
   
   if (navigator.appName.indexOf("Microsoft")>=0) 
   {
		winStats+=',left=20,top=30';
   }
   else
   {
		winStats+=',screenX=20,screenY=30';
   }
   var new_window_handle=window.open(newWinURL,"FP_Map_Viewer",winStats);   
   
   	if (new_window_handle.focus) {
		new_window_handle.focus();
	}     
}

function new_window(newWinURL, newWinTitle, winWidth, winHeight, scrollbars, menubar, toolbar, location, directories) 
{
   var winStats;
   
   winStats+='toolbar='+toolbar+',location='+location+',directories='+directories+',menubar='+menubar;
   winStats+=',scrollbars='+scrollbars+',resizable=1,dependent=1';
   winStats+=',width='+winWidth+',height='+winHeight;
   
   if (navigator.appName.indexOf("Microsoft")>=0) 
   {
		winStats+=',left='+(screen.width - winWidth)/2+',top='+(screen.height - winHeight)/2;
   }
   else
   {
		winStats+=',screenX='+(screen.width - winWidth)/2+',screenY='+(screen.height - winHeight)/2;
   }
   var new_window_handle=window.open(newWinURL,newWinTitle,winStats);   
   
   	if (new_window_handle.focus) {
		new_window_handle.focus();
	}   
} 

function preloadImages() 
{
	var d=document; 
	if(d.images)
	{ 
		if(!d.p)
		{
			d.p=new Array();
		}
		var i, j=d.p.length, a=preloadImages.arguments; 
		for(i=0; i<a.length; i++)
		{	
			if (a[i].indexOf("#")!=0)
			{ 
				d.p[j]=new Image; 
				d.p[j++].src=a[i];
			}
		}
	}
}

function openHelp()
{
	new_window("help.aspx", "WhatsNew", 535, 500, 1, 1, 0, 0, 0);
}

function openDef(fieldName)
{
	new_window("definition.aspx?fieldDef=" + fieldName, "OpenDef", 450, 175, 1, 0, 0, 0, 0);
}

function openEnvDef(ID, defType, winheight)
{
	new_window("envdefinition.aspx?ID=" + ID + "&Type=" + defType, "OpenDef", 465, winheight, 1, 0, 0, 0, 0);
}

function openProfile(id)
{
	new_window("profile.aspx?FacID=" + id, "Profile", 725, 465, 1, 1, 0, 0, 0);
}

function openComplianceProfile(id)
{
	new_window("profile.aspx?FacID=" + id + "&Compliance=1", "Profile", 725, 465, 1, 1, 0, 0, 0);
}

function openGlossary()
{
	new_window("glossary.aspx", "Glossary", 750, 465, 1, 1, 0, 0, 0);
}

// Initialize the capturing of the enter key.
function initEnterKey() 
{
	// Test for IE and Netscape
	ns4 = (document.layers)?true:false;
	ie4 = (document.all)?true:false;
	
	document.onkeydown = pressKey; //says what function to call when the enter key is pressed
	if (ns4) {document.captureEvents(Event.KEYDOWN)} // initiates the event capturing function for Netscape
}

// When Enter is clicked then submit form
function pressKey(e) 
{
	// Test for IE and Netscape
	ns4 = (document.layers)?true:false;
	ie4 = (document.all)?true:false;
	
	if (ns4) {var nKey=e.which; var ieKey=0}
	if (ie4) {var ieKey=event.keyCode; var nKey=0}
	if (nKey==13 || ieKey==13) // if "Enter" key is pressed
	{   
		//document.forms[0].submit();
		document.forms[0].btnSearch.click();
		return false;
	}
	else
	{
		return true;
	}
}



