﻿/*是否为IE浏览器*/

var server_host = '/';
var rankhelp_doc = '/help/rankhelp.html';
var isIE = navigator.userAgent.indexOf("compatible") > -1 && navigator.userAgent.indexOf("MSIE") > -1 && (navigator.appName !== "Oprea");
var isIE7 = (isIE && window.XMLHttpRequest) ? true : false;
var isIE6 = (isIE && !window.XMLHttpRequest && window.ActiveXObject) ? true : false;
var isFirefox = navigator.userAgent.indexOf('Firefox') == -1 ? false : true;
var userAgent = navigator.userAgent.toLowerCase();

var is_opera = userAgent.indexOf('opera') != -1 && opera.version();
var is_moz = (navigator.product == 'Gecko') && userAgent.substr(userAgent.indexOf('firefox') + 8, 3);
var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera) && userAgent.substr(userAgent.indexOf('msie') + 5, 3);


function loadPng(o) {
    if (isIE6) {
        try {
            var img = o; var imgName = o.src.toUpperCase();
            if (imgName.substring(imgName.length - 3, imgName.length) == "PNG") {
                var imgID = (img.id) ? "id='" + img.id + "' " : "";
                var imgClass = (img.className) ? "class='" + img.className + "' " : "";
                var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
                var imgStyle = "display:inline-block;" + img.style.cssText;
                if (img.align == "left") imgStyle = "float:left;" + imgStyle;
                if (img.align == "right") imgStyle = "float:right;" + imgStyle;
                if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
                var strNewHTML = "<span " + imgID + imgClass + imgTitle + " style=\"" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + img.src + "\', sizingMethod='image');width:1px;\"></span>"; img.outerHTML = strNewHTML;
            }
        }
        catch (e) { }
    }
}

//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; //停止循环
        }
    }
}
//input鼠标点击清除，失去焦点还原默认内容的方法
function clearDefaultText(el, message) {
    var obj = el;
    if (typeof (el) == "string")
        obj = document.getElementById(id);
    if (obj.value == message) {
        obj.value = "";
    }
    obj.onblur = function () {
        if (obj.value == "") {
            obj.value = message;
        }
    }
}


//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;
            }
        }
    }
}


function s_checks_(obj_name, aValue) {

    if (aValue == "") {
        return;
    }

    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).split("-")[0]) {
                sd[j].checked = true;
            }
        }
    }
}



function copyUrl(str) {
    var clipBoardContent = str;
    window.clipboardData.setData("Text", clipBoardContent);
    alert("复制成功啦!");
} 


////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 visit(href) {
    var target = "_blank";
    if (navigator.appName.toLowerCase().search("microsoft") != -1) {
        var bodyElem = document.getElementsByTagName("body")[0];
        var elem = document.createElement("a");
        elem.style.display = "none";
        elem.href = href;
        elem.target = target;
        bodyElem.appendChild(elem);
        elem.click();
        bodyElem.removeChild(elem);
    } else {
        if (target == undefined || target == "" || target == "_self") {
            window.location.href = href;
        } else {
            window.open(href);
        }
    }
} 










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 ximap(o) {

    var a = "#f5f7fc";
    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 xib(o) {

    var a = "#f0f0f0";
    var b = "#ffffff";
    var c = "#fff5dc";
    //  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;
        }
    }
}



function xiqNull(o) {

    var a = "#ffffff";
    var b = "#ffffff";
    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;
        }
    }
}


function xiqB2b(o) {

    var a = "#ffffff";
    var b = "#ffffff";
    var c = "#fffae3";
    var d = "#fffae3";


    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].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 xifc(o) {

    var a = "#f8faff";
    var b = "#ffffff";
    var c = "#f1f5ff";



    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].onmouseover = function() {
            if (this.x != "1") {
                this.style.backgroundColor = c;
                this.className = "listtrbin";
            }

        }
        t[i].onmouseout = function() {
            if (this.x != "1") {
                this.style.backgroundColor = (this.sectionRowIndex % 2 == 0) ? a : b;
                this.className = "listtrb";
            }

        }
    }
}




function xifcmap(o) {

    var a = "#f8faff";
    var b = "#ffffff";
    var c = "#f1f5ff";



    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].onmouseover = function() {
            if (this.x != "1") {
                this.style.backgroundColor = c;
                this.className = "mmlisttrbin";
            }

        }
        t[i].onmouseout = function() {
            if (this.x != "1") {
                this.style.backgroundColor = (this.sectionRowIndex % 2 == 0) ? a : b;
                this.className = "mmlisttrb";
            }

        }
    }
}


function xige(o) {
    var trs = document.getElementById(o).getElementsByTagName("tr"); //获取tbid的table中所有tr的信息 
    for (var i = 0; i < trs.length; i++) {
        if (trs[i].className != "sub") {
            if (i % 2 == 0) {
                trs[i].className = "tr1";
            }
            else {
                trs[i].className = "tr2";
            }
        }
    }
} 








//idqz:id前缀,idnow:目前第几个,tabcount:总共有几个,incss选中样式,outcss:离开样式
function showTabs(idqz, idnow, tabcount, incss, outcss) {

    var tabsNumber = tabcount;
    for (i = 0; i < tabsNumber; i++) {
        if (i == idnow) {
            $("#panel-" + idqz + i).show();
            $("#" + idqz + i).removeClass(outcss);
            $("#" + idqz + i).addClass(incss);
        }
        else {
            $("#panel-" + idqz + i).hide();
            $("#" + idqz + i).removeClass(incss);
            $("#" + idqz + i).addClass(outcss);
        }
    }
}

//idqz:id前缀,idnow:目前第几个,incss选中样式,outcss:离开样式:10个
function showTabs2(idqz, idnow, incss, outcss) {

    var tabsNumber = 10;
    for (i = 0; i < tabsNumber; i++) {

        if ($("#" + idqz + i).length > 0) {

            if (i == idnow) {
                $("#panel-" + idqz + i).show();
                $("#" + idqz + i).removeClass(outcss);
                $("#" + idqz + i).addClass(incss);
            }
            else {
                $("#panel-" + idqz + i).hide();
                $("#" + idqz + i).removeClass(incss);
                $("#" + idqz + i).addClass(outcss);
            }
        }
    }
}



///*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');
//        }
//    });
//}


//图片预览this,
function onUploadImgChange(sender, width, height, index) {
    //try {
    index = index == undefined ? "" : index;
    if (!sender.value.match(/.jpg|.gif|.png|.bmp/i)) {
        alert('请上传.jpg|.gif|.png|.bmp类型的图片');
        return false;
    }

    var objPreview = $(".previewpic" + index);
    var objPreviewFake = document.getElementById('previewfake' + index);

    if (sender.files && sender.files[0]) {
        objPreview.show();
        objPreview.attr("width", width);
        objPreview.attr("height", height);

        objPreview.attr("src", sender.files[0].getAsDataURL());
    } else if (objPreviewFake.filters) {

        sender.select();
        var imgSrc = document.selection.createRange().text;
        objPreviewFake.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = imgSrc;

        objPreviewFake.style.width = width + 'px';
        objPreviewFake.style.height = height + 'px';
        objPreview.hide();
        sender.blur();
    }
    //} catch (ex) {
    ///    alert("图片加载失败！");
    // }
}    





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;
}

