﻿document.write('<link rel="shortcut icon" href="/images/yihua.ico" type="image/x-icon" /><link rel="BOOKMARK" href="/images/yihua.ico" type="image/x-icon" />');
　
function $$(el) {
    if (document.getElementById) {
        return document.getElementById(el);
    } else if (document.all) {
        return document.all[el];
    } else if (document.layers) {
        return document.layers[el];
    }
}
function Addme() {
    url = document.URL; 
    title =  document.title; //你自己的主页名称 
    window.external.AddFavorite(url, title);
}
function getWeb() {
    document.getElementById('purl ').value = document.URL;
    document.getElementById('ptitle ').value = document.title;
}
function copy(e) {
    e.select();
    window.clipboardData.setData('Text ', e.value);
    alert("复制成功 ");
}
//禁止右键
//document.oncontextmenu = function() { return false;}

function runClock() {
    theTime = window.setTimeout("runClock()", 1000);
    var today = new Date();
    var display = today.toLocaleString();
    document.getElementById("date").innerText = display;
}
function closedWindow() {
    window.opener = null; window.open('', '_self'); window.close();
}
function closedWindows() {
    window.close();
}
function disPlay(id1, id2) {
    document.all(id1).style.display = "none";
    document.all(id2).style.display = "block";
}
function getAbsPoint(e) {  //获取当前坐标
    var x = e.offsetLeft, y = e.offsetTop;
    while (e = e.offsetParent) {
        x += e.offsetLeft;
        y += e.offsetTop;
    }
    return( x + "," +  y);
}
function AddFavorite() {
    var sURL = document.URL;
    var sTitle = document.title;
    try {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e) {
        try {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e) {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}
function SetHome(obj) {
    var vrl = 'http://www.51huayi.com/';
    try {
        obj.style.behavior = 'url(#default#homepage)'; obj.setHomePage(vrl);
    }
    catch (e) {
        if (window.netscape) {
            try {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            }
            catch (e) {
                alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'");
            }
            var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
            prefs.setCharPref('browser.startup.homepage', vrl);
        }
    }
}


function DrawImage(ImgD, FitWidth, FitHeight) {
    var image = new Image();
    image.src = ImgD.src;
    if (image.width > 0 && image.height > 0) {
       
        if (image.width / image.height >= 1) {
            ImgD.width = FitWidth;
            var he = (image.height * FitWidth) / image.width;
            ImgD.height = he;
            if (he > FitHeight) {
                ImgD.width = (FitWidth * FitHeight) / he;
                ImgD.height = FitHeight;
            }
        } else {
        ImgD.height = FitHeight;
        var wi = (image.width * FitHeight) / image.height;
            ImgD.width = wi;
            if (wi > FitWidth) {
                ImgD.height = (FitHeight * FitWidth) / wi;
                ImgD.width = FitWidth;
            }
        }
    }
}


function IsNull(_objname) {
    if ($$(_objname).value == "") {
        return true;
    }
    return false;
}

function XHR() {	// Creat XMLHttpRequest
    var xhr;
    try {
        xhr = new XMLHttpRequest();
    } catch (e) {
        var a = ['MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'MICROSOFT.XMLHTTP.1.0', 'MICROSOFT.XMLHTTP.1', 'MICROSOFT.XMLHTTP'];
        for (var i = 0; i < a.length; i++) {
            try {
                xhr = new ActiveXObject(a[i]);
                break;
            } catch (e) { }
        }
    }
    return xhr;
}
function ReadCart() {
    var xmlHttp = XHR();
    xmlHttp.open("POST", "/ReadShoppIng.aspx", true);
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    var data = "flag=" + Math.random();
    xmlHttp.onreadystatechange = function() {
        if (xmlHttp.readyState == 4) {
            if (xmlHttp.status == 200) {
                str = xmlHttp.responseText;
                var tmp = str.split("|||");
                if (tmp[0] > 0) {
                    //window.location.reload();
                    $$("ShopCartTmp").innerHTML = tmp[1];
                    $$("CardNums").innerHTML = tmp[0];
                }
                if (tmp[0] == 0) {
                    $$("ShopCartTmp").innerHTML = "您的购物车为空！";
                    $$("CardNums").innerHTML = 0;
                }
            }
        }
    };     //请求结束调用test函数
    xmlHttp.send(data);
}
function delcart(n_pid, uid) {
    if (!isNaN(uid) && !isNaN(n_pid)) {
        var xmlHttp = XHR();
        xmlHttp.open("POST", "/shoppingData.aspx", true);
        xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        var aIdArray = new Array("flag=" + Math.random());
        aIdArray[1] = "&pid=" + n_pid;
        aIdArray[2] = "&comId=1";
        aIdArray[3] = "&uid=" + uid;
        var data = aIdArray.join('');
        xmlHttp.onreadystatechange = function() {
        if (xmlHttp.readyState == 4) {
            if (xmlHttp.status == 200) {
                str = xmlHttp.responseText;
                ReadCart()
            }
        }
        };  //请求结束调用test函数
        xmlHttp.send(data);
    }
    return false;
}
function loads() {
    ReadCart();
}
function ShowMsg(e, num) {
    var point = getAbsPoint(e);
    var tmp = point.split(",");
   
    if (tmp[0] != null) {
        $$("TabMsg"+num).style.top = (parseInt(tmp[1]) + 30) + "px";
        $$("TabMsg" + num).style.left = parseInt(tmp[0])-80 + "px";
        $$("TabMsg" + num).style.display = "block";
    }
}
function HideMsg(num) {
    $$("TabMsg" + num).style.display = "none";
}
function ShowSmallCart() {
    if ($$("ShopCartTmp").style.display == "none" || $$("ShopCartTmp").style.display == "") {
        //loads();
        $$("ShopCartTmp").style.display = "block";
        $$("cart_bian").style.display = "block";
    } /*else {
        $$("ShopCartTmp").style.display = "none";
    }*/
}
function HideSmallCart() {
    $$("ShopCartTmp").style.display = "none";
    $$("cart_bian").style.display = "none";
}
function SetCookie(name,value,Days)
{ 
    var exp  = new Date();
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
function getCookie(name)//取cookies函数        
{
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
     if(arr != null) return unescape(arr[2]); return null;

}
function delCookie(name)//删除cookie
{
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
    if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}
function ShowClass(cid,cl) {
    cl.className = "onm";
}
function HideClass(cid,cl) {
    cl.className = "";
}
