﻿// Function clears a form
function ClearForm()
{
    document.aspnetForm.reset();
}






// Function disables a button and show the searching graphic
function RunSearch(ButtonToHide, ButtonToShow, PanelToShow)
{

    if (document.getElementById)
    {
        document.getElementById(ButtonToHide).style.display = "none";
        document.getElementById(ButtonToShow).style.display = "inline";
        document.getElementById(PanelToShow).style.display = "inline";
    }
    else
    {
        if (document.layers)
        {
            document.ButtonToHide.display = "none";
            document.ButtonToShow.display = "inline";
            document.PanelToShow.display = "inline";
        }
        else
        {
            document.all.ButtonToHide.style.display = "none";
            document.all.ButtonToShow.style.display = "inline";
            document.all.PanelToShow.style.display = "inline";
        }
    }

}






// Function displays an alert message that the user is leaving the site
function LeavingSite()
{
    window.alert("You are visiting a site outside of Hobbyretailer.com.  We are not responsible for any content displayed on the site you are about to view.");
}






// Function for loading the google map onto the page
function LoadMap(Address, City, State, Retailer) {
        
        
        
    var map = new GMap2(document.getElementById("map"));
    var geocoder = new GClientGeocoder();
    var FullAddress = Address + ", " + City + " " + State;
    
    geocoder.getLatLng(
    FullAddress, 
    function(point) {
    
        if (!point) {
            alert(FullAddress + " not found");
        } else {
        
            map.addControl(new GSmallMapControl());
            map.setCenter(point, 11);
            var marker = new GMarker(point);
            map.addOverlay(marker);
            marker.openInfoWindowHtml("<span style='font-size:11px;text-align:left;'>" + "<u><strong>" + Retailer + "</strong></u><br />" + Address + "<br />" + City + ", " + State + "</span>");
        
        }
    
    }
    );



}






// Function for showing the captcha control definition
function ShowCaptcha()
{

    // Grab the current page height
    var PageHeight = screen.height;
    var PageWidth = screen.width;
    
    
    // Determine the top and left positions
    var PageTop = ((PageHeight - 440) / 2);
    var PageLeft = ((PageWidth - 440) / 2);
        
    
    // Open up the new window
    window.open("/hobbyretailer/Captcha/codeverification.html", "null", "width=440, height=440, top=" + PageTop + ", Left=" + PageLeft + "location=no, menubar=no, resizeable=no, scrollbars=no, status=no, titlebar=no, toolbar=no");


}






// Function for displaying the captcha error
function InvalidCaptcha()
{
    window.alert("Invalid validation code entered");
}






// Function for displaying the checkbox error
function InvalidCheckbox()
{
    window.alert("Please select at least 1 checkbox for what you are interested in learning more information about.  If you wish, you may select both checkboxes");
}

