﻿//radio自动选中
function s_radio(radio_name, aValue) {    //传入一个对象
    var radio_oj = document.getElementsByName(radio_name);
    for (var i = 0; i < radio_oj.length; i++) //循环
    {
        if (radio_oj[i].value == aValue) //比较值
        {
            radio_oj[i].checked = true; //修改选中状态
            break; //停止循环
        }
    }
}



//select自动选中
function s_select(obj_name, aValue) {    //传入一个对象
    var radio_oj = document.getElementById(obj_name);
    for (var i = 0; i < radio_oj.length; i++) //循环
    {
        if (radio_oj[i].value == aValue) //比较值
        {
            radio_oj[i].selected = true; //修改选中状态
            break; //停止循环
        }
    }
}

function s_checks(obj_name, aValue) {
    var sd = document.getElementsByName(obj_name);
    var statdata = aValue;
    var arr = statdata.split(",");
    for (var i = 0; i < arr.length; i++) {
        for (var j = 0; j < sd.length; j++) {
            if (arr[i] == sd[j].value) {
                sd[j].checked = true;
            }
        }
    }
}



////radio自动选中(不用了)
//function changeaaaa(radio_name, aValue) {    //传入一个对象
//    var radio_oj = document.getElementsByName(radio_name);

//    for (var i = 0; i < radio_oj.length; i++) //循环
//    {
//        if (radio_oj[i].value == aValue) //比较值
//        {
//            radio_oj[i].checked = true; //修改选中状态
//            break; //停止循环
//        }
//    }
//}




function popWin(url, win, para) {
    var win = window.open(url, win, para);
    win.focus();
}
function setrefs() {
    window.location.href = window.location.href;
}

function setgo(url) {
    window.location.href = url;
}
function setback() {
   history.back(-1); 
}
function setPLocation(url, setFocus) {
    if (setFocus) {
        window.opener.focus();
    }
    window.opener.location.href = url;
}




function imgsize(ImgD, FitWidth, FitHeight) {
    var image = new Image();
    image.src = ImgD.src;
    if (image.width > 0 && image.height > 0) {
        if (image.width / image.height >= FitWidth / FitHeight) {
            if (image.width > FitWidth) {
                ImgD.width = FitWidth;
                ImgD.height = (image.height * FitWidth) / image.width;
            } else {
                ImgD.width = image.width;
                ImgD.height = image.height;
            }
        } else {
            if (image.height > FitHeight) {
                ImgD.height = FitHeight;
                ImgD.width = (image.width * FitHeight) / image.height;
            } else {
                ImgD.width = image.width;
                ImgD.height = image.height;
            }
        }
    }
}

//创建fck('txtArea')
function fck(tname) {
    var oFCKeditor = new FCKeditor(tname); //参数与textarea中name对应。 
    oFCKeditor.BasePath = "/FCKEditor/";
    oFCKeditor.Width = "100%";
    oFCKeditor.Height = "200px";
    oFCKeditor.Value = "wiki";
    oFCKeditor.ToolbarSet = "Basic";
    oFCKeditor.ReplaceTextarea(); //替换textarea标签内容 
} 



//openScript
function openScript(url, width, height) {
    var Win = window.open(url, "openScript", 'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=no');
}


//自适应iframe高度
function SetCwinHeight(objname) {
    var bobo = $E(objname);
    if (document.getElementById) {
        if (bobo && !window.opera) {
            if (bobo.contentDocument && bobo.contentDocument.body.offsetHeight) {
                bobo.height = bobo.contentDocument.body.offsetHeight;
            } else if (bobo.Document && bobo.Document.body.scrollHeight) {
                bobo.height = bobo.Document.body.scrollHeight;
            }
        }
    }
}


//选取所有
function CheckAll(form) {
    for (var i = 0; i < form.elements.length; i++) {
        var e = form.elements[i];
        if (e.name != 'chkall') e.checked = form.chkall.checked;
    }
}




function Nav() {
    if (window.navigator.userAgent.indexOf("MSIE") >= 1) return 'IE';
    else if (window.navigator.userAgent.indexOf("Firefox") >= 1) return 'FF';
    else return "OT";
}
function showhide(objname) {
    var obj = document.getElementById(objname);
    if (obj.style.display != "none")
        obj.style.display = "none";
    else {
        if (Nav() == 'IE') obj.style.display = "block";
        else obj.style.display = "table-row";
    }
}

