//FROM::Dynamic HTML (O'Reilly Book)
var isNav, isIE;
if( parseInt( navigator.appVersion) >= 4 )
{
	if( navigator.appName == "Netscape" )
	{ isNav = true; }
	else{ isIE = true; }
}
//FROM::http://www.howtocreate.co.uk/tutorials/index.php?tut=0&part=14&TOshow=MOZ
function getRefToDiv(divID) {
    if( document.layers ) { //Netscape layers
        return document.layers[divID]; }
    if( document.getElementById ) { //DOM; IE5, NS6, Mozilla, Opera
        return document.getElementById(divID); }
    if( document.all ) { //Proprietary DOM; IE4
        return document.all[divID]; }
    if( document[divID] ) { //Netscape alternative
        return document[divID]; }
    return false;
}
function showDiv(divID_as_a_string) {
    //get a reference as above ...
    myReference = getRefToDiv(divID_as_a_string);
    if( !myReference ) {
        //window.alert('Nothing works in this browser');
        return false; //don't go any further
        //return anything would work,
        //but I am using false to show failure
    }
    //now we have a reference to it
    if( myReference.style ) { //DOM &amp; proprietary DOM
        myReference.style.visibility = 'visible';
    } else {
        if( myReference.visibility ) { //Netscape
            myReference.visibility = 'show';
        } else {
            window.alert('Nothing works in this browser');
            return false; //don't go any further
        }
    }
    return true;
}
function hideDiv(divID_as_a_string) {
    //get a reference as above ...
    myReference = getRefToDiv(divID_as_a_string);
    if( !myReference ) {
        //window.alert('Nothing works in this browser');
        return false; //don't go any further
        //return anything would work,
        //but I am using false to show failure
    }
    //now we have a reference to it
    if( myReference.style ) { //DOM &amp; proprietary DOM
        myReference.style.visibility = 'hidden';
    } else {
        if( myReference.visibility ) { //Netscape
            myReference.visibility = 'hide';
        } else {
            window.alert('Nothing works in this browser');
            return false; //don't go any further
        }
    }
    return true;
}
function disableButton(buttonID_as_a_string) {
    //get a reference as above ...
    myReference = getRefToDiv(buttonID_as_a_string);
    if( !myReference ) {
        //window.alert('Nothing works in this browser');
        return false; //don't go any further
        //return anything would work,
        //but I am using false to show failure
    }
    //now we have a reference to it
	myReference.disabled = true;
    return true;
}
//FROM::AIA, LLC
function delObject( id,tbl,loc )
{
	if( ( id == null ) || ( id == "" ) )
	{ alert( "Nothing selected for deletion - please try again." ); }
	else
	{
		if( confirm( "Are you sure you wish to delete this item?" ) )
		{ window.location = "delObj.aspx?objID=" + id + "&tbl=" + tbl + "&loc=" + loc; }
	}
}
function showWCAddr()
{
	var state = document.locform.lst.value;
	if( state == 'CA' || state == 'CT' )
	{ document.all.wca.style.display = "inline"; }
	else
	{ document.all.wca.style.display = "none"; }
}
function ToggleCheck( dml )   //This function will handle select or deselect all
{
	//var dml = document.showloc;
	var len = dml.elements.length;
	var sav = document.getElementById("cbSelAll").checked;
	var idx;
	
	for( idx=0; idx<len; idx++ )
	{
		var str = dml.elements[idx].name;
		var pos = str.indexOf("cb-");
		if( pos >= 0 )
		{
			if( sav ) { dml.elements[idx].checked = 1; }
			else { dml.elements[idx].checked = 0; }
		}
	}
}
function checkStatus( dml )   //This function will keep the select|deselect all button in sync with other check boxes
{
	var len = dml.elements.length;
	var isC = true;   //Assume ALL checked
	var idx;
	
	for( idx=0; idx<len; idx++ )
	{
		var str = dml.elements[idx].name;
		var pos = str.indexOf("cb-");
		if( pos >= 0 )
		{
			if( dml.elements[idx].checked != 1 )
			{ isC = false; }
		}
	}
	if( !isC )
	{ document.getElementById("cbSelAll").checked = 0; }
	else{ document.getElementById("cbSelAll").checked = 1; }
}
function csValidateState( source, e )
{
	// Check for valid state code
	switch( e.Value.toUpperCase() )
	{
		case "AL": //Alabama
		case "AK": //Alaska
		case "AZ": //Arizona
		case "AR": //Arkansas
		case "CA": //California
		case "CD": //Canada
		case "CO": //Colorodo
		case "CT": //Connecticut
		case "DE": //Delaware
		case "DC": //District of Columbia
		case "FL": //Florida
		case "GA": //Georgia
		case "HI": //Hawaii
		case "ID": //Idaho
		case "IL": //Illinois
		case "IN": //Indiania
		case "IA": //Iowa
		case "KS": //Kansas
		case "KY": //Kentucky
		case "LA": //Louisiana
		case "ME": //Maine
		case "MD": //Maryland
		case "MA": //Massachusetts
		case "MI": //Michigan
		case "MN": //Minnesota
		case "MS": //Mississippi
		case "MO": //Missouri
		case "MT": //Montana
		case "NA": //Not Applicable (Dummy) State
		case "NE": //Nebraska
		case "NV": //Nevada
		case "NH": //New Hampshire
		case "NJ": //New Jersey
		case "NM": //New Mexico
		case "NY": //New York
		case "NC": //North Carolina
		case "ND": //North Dakota
		case "OH": //Ohio
		case "OK": //Oklahoma
		case "OR": //Oregon
		case "PA": //Pennsylvania
		case "PR": //Puerto Rico
		case "RI": //Rhode Island
		case "SC": //South Carolina
		case "SD": //South Dakota
		case "TN": //Tennessee
		case "TX": //Texas
		case "UT": //Utah
		case "VT": //Vermont
		case "VI": //Virgin Islands
		case "VA": //Virginia
		case "WA": //Washington
		case "WV": //West Virginia
		case "WI": //Wisconsin
		case "WY": //Wyoming
			e.IsValid = true;
			break;
		default:
			e.IsValid = false;
			break;
	}
}
function SetQuantity( frm, amt )   //This function will handle select or deselect all
{
	var len = frm.elements.length;
	var idx;
	
	for( idx=0; idx<len; idx++ )
	{
		var str = frm.elements[idx].name;
		var pos = str.indexOf("tb-");
		if( pos >= 0 )
		{ frm.elements[idx].value = amt; }
	}
}
function change( id, newClass ) 
{
	var identity = document.getElementById(id);
	identity.className = newClass;
}
function printBroker( dml, winhide, winshow, winclass )
{
	var len = dml.elements.length;
	var chk = false;
	var idx, str, pos;
	
	for( idx=0; idx<len; idx++ )
	{
		str = dml.elements[idx].name;
		pos = str.indexOf("cb-");
		if( pos >= 0 )
		{
			if( dml.elements[idx].checked == 1 )
			{ chk = true; break; }
		}
	}
	
	if( chk )
	{
		hideDiv( winhide );
		change( winshow, winclass );
		showDiv( winshow );
	}
	else
	{ alert( "Nothing selected to print, please try again." ); }
}
function goProp( inputobj ) 
{
	alert(" Hello...?");
	return;   //Skip for now...
	//var objval = inputobj.value;
	//var slash = objval.lastIndexOf( "\\" );
	//document.policy.ear_sim.value = objval.substr( slash + 1 );
}
function disableClick( inputobj ) 
{
	btn = document.getElementById("btnSub"); 
	btn.disabled = true;
	
	btn = document.getElementById("btnCan"); 	
	btn.disabled = true;
}