// show/hide functions
function show(id)
{
	d = document.getElementById(id);
	d.style.display = "block";
}

function hide(id)
{
	d = document.getElementById(id);
	d.style.display = "none";
}

function showinline(id)
{
	d = document.getElementById(id);
	d.style.display = "inline";
}

function showstandard(id) {
    d = document.getElementById(id);
    d.style.display = "";
}
sfHover = function() {

	var sfEls = document.getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


function showResourceTypes()
{
document.getElementById("theTypes").style.display = "block";
}

function showlocatorflyout() {
	document.getElementById("locatorflyout").style.display = "block";
	}
function hidelocatorflyout() {
	document.getElementById("locatorflyout").style.display = "none";
	}
function showcloseflyout() {
	/* //delay of 0.5 seconds before div appears which allows user to improperly dbl-click without getting erratic response
	setTimeout('(document.getElementById("closeflyout").style.display = "block")', 500);*/
	document.getElementById("closeflyout").style.display = "block";
	}
function hidecloseflyout() {
	/*//delay of 2 seconds before div disappears which allows user to move mouse off
	setTimeout('(document.getElementById("closeflyout").style.display = "none")', 2000);*/
	document.getElementById("closeflyout").style.display = "none";
	}


/* Client-side access to querystring name=value pairs
	Version 1.2.3
	22 Jun 2005
	Adam Vandenberg
*/
function Querystring(qs) { // optionally pass a querystring to parse
	this.params = new Object()
	this.get=Querystring_get
	
	if (qs == null)
		qs=location.search.substring(1,location.search.length)

	if (qs.length == 0) return

// Turn <plus> back to <space>
// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
	qs = qs.replace(/\+/g, ' ')
	var args = qs.split('&') // parse out name/value pairs separated via &
	
// split out each name=value pair
	for (var i=0;i<args.length;i++) {
		var value;
		var pair = args[i].split('=')
		var name = unescape(pair[0])

		if (pair.length == 2)
			value = unescape(pair[1])
		else
			value = name
		
		this.params[name] = value
	}
}

function Querystring_get(key, default_) {
	// This silly looking line changes UNDEFINED to NULL
	if (default_ == null) default_ = null;
	
	var value=this.params[key]
	if (value==null) value=default_;
	
	return value
}

function maskPhone(f){
    tel='';
    var val = f.value;
    val = val.replace('(','');
    val = val.replace(')','');
    val = val.replace('-','');
    val = val.split('');
    for(var i=0;i<val.length;i++){
        if(i==0){val[i]='('+val[i]}
        if(i==2){val[i]=val[i]+') '}
        if(i==5){val[i]=val[i]+'-'}
        tel=tel+val[i]
    }
    f.value=tel;
} 

function doClick(buttonName, e)
{
    var key;
    if(window.event)
      key = window.event.keyCode;     //IE
    else
      key = e.which;     //firefox
    if (key == 13)
    {
        //Get the button the user wants to have clicked
        var btn = document.getElementById(buttonName);
        if (btn != null)
        { 
            //If we find the button click it
            btn.click();
            //This prevents any further event processing,
            //which is what we want.
            return false;
        }
    }
}

function surveyPageLoad(initVal) {
    var yesNo = "No";
    yesNo = initVal;
    if (yesNo == "Yes") {
        document.getElementById("ContactYes").checked = true
        surveyShowPreferred();
    }
    else {
        document.getElementById("ContactNo").checked = true;
        surveyHidePreferred();
    }
}

function surveyShowPreferred() {
    show('PreferredContactDiv');
    hide('ContactDiv');
    hide('CommentsP');
    if (document.getElementById('ctl00_MainContent_ContactPreferredMethodRbl_0').checked) {
        show('ContactDiv');
        surveyShowPhoneFields();
    }
    if (document.getElementById('ctl00_MainContent_ContactPreferredMethodRbl_1').checked) {
        show('ContactDiv');
        surveyShowEmailFields();
    }
}

function surveyHidePreferred() {
    hide('PreferredContactDiv');
    hide('ContactDiv');
    show('CommentsP');
}

function surveyInitFields() {
    show('ContactDiv');
    hide('StreetRow');
    hide('CityRow');
    hide('StateRow');
    hide('PostalCodeRow');
}
function surveyShowEmailFields() {
    surveyInitFields();
    showstandard('StreetRow');
    showstandard('CityRow');
    showstandard('StateRow');
    showstandard('PostalCodeRow');
}

function surveyShowPhoneFields() {
    surveyInitFields();
}