function xi(o) {

    var a = "#edf3fc";
    var b = "#ffffff";
    var c = "#fcf5dd";
  //  var d = "#daecf1";


    var t = document.getElementById(o).getElementsByTagName("tr");
    for (var i = 0; i < t.length; i++) {
        t[i].style.backgroundColor = (t[i].sectionRowIndex % 2 == 0) ? a : b;
//        t[i].onclick = function() {
//            if (this.x != "1") {
//                this.x = "1"; //本来打算直接用背景色判断，FF获取到的背景是RGB值，不好判断
//                this.style.backgroundColor = d;
//            } else {
//                this.x = "0";
//                this.style.backgroundColor = (this.sectionRowIndex % 2 == 0) ? a : b;
//            }
//        }
        t[i].onmouseover = function() {
            if (this.x != "1") this.style.backgroundColor = c;
        }
        t[i].onmouseout = function() {
            if (this.x != "1") this.style.backgroundColor = (this.sectionRowIndex % 2 == 0) ? a : b;
        }
    }
}


function xiq(o) {

    var a = "#ffffff";
    var b = "#f5f7fc";
    var c = "#ebf1ff";
    var d = "#daecf1";


    var t = document.getElementById(o).getElementsByTagName("tr");
    for (var i = 0; i < t.length; i++) {
        t[i].style.backgroundColor = (t[i].sectionRowIndex % 2 == 0) ? a : b;
//        t[i].onclick = function() {
//            if (this.x != "1") {
//                this.x = "1"; //本来打算直接用背景色判断，FF获取到的背景是RGB值，不好判断
//                this.style.backgroundColor = d;
//            } else {
//                this.x = "0";
//                this.style.backgroundColor = (this.sectionRowIndex % 2 == 0) ? a : b;
//            }
//        }
        t[i].onmouseover = function() {
            if (this.x != "1") this.style.backgroundColor = c;
        }
        t[i].onmouseout = function() {
            if (this.x != "1") this.style.backgroundColor = (this.sectionRowIndex % 2 == 0) ? a : b;
        }
    }
}







/*tab切换*/
function showtabs(main, obj1_qz) {

    $(document).ready(function() {
        if (obj1_qz == "0") {

            $("#tab0" + main).show();
            $("#tab1" + main).hide();
            $("#rtabtitle" + main).removeClass('rtabtitle1');
            $("#rtabtitle" + main).addClass('rtabtitle0');
        }
        else {

            $("#tab1" + main).show();
            $("#tab0" + main).hide();
            $("#rtabtitle" + main).removeClass('rtabtitle0');
            $("#rtabtitle" + main).addClass('rtabtitle1');
        }
    });
}









var req; //定义变量，用来创建xmlhttprequest对象
// var divName;

function creatPinlun(tbid, tbname, pages) // 创建xmlhttprequest,ajax开始
{
    // var url = "ajaxServer.aspx" + "?" + Math.random(); //要请求的服务端地址

    // divName = div; 

    var url = "/include/feedbackpage.aspx?tbid=" + tbid + "&tbname=" + tbname + "&pages=" + pages + "";


    if (window.XMLHttpRequest) //非IE浏览器及IE7(7.0及以上版本)，用xmlhttprequest对象创建
    {
        req = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) //IE(6.0及以下版本)浏览器用activexobject对象创建,如果用户浏览器禁用了ActiveX,可能会失败.
    {
        req = new ActiveXObject("Microsoft.XMLHttp");
    }

    if (req) //成功创建xmlhttprequest
    {
        req.open("GET", url, true); //与服务端建立连接(请求方式post或get，地址,true表示异步)
        req.onreadystatechange = callback; //指定回调函数
        //req.send(null); //发送请求
        req.send(url); //发送请求
    }
}

function callback() //回调函数，对服务端的响应处理，监视response状态
{
    if (req.readyState == 4) //请求状态为4表示成功
    {
        if (req.status == 200) //http状态200表示OK
        {
            Dispaly(); //所有状态成功，执行此函数，显示数据
        }
        else //http返回状态失败
        {
            alert("服务端返回状态" + req.statusText);
        }
    }
    else //请求状态还没有成功，页面等待
    {
        document.getElementById("divpinlun").innerHTML = "数据加载中";
    }
}

function Dispaly() //接受服务端返回的数据，对其进行显示
{
    document.getElementById("divpinlun").innerHTML = req.responseText;
}



function ytgs(i) {
    i.className = "ytgs";
}
function ytgs1(i) {
    i.className = "ytgs1";
}


function tbcss(i, cssname) {
    var aa = cssname;
    i.className =aa;
}
