﻿function highlight_on(elmnt) {
    document.all[elmnt].style.background = "#FFFFFF";
    document.all[elmnt + 'Link'].style.color = "#FFFFFF";
}
function highlight_off(elmnt) {
    document.all[elmnt].style.background = "#FFFFFF";
    document.all[elmnt + 'Link'].style.color = "#8C7CA5";
}

function rejectWhiteSpace(myForm, elementName, message) {
    var inputValue = myForm.elements[elementName].value;
    var regExpress = /\S/

    if (inputValue == "" || regExpress.test(inputValue) == false) {
        alert(message);
        myForm.elements[elementName].focus();
        return false;
    }

    return true;
}

function checkQuantity(myForm, elementName, message) {
    var inputValue = myForm.elements[elementName].value;

    if (isNum(inputValue) && inputValue > 0)
        return true;

    alert(message);
    myForm.elements[elementName].focus();
    return false;
}

function checkSearchBoxes(myForm, message) {

    var inputItemValue = myForm.elements["ItemIDText"].value;
    var inputQtyValue = myForm.elements["QuantityText"].value;

    if (inputItemValue.length > 0 && isNum(inputQtyValue) && inputQtyValue > 0)
        return true;

    alert(message);
    return false;
}

function isNum(value) {
    if (value == "")
        return false;

    for (var i = 0; i < value.length; i++)
        if (value.charAt(i) < "0" || value.charAt(i) > "9")
            return false;

    return true;
}

function newWindow(url, wide, high) {
    myNewWin = window.open(url, "myWin", "width=" + wide + ",height=" + high + ",left=0,top=0,status=no,scrollbars=yes,resizable=yes,toolbar=no,location=no,menubar=no");
}


function ChangeDiv(the_div, the_change) {
    var the_style = getStyleObject(the_div);
    if (the_style != false) {
        the_style.display = the_change;
    }
}

function HideContent() {
    ChangeDiv("OverviewDiv", "none");
    ChangeDiv("DirectionsDiv", "none");
    ChangeDiv("IngredientsDiv", "none");
    ChangeDiv("ReviewsDiv", "none");
    ChangeDiv("ResourcesDiv", "none");
    ChangeDiv("SpecsDiv", "none");
    ChangeDiv("MSDSDiv", "none");
}

function SelectTab(objectId) {
    //Set All Tabs Inactive
    document.all("LeftOverview").className = "TabILeftBtn";
    document.all("Overview").className = "TabIBtn";
    document.all("RightOverview").className = "TabIRightBtn";
    document.all("LeftDirections").className = "TabILeftBtn";
    document.all("Directions").className = "TabIBtn";
    document.all("RightDirections").className = "TabIRightBtn";
    document.all("LeftIngredients").className = "TabILeftBtn";
    document.all("Ingredients").className = "TabIBtn";
    document.all("RightIngredients").className = "TabIRightBtn";
    document.all("LeftReviews").className = "TabILeftBtn";
    document.all("Reviews").className = "TabIBtn";
    document.all("RightReviews").className = "TabIRightBtn";
    document.all("LeftResources").className = "TabILeftBtn";
    document.all("Resources").className = "TabIBtn";
    document.all("RightResources").className = "TabIRightBtn";
    document.all("LeftMSDS").className = "TabILeftBtn";
    document.all("MSDS").className = "TabIBtn";
    document.all("RightMSDS").className = "TabIRightBtn";
    //Set Active Tab based on what was passed in.
    document.all('Left' + objectId).className = "TabALeftBtn";
    document.all('Right' + objectId).className = "TabARightBtn";
    document.all(objectId).className = "TabABtn";

}
function getStyleObject(objectId) {
    if (document.getElementById && document.getElementById(objectId)) {
        return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
        return document.all(objectId).style;
    } else {
        return false;
    }
}


