﻿

// jquery no conflict. use $j or jQuery outside of ready function
var $j = jQuery.noConflict();


// jQuery document ready
jQuery(function ($) {

    // JS enabled
    $('html').addClass('js');

    var $body = $('body');

    // Few setups for IE6
    if (document.all) {
        //add class to drop downs and buttons. some extra verbosity to move the class of the current item up to the the ul to avoid IE6's multiple class bugginess (.blah.over)
        var IEulClass = "";
        $('#nav>li, button').hover(
   			function () { $(this).addClass('over').find('ul.cols').show(); IEulClass = $(this).attr("class"); $(this).parents("#nav").addClass(IEulClass); },
   			function () { $(this).removeClass('over').find('ul.cols').hide(); $(this).parents("#nav").removeClass(IEulClass); }
		);
    } // if document.all

    //pleasantNav('#nav>li');

    // use the label as default input text and hide the label
    $('#header input, #site-login input').inputSetter();

});  // document ready

/*
Input Setter - pdf, 2008 isite design
pull label and insert as field. clear with click.	

ex: $("#sitesearch input").inputSetter(1); // makes default text lowercase
$("#sitesearch input").inputSetter(); // no lowercasing

*/

jQuery.fn.inputSetter = function (lower) {
    return this.each(function () {
        var $input = jQuery(this);
        var $label = jQuery("label[for='" + $input.attr("id") + "']");
        var labeltext = lower && lower == 1 ? $label.text().toLowerCase() : $label.text();
        $label.hide();
        var inputtext = $input.val();
        if (inputtext.length == 0)
            $input.val(labeltext);
        $input.focus(function () { if (this.value == labeltext) { this.value = ""; } })
			  .blur(function () { if (!this.value.length) { this.value = labeltext; } });
    });
};

// Gets current year for footer copyright
function getYear() {
    var d = new Date();
    yr = d.getFullYear();
    document.write(yr);
}

// IE6 fixes
// make sure IE has the abbr and acronym tag
if (document.all) {
    document.createElement("abbr");
    document.createElement("acronym");
}
// prevent IE6 flicker
try { document.execCommand('BackgroundImageCache', false, true); } catch (e) { }

// PNG transparency in Win IE 5.5 & 6
function correctPNG() {
    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='scale');\"></span>"
                img.outerHTML = strNewHTML
                i = i - 1
            }
        }
    }
}
window.attachEvent("onload", correctPNG);
