﻿// 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\"><img src=\"/sitefiles/images/homepage_no_flash.gif\" alt=\"Get Adobe Flash Player\" /></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";
    }
}






// 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");


}



function checkEnter(e) {
    var characterCode;
    if (e && e.which) {
        e = e;
        characterCode = e.which;
    }
    else {
        e = event;
        characterCode = e.keyCode;
    }
    if (characterCode == 13) {
        SearchTipsHomepage("/hidden/search/tips%20search.aspx");
        return false;
    }
}






// 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;
}






// Submit action for the tips database search
function SearchTips(url) {


    var keywords = document.getElementById("txtTipsKeywords").value;
    var category = document.getElementById("tipsCategory").value;
    var eKeywords = escape(keywords);
    var eCategory = escape(category);
    location.href = url + "?category=" + eCategory + "&keywords=" + eKeywords;


}




// Submit action for tips search on the homepage
function SearchTipsHomepage(url) {
    var keywords = document.getElementById("txtHomepageTipsKeywords").value;
    var eKeywords = escape(keywords);
    location.href = url + "?category=&keywords=" + eKeywords;
}









// Submit action for the kit reviews search
function SearchKitReviews(url) {


    var keywords = document.getElementById("kitReviewKeywords").value;
    var eKeywords = escape(keywords);
    location.href = url + "?keywords=" + eKeywords;


}


function noEnter(e) {
    var key;
    if (window.event) {
        key = window.event.keyCode;
    }
    else {
        key = e.which;
    }
    if (key == 13) {
        return false;
    }
    else {
        return true;
    }
}
