﻿// Function fixes the transparent png on IE 6
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='image');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }
}






// No flash content
function noFlash() {
    document.write("<a href=\"http://www.adobe.com/go/getflashplayer\" target=\"_blank\"><div style=\"margin:10px 0 0 0;padding:20px 0 20px 0;border:2px solid #CCCCCC;text-align:center;vertical-align:middle;\"><img src=\"/sitefiles/images/noflash.png\" alt=\"\" /></div></a>");
}



// No flash content homepage
function noFlashHomepage() {
    document.write("<a href=\"http://www.adobe.com/go/getflashplayer\" target=\"_blank\">");
    document.write("<div style=\"border:1px solid #CCCCCC;text-align:center;padding:10px;\"><img src=\"/sitefiles/images/noflash_homepage.png\" alt=\"\" /></div>");
    document.write("</a>");
}






// Opens a new window centered on the page
function OpenNewWindow(WindowPath, WindowWidth, WindowHeight) {

    // Grab the current page width and height
    var PageHeight = screen.height;
    var PageWidth = screen.width;



    // Determine the top and left positions
    var PageTop = ((PageHeight - WindowHeight) / 2);
    var PageLeft = ((PageWidth - WindowWidth) / 2);



    // Set the window properties
    var WindowProperties = "width=" + WindowWidth + ", height=" + WindowHeight + ", top=" + PageTop + ", left=" + PageLeft + ", location=no, menubar=no, resizeable=yes, scrollbars=yes, status=no, titlebar=no, toolbar=no";



    // Open the new window
    window.open(WindowPath, "null", WindowProperties);


}






// Opens a new window centered on the page
function OpenNewWindowNoScroll(WindowPath, WindowWidth, WindowHeight) {

    // Grab the current page width and height
    var PageHeight = screen.height;
    var PageWidth = screen.width;



    // Determine the top and left positions
    var PageTop = ((PageHeight - WindowHeight) / 2);
    var PageLeft = ((PageWidth - WindowWidth) / 2);



    // Set the window properties
    var WindowProperties = "width=" + WindowWidth + ", height=" + WindowHeight + ", top=" + PageTop + ", left=" + PageLeft + ", location=no, menubar=no, resizeable=no, scrollbars=no, status=no, titlebar=no, toolbar=no";



    // Open the new window
    window.open(WindowPath, "null", WindowProperties);


}






// Opens the e-mail friend window
function EmailFriend(ID) {

    // Grab the current page width and height
    var PageHeight = screen.height;
    var PageWidth = screen.width;



    // Determine the top and left positions
    var PageTop = ((PageHeight - 600) / 2);
    var PageLeft = ((PageWidth - 800) / 2);



    // Set the window properties
    var WindowProperties = "width=800, height=600, top=" + PageTop + ", left=" + PageLeft + ", location=no, menubar=no, resizeable=yes, scrollbars=yes, status=no, titlebar=no, toolbar=no";



    // Open the new window
    var URL = "/sitefiles/utilities/tellfriend.aspx?id=" + ID;
    window.open(URL, "null", WindowProperties);

}






// E-mail newsletter box scripts
function RemoveEmail(tb) {
    if (tb.value == "E-mail address") {
        tb.value = "";
    }
}
function ResetEmail(tb) {
    if (tb.value == "") {
        tb.value = "E-mail address";
    }
}






// Disables all the how to radio buttons
function DisableHowToButtons() {
    document.getElementById("articlesearch_0_rblHowTos_0").disabled = true;
    document.getElementById("articlesearch_0_rblHowTos_1").disabled = true;
    document.getElementById("articlesearch_0_rblHowTos_2").disabled = true;
}






// Disables all the how to radio buttons
function EnableHowToButtons() {
    document.getElementById("articlesearch_0_rblHowTos_0").disabled = false;
    document.getElementById("articlesearch_0_rblHowTos_1").disabled = false;
    document.getElementById("articlesearch_0_rblHowTos_2").disabled = false;
}







// Toggle for the how-to checkbox
function HowToToggle() {
    if (document.getElementById("articlesearch_0_chkHowTos").checked) {
        EnableHowToButtons();
    }
    else {
        DisableHowToButtons();
    }
}






// Shows the captcha control
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("/sitefiles/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");


}






// Executes the site search on the button click
function searchSite(url) {
    var keywords = document.getElementById("txtSiteSearch").value;
    var encoded = escape(keywords);
    location.href = url + "?keywords=" + encoded;
}






// Execute the hotspots search on the homepage
function searchHotspots(url) {
    location.href = url + "?location=" + document.getElementById("hotspotLocations").value + "&keywords=";
}






// On enter event for the text box
function onEnterSiteSearch(url) {
    if (event.keyCode == 13) {
        event.cancelBubble = true;
        event.returnValue = false;
        searchSite(url);
    }
}
