$(document).ready(function(){
    $('.tips_img').mouseover(function(e){
        var now    = $(this);
        var offset = $(this).offset();
        var parent = $(this).closest('span');
        // now.data('tips',now.attr('title')).attr('title','');
        nowdata = parent.find(":input").attr("tips");
        parent.append('<div class="tooltipdi" style="right:-298px;px;top:-2px"><span><b></b><em></em>'+nowdata+'</span></div>');
        var tips_div = parent.find('.tooltipdi');
        parent.one('mouseout',function(){
            //setTimeout(function(){
                //if(parent.data('hover')!=1){
                    now.attr('title',nowdata);
                    tips_div.remove();
                //}
            //},1150);
        });
        // tips_div.bind({'mouseover':function(){
            // parent.data('hover',1);
        // },'mouseout':function(){
            // parent.data('hover',0);
            // now.attr('title',now.data('tips'));
            // tips_div.remove();
        // }});
    });
});
function CheckUrl(str) { 
    var RegUrl = new RegExp(); 
    RegUrl.compile("^[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$");
    if (!RegUrl.test(str)) { 
    return false; 
    } 
    return true; 
}
function strlen(str){
    var len = 0;
    for (var i=0; i<str.length; i++) { 
     var c = str.charCodeAt(i); 
    //单字节加1 
     if ((c >= 0x0001 && c <= 0x007e) || (0xff60<=c && c<=0xff9f)) { 
       len++; 
     } 
     else { 
      len+=2; 
     } 
    }
    return len;
}
function showIframe(url,w,h){
    //添加iframe
    var if_w = w; 
    var if_h = h; 
    //allowTransparency='true' 设置背景透明
    $("<iframe width='" + if_w + "' height='" + if_h + "' id='YuFrame1' name='YuFrame1' style='position:absolute;z-index:4;'  frameborder='no' marginheight='0' marginwidth='0' allowTransparency='true'></iframe>").prependTo('body');    
    var st=document.documentElement.scrollTop|| document.body.scrollTop;//滚动条距顶部的距离
    var sl=document.documentElement.scrollLeft|| document.body.scrollLeft;//滚动条距左边的距离
    var ch=document.documentElement.clientHeight;//屏幕的高度
    var cw=document.documentElement.clientWidth;//屏幕的宽度
    var objH=$("#YuFrame1").height();//浮动对象的高度
    var objW=$("#YuFrame1").width();//浮动对象的宽度
    var objT=Number(st)+(Number(ch)-Number(objH))/2;
    var objL=Number(sl)+(Number(cw)-Number(objW))/2;
    $("#YuFrame1").css('left',objL);
    $("#YuFrame1").css('top',objT);
 
    $("#YuFrame1").attr("src", url)
 
    //添加背景遮罩
    $("<div id='YuFrame1Bg' style='background-color: Gray;display:block;z-index:3;position:absolute;left:0px;top:0px;filter:Alpha(Opacity=30);/* IE */-moz-opacity:0.4;/* Moz + FF */opacity: 0.4; '/>").prependTo('body'); 
    var bgWidth = Math.max($("body").width(),cw);
    var bgHeight = Math.max($("body").height(),ch);
    $("#YuFrame1Bg").css({width:bgWidth,height:bgHeight});
 
    //点击背景遮罩移除iframe和背景
    $("#YuFrame1Bg").click(function() {
        $("#YuFrame1").remove();
        $("#YuFrame1Bg").remove();
    });
}

//art信息提示
function msg(status,msg,lock,time){
    alert(msg);
}
//刷新框架页面
function main_refresh(){
    window.main.location.reload();
}

//关闭所有框架
function closeiframe(){
    var list = window.art.dialog.list;
    for (var i in list){
        if(i.substring(0,3)!=="msg"){
            list[i].close();
        };
    };
}

function checkselect(text) {
    var ids='';
    $("input[name='all_check[]']:checked").each(function(i, n){
        ids += $(n).val() + ',';
    });
    if(ids=='') {
        window.top.art.dialog({content:'请选择'+text,lock:true,width:'200',height:'50',time:1.5},function(){});
        return false;
    } else {
        myform.submit();
    }
}
function edit(url,text,width){
    window.top.art.dialog({
            id:'add',
            iframe:url, 
            title:text, 
            width:width?width:700, 
            height:'500', 
            lock:true
        }, function(){
            var d = window.top.art.dialog({id:'add'}).data.iframe;
            var form = d.document.getElementById('dosubmit');
            form.click();
            return false;
        }, function(){
            window.top.art.dialog({id:'add'}).close()
        });
        void(0);
}
function all_add(url,text){
    window.top.art.dialog({
            id:'add',
            iframe:url, 
            title:text, 
            width:'700', 
            height:'500', 
            lock:true
        }, function(){
            var d = window.top.art.dialog({id:'add'}).data.iframe;
            var form = d.document.getElementById('dosubmit');
            form.click();
            return false;
        }, function(){
            window.top.art.dialog({id:'add'}).close()
        });
        void(0);
}
function all_deletes(url){
    if(confirm("确认删除吗")){
        window.location.href=url;
      }
}