﻿//Code Developed By Don Jereczek
//HP Hood IT Services
//Last Modified 09/11/2009

//PreLoad Navigation Images
function simplePreload() {
    var args = simplePreload.arguments;
    document.imageArray = new Array(args.length);
    for (var i = 0; i < args.length; i++) {
        document.imageArray[i] = new Image;
        document.imageArray[i].src = args[i];
    }
}

//Searchbox Automation
function clearSearch(obj) {
    if (obj.value == 'SEARCH HELUVAGOOD.COM') { obj.value = ''; }
}

function resetSearch(obj) {
    if (obj.value == '') { obj.value = 'SEARCH HELUVAGOOD.COM'; }
}

//Swap side navigation images
function swapSideImage(imageID, state) {
    var obj = document.getElementById(imageID);
    var objsrc = obj.src;

    if (state == 'On') {
        objsrc = objsrc.replace('_Off', '_On');
    } else {
        objsrc = objsrc.replace('_On', '_Off');
    }

    obj.src = objsrc;
}

//Swap brand images and descriptions
function swapBrand(imageID, state, desc) {
    var obj = document.getElementById(imageID);
    var objsrc = obj.src;

    if (state == 'On') {
        objsrc = objsrc.replace('_Off', '_On');
        document.getElementById(desc).style.display = 'inline';
    } else {
        objsrc = objsrc.replace('_On', '_Off');
        document.getElementById(desc).style.display = 'none';
    }

    obj.src = objsrc;
}

//Preload for auto navigation images
function navPreload(element) {
    var getMenu = document.getElementById(element);
    var getImages = getMenu.getElementsByTagName("img");
    document.imageArray = new Array(getImages.length);  
    for (var i = 0; i < getImages.length; i++) {
        var objsrc = getImages[i].src;
        objsrc = objsrc.replace('_Off', '_On');
        document.imageArray[i] = new Image;
        document.imageArray[i].src = objsrc;
    }
}

//Format date for Press Release
function pressDate(date) {
    var m_names = new Array("January", "February", "March",
"April", "May", "June", "July", "August", "September",
"October", "November", "December");
    document.write(m_names[parseInt(date.substr(5, 2), 10) - 1] + " " + date.substr(8, 2)
+ ", " + date.substr(0, 4));
}

//Generic Popup Window
function popupWin(url, width, height) {
    newwindow = window.open(url, 'name', 'height=' + height + ',width=' + width + ', scrollbars=yes');
    if (window.focus) { newwindow.focus() }
    return false;
}

// JQuery +
$(function () {

    // Set classes on the Home Features.
    $(".homeFeaturesArea .homeFeatures_frame a:first-child").addClass("homeFeature_item01");
    $(".homeFeaturesArea .homeFeatures_frame a:eq(1)").addClass("homeFeature_item02");
    $(".homeFeaturesArea .homeFeatures_frame a:eq(2)").addClass("homeFeature_item03");

    // Apply a class to the last Breadcrumb anchor for CSS traction.
    $(".contCrumb a:last-child").addClass("bc_last");

    // Add class names to the Top Nav tabs in order to apply specific widths.
    $(".heluvagood_menu .ekmenu_menu_level_0:first-child").addClass("tab_01")
    $(".heluvagood_menu * .ekmenu_menu_level_0:eq(1)").addClass("tab_02");
    $(".heluvagood_menu * .ekmenu_menu_level_0:eq(2)").addClass("tab_03");
    $(".heluvagood_menu * .ekmenu_menu_level_0:eq(3)").addClass("tab_04");
    $(".heluvagood_menu * .ekmenu_menu_level_0:eq(4)").addClass("tab_05");

    // Set alternating in-line images to float right or left alternately.
    //$("p img.img_float:odd").addClass("img_float_left");
    $("div.landing p img").addClass("img_float");
    $("div.landing p img.img_float:odd").addClass("img_float_left");

    // Add a class tothe last subnav item for CSS traction
    $("div.subnav ul li:last-child").addClass("last");

    // Adds a break after Coupons or Promotion items if different heights (need to uncomment if heights differ).
    //$("div.feature_coupons img:odd").after("<div style='clear:both;height:0;'></div>");

});
// JQuery -