
// JavaScript Document
$(document).ready(function() {
    $('.toolTip').hover(
        function() {
        this.tip = this.title;
        $(this).append(
            '<div class="toolTipWrapper">'
                +'<div class="toolTipTop"></div>'
                +'<div class="toolTipMid">'
                    +this.tip
                +'</div>'
                +'<div class="toolTipBtm"></div>'
            +'</div>'
        );
        this.title = "";
        this.width = $(this).width();
        $(this).find('.toolTipWrapper').css({left:this.width-22})
        $('.toolTipWrapper').fadeIn(300);
    },
    function() {
        $('.toolTipWrapper').fadeOut(100);
        $(this).children().remove();
            this.title = this.tip;
        }
    );
});
$(document).ready( function() {
    
    $('.downloadPDF').each( function(intIndex){
        var pdfSection = $(this);
        pdfSection.find('.button').eq(0).bind("click", function() {
            openSelected(pdfSection);
        } );
    }
    );
    
});
$(document).ready(function() {
  $('table.alternatingTable tbody tr:even').addClass('even');
});
$(document).ready(function() {
  $('table.alternatingDiv table:even').addClass('even');
});
$(document).ready(function(){
 //toggle the componenet with class msg_body
 $(".shareMoreExpandable").click(function(){
 $(".shareMore").toggleClass("moreExpanded");
});
});

function openSelected(section){
    var selection = section.find(".dropDown").eq(0).val();
    if (selection != "none")
        window.open(selection);
    }
function downloadPDF(){
    var selection = this.options[this.selectedIndex];
    if (selection.value != "none"){
        window.open(selection.value,"HRPolicy");
    }
}
function findViewDownloadButtons(){
    
}
function portraitHover(element){
    element.style.background = "url(/images/careers/insiders/rolloverbox.jpg)";
}
function portraitLeave(element){
    if (element.className == "portrait")
        element.style.background = "none";
}
function swapInsiderComplete(portraits, text, portraitName, textName){
    swapInsiderFocus(portraits,portraitName);
    swapContent(text,textName);
}
function swapInsiderFocus(swapable, divName){
    for(var i=0; i<swapable.length; i++){
        document.getElementById(swapable[i]).style.background = "none";
        document.getElementById(swapable[i]).className = "portrait";
    }
    
    document.getElementById(divName).style.background= "url(/images/careers/insiders/rolloverbox.jpg)";
    document.getElementById(divName).className = "portrait pactive";
}
//swapable is an array of elements that can be swapped and divName is the div to swap in
function swapContent(swapable,divName){
    //make all of the swapable element for this particular section display: none
    for(var i=0; i<swapable.length; i++){
        document.getElementById(swapable[i]).style.display = "none";
    }
    //turn back on the one you want
    document.getElementById(divName).style.display = "block";
}
function imgSwap (img, swapped) {
        document.getElementById(img).src = swapped;
}
function is_child_of(parent, child) {
    if( child != null ) {            
        while( child.parentNode ) {
            if( (child = child.parentNode) == parent ) {
                return true;
            }
        }
    }
    return false;
}
function fixOnMouseOut(element, event, JavaScript_code) {
    var current_mouse_target = null;
    if( event.toElement ) {                
        current_mouse_target              = event.toElement;
    } else if( event.relatedTarget ) {                
        current_mouse_target              = event.relatedTarget;
    }
    if( !is_child_of(element, current_mouse_target) && element != current_mouse_target ) {
        eval(JavaScript_code);
    }
}
ddaccordion.init({ //sidebar sollapsible areas initialization
    headerclass: "expandable", //Shared CSS class name of headers group that are expandable
    contentclass: "featureContent", //Shared CSS class name of contents group
    revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click" or "mouseover
    mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
    collapseprev: true, //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: false, //persist state of opened contents within browser session?
    toggleclass: ["", "openheader"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
    togglehtml: ["prefix", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
    animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
    oninit:function(headers, 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
        //do nothing
    }
})
ddaccordion.init({ //collapsible content areas initialization
    headerclass: "collapsablehead", //Shared CSS class name of headers group that are expandable
    contentclass: "collapsable", //Shared CSS class name of contents group
    revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click" or "mouseover
    mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
    collapseprev: false, //Collapse previous content (so only one open at any time)? true/false 
    defaultexpanded: [0,1], //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: false, //persist state of opened contents within browser session?
    toggleclass: ["", "openedheader"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
    togglehtml: ["suffix", "&nbsp;[+]", "&nbsp;[-]"], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
    animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
    oninit:function(headers, 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
        //do nothing
    }
})
ddaccordion.init({ // 2 column collapsible content initialization Column
    headerclass: "columnedcollapsableheadA", //Shared CSS class name of headers group that are expandable
    contentclass: "columnedcollapsableA", //Shared CSS class name of contents group
    revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click" or "mouseover
    mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
    collapseprev: false, //Collapse previous content (so only one open at any time)? true/false 
    defaultexpanded: [0], //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: false, //persist state of opened contents within browser session?
    toggleclass: ["", "openedheader="], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
    togglehtml: ["suffix", "&nbsp;[+]", "&nbsp;[-]"], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
    animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
    oninit:function(headers, 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
        //do nothing
    }
})
ddaccordion.init({ // 2 column collapsible content initialization Column B
    headerclass: "columnedcollapsableheadB", //Shared CSS class name of headers group that are expandable
    contentclass: "columnedcollapsableB", //Shared CSS class name of contents group
    revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click" or "mouseover
    mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
    collapseprev: false, //Collapse previous content (so only one open at any time)? true/false 
    defaultexpanded: [0], //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: false, //persist state of opened contents within browser session?
    toggleclass: ["", "openedheader"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
    togglehtml: ["suffix", "&nbsp;[+]", "&nbsp;[-]"], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
    animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
    oninit:function(headers, 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
        //do nothing
    }
})
ddaccordion.init({ //diversity timeline initialization
    headerclass: "diversityTimelinehead", //Shared CSS class name of headers group that are expandable
    contentclass: "diversityTimeline", //Shared CSS class name of contents group
    revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click" or "mouseover
    mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
    collapseprev: false, //Collapse previous content (so only one open at any time)? true/false 
    defaultexpanded: [0,4,9,14,20,30,37], //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: false, //persist state of opened contents within browser session?
    toggleclass: ["", "openedheader"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
    togglehtml: ["suffix", "&nbsp;[+]", "&nbsp;[-]"], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
    animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
    oninit:function(headers, 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
        //do nothing
    }
})

function clickclear(thisfield, defaulttext) {
    if (thisfield.value == defaulttext) {
        thisfield.value = "";
    }
}
function clickrecall(thisfield, defaulttext) {
    if (thisfield.value == "") {
        thisfield.value = defaulttext;
    }
}

function appendQueryString(selector, url) {
    if(selector != null) {
        // Pass query string parameters in
        selector.attr('src', url + location.search);
    }
};


