﻿function UrlSearch() { //重复时只取最后一个
    var name, value;
    var str = window.location.href; //取得整个地址栏
    var num = str.indexOf("?")
    str = str.substr(num + 1); //取得所有参数
    var arr = str.split("&"); //各个参数放到数组里
    for (var i = 0; i < arr.length; i++) {
        num = arr[i].indexOf("=");
        if (num > 0) {
            name = arr[i].substring(0, num);
            value = arr[i].substr(num + 1);
            this[name] = value;
        }
    }
    this["getall"] = str;
}
var RQ = new UrlSearch(); //实例化
function formatStr(s) {
    if (typeof (s) == "string")
        return s;
    else
        return "";
}
function joinValue(parameter) {
    eval("var temp=RQ." + parameter);
    if ((typeof (temp) == "string") && (typeof (temp) != null)) {
        return "&" + parameter + "=" + temp.replace(/(^\s*)|(\s*$)/g, "");
    }
    else
        return "";
}
function q(parameter) {
    eval("var temp=RQ." + parameter);
    if ((typeof (temp) == "string") && (typeof (temp) != null)) {
        return temp.replace(/(^\s*)|(\s*$)/g, "");
    }
    else
        return "";
}
/*获取当前页页码*/
function thispage() {
    var r = /^\+?[1-9][0-9]*$/;
    if (r.test(q('page')))
        return q('page');
    else
        return "1";
}
//全选
function CheckAll(form) {
    var f;
    if (form == null)
        f = document.getElementsByTagName('FORM')[0];
    else
        f = document.getElementById(form);
    for (var i = 0; i < f.elements.length; i++) {
        var e = f.elements[i];
        if (e.name != 'chkall' && e.type == "checkbox")
            e.checked = document.getElementById("chkall").checked;
    }
}
//全不选
function CheckNo(form) {
    var f;
    if (form == null)
        f = document.getElementsByTagName('FORM')[0];
    else
        f = document.getElementById(form);
    for (var i = 0; i < f.elements.length; i++) {
        var e = f.elements[i];
        if (e.type == "checkbox")
            e.checked = false;
    }
}
function WinFullOpen(url) {
    var newwin = window.open("", "", "scrollbars");
    if (document.all) {
        newwin.moveTo(0, 0);
        newwin.resizeTo(screen.width, screen.height);
    }
    newwin.location = url;
}
String.prototype.Trim = function() { return this.replace(/(^\s*)|(\s*$)/g, ""); }
String.prototype.LTrim = function() { return this.replace(/(^\s*)/g, ""); }
String.prototype.RTrim = function() { return this.replace(/(\s*$)/g, ""); }
/*ajax调用新闻！*/
var page = thispage();
function ajaxList(currentpage, pagesize, AjaxUrl, AjaxAction, AjaxTemplate) {
    page = currentpage;
    CnvpCms.Loading.show("正在加载数据,请等待...", 200, 60);
    $.ajax({
        type: "get",
        dataType: "json",
        data: "page=" + currentpage + "&pagesize=" + pagesize + "&time=" + (new Date().getTime()),
        url: AjaxUrl + "?Action=" + AjaxAction,
        error: function() {
            CnvpCms.Alert("读取数据有误,请稍候重试", "0");
        },
        success: function(d) {
            switch (d.result) {
                case '1':
                    CnvpCms.Loading.hide();
                    $("#ajaxList").setTemplateURL(AjaxTemplate + "?time=" + (new Date().getTime()), null, { filter_data: true });
                    $("#ajaxList").processTemplate(d);
                    $("#ajaxPageBar").html(d.pagerbar);
                    break;
            }
        }
    });
}


/*ajax调用列表！*/
var page = thispage();

function ajaxLists(currentpage) {
    page = currentpage;
    CnvpCms.Loading.show("正在加载数据,请等待...", 200, 60);
    $.ajax({
        type: "get",
        dataType: "json",
        data: "page=" + currentpage + "&pagesize=" + pagesize + "&OrderBy=" + OrderBy + "&time=" + (new Date().getTime()) + "&" + StrWhere,
        url: AjaxUrl + "?Action=" + AjaxAction,
        error: function() {
            CnvpCms.Alert("读取数据有误,请稍候重试", "0");
        },
        success: function(d) {
            switch (d.result) {
                case '1':
                    CnvpCms.Loading.hide();
                    $("#ajaxList").setTemplateURL(AjaxTemplate + "?time=" + (new Date().getTime()), null, { filter_data: true });
                    $("#ajaxList").processTemplate(d);
                    $("#ajaxPageBar").html(d.pagerbar);
                    break;
            }
        }
    });
}



