// Opens a child window - declaration matches the "window.open" signature exactly
function __WindowOpen(sUrl,sName,sOptions){
	if(sOptions==null){sOptions="menubar=1,resizable=1,scrollbars=1,status=1,titlebar=1,toolbar=1,location=1";}
	window.open(sUrl,sName,sOptions);
}

// Toggles the show or hide state of an HTML element based on the specified ID
function __ToggleShowHide(sID,sShowImageFile,sHideImageFile){var o=document.getElementById(sID),i=document.getElementById(sID+'_IMG');
	if(o!=null){
		if(o.style.display=='none'){o.style.display='';}else{o.style.display='none';}
		if(i!=null){if(i.src.indexOf('ShowHideMinus')<0){i.src=sHideImageFile;}else{i.src=sShowImageFile;}}
	}
}

// Initialize header search event handlers
var nn,ie;
function __InitializeSearch(){
	nn=(navigator.appName.indexOf("Netscape")>=0&&parseInt(navigator.appVersion.charAt(0))>=4)?true:false;
	ie=(navigator.appName.indexOf("Explorer")>=0&&parseInt(navigator.appVersion.charAt(0))>=4)?true:false;
	document.onkeypress=__KeyPressed;
	if(nn)document.captureEvents(Event.KEYPRESS);
}
	
// Establish the header search button context
var currSearchButton;
function __SetSearchButton(btn){currSearchButton=btn;}

// Establish the key pressed and spawn the search button script
function __KeyPressed(k){
	if(currSearchButton=="")return;
	if(nn)key=k.which;
	if(ie)key=event.keyCode;
	if(key==13){
		if(nn){__SubmitSearch('sSearch','0');}
		else{document.getElementById(currSearchButton).click();}
	}
}

// Handle search button submittal
function __SubmitSearch(sTxtID,bAdv){
	var t=document.getElementById(sTxtID);
	if(t!=null){window.location.href="Search.aspx?Search="+escape(t.value)+((bAdv=='1')?'&SV=1':'');t.focus();}
}

// Handles the ZipCode submission on the Consumers Home page
function __AgencyLocator(sBaseUrl) {
	var oZip = document.getElementById("zip");
	var oForm = document.getElementById("main");
	oForm.action = sBaseUrl + "?zip="+oZip.value;
	oForm.submit;
}

//agencylocator - sets focus to the correct field based on the selected search type
function __SetFocus(sField) {
	var oDDLSearchType = document.getElementById("ddlSearchType");
//0 - AgencyName
//1 - ZipCodeRadius
//2 - CityState
//3 - AgencyNumber
//4 - DMMID
	if(sField=="") {
		switch (oDDLSearchType.selectedIndex) {
			case 0:
				sField = "txtName";
				break;
			case 1:
				sField = "txtZipCode";
				break;
			case 2:
				sField = "txtCity";
				break;
			case 3:
				sField = "txtAgencyNumber";
				break;
			case 4:
				sField = "txtDMM";
				break;
		}
	}
	
	var oObj = document.getElementById(sField);
	if (oObj!=null) oObj.focus();
	
	return true;
}

function __InitializeAgencySearch(){
	nn=(navigator.appName.indexOf("Netscape")>=0&&parseInt(navigator.appVersion.charAt(0))>=4)?true:false;
	ie=(navigator.appName.indexOf("Explorer")>=0&&parseInt(navigator.appVersion.charAt(0))>=4)?true:false;
	document.onkeypress=__SubmitOnEnter;
	if(nn)document.captureEvents(Event.KEYPRESS);
}

function __SubmitOnEnter() {
	if(nn) key=k.which;
	if(ie) key=event.keyCode;
	if(key==13){
		document.getElementById("btnFind").click();
	}
}

function bookmarksite(url, title){
	if (window.sidebar) { 
		alert('Press Ctrl-D to bookmark this page'); 
	} else if( document.all ) { 
		window.external.AddFavorite( url, title); 
	} else if( window.opera && window.print ) { 
		return true; 
	} 
}
//Begin rollover fade code
var fadeIntervals = new Object();

function showIE(itemID)
{
	clearInterval(fadeIntervals[itemID+"FadeOUT"]);
	var value = document.getElementById(itemID).filters[0].opacity;
	if (value<100)
		value+=10;
	else{
		clearInterval(fadeIntervals[itemID+"FadeUP"]);
	}
	document.getElementById(itemID).filters[0].opacity=value;
}

function hideIE(itemID)
{
	clearInterval(fadeIntervals[itemID+"FadeUP"]);
	var value = document.getElementById(itemID).filters[0].opacity;
	if (value>0)
		value-=10;
	else{
		clearInterval(fadeIntervals[itemID+"FadeOUT"]);
	}
	document.getElementById(itemID).filters[0].opacity=value;
}

function showMOZ(itemID)
{
	clearInterval(fadeIntervals[itemID+"FadeOUT"]);
	value = parseFloat(document.getElementById(itemID).style.MozOpacity);
	if (value<1) {
		value+=.1;
	}		
	else{
		clearInterval(fadeIntervals[itemID+"FadeUP"]);
	}
	document.getElementById(itemID).style.MozOpacity=value;
}

function hideMOZ(itemID)
{

	clearInterval(fadeIntervals[itemID+"FadeUP"]);
	var value = parseFloat(document.getElementById(itemID).style.MozOpacity);
	if (value>0)
		value-=.1;
	else{
		clearInterval(fadeIntervals[itemID+"FadeOUT"]);
	}
	document.getElementById(itemID).style.MozOpacity=value;
}

function fadeUP(itemID)
{
	if (window.sidebar)
	{
		fadeIntervals[itemID+"FadeUP"] = setInterval("showMOZ('"+itemID+"')",10);
	}
	if (document.all)
	{
		fadeIntervals[itemID+"FadeUP"] = setInterval("showIE('"+itemID+"')",10);
	}
}

function fadeOUT(itemID)
{
	setTimeout(function () {
		startFade(itemID);
		}, 400);
}

function startFade(itemID)
{
	if (window.sidebar)
	{
		fadeIntervals[itemID+"FadeOUT"] = setInterval("hideMOZ('"+itemID+"')",10);
	}
	if (document.all)
	{
		fadeIntervals[itemID+"FadeOUT"] = setInterval("hideIE('"+itemID+"')",10);
	}
}
//end rollover fade code
function showCalendar(sFld , sPageName) {
			calendar_window = window.open('calendar.aspx?formname='+sPageName+'.'+sFld, 'calWin', config='height=248,width=288,toobar=no, menubar=no, scrollbars=no, resizable=no,location=no, directories=no,status=no');
			calendar_window.focus(); 
			}
