﻿/************ 通用脚本 ************/

//设置页面元素光标移动时，切换图片
function setSelectedImage(type, name, pic, picSelected) {
    if (type == "css") {
        $(name).mouseover(function() {
            $(name).css("background-image", "url(" + picSelected + ")");
        });
        $(name).mouseout(function() {
            $(name).css("background-image", "url(" + pic + ")");
        });
    } else {
        $(name).mouseover(function() {
            $(name).attr("src", picSelected);
        });
        $(name).mouseout(function() {
            $(name).attr("src", pic);
        });
    }
}

//设置页面元素点击时，页面跳转
function setClickHref(name, url) {
    $(name).click(function() { location.href = url; });
}

function setClickHref2(name, url) {
    $(name).click(function() {
        top.topHeader.resetTime();
        location.href = url;
    });
}

//设置页面元素点击时，页面跳转
function setClickTopHref(name, url) {
    $(name).click(function() {
        top.topHeader.resetTime();
        top.location.href = url;
    });
}

function showInfo(msg, fn) {
    $.messager.alert("提示", msg, "info", fn);
}

function showConfirm(msg, fn) {
    $.messager.confirm("询问", msg, fn);
}

function GetQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]);
    return null;
}

function Fkey() {
    var WsShell = new ActiveXObject('WScript.Shell')
    WsShell.SendKeys('{F11}');
}

//首页
function firstPage() {
    var pageIndex = $("#txtPageIndex").val();
    if (pageIndex != 1) {
        pageIndex = 1;
        $("#txtPageIndex").val(pageIndex);
        $("#frmSearch").submit();
    }
}

/*
上一页 */
function previous() {
    var pageIndex = $("#txtPageIndex").val();
    if (pageIndex != 1) {
        pageIndex--;
        $("#txtPageIndex").val(pageIndex);
        $("#frmSearch").submit();
    }
}

/*
下一页 */
function next() {
    var pageIndex = $("#txtPageIndex").val();
    var pageCount = $("#txtPageCount").val();   
    if (pageIndex != pageCount)
    {
        pageIndex++;
        $("#txtPageIndex").val(pageIndex);
        $("#frmSearch").submit();
    }
}

//末页
function lastPage() {
    var pageIndex = $("#txtPageIndex").val();
    var pageCount = $("#txtPageCount").val();
    if (pageIndex != pageCount) {
        pageIndex = pageCount;
        $("#txtPageIndex").val(pageIndex);
        $("#frmSearch").submit();
    }
}

//跳转
function goPage() {
    var pageIndex = $("#txtPageIndex").val();
    var pageSelect = $("#txtSelect").combobox("getValue");
    if (pageIndex != pageSelect) {
        pageIndex = pageSelect;
        $("#txtPageIndex").val(pageIndex);
        $("#frmSearch").submit();
    }
}

function searchList() {
    $("#txtPageIndex").val("1");
    $("#frmSearch").submit();
}

function isNullOrEmpty(id, name) {
    var value = $("#" + id).val();
    if (value == "") {
        showInfo("请输入" + name + "!", function() { $("#" + id).select(); });
        return true;
    }
    return false;
}

function notIsNullOrEmptyDataList(id) {
    var value = $("#" + id).combobox('getValue');
    if (value == "") { 
        return false;
    }
    return true;
}

function isNullOrEmptyDataList(id, name) {
    var value = $("#" + id).combobox('getValue'); 
    if (value == "") {
        showInfo("请输入" + name + "!", function() { $("#" + id).select(); });
        return true;
    }
    return false;
}

function notIsNullOrEmpty(id) {
    var value = $("#" + id).val();
    if (value == "") {
        return false;
    }
    return true;
}


function Valid(txtValid, loginValid) {
    if ($("#" + txtValid).val() != $("#" + loginValid).val()) {
        showInfo("验证码不正确，请重新输入！", function() { $("#" + txtValid).select(); });
        return false;
    }
    return true;
}

function back() {
    window.history.go(-1);
}

/*
新增
*/
function add(url) {
    list.style.display = "none";
    ifrm.location.replace(url);
    info.style.display = "block";
}

/*
修改
*/
function edit(url,id,name) {
    list.style.display = "none";
    ifrm.location.replace(url + '?tName=' + escape(name) + '&id=' + id);
    info.style.display = "block";
}

function edit1(url, id, TypeId,name) {
    list.style.display = "none";
    ifrm.location.replace(url + '?tid=' + TypeId + '&id=' + id+'&tName='+ escape(name));
    info.style.display = "block";
}

/*
跳转
*/
function GoTo(url) {
  //  list.style.display = "none";
  //  ifrm.location.replace(url);
    window.location.replace(url);
 //   info.style.display = "block";
}


function cancel(form) {
    showConfirm("确实是否取消操作？", function() {
        form.reset();
    });
}

/*
返回
*/
function backList() {
    frmSearch.submit();
}

function Del(id) {
    showConfirm("是否删除该用户信息？", function () {
        $("#txtId").val(id);
        $("#txtMethod").val("Del");
        frmSearch.submit();
    });
}




 