/*ajax调用列表！*/
var page = thispage();

function ajaxListss(currentpage) {
    page = currentpage;
    //CnvpCms.Loading.show("正在加载数据,请等待...", 200, 60);
    $.ajax({
        type: "get",
        dataType: "json",
        data: "page=" + currentpage + "&pagesize=" + pagesize + "&OrderBy=" + OrderBy + "&time=" + (new Date().getTime()) + "&" + StrWhere,
        url: AjaxUrl + "?Action=" + AjaxAction,
        error: function() {
            CnvpCms.Alert("读取数据有误,请稍候重试", "0");
        },
        success: function(d) {
            switch (d.result) {
                case '1':
                   // CnvpCms.Loading.hide();
                    $("#ajaxList").setTemplateURL(AjaxTemplate + "?time=" + (new Date().getTime()), null, { filter_data: true });
                    $("#ajaxList").processTemplate(d);
                    $("#ajaxPageBar").html(d.pagerbar);
                    break;
            }
        }
    });
}







/*ajax调用列表！*/
var page = thispage();

function ajaxNews(currentpage) {
    page = currentpage;
    $("#ajaxList").empty();
    $("#newsload").css("display", "");   
    $.ajax({
        type: "get",
        dataType: "json",
        data: "page=" + currentpage + "&pagesize=" + pagesize + "&OrderBy=" + OrderBy + "&time=" + (new Date().getTime()) + "&" + StrWhere,
        url: AjaxUrl + "?Action=" + AjaxAction,
        error: function() {
            alert("读取数据有误,请稍候重试", "0");
        },
        success: function(d) {
            switch (d.result) {
                case '1':
                    $("#newsload").css("display", "none");                 
                    $("#ajaxList").setTemplateURL(AjaxTemplate + "?time=" + (new Date().getTime()), null, { filter_data: true });
                    $("#ajaxList").processTemplate(d);
                    $("#ajaxPageBar").html(d.pagerbar);
                    break;
            }
        }
    });
}



function ajaxListNews(TopNum,tid, StrID,act) {
    $("#"+StrID).empty();
    $("#"+StrID+"_a").css("display", "");   
    $.ajax({
        type: "get",
        dataType: "json",
        data: "TopNum=" + TopNum + "&tid=" + tid + "&time=" + (new Date().getTime()),
        url: AjaxUrl + "?Action="+act,
        error: function() {
            alert("数据读取错误！");
        },
        success: function(d) {
            switch (d.result) {
				   
                case '1':$("#"+StrID+"_a").css("display", "none");
                    $("#" + StrID).setTemplateURL(AjaxTemplate + "?time=" + (new Date().getTime()), null, { filter_data: true });
                    $("#" + StrID).processTemplate(d);
                    break;
            }
        }
    });
}


function ajaxListNewsHot(TopNum,tid, StrID,act) {
    $("#"+StrID).empty();
    $("#"+StrID+"_a").css("display", "");   
    $.ajax({
        type: "get",
        dataType: "json",
        data: "TopNum=" + TopNum + "&tid=" + tid + "&time=" + (new Date().getTime()),
        url: AjaxUrl + "?Action=HotNews",
        error: function() {
            alert("数据读取错误！");
        },
        success: function(d) {
            switch (d.result) {
				   
                case '1':$("#"+StrID+"_a").css("display", "none");
                    $("#" + StrID).setTemplateURL("/cms/ArticleListHot.html?time=" + (new Date().getTime()), null, { filter_data: true });
                    $("#" + StrID).processTemplate(d);
                    break;
            }
        }
    });
}


function SelectAllChkbox(flag) {
    var getChkboxs = document.getElementsByName("chkbox");
    for (var i = getChkboxs.length - 1; i >= 0; i--) {
        getChkboxs[i].checked = flag;
    }
}
function selectAllChkboxs() {
    var getChkboxs = document.getElementsByName("chkbox");
    var getchkbox = document.getElementById("ChkAll");
    for (var i = 0; i < getChkboxs.length; i++) {
        getChkboxs[i].checked = getchkbox.checked;
    }
}
function UnselectChkAllBtn() {
    var getchkbox = document.getElementById("ChkAll");
    if (getchkbox.checked) getchkbox.checked = false;
}

