﻿//====================== Shortcut Functions ====================================
function $(x) {
    return document.getElementById(x);
}
function $t(x) {
    return document.getElementsByTagName(x);
}
function STO(exp, timeout) {
    return window.setTimeout(exp, timeout);
}
function DecToHexa(_26) {
    var _27 = parseInt(_26).toString(16);
    if (_26 < 16) {
        _27 = "0" + _27;
    }
    return _27;
}
//===============================================================================
function writeSessionCookie(cookieName, cookieValue) {
    if (testSessionCookie()) {
        document.cookie = escape(cookieName) + "=" + escape(cookieValue) + "; path=/";
        return true;
    }
    else return false;
}
function getCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}
function getCookieValue(cookieName) {
    var exp = new RegExp(escape(cookieName) + "=([^;]+)");
    if (exp.test(document.cookie + ";")) {
        exp.exec(document.cookie + ";");
        return unescape(RegExp.$1);
    }
    else return false;
}
function getCartInfo() {
    var cartInfo = new Array()
    var strCookie = getCookieValue('SCIFO')
    var arrCookie = strCookie.split("&")
    for (var i = 0; i < arrCookie.length; i++) {
        var arrCookieVals = arrCookie[i].split("=")
        cartInfo[arrCookieVals[0]] = arrCookieVals[1]
    }
    return cartInfo
}
function deleteCookie(cookieName) {

    if (getCookieValue(cookieName)) writePersistentCookie(cookieName, "Pending delete", "years", -1);
    return true;
}
function testSessionCookie() {
    document.cookie = "testSessionCookie=Enabled";
    if (getCookieValue("testSessionCookie") == "Enabled")
        return true
    else
        return false;
}
function testPersistentCookie() {
    writePersistentCookie("testPersistentCookie", "Enabled", "minutes", 1);
    if (getCookieValue("testPersistentCookie") == "Enabled")
        return true
    else
        return false;
}
function writePersistentCookie(CookieName, CookieValue, periodType, offset) {
    var expireDate = new Date();
    offset = offset / 1;
    var myPeriodType = periodType;
    switch (myPeriodType.toLowerCase()) {
        case "years":
            var year = expireDate.getYear();
            // Note some browsers give only the years since 1900, and some since 0.
            if (year < 1000) year = year + 1900;
            expireDate.setYear(year + offset);
            break;
        case "months":
            expireDate.setMonth(expireDate.getMonth() + offset);
            break;
        case "days":
            expireDate.setDate(expireDate.getDate() + offset);
            break;
        case "hours":
            expireDate.setHours(expireDate.getHours() + offset);
            break;
        case "minutes":
            expireDate.setMinutes(expireDate.getMinutes() + offset);
            break;
        default:
            alert("Invalid periodType parameter for writePersistentCookie()");
            break;
    }
    document.cookie = escape(CookieName) + "=" + escape(CookieValue) + "; expires=" + expireDate.toGMTString() + "; path=/";
}
function FillShipping(container) {
    if ($(container + "_cbSame").checked) {
        $(container + "_txtFname_s").value = $(container + "_txtFname").value;
        $(container + "_txtLname_s").value = $(container + "_txtLname").value;
        $(container + "_txtAddress1_s").value = $(container + "_txtAddress1").value;
        $(container + "_txtAddress2_s").value = $(container + "_txtAddress2").value;
        $(container + "_txtCity_s").value = $(container + "_txtCity").value;
        $(container + "_txtZip_s").value = $(container + "_txtZip").value;
        $(container + "_txtPhone_s").value = $(container + "_txtPhone").value;
        $(container + "_txtState_s").value = $(container + "_txtState").value;
        $(container + "_txtCompany_s").value = $(container + "_txtCompany").value;
        $(container + "_ddlState_s").selectedIndex = $(container + "_ddlState").selectedIndex;
        $(container + "_ddlCountry_s").selectedIndex = $(container + "_ddlCountry").selectedIndex;
    }
}
window.onloadListeners = new Array();
window.addOnLoadListener = function(listener) {
    window.onloadListeners[window.onloadListeners.length] = listener;
}
window.onload = function() {
    for (var i = 0; i < window.onloadListeners.length; i++) {
        func = window.onloadListeners[i];
        func.call();
    }
}
function fireAll() {
    for (var i = 0; i < window.onloadListeners.length; i++) {
        func = window.onloadListeners[i];
        func.call();
    }
}
function Increment(textBoxId, increment) {
    var textBoxControl = GetTextbox(textBoxId);
    if (textBoxControl != null) textBoxControl.value = parseInt(textBoxControl.value) + increment;
}
function Decrement(textBoxId, increment) {
    var textBoxControl = GetTextbox(textBoxId);
    if (textBoxControl != null && parseInt(textBoxControl.value) != 0) textBoxControl.value = parseInt(textBoxControl.value) - increment;
}
function GetTextbox(textBoxId) {
    for (var i = 0; i < document.forms.length; i++) {
        var theForm = document.forms[i];
        if (typeof (theForm[textBoxId]) != "undefined") {
            var textBoxControl = theForm[textBoxId];
            if (isNaN(parseInt(textBoxControl.value))) textBoxControl.value = 0;
            return textBoxControl;
        }
    }
    return null;
}
//================================================================
function fP(hP, hRP, txtP, txtRP) {
    if (hP != undefined && hP != "") {
        txtP.value = hP.value;
    }
    if (hRP != undefined && hRP != "") {
        txtRP.value = hRP.value;
    }
}
function checkStatus() {
    var tcs = getCookie('TCS');
    if (tcs != null && (tcs == 3 || tcs == 4)) {
        $("mainPane").style.visibility = "visible";
        $("mainPane").style.visibility = "visible";
    }
    else {
        $("loading").style.visibility = "visible";
        $("loading").style.visibility = "visible";
        window.location.replace('default.aspx');
    }
}
//===================================================================================================
function Get_Cookie(name) {
    var start = document.cookie.indexOf(name + '=');
    var len = start + name.length + 1;
    if ((!start) && (name != document.cookie.substring(0, name.length)))
        return null;
    if (start == -1)
        return null;
    var end = document.cookie.indexOf(';', len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len, end));
}
function Set_Cookie(name, value, expires, path, domain, secure) {
    // set time, it's in milliseconds
    var today = new Date();
    today.setTime(today.getTime());

    /*
    if the expires variable is set, make the correct 
    expires time, the current script below will set 
    it for x number of days, to make it for hours, 
    delete * 24, for minutes, delete * 60 * 24
    */
    if (expires) {
        expires = expires * 1000 * 60 * 60 * 24;
    }
    var expires_date = new Date(today.getTime() + (expires));

    document.cookie = name + "=" + escape(value) +
((expires) ? ";expires=" + expires_date.toGMTString() : "") +
((path) ? ";path=" + path : "") +
((domain) ? ";domain=" + domain : "") +
((secure) ? ";secure" : "");
}
function Delete_Cookie(name, path, domain) {
    if (Get_Cookie(name))
        document.cookie =
      name + '=' +
      ((path) ? ';path=' + path : '') +
      ((domain) ? ';domain=' + domain : '') +
      ';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}
//================================== EasyAjax ===========================================================================

var IS_IE = true;
try {
    window.attachEvent = window.HTMLDocument.prototype.attachEvent = window.HTMLElement.prototype.attachEvent = function(type, callback) { this.addEventListener(type.substring(2), callback, false); }
    window.detachEvent = window.HTMLDocument.prototype.detachEvent = window.HTMLElement.prototype.detachEvent = function(type, callback) { this.removeEventListener(type.substring(2), callback, false); }

    CSSStyleDeclaration.prototype.__defineGetter__('pixelLeft', function() { return parseInt(this.left) || 0; });
    CSSStyleDeclaration.prototype.__defineSetter__('pixelLeft', function(i) { this.left = i + "px"; });
    CSSStyleDeclaration.prototype.__defineGetter__('pixelTop', function() { return parseInt(this.top) || 0; });
    CSSStyleDeclaration.prototype.__defineSetter__('pixelTop', function(i) { this.top = i + "px"; });

    IS_IE = false;
}
catch (e) { }
function Queue() {
    var queue = new Array();
    var space = 0;
    this.enqueue = function(element) {
        queue.push(element);
    }
    this.dequeue = function() {
        if (queue.length) {
            var element = queue[space];

            if (++space * 2 >= queue.length) {
                for (var i = space; i < queue.length; i++)
                    queue[i - space] = queue[i];

                queue.length -= space;
                space = 0;
            }

            return element;
        }
        else
            return undefined;
    }
}
var EasyAjax = {
    callQueue: new Queue(),
    waiting: false,
    callNext: function() {
        if (!EasyAjax.waiting) {
            var queuedCall = EasyAjax.callQueue.dequeue();
            if (queuedCall != undefined) {
                EasyAjax.waiting = true;
                var url = queuedCall[0];
                var params = queuedCall[1];
                var callback = queuedCall[2];
                var content = "";
                if (params)
                    for (var key in params)
                    content += (key + "=" + encodeURI(params[key]) + "&");
                var xmlhttp;
                if (window.XMLHttpRequest)
                    xmlhttp = new XMLHttpRequest();
                else if (window.ActiveXObject)
                    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                setTimeout
				(
					function() {
					    if (xmlhttp.readyState != 4) {
					        xmlhttp.abort();
					        EasyAjax.waiting = false;
					        EasyAjax.callNext();
					    }
					},
					10000
				);
                if (callback)
                    xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4) { callback(xmlhttp.responseText); EasyAjax.waiting = false; EasyAjax.callNext(); } };
                if (params) {
                    xmlhttp.open("POST", url, true);
                    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                    xmlhttp.setRequestHeader("Content-length", content.length);
                    xmlhttp.setRequestHeader("Connection", "close");
                    xmlhttp.send(content);
                }
                else {
                    if (url.indexOf("?") == -1)
                        url += "?";
                    else
                        url += "&";
                    url += "n=" + Math.floor(Math.random() * 999999999)

                    xmlhttp.open("GET", url, true);
                    xmlhttp.send(null);
                }
            }
        }
    },
    reload: function(node, params) {
        EasyAjax.callQueue.enqueue([node.getAttribute("url"), params, function(responseText) { node.innerHTML = responseText; } ]);
        EasyAjax.callNext();
    },
    init: function() {
        EasyAjax.step(document.body);
    },
    step: function(node) {
        if (node.nodeName.toUpperCase() == "EASY:AJAX" || node.nodeName.toUpperCase() == "AJAX" || node.nodeName.toUpperCase() == "DIV") {
            node.reload = function(params) { EasyAjax.reload(node, params); }
            if (node.getAttribute("interval")) {
                node.reload();
                setInterval(function() { node.reload(); }, node.getAttribute("interval"));
            }
        }

        for (var i = 0; i < node.childNodes.length; i++)
            EasyAjax.step(node.childNodes[i]);
    }
};
window.attachEvent("onload", EasyAjax.init);
//========================================== AutoComplete =================================================================================
AutoComplete = function(input, suggestions, type, button2click) {
    var timer;

    input.attachEvent("onkeyup", handleKeyUp);
    input.attachEvent("onkeydown", handleArrowKeys);
    suggestions.attachEvent("onmouseover", handleMouseOver);
    suggestions.attachEvent("onclick", handleMouseClick);
    suggestions.attachEvent("onmouseout", handleMouseOut);

    function handleMouseOut(event) {
        var target = event.srcElement ? event.srcElement : event.target;
        var id = target ? (target.id ? target.id : "ITEMDIV") : "NO TARGET";

        if (timer)
            clearTimeout(timer);

        if (input.value.length > 0)
            timer = STO("$opacity('" + suggestions.id + "', 100, 0, 250);", 2000);
    }
    function handleMouseClick(event) {
        var target = event.srcElement ? event.srcElement : event.target;
        var id = target ? (target.id ? target.id : "ITEMDIV") : "NO TARGET";
        if (id == "ITEMDIV") {
            if (IS_IE)
                input.value = target.innerText;
            else
                input.value = target.textContent;

            $opacity(suggestions.id, 100, 0, 250);
            __doPostBack(button2click, '');
        }
    }
    function handleMouseOver(event) {
        if (timer)
            clearTimeout(timer);
        var target = event.srcElement ? event.srcElement : event.target;
        var id = target ? (target.id ? target.id : "ITEMDIV") : "NO TARGET";
        var selectedId;
        if (id == "ITEMDIV") {
            selectedId = target;
        }
        var mainDiv = $('autocomplete');
        var divs = mainDiv.getElementsByTagName('DIV');
        for (i in divs) {
            var div = divs[i];
            if (div == selectedId) {
                div.className = "selected"
            }
            else {
                div.className = ""
            }
        }
    }
    function handleKeyUp(event) {
        if (event.keyCode != 40 && event.keyCode != 38 && event.keyCode != 13 && event.keyCode != 27) {
            if (input.value.length == 0)
                suggestions.innerHTML = "";
            if (timer)
                clearTimeout(timer);

            if (input.value.length >= 2)
                timer = STO(reload, 400);
        }
        else if (event.keyCode == 13) {
            var cursor = getCursor();
            var parent = suggestions.firstChild;
            if (cursor != -1 && cursor < parent.childNodes.length) {
                if (IS_IE)
                    input.value = parent.childNodes[cursor].innerText;
                else
                    input.value = parent.childNodes[cursor].textContent;
                $opacity(suggestions.id, 100, 0, 250)
            }
        }
        else if (event.keyCode == 27) {
            $opacity(suggestions.id, 100, 0, 250)
        }
    }
    function reload() {
        $opacity(suggestions.id, 0, 100, 250);
        if (type.type == "hidden") {
            var searchVal = type.value;
        }
        else {
            var searchVal = type.options[type.selectedIndex].value;
        }
        positionDiv(input, suggestions);
        suggestions.reload({ prefix: input.value, type: searchVal });
    }
    function handleArrowKeys(event) {
        try {
            var cursor = getCursor();
            var parent = suggestions.firstChild;

            if (cursor != -1 && (event.keyCode == 40 || event.keyCode == 38)) {
                if (event.keyCode == 40) {
                    if (cursor == parent.childNodes.length)
                        parent.childNodes[0].className = "selected"
                    else if (cursor < parent.childNodes.length - 1) {
                        parent.childNodes[cursor].className = ""
                        parent.childNodes[cursor + 1].className = "selected"
                    }
                }
                else {
                    if (cursor > 0) {
                        parent.childNodes[cursor].className = ""
                        parent.childNodes[cursor - 1].className = "selected"
                    }
                }
                if (IS_IE)
                    input.value = parent.childNodes[cursor].innerText;
                else
                    input.value = parent.childNodes[cursor].textContent;
            }
        }
        catch (e) { }
    }
    function getCursor() {
        if (suggestions.innerHTML.length == 0)
            return -1;
        var parent = suggestions.firstChild;
        for (var i = 0; i < parent.childNodes.length; i++)
            if (
					parent.childNodes[i].className == "selected"
			   )
            return i;
        return parent.childNodes.length;
    }
}
function $opacity(id, opacStart, opacEnd, millisec) {
    if ($(id).style.width == 0) {
        $(id).style.width = act_width(id);
    }
    var speed = Math.round(millisec / 100);
    var timer = 0;
    if (opacStart > opacEnd) {
        STO("$('" + id + "').innerHTML = ''", (millisec * 2));
        for (i = opacStart; i >= opacEnd; i--) {
            STO("changeOpac(" + i + ",'" + id + "')", (timer * speed));
            timer++;
        }
    }
    else if (opacStart < opacEnd) {
        for (i = opacStart; i <= opacEnd; i++) {
            STO("changeOpac(" + i + ",'" + id + "')", (timer * speed));
            timer++;
        }
    }
}
function changeOpac(opacity, id) {
    var object = $(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}
function positionDiv(inp, div) {
    var x = 0;
    var y = inp.offsetHeight;
    while (inp.offsetParent && inp.tagName.toUpperCase() != 'BODY') {
        x += inp.offsetLeft;
        y += inp.offsetTop;
        inp = inp.offsetParent;
    }
    x += inp.offsetLeft;
    y += inp.offsetTop;

    div.style.left = x + 'px';
    div.style.top = y + 'px';
}
//============================ Remove all non-digits ==================================
function cleanString(str) {
    return str.replace(/[^\d]/g, "");
}
//========================== Modal Dialog ===========================================
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;
}
function posLeft() {
    return typeof window.pageXOffset != 'undefined' ? window.pageXOffset : document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;
}
function posTop() {
    return typeof window.pageYOffset != 'undefined' ? window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;
}
function scrollFix() {
    var obol = $('ol');
    obol.style.top = posTop() + 'px';
    obol.style.left = posLeft() + 'px'
}
function sizeFix() {
    var obol = $('ol');
    obol.style.height = pageHeight() + 'px';
    obol.style.width = pageWidth() + 'px';
}
function kp(e) {
    ky = e ? e.which : event.keyCode;
    if (ky == 88 || ky == 120) hm();
    return false
}
function inf(h) {
    //tag = $t('select');
    //for (i = tag.length - 1; i >= 0; i--) tag[i].style.visibility = h;
    tag = $t('iframe');
    for (i = tag.length - 1; i >= 0; i--) tag[i].style.visibility = h;
    tag = $t('object');
    for (i = tag.length - 1; i >= 0; i--) tag[i].style.visibility = h;
}
function sm(obl, wd, ht) {
    var h = 'hidden';
    var b = 'block';
    var p = 'px';
    var obol = $('ol');
    var obbxd = $('mbd');
    obbxd.innerHTML = $(obl).innerHTML;
    obol.style.height = pageHeight() + p;
    obol.style.width = pageWidth() + p;
    obol.style.top = posTop() + p;
    obol.style.left = posLeft() + p;
    obol.style.display = b;
    var tp = posTop() + ((pageHeight() - ht) / 2) - 12;
    var lt = posLeft() + ((pageWidth() - wd) / 2) - 12;
    var obbx = $('mbox');
    obbx.style.top = (tp < 0 ? 0 : tp) + p;
    obbx.style.left = (lt < 0 ? 0 : lt) + p;
    obbx.style.width = wd + p;
    obbx.style.height = ht + p;
    inf(h);
    obbx.style.display = b;
    return false;
}
function hm() {
    var v = 'visible';
    var n = 'none';
    $('ol').style.display = n;
    $('mbox').style.display = n;
    inf(v);
    document.onkeypress = ''
}
function initmb() {
    var ab = 'absolute';
    var n = 'none';
    var obody = $t('body')[0];
    var frag = document.createDocumentFragment();
    var obol = document.createElement('div');
    obol.setAttribute('id', 'ol');
    obol.style.display = n;
    obol.style.position = ab;
    obol.style.top = 0;
    obol.style.left = 0;
    obol.style.zIndex = 998;
    obol.style.width = '100%';
    frag.appendChild(obol);
    var obbx = document.createElement('div');
    obbx.setAttribute('id', 'mbox');
    obbx.style.display = n;
    obbx.style.position = ab;
    obbx.style.zIndex = 999;
    var obl = document.createElement('span');
    obbx.appendChild(obl);
    var obbxd = document.createElement('div');
    obbxd.setAttribute('id', 'mbd');
    obl.appendChild(obbxd);
    frag.insertBefore(obbx, obol.nextSibling);
    obody.insertBefore(frag, obody.firstChild);     window.onscroll = scrollFix;
    window.onresize = sizeFix;
}
window.onload = initmb;
//========================== Event Management =============================
function addEvent(el, evType, handle) {
    if (el.addEventListener) el.addEventListener(evType, handle, false);
    else if (el.attachEvent) {
        el["e" + evType + handle] = handle;
        el[evType + handle] = function() { el["e" + evType + handle](window.event) }

        el.attachEvent("on" + evType, el[evType + handle]);
    }
}
function removeEvent(el, evType, handle) {
    if (el.removeEventListener) el.removeEventListener(evType, handle, false);
    else if (el.detachEvent) {
        el.detachEvent("on" + evType, el[evType + handle])
        el[evType + handle] = null
        el["e" + evType + handle] = null;
    }
}
function preventDefault(evt) {
    var e = evt ? evt : window.event;
    if (e.preventDefault) {
        e.preventDefault();
    } else {
        e.returnValue = false;
    }
}
function stopPropagation(evt) {
    var e = evt ? evt : window.event;
    if (e.stopPropagation) {
        e.stopPropagation();
    } else {
        e.cancelBubble = true;
    }
}
//========================== Visual Effects =======================================

