﻿//更换验证码
function change(id)
{
    document.getElementById(id).src = "/CheckCode.ashx?num=" + Math.random();
    return false;
}

//判断为空
var err='<img alt="" height="20" src="/corp/images/err.gif" width="20" /> ';
var yes = '<img alt="" height="20" src="/corp/images/yes.gif" width="20" /> ';

function IsNull(obj,tdID)
{
    if(obj.value=="")
    {
        document.getElementById(tdID).innerHTML=err;
    }
    else
    {
        document.getElementById(tdID).innerHTML=yes;
    }
}

function addfavorite()
{
//    方法一：
//    if (document.all)
//    {
//        window.external.addFavorite(document.location.href,document.title);
//    }
//    else if (window.sidebar)
//    {
//        window.sidebar.addPanel(document.title,document.location.href, ""); 
//    }

    //方法二：
    if (window.sidebar)
    { 
        window.sidebar.addPanel(document.title,document.location.href,""); 
    }
    else if(document.all)
    {
        window.external.AddFavorite(document.location.href,document.title);
    }
    else if(window.opera && window.print)
    {
        return true;
    }
}


function SetHomePage(obj)
{
    var url=document.location.href;  // window.location.href
    try
    {
        obj.style.behavior='url(#default#homepage)';
        obj.setHomePage(url);
    }
    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',url);
         }
    }
}
//隐藏的用户登录form提交 by gxl
function tologin() {
    document.getElementById("UserName").value = document.getElementById("UserName1").value;
    document.getElementById("UserPass").value = document.getElementById("UserPass1").value;
    document.getElementById("UserValidate").value = document.getElementById("UserValidate1").value;
    if (document.getElementById("UserToUrl1")) {
        document.getElementById("UserToUrl").value = document.getElementById("UserToUrl1").value;
    }
    document.getElementById("User_Login").submit();
    return false;
}

//商品查询 start
//两个参数 1、查询内容 2、查询方式（名称 或 编号） 弹出窗口
function goodsSearchWopen() {
    window.open("/corp/goodsSearch.aspx?sc=" + encodeURI(document.getElementById('Scontent').value) + "&flag=" + document.getElementById('weight').value + "&page=0");
}
//一个参数 根据编号 查询
function goodsSearchWopenOnlyByID() {
    window.open("/corp/goodsSearch.aspx?sc=" + encodeURI(document.getElementById('Scontent').value) + "&flag=0" + "&page=0");
}
//两个参数 1、查询内容 2、查询方式（名称 或 编号） 在本页转向
function goodsSearchNewWopen(ScontentID, WeightID) {
    window.open("/corp/goodsSearch.aspx?sc=" + encodeURI(document.getElementById(ScontentID).value) + "&flag=" + document.getElementById(WeightID).value + "&page=0", "_self");
}
function searchInfo() {
    if (document.getElementById('Scontent').value == "") {
        alert("请输入查询内容！");
    }
    else {
        goodsSearchWopen();
    }
}
function searchInfoOnlyById() {
    if (document.getElementById('Scontent').value == "") {
        alert("请输入查询内容！");
    }
    else {
        goodsSearchWopenOnlyByID();
    }
}
function searchInfoInSelf(ScontentID,WeightID) {
    if (document.getElementById(ScontentID).value == "") {
        alert("请输入查询内容！");
    }
    else {
        goodsSearchNewWopen(ScontentID, WeightID);
    }
}
function onkey(e) {
    var evt = window.event || e;
    if (evt.keyCode == 13) {
        document.getElementById("keyDownS").focus();
    }
}
//end
