﻿
//----------- Get A DOM Object By Regular Expression and TagName ----------//

// get a single dom object

function getSingleDomObj(tagName, regexp)
{
    var i;
    var found = false;
    var domObj;
    var tagArray = document.getElementsByTagName(tagName);

    for (i = 0; i < tagArray.length && found == false; i++)
    {
        if (regexp.test(tagArray[i].getAttribute("ID")))
        {
            domObj = tagArray[i];
            found = true;
        }
    }
    return domObj;
}

//get an array of objects of the same type

function getAllDomObjects(tagName, regexp)
{
    var i,j;
    var found = false;
    var domObjArr = new Array();
    var tagArray = document.getElementsByTagName(tagName);

    for (i = 0, j = 0; i < tagArray.length; i++)
    {
        if (regexp.test(tagArray[i].getAttribute("ID")))
        {
            domObjArr[j] = tagArray[i];
            j++;
        }
    }
    return domObjArr;
}

//------------------------------- Opacity --------------------------------//

//change the opacity of any object that is transfered as a parameter

function OpacAnyObj(obj, opacityValue)
{
    if (typeof document.body.style.opacity != 'undefined')//FF 
    {
        obj.style.opacity = opacityValue / 100;
    }
    else if (typeof document.body.style.filter != 'undefined') //IE
    {
        obj.style.filter = "alpha(opacity=" + opacityValue + ")";
    }
}

// change the opacity of the large image. the table containing the large image is
// global variable and we get its reference directly

function OpacLargeImage(opacityValue)
{
    if (largeImagesTableObj != 'undefined')
    {
        getWhiteTable();
        obj = largeImagesTableObj;
    }

    if (typeof document.body.style.opacity != 'undefined')//FF 
    {
        obj.style.opacity = opacityValue / 100;
    }
    else if (typeof document.body.style.filter != 'undefined') //IE
    {
        obj.style.filter = "alpha(opacity=" + opacityValue + ")";
    }
}

//--------------------------------- Get Page Dimensions -------------------------------//

// Browser Window Size and Position
// copyright Stephen Chapman, 3rd Jan 2005, 8th Dec 2005
// you may copy these functions but please keep the copyright notice as well

function pageWidth()
{
    return window.innerWidth != null ?
        window.innerWidth : document.documentElement && document.documentElement.clientWidth ?
            document.documentElement.clientWidth : document.body != null ?
                document.body.clientWidth : null;
}

function pageHeight()
{
    return window.innerHeight != null ?
        window.innerHeight : document.documentElement && document.documentElement.clientHeight ?
            document.documentElement.clientHeight : document.body != null ? 
                document.body.clientHeight : null;
}

//--------------------------- Contact Page -----------------------------------//

function clearText(obj)
{
    obj.innerHTML = " ";
}

function changeColor(obj)
{
    obj.style.color = "#232323";
}

function changeDirection(obj)
{
    obj.style.dir = "ltr";
    obj.style.textAlign = "left";
}

function checkEmail(obj)
{
    if (obj.value == "")
    {
        obj.value = "*";
        obj.style.color = "#e3011b";        
    }
    else if ((a = obj.value.indexOf('@')) < 0 ||
             (d = obj.value.indexOf('.')) < 0 || a > d ||
              a == obj.value.length - 1 || d == obj.value.length - 1)
    {
        obj.style.color = "#e3011b";
    }
    else
    {
        obj.style.color = "#232323";
    }
}

//------------------------- functions for underlining the categories menu -------------------//

// these are styling functions trigerred in the browser events onmouseover and onmouseout

function showULine(obj)
{
    var color = "#ababcd"; //"#c3c3e5";
    var width = "2px";
    var type = "solid";
    obj.style.borderBottom = color + " " + width + " " + type;
}

function whitenULine(obj)
{
    var color = "#ffffff";
    var width = "2px";
    var type = "solid";
    obj.style.borderBottom = color + " " + width + " " + type;
}

//------------------------- functions for catalog page -------------------//

function selectCategoryOver()
{
    var cat = new RegExp("categorySelector");
    var max = new RegExp("priceSelectorMax");
    var min = new RegExp("priceSelectorMin");
    var div1 = getSingleDomObj("div", cat);
    var div2 = getSingleDomObj("div", max);
    var div3 = getSingleDomObj("div", min);
    div1.style.height = "260px";
    div2.style.height = "162px";
    div3.style.height = "162px";
}
function selectCategoryOut()
{
    var cat = new RegExp("categorySelector");
    var max = new RegExp("priceSelectorMax");
    var min = new RegExp("priceSelectorMin");
    var div1 = getSingleDomObj("div", cat);
    var div2 = getSingleDomObj("div", max);
    var div3 = getSingleDomObj("div", min);
    div1.style.height = "52px";
    div2.style.height = "370px";
    div3.style.height = "370px";
}

function selectCategoryOutNew()
{
    var timer, count = 0;
    var cat = new RegExp("categorySelector");
    var max = new RegExp("priceSelectorMax");
    var min = new RegExp("priceSelectorMin");
    var div1 = getSingleDomObj("div", cat);
    var div2 = getSingleDomObj("div", max);
    var div3 = getSingleDomObj("div", min);

    while (count < 65)
    {
        timer = setTimeout("changeSelectorsHeight()", 10 * count);
        count++;
    }
}

function changeSelectorsHeight()
{
    var cat = new RegExp("categorySelector");
    var max = new RegExp("priceSelectorMax");
    var min = new RegExp("priceSelectorMin");
    var div1 = getSingleDomObj("div", cat);
    var div2 = getSingleDomObj("div", max);
    var div3 = getSingleDomObj("div", min);
    if (getIntHeight(div1.style.height) > 54)
    {
        div1.style.height = getIncrementedHeight(div1.style.height, -2).toString() + "px";
        div2.style.height = getIncrementedHeight(div2.style.height, 2).toString() + "px";
        div3.style.height = getIncrementedHeight(div3.style.height, 2).toString() + "px";
    }
}

function getIncrementedHeight(currHeightStr, increment)
{
    var h = getIntHeight(currHeightStr);
    return h + increment;
}

function getIntHeight(currHeightStr)
{
    var px = currHeightStr.indexOf("px");
    return parseInt(currHeightStr.substring(0, px));
}

function scrollUp()
{
    var i, timer;
    var divArr = document.getElementsByTagName('div');
    var regexpDiv = /textHider/;

    clearTimeout(timer);
    for (i = 0; i < divArr.length; i++)
    {
        if (regexpDiv.test(divArr[i].getAttribute("ID")))
        {
            divArr[i].scrollTop += -6;
        }
    }
    timer = setTimeout("scrollUp()", 7);
}




