/*
Toggles whether a <div> layer is shown, or hidden.

params:
div: The <div> layer to toggle
field: A <asp:HiddenField> which can be passed in
       to persist the visibility of the <div> for 
       the browser session.
*/
function showHide(div, field) 
{
    if(document.getElementById(div).style.display == "none") 
    {
        document.getElementById(div).style.display = "block";   
        //document.aspnetForm.field.value = "block";
    }
    else if (document.getElementById(div).style.display == "block")
    {
        document.getElementById(div).style.display = "none";              
        //document.aspnetForm.field.value = "none";
    }
}

function populatePageLink(page, element)
{
	document.getElementById(element).value = page;
}

function writeToSearch(search) 
{
    document.aspnetForm.ctl00$ContentPlaceHolder1$txtCitySearch.value = search;
    document.aspnetForm.ctl00$ContentPlaceHolder1$btnCitySearch.click();
}

function writeQueryString(page, dest) 
{
    // get the current page
    var url = window.location.protocol + "//" + window.location.host + page;
    
    // now add in all the vars that are needed to load the page.
    url = url + "?lat=" + document.aspnetForm.ctl00$ContentPlaceHolder1$lat.value;
    url = url + "&lng=" + document.aspnetForm.ctl00$ContentPlaceHolder1$lng.value;
    url = url + "&mr=" + document.aspnetForm.ctl00$ContentPlaceHolder1$maxResults.value;
    url = url + "&rad=" + document.aspnetForm.ctl00$ContentPlaceHolder1$radius.value;
    url = url + "&loc=" + escape(document.aspnetForm.ctl00$ContentPlaceHolder1$txtCitySearch.value);
    
    // Write the url to the location bar.
    document.aspnetForm.linkUrl.value = url;
}

/*
 Opens a new browser window with the provided dimensions.
*/
function OpenWindow(url, name, width, height) 
{
    var options = "width=" + width + ",height=" + height;
    options += ",resizable=no, toolbar=no, status=no, menubar=no, copyhistory=no, scrollbars=yes";
    
    window.open(url, name, options, true);
}