﻿$(document).ready(function () {

// 广告管理系统专用[2011-06-28]
// create xhtml strict friendly iframe
    $('div.ad_box').each(
		function (i) {
			$(this).replaceWith("<iframe class='ad_box' src='" + $(this).attr("ad-href") + "?slot=" + $(this).attr("ad-slot") + "&node=" + $(this).attr("ad-node") + "&cachetag=" + ($(this).attr("ad-cache") == "true" ? (new Date()).toDateString() : Math.random()) + "' width='" + $(this).attr("ad-width") + "' height='" + $(this).attr("ad-height") + "' frameborder='0' scrolling='no'></iframe>");
		}
	);
// 广告管理系统专用[2011-06-28]

    var zIndexNumber = 1000;
    // Put your target element(s) in the selector below!
    $("div,ul").each(function () {
        $(this).css('zIndex', zIndexNumber);
        zIndexNumber -= 10;
    });

});

function Load(path, elem, cache) {
    var cacheBool = true;
    if (cache == null || cache == undefined || (!cache)) { cacheBool = false; }
    $.ajax({
        url: path,
        cache: cacheBool,
        success: function(html) {
            $(elem).replaceWith(html)
        }
    });
}

//IE和firefox通用的复制到剪贴板的JS函数
function copyToClipboard(txt) {
    if (window.clipboardData) {
        window.clipboardData.clearData();
        window.clipboardData.setData("Text", txt);
    } else if (navigator.userAgent.indexOf("Opera") != -1) {
        window.location = txt;
    } else if (window.netscape) {
        try {
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
        } catch (e) {
            alert("“复制到剪贴板操作”被浏览器拒绝！您的浏览器可能安全设置比较严格。\n要启动此操作，请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");
        }
        var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
        if (!clip)
            return;
        var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
        if (!trans)
            return;
        trans.addDataFlavor('text/unicode');
        var str = new Object();
        var len = new Object();
        var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
        var copytext = txt;
        str.data = copytext;
        trans.setTransferData("text/unicode", str, copytext.length * 2);
        var clipid = Components.interfaces.nsIClipboard;
        if (!clip)
            return false;
        clip.setData(trans, null, clipid.kGlobalClipboard);
        //alert("复制成功！")
    }
}

function startmarquee(lh, speed, delay, index) {
    var t;
    var p = false;
    var o = document.getElementById("marqueebox" + index);
    o.innerHTML += o.innerHTML;
    o.onmouseover = function() { p = true }
    o.onmouseout = function() { p = false }
    o.scrollTop = 0;
    function start() {
        t = setInterval(scrolling, speed);
        if (!p) o.scrollTop += 2;
    }
    function scrolling() {
        if (o.scrollTop % lh != 0) {
            o.scrollTop += 2;
            if (o.scrollTop >= o.scrollHeight / 2) o.scrollTop = 0;
        } else {
            clearInterval(t);
            setTimeout(start, delay);
        }
    }
    setTimeout(start, delay);
}

function clicknav(num) {
    var arr = new Array(6);
    arr[0] = -47;
    arr[1] = 45;
    arr[2] = 138;
    arr[3] = 230;
    arr[4] = 323;
    arr[5] = 414;
    for (var i = 1; i <= 6; i++) {
        document.getElementById("n" + i).style.display = "none";
        if (num == i) {
            document.getElementById("n" + num).style.display = "block";
            document.getElementById("n" + num).style.top = 26 + "px";
            document.getElementById("n" + num).style.left = arr[num - 1] + "px";
        }
    }
}
function missnav(num) {
    for (var i = 1; i <= 6; i++) {
        document.getElementById("n" + i).style.display = "none";
    }
}

function clicknav_en(num) {
    var arr = new Array(4);
    arr[0] = -47;
    arr[1] = 12;
    arr[2] = 105;
    arr[3] = 205;
    for (var i = 1; i <= 6; i++) {
        document.getElementById("n" + i).style.display = "none";
        if (num == i) {
            document.getElementById("n" + num).style.display = "block";
            document.getElementById("n" + num).style.top = 26 + "px";
            document.getElementById("n" + num).style.left = arr[num - 1] + "px";
        }
    }
}
function missnav_en(num) {
    for (var i = 1; i <= 6; i++) {
        document.getElementById("n" + i).style.display = "none";
    }
}

