﻿var myarray = new Array("http", "www", "src", "插你", "我操", "短信投票", "承接", "联系电话", "投票服务", "插下", "日你", "日死你", "插下你", "插死你", "插一下", "搞你", "和你搞", "bb", "sb", "小b", "小样",
"投票联盟", "解决投票", "我日", "鸡巴", "你妈B", "你妈的", "操你妈", "干你", "干你妈", "干你娘", "干你老母", "日你老母", "操你老母", "插你老母");
var pretext;

function checktxtdiv(o) {
    var v = document.getElementById(o).value.toLowerCase();
    if (v.length < 5) { alert("发贴内容太少"); return false; }
    for (i = 0; i < myarray.length; i++) {
        if (v.replace(/[ ]/g, "").indexOf(myarray[i]) != -1) { alert("内容包括禁止使用的字句"); return false; }
    }
    if (pretext == v) { alert("请勿重复发言,谢谢合作!"); return false; }
    pretext = v;
    return true;
}

function GetQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
}

function GetmaContent( o) {
    SendAjax("http://www.hnnypp.com:83/searchgo.aspx?no=" + no, o);
}
//iframe自适应高度
function SetCwinHeight(iframeID) {
    var bobo = document.getElementById(iframeID);
    if (document.getElementById) {
        if (bobo && !window.opera) {
            if (bobo.contentDocument && bobo.contentDocument.body.offsetHeight) {
                bobo.height = bobo.contentDocument.body.offsetHeight + 20 + 'px';
            } else if (bobo.Document && bobo.Document.body.scrollHeight) {
                bobo.height = bobo.Document.body.scrollHeight + 20 + 'px';
            }
        }
    }
}


function SendAjax(url, divname) {
    document.getElementById(divname).innerHTML = "<img src='/image/load1.gif' style='width:14px;height:14px'/>";
    jQuery.post(url, null, function (response) {
        jQuery("#" + divname).html(response);
    });
}
$(function () {
     $("#btnfwsearch").click(function () {
        var txtsearch = $("#txtfwsearch").val();
       // if(txtsearch.length!=16 || txtsearch.length!=18){
        //   alert("输入18位有效的防伪码!"); $("#txtfwsearch").focus(); return false;
       // }
       $(this).attr("href", "/fanwei/insert.aspx?no=" + txtsearch);
        $("#txtfwsearch").val("");

    });
});

function SendAjaxNoImage(url, divname) {
    jQuery.post(url, null, function (response) {
        jQuery("#" + divname).html(response);
    });
}


//news
function GetNews(typeid, o) {
    SendAjax("/command/getnew.aspx?typeid=" + typeid, o);
}
//文章读取,可以多类型读取 typeid=1,3,4
function GetNewsOfInputs(typeid, o, icon, topsize, titlelength, showtype, showtypetextlength) {
    var str = "";
    if (titlelength != null) { str += "&titlelength=" + titlelength; }
    if (topsize != null) { str += "&topsize=" + topsize; }
    if (icon != null) { str += "&icon=" + icon; }
    if (showtype != null) { str += "&showtype=" + showtype; } //显示类型,1显示标题加简短内容
    if (showtypetextlength != null) { str += "&showtypetextlength=" & showtypetextlength; } //要显示的内容长度
    SendAjax("/command/getnew.aspx?typeid=" + typeid + str, o);
}

function GetNewsone(news_id, length, o) {
    var str = "";
    if (length != null) { str = "&length=" + length; }
    SendAjax("/command/getnewone.aspx?newsid=" + news_id + str, o);
}


function ShellCommand(page, querystringstr, showdiv) {
    var str = "";
    if (querystringstr != null) { str = "?" + querystringstr; }
    SendAjax("/command/" + page + ".aspx" + str, showdiv);
}

//house
//调整指定图片的宽度
function SetImageWidth(img, width) {
    o = document.images
    for (i = 0; i < o.length; i++) {
        if (o[i].id = img) {
            if (o[i].width > width) {
                o[i].width = width;
            }
        }
    }

}

//调整指定obj中的所有图片的宽度不超过obj
function resizeImg(obj, width) {
    var obj = document.getElementById(obj);
    var objContent = obj.innerHTML;
    var imgs = obj.getElementsByTagName('img');
    if (imgs == null) return;
    for (var i = 0; i < imgs.length; i++) {
        if (imgs[i].width > width) {
            imgs[i].style.width = width + "px";
            //imgs[i].onclick=function(){window.open(imgs[i].src);}
        }
    }
}
//设置指定对象字体大小
function zoom(obj, fontsize) {
    document.getElementById(obj).style.fontSize = fontsize;
}


function GetCheck(showdiv) {
    var par1 = $("txtcheck1");
    if (par1.value == "") { alert("请输入身份码"); par1.focus(); return false; }
    var par2 = $("txtcheck2");
    if (par2.value == "") { alert("请输入防伪码"); par2.focus(); return false; }
    $(showdiv).innerHTML = "正在查询，请稍候...";
    var pass = $("txtpass");
    var pa = "";
    if (pass != null) { pa = "&pass=" + pass.value; }
    SendAjax("/command/check.aspx?par1=" + par1.value + "&par2=" + par2.value + pa, showdiv);
}


function sho(str) {
    var str1 = "t" + str;
    var str2 = "s" + str;
    document.getElementById('s1').style.display = "none";
    document.getElementById('s2').style.display = "none";
    document.getElementById("t1").className = "li";
    document.getElementById("t2").className = "li";
    document.getElementById(str2).style.display = "block";
    document.getElementById(str1).className = "lim";
}

function shonews1(str) {
    var str1 = "news" + str;
    var str2 = "n" + str;

    document.getElementById('n1').style.display = "none";
    document.getElementById('n2').style.display = "none";
    document.getElementById("news1").className = "li";
    document.getElementById("news2").className = "li";
    document.getElementById(str2).style.display = "block";
    document.getElementById(str1).className = "lim";
}

function shonews2(str) {
    var str1 = "news" + str;
    var str2 = "n" + str;

    document.getElementById('n3').style.display = "none";
    document.getElementById('n4').style.display = "none";
    document.getElementById("news3").className = "li";
    document.getElementById("news4").className = "li";
    document.getElementById(str2).style.display = "block";
    document.getElementById(str1).className = "lim";

}


function HomeLogin(value) {
    try {
        if (value != null) {
            var checklogin = shop.checklogin().value;
            if (checklogin != null) {  //已登录
                $("#Labeluser").html(checklogin);
                $("#divloginok").show();
                $("#divLogin").hide();
            }
        }
        else {
            var txtuser = $("#txtusername");
            var txtpass = $("#txtpassword");
            if (txtuser.val() == '') { alert('用户名不能为空'); txtuser.focus(); return false; };
            if (txtpass.val() == '') { alert('请输入密码'); txtpass.focus(); return false; };

            var u = shop.ReturnLoginUsername(txtuser.val(), txtpass.val()).value;
            if (u != null) {
                $("#Labeluser").html(u);
                $("#divloginok").show();
                $("#divLogin").hide();
            } else {
                alert("登录失败");
            }
        }
       
    } catch (e) {alert(e);
    }
}