function addslashes(str) {
    str = str.replace(/\"/g, "\\\"");
    str = str.replace(/\'/g, "\\'");
    return str;
}
function $toggle(id) {
    if (act_height(id) == 0) {
        $blinddown(id);
    } else {
        $blindup(id);
    }
}
function act_height(id) {
    height = $(id).clientHeight;
    if (height == 0) {
        height = $(id).offsetHeight;
    }
    return height;
}
function act_width(id) {
    width = $(id).clientWidth;
    if (width == 0) {
        width = $(id).offsetWidth;
    }
    return width;
}
function max_height(id) {
    var ids = $(id).style;
    ids.overflow = "hidden";
    if (act_height(id) != 0) {
        return act_height(id);
    } else {
        origdisp = ids.display;
        origheight = ids.height;
        origpos = ids.position;
        origvis = ids.visibility;
        ids.visibility = "hidden";
        ids.height = "";
        ids.display = "block";
        ids.position = "absolute";
        height = act_height(id);
        ids.display = origdisp;
        ids.height = origheight;
        ids.position = origpos;
        ids.visibility = origvis;
        return height;
    }
}
function $blindup(id, _2f) {
    if (!_2f) {
        _2f = 200;
    }
    acth = act_height(id);
    maxh = max_height(id);
    if (acth == maxh) {
        $(id).style.display = "block";
        var _30;
        _30 = Math.ceil(_2f / acth);
        for (i = 0; i <= acth; i++) {
            newh = acth - i;
            STO("$('" + id + "').style.height='" + newh + "px'", _30 * i);
        }
    }
}
function $blinddown(id, _32) {
    if (!_32) {
        _32 = 200;
    }
    acth = act_height(id);
    if (acth == 0) {
        maxh = max_height(id);
        $(id).style.display = "block";
        $(id).style.height = "0px";
        var _33;
        _33 = Math.ceil(_32 / maxh);
        for (i = 1; i <= maxh; i++) {
            STO("$('" + id + "').style.height='" + i + "px'", _33 * i);
        }
    }
}

function $pulsate(id, num, speed) {
    if (!speed) speed = 300;
    for (i = 1; i <= num; i++) {
        numx = i * ((speed * 2) + 100) - (speed * 2);
        STO("$opacity('" + id + "', 100, 0, " + speed + ")", numx);
        STO("$opacity('" + id + "', 0, 100, " + speed + ")", numx + speed + 100);
    }
}

function $shiftOpacity(id, millisec) {
    if ($(id).style.opacity < 0.5) {
        $opacity(id, 0, 100, millisec);
    } else {
    $opacity(id, 100, 0, millisec);
    }
}
function currentOpac(id, opacEnd, millisec) {
    var currentOpac = 100;
    if ($(id).style.opacity < 100) {
        currentOpac = $(id).style.opacity * 100;
    }
    $opacity(id, currentOpac, opacEnd, millisec);
}
function $highlight(id, _44, _45, _46) {
    if (_44) {
        milli = _44;
    } else {
        milli = 900;
    }
    if (_45) {
        endcol = _45;
    } else {
        endcol = "#FFFFFF";
    }
    if (_46) {
        origcol = _46;
    } else {
        origcol = "#FFFFA6";
    }
    $colorize(origcol, endcol, id, milli, "high");
}
function $textColor(id, _48, _49, _4a) {
    if (_4a) {
        milli = _4a;
    } else {
        milli = 900;
    }
    $colorize(_48, _49, id, milli, "text");
}
function $morphColor(id, _4c, _4d, _4e, _4f, _50, _51, _52) {
    if (_52) {
        milli = _52;
    } else {
        milli = 900;
    }
    $colorize(_4c, _4d, id, milli, "text");
    $colorize(_4e, _4f, id, milli, "back");
    if (_50 != false) {
        $colorize(_50, _51, id, milli, "border");
    }
}
function $colorize(_53, end, id, _56, _57) {
    dr = parseInt(_53.substring(1, 3), 16);
    dg = parseInt(_53.substring(3, 5), 16);
    db = parseInt(_53.substring(5, 7), 16);
    fr = parseInt(end.substring(1, 3), 16);
    fg = parseInt(end.substring(3, 5), 16);
    fb = parseInt(end.substring(5, 7), 16);
    steps = _56 / 10;
    cr = dr;
    cg = dg;
    cb = db;
    sr = (fr - dr) / steps;
    sg = (fg - dg) / steps;
    sb = (fb - db) / steps;
    var zzi = 10;
    for (var x = 0; x < steps; x++) {
        color = "#" + DecToHexa(cr) + DecToHexa(cg) + DecToHexa(cb);
        if (x == (steps - 1)) {
            if (_57 == "high") {
                color = "";
            } else {
                color = end;
            }
        }
        mytime = (x);
        if (_57 == "back" || _57 == "high") {
            newfonc = "$(\"" + id + "\").style.backgroundColor=\"" + color + "\";";
        } else {
            if (_57 == "text") {
                newfonc = "$(\"" + id + "\").style.color=\"" + color + "\";";
            } else {
                if (_57 == "border") {
                    newfonc = "$(\"" + id + "\").style.borderColor=\"" + color + "\";";
                }
            }
        }
        STO(newfonc, zzi);
        cr += sr;
        cg += sg;
        cb += sb;
        zzi += 10;
    }
}
function $blending(div1, div2, millisec) {
    var speed = Math.round(millisec / 100);
    var timer = 0;
    changeOpac(0, div1.id);
    div1.style.display = "none";
    div2.style.display = "block";
    div2.style.opacity = 0;
    for (i = 0; i <= 100; i++) {
        STO("changeOpac(" + i + ",'" + div2.id + "')", (timer * speed));
        timer++;
    }
}
//======================= Accordion ==============================
var AccoCache = new Array();
function $AccoInit(str) {
    accomax = str.match(/[;]/g).length;
    for (var i = 0; i < accomax; i++) {
        pos = str.indexOf(";");
        AccoCache.push(str.substring(0, pos));
        str = str.substring(pos + 1, str.length);
    }
}
function $accopush(accobjnum, elastic) {
    for (var i = 0; i < AccoCache.length; i++) {
        if (i != accobjnum) {
            $blindup(AccoCache[i], 200);
        }
        else {
            if (elastic == true) STO("$blinddown('" + AccoCache[i] + "', 200)", 400);
            else $blinddown(AccoCache[i], 200);
        }
    }
}

// ============================== SlideShow ===============================
var SlishCache = new Array();
function $slish(id, str, time) {
    slishnum = 1;
    slishid = id;
    slishtime = time;
    slishdelay = false;
    slishmax = str.match(/[;]/g).length;
    for (var i = 0; i < slishmax; i++) {
        pos = str.indexOf(";");
        SlishCache.push(str.substring(0, pos));
        str = str.substring(pos + 1, str.length);
    }
}
function $slishPLAY(time) {
    if (slishdelay == false) {
        slishdelay = time;
        $slishAUTO();
    }
}
function $slishSTOP() {
    slishdelay = false;
}
function $slishAUTO() {
    if (slishdelay != false) {
        if (slishnum < slishmax) slishnum += 1;
        else slishnum = 1;
        num2 = slishnum - 1;
        id = slishid;
        $opacity(id, 100, 0, slishtime);
        STO("$opacity('" + id + "', 0, 100, " + slishtime + ")", slishtime);
        STO("$('" + id + "').src='" + SlishCache[num2] + "'", slishtime);
        STO("$slishAUTO()", slishdelay);
    }
}
function $slishNEXT() {
    if (slishnum < slishmax) slishnum += 1;
    else slishnum = 1;
    $slishToNum(slishnum);
}
function $slishPREV() {
    if (slishnum > 1) slishnum -= 1;
    else slishnum = slishmax;
    $slishToNum(slishnum);
}
function $slishToNum(num) {
    slishdelay = false;
    slishnum = num;
    num2 = num - 1;
    id = slishid;
    $opacity(id, 100, 0, slishtime);
    STO("$opacity('" + id + "', 0, 100, " + slishtime + ")", slishtime);
    STO("$('" + id + "').src='" + SlishCache[num2] + "'", slishtime);
}
//============== trim() =======================
String.prototype.trim = function() {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}
//=========== Verify Zip ==============
function isValidZipCode(zipField) {
    var zip = $(zipField).value
    var re = /^\d{5}([\-]\d{4})?$/;
    if (re.test(zip)) { $blending($("ppCancel"), $("ppBuyN"), 500); }
    else { $blending($("ppBuyN"), $("ppCancel"), 500); }
}
//=========== Verify Country ==============
function isValidCountry(countryField,zipField) {
    var zip = $(zipField).value
    var re = /^\d{5}([\-]\d{4})?$/;
    if (!re.test(zip)) {
        if ($(countryField)[$(countryField).selectedIndex].value != "United States") {
            $blending($("ppCancel"), $("ppBuyN"), 500);
        }
        else { $blending($("ppBuyN"), $("ppCancel"), 500); }
    }
}
//=========================================
function ShowGChelp() {
    popupWin = window.open('support/googlecheckout.html', 'GCH', 'scrollbars=no,resizable=no,toolbar=no,width=600,height=300,left=50,top=50'); popupWin.focus();
}
function verifyDestination( txtDestZip) {
    if ($(txtDestZip).value.trim() == "") { sm('dialogBox', 400, 200); }
    else { __doPostBack('paypalcheckout', $(txtDestZip).value); }
}
/*
function doPayPalCheckout(txtPpZip, txtDestZip) {
    $(txtDestZip).value = $(txtPpZip).value; __doPostBack('paypalcheckout', $(txtPpZip).value)
}
*/
function hiliteInput(inpID) {
    var defColor = "#FFFFFF";
    $(inpID).style.backgroundColor = "#FF6464";
    $(inpID).focus();
    $pulsate(inpID, 4, 400);
    STO("$('" + inpID + "').style.backgroundColor = '" + defColor +"'",3000);
}

//========================== Digits only textbox ========================
function digitOnly(evt) {
    var charCode = (evt.which) ? evt.which : event.keyCode
    if ((charCode == 8) || (charCode == 46) || (charCode == 37) || (charCode == 39)) return true;
    else {
        if ((charCode >= 48 && charCode <= 57) || (charCode >= 96 && charCode <= 105)) return true;
        else return false;
    } 
}

