
//stuHover = function() {
//    var cssRule;
//    var newSelector;
//    for (var i = 0; i < document.styleSheets.length; i++)
//        for (var x = 0; x < document.styleSheets[i].rules.length; x++) {
//        cssRule = document.styleSheets[i].rules[x];
//        if (cssRule.selectorText.indexOf("LI:hover") != -1) {
//            newSelector = cssRule.selectorText.replace(/LI:hover/gi, "LI.iehover");
//            document.styleSheets[i].addRule(newSelector, cssRule.style.cssText);
//        }
//    }
//    var getElm = document.getElementById("nav").getElementsByTagName("LI");
//    for (var i = 0; i < getElm.length; i++) {
//        getElm[i].onmouseover = function() {
//            this.className += " iehover";
//        }
//        getElm[i].onmouseout = function() {
//            this.className = this.className.replace(new RegExp(" iehover\\b"), "");
//        }
//    }
//}
//if (window.attachEvent) window.attachEvent("onload", stuHover);


function boxmove(d1, d2, d3, e, obj) {
    var speed = 50;
    var demo = document.getElementById(d1);
    var demo1 = document.getElementById(d2);
    var demo2 = document.getElementById(d3);
    demo2.innerHTML = demo1.innerHTML;
    function boxTop() {
        if (demo2.offsetTop - demo.scrollTop <= 0) { demo.scrollTop -= demo1.offsetHeight }
        else { demo.scrollTop++ }
    }
    function boxRight() {
        if (demo.scrollLeft <= 0) { demo.scrollLeft += demo2.offsetWidth }
        else { demo.scrollLeft-- }
    }
    function boxBottom() {
        if (demo1.offsetTop - demo.scrollTop >= 0) { demo.scrollTop += demo2.offsetHeight }
        else { demo.scrollTop-- }
    }
    function boxLeft() {
        if (demo2.offsetWidth - demo.scrollLeft <= 0) { demo.scrollLeft -= demo1.offsetWidth }
        else { demo.scrollLeft++ }
    }
    if (e == 1) {
        var MoveTop = setInterval(boxTop, speed);
        demo.onmouseover = function() { clearInterval(MoveTop); }
        demo.onmouseout = function() { MoveTop = setInterval(boxTop, speed) }
    }
    if (e == 2) {
        var MoveRight = setInterval(boxRight, speed);
        demo.onmouseover = function() { clearInterval(MoveRight) }
        demo.onmouseout = function() { MoveRight = setInterval(boxRight, speed) }
    }
    if (e == 3) {
        var MoveBottom = setInterval(boxBottom, speed);
        demo.onmouseover = function() { clearInterval(MoveBottom); }
        demo.onmouseout = function() { MoveBottom = setInterval(boxBottom, speed) }
    }
    if (e == 4) {
        var MoveLeft = setInterval(boxLeft, speed)
        demo.onmouseover = function() { clearInterval(MoveLeft) }
        demo.onmouseout = function() { MoveLeft = setInterval(boxLeft, speed) }
    }
    if (e == "top") {
        MoveTop = setInterval(boxTop, speed)
        obj.onmouseout = function() { clearInterval(MoveTop); }
    }
    if (e == "right") {
        MoveRight = setInterval(boxRight, speed)
        obj.onmouseout = function() { clearInterval(MoveRight); }
    }
    if (e == "bottom") {
        MoveBottom = setInterval(boxBottom, speed)
        obj.onmouseout = function() { clearInterval(MoveBottom); }
    }
    if (e == "left") {
        MoveLeft = setInterval(boxLeft, speed)
        obj.onmouseout = function() { clearInterval(MoveLeft); }
    }
}


var setGradient = (function() {
    var p_dCanvas = document.createElement('canvas');
    var p_useCanvas = !!(typeof (p_dCanvas.getContext) == 'function');
    var p_dCtx = p_useCanvas ? p_dCanvas.getContext('2d') : null;
    var p_isIE = /*@cc_on!@*/false;
    try { p_dCtx.canvas.toDataURL() } catch (err) {
        p_useCanvas = false;
    };
    if (p_useCanvas) {
        return function(dEl, sColor1, sColor2, bRepeatY, height) {
            if (typeof (dEl) == 'string') dEl = document.getElementById(dEl);
            if (!dEl) return false;
            var nW = dEl.offsetWidth;
            var nH = dEl.offsetHeight;
            p_dCanvas.width = nW;
            p_dCanvas.height = nH;
            if (!height) {
                p_dCanvas.height = height;
            }
            var dGradient;
            var sRepeat;
            if (bRepeatY) {
                dGradient = p_dCtx.createLinearGradient(0, 0, nW, 0);
                sRepeat = 'repeat-y';
            } else {
                dGradient = p_dCtx.createLinearGradient(0, 0, 0, nH);
                sRepeat = 'repeat-x';
            }

            dGradient.addColorStop(0, sColor1);
            dGradient.addColorStop(1, sColor2);

            p_dCtx.fillStyle = dGradient;
            p_dCtx.fillRect(0, 0, nW, nH);
            var sDataUrl = p_dCtx.canvas.toDataURL('image/png');

            with (dEl.style) {
                backgroundRepeat = sRepeat;
                backgroundImage = 'url(' + sDataUrl + ')';
                backgroundColor = sColor2;
            };
        }
    } else if (p_isIE) {

        p_dCanvas = p_useCanvas = p_dCtx = null;
        return function(dEl, sColor1, sColor2, bRepeatY) {
            if (typeof (dEl) == 'string') dEl = document.getElementById(dEl);
            if (!dEl) return false;
            dEl.style.zoom = 1;
            var sF = dEl.currentStyle.filter;
            dEl.style.filter += ' ' + ['progid:DXImageTransform.Microsoft.gradient(    GradientType=', +(!!bRepeatY), ',enabled=true,startColorstr=', sColor1, ', endColorstr=', sColor2, ')'].join('');
        };

    } else {
        p_dCanvas = p_useCanvas = p_dCtx = null;
        return function(dEl, sColor1, sColor2) {

            if (typeof (dEl) == 'string') dEl = document.getElementById(dEl);
            if (!dEl) return false;
            with (dEl.style) {
                backgroundColor = sColor2;
            };
        }
    }
})(); 