﻿jQuery(document).ready(function() {
    /**///png fix
    //did not work as advertised for ie6 so i went with htc fix
    //$('img[@src$=.png]').ifixpng();    
    /**/

    /**///Menu Interaction
    $("#nav > div").hover(
        function() {
            if (this.className != 'on') {
                $(this).addClass('over');
            }
        },
        function() {
            if (this.className != 'on') {
                $(this).removeClass('over');
            }
        }
    );
    /**/

    /**///preload images in css
    //7-30-2008 *seems to be breaking my jquery hover effects for all hover effects placed after it
    //from http://www.filamentgroup.com/lab/update_automatically_preload_images_from_css_with_jquery/
    //$.preloadCssImages();
    /**/
    

    /**/// Function for Replacing text
    String.prototype.replaceAll = function(
            strTarget, // The substring you want to replace
            strSubString // The string you want to replace in.
        ) {
        var strText = this;
        var intIndexOfMatch = strText.indexOf(strTarget);

        // Keep looping while an instance of the target string
        // still exists in the string.
        while (intIndexOfMatch != -1) {
            // Relace out the current instance.
            strText = strText.replace(strTarget, strSubString)

            // Get the index of any next matching substring.
            intIndexOfMatch = strText.indexOf(strTarget);
        }

        // Return the updated string with ALL the target strings
        // replaced out with the new substring.
        return (strText);
    }
    /**/

    /**///Remove Javascript that opens new window for Email Links
    var regx_value = "((window.open\\('mailto\:" + "([\_a-zA-Z0-9\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)" + "'\\)))";
    var regx = new RegExp(regx_value, "gmi");
    var regx_isMatch;
    $("form script").each(function(i) {
        regx_isMatch = regx.exec(this.innerHTML);
        if (regx_isMatch != null) {
            $("form script").eq(i).remove();
        }
    });
    /**/

    /*///Prevent Double Click on Form Buttons
    $("form").submit(function() {
        $(":submit", this).click(function() {
            return false;
        });
    }); 
    /**/

});

/**///Launch Popup.aspx
function launchPopup(popupLink, popupWidth, popupHeight) {
    var popupFeatures = "width=" + popupWidth;
    popupFeatures += ", height=" + popupHeight;
    popupFeatures += ", status=no";
    popupFeatures += ", menubar=no";
    popupFeatures += ", scrollbars=no";
    popupFeatures += ", resizable=no";
    popupFeatures += ", address=no";
    window.open(popupLink, null, popupFeatures);
}
/**/

/*///Remove Javascript that opens new window for Email Links
//Doesn't work well for Applications
function removeJS(type) {
    var regx_value;
    switch (type) {
        case "email":
            regx_value = "((window.open\\('mailto\:" + "([\_a-zA-Z0-9\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)" + "'\\)))";
            break;
    }
    var scripts = document.forms[0].getElementsByTagName("script");
    var regx = new RegExp(regx_value, "gmi");
    var scriptSrc;
    var regx_isMatch;
    for (var i = 0; i < scripts.length; i++) {
        scriptSrc = scripts[i].innerHTML;
        regx_isMatch = regx.exec(scriptSrc);
        if (regx_isMatch != null) {
            document.forms[0].removeChild(scripts[i]);
        }
    }
}
/**/