function Del(Url, Action) {
    var ids = '0';
    $("input[@name='chkbox']").each(function() {
        if ($(this).attr("checked") == true) {
            ids += "," + $(this).attr("value");

        }
    })

    if (ids == "0") {
        parent.CnvpCms.Alert("没有任何选择项", "0");
        return;
    }
    CnvpCms.Loading.show("正在处理...", 200, 60);
    $.ajax({
        type: "post",
        dataType: "json",
        data: "ID=" + ids,
        url: Url + "?Action=" + Action + "&time=" + (new Date().getTime()),
        error: function() {
            parent.CnvpCms.Alert("读取数据有误,请稍候重试", "0");
        },
        success: function(d) {
            switch (d.result) {
                case '1':
                    parent.window.frames['rightframe'].PageLoad();
                    parent.CnvpCms.Popup.hide();
                    break;
            }
        }
    });
}

function AjaxDel(Url, Action, T) {
    var ids = '0';
    $("input[@name='chkbox']").each(function() {
        if ($(this).attr("checked") == true) {
            ids += "," + $(this).attr("value");

        }
    })
    if (ids == "0") {
        parent.CnvpCms.Alert("没有任何选择项", "0");
        return;
    }
    $.ajax({
        type: "post",
        dataType: "json",
        data: "ID=" + ids,
        url: Url + "?Action=" + Action + "&T=" + T + "&time=" + (new Date().getTime()),
        error: function() {
            parent.CnvpCms.Alert("读取数据有误,请稍候重试", "0");
        },
        success: function(d) {
            switch (d.result) {
                case '1':
                    parent.window.frames['rightframe'].location.reload();
                    parent.CnvpCms.Popup.hide();
                    break;
            }
        }
    });
}

function AjaxOper(Url, Action, TypeID,TypeIDValue,UpKey) {
    var ids = '0';
    $("input[@name='chkbox']").each(function() {
        if ($(this).attr("checked") == true) {
            ids += "," + $(this).attr("value");

        }
    })
    if (ids == "0") {
        parent.CnvpCms.Alert("没有任何选择项", "0");
        return;
    }
   
    $.ajax({
        type: "post",
        dataType: "json",
        data: "ID=" + ids,
        url: Url + "?Action=" + Action + "&T=" + TypeID + "&TV=" + TypeIDValue + "&UpKey="+UpKey+"&time=" + (new Date().getTime()),
        error: function() {
            parent.CnvpCms.Alert("读取数据有误,请稍候重试", "0");
        },
        success: function(d) {
            switch (d.result) {
                case '1':
                    parent.window.frames['rightframe'].location.reload();                  
                    break;
            }
        }
    });
}

function ChgToTypeID(TypeID) {
    var ids = '0';
    $("input[@name='chkbox']").each(function() {
        if ($(this).attr("checked") == true) {
            ids += "," + $(this).attr("value");

        }
    })
    if (ids == "0") {
        parent.CnvpCms.Alert("没有任何选择项", "0");
        return;
    }
   
    $.ajax({
        type: "post",
        dataType: "json",
        data: "ID=" + ids,
        url: "../CMS.aspx?Action=ChgToTypeID&TypeID=" + TypeID + "&T=" + T + "&time=" + (new Date().getTime()),
        error: function() {
            parent.CnvpCms.Alert("读取数据有误,请稍候重试", "0");
        },
        success: function(d) {
            switch (d.result) {
                case '1':
                    parent.window.frames['rightframe'].location.reload();
                    
                    break;
            }
        }
    });
}






function Do_W_R(str, str1) {
    var TT = $("#" + str).attr("value");
    if (TT == '0') {
        $(str1).html("×");
    }
    $(str1).html("√");
}

$("input").focus(
  function() {
      $(this).addClass("oncus");
  }
);
$("input").blur(
  function() {
      $(this).removeClass("oncus");
  },
  function() {
      $(this).addClass("input01");
  }
);

function doZoom(size) {
    document.getElementById('zoom').style.fontSize = size + 'px'
}
