﻿jQuery.fn.pngfix = function(settings) {
    settings = jQuery.extend({
        imgs: true,
        shim: '/blank.gif'
    }, settings);
    
    return this.each(function(){
        if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7 && parseInt(jQuery.browser.version, 10) > 4) {
            jQuery(this).find('*').andSelf().each(function(i,obj) {
                var self = jQuery(obj);
                // image elements
                if (settings.imgs && self.is('img[src$=png]')){
                    var styles = {
                        'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + self.attr('src') + "', sizingMethod='scale')"
                    };
                    self.css(styles).attr('src', settings.shim);
                };
            });
        };
    });
};//end pngfix


ddaccordion.init({
    headerclass: "mainNavCategory", //Shared CSS class name of headers group
    contentclass: "mainNavSubcategory", //Shared CSS class name of contents group
    revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click" or "mouseover"
    collapseprev: false, //Collapse previous content (so only one open at any time)? true/false 
    defaultexpanded: [], //index of content(s) open by default [index1, index2, etc]. [] denotes no content.
    onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
    animatedefault: false, //Should contents open by default be animated into view?
    persiststate: true, //persist state of opened contents within browser session?
    toggleclass: ["", ""], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
    togglehtml: ["prefix", "<img src='/expandbtn.jpg' alt='Expand Navigation'/>", "<img src='/collapsebtn.jpg' alt='Collapse Navigation'/>"], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
    animatespeed: "fast", //speed of animation: "fast", "normal", or "slow"
    oninit:function(expandedindices){ //custom code to run when headers have initalized
        //do nothing
    },
       onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
        // redraw footer in ie6
        if (document.getElementById){
            var ftrID = document.getElementById("footer")
            ftrID.style.display="none"
            ftrID.style.display="block"
            }
       }
}); //END ddaccordian.init

$(document).ready(function(){
    //fix transparency issue for banner
   $('#decBanner').pngfix();

    //clear default search box text
    var elmSearch = document.getElementById("query-field");
        elmSearch.onclick = function(){
            if (elmSearch.defaultValue==elmSearch.value) elmSearch.value = "";
        }

    //enable "Expand All" and "Collapse All" buttons for main navigation
    var elmExpand = document.getElementById("expand");
    elmExpand.onclick = function(){
        ddaccordion.expandall('mainNavCategory');
        return false;
    }
    var elmCollapse = document.getElementById("collapse");
    elmCollapse.onclick = function(){
        ddaccordion.collapseall('mainNavCategory');
        return false;
    }
    
});
