﻿// JScript 文件
// Trim() , Ltrim() , RTrim()    
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, "");    
}    


function obj(o){return document.getElementById(o);}

//验证图片格式
function CheckFileExt(obj_id)
{
    var fileext=obj(obj_id).value.substring(obj(obj_id).value.lastIndexOf("."),obj(obj_id).value.length)
    fileext=fileext.toLowerCase()
    if ((fileext!='.jpg')&&(fileext!='.gif')&&(fileext!='.jpeg')&&(fileext!='.png')&&(fileext!='.bmp'))
    {
       return false;
    }
    else{return true;}
}

//email检测
function IsEmail(mailValue)
{
    return(new RegExp(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/).test(mailValue));
}

//数字，中线，下划线
function CheckChar(objValue){
    var   reg   =/[0-9_-]+$/;
    return reg.test(objValue);
}

function UInt(objValue){
    var reg = /^[0-9]+$/;
    return reg.test(objValue);
}

function CheckDecmal(objValue)
{
var reg = /^(?:[1-9][0-9]*\.[0-9]¦0\.(?!0$)[0-9])$/;
return reg.test(objValue);
}

//非中文检测
function IsEnglish(objValue){
    if (objValue == objValue.replace(/[^\u4E00-\u9FA5]/g,'')){
       return false;
    }
    return true;
}

//用户名字符检测
function CheckUserName(m_name){
    var   reg   =/[A-Za-z0-9_]+$/;
    return reg.test(m_name);
}

//window.open弹窗　　
function ShowDialog2(url,w,h) { 
　　var iWidth=w; //窗口宽度 
　　var iHeight=h;//窗口高度 
　　var iTop=(window.screen.height-iHeight)/2; 
　　var iLeft=(window.screen.width-iWidth)/2; 
　　window.open( url,"newwindow","Scrollbars=no,Toolbar=no,Location=no,Direction=no,Resizeable=no, Width="+iWidth+" ,Height="+iHeight+",top="+iTop+",left="+iLeft ); 
}　　

//确认删除操作
function ConfirmDel()
{
if (confirm("确认删除?"))
	return true;
else
	return false;
}

//定时关闭窗口
var i=10;
function clock(){
    document.title="本窗口将在"+i+"秒后close!"; 
    if(i==0){ 
        clearTimeout(st); 
        window.opener=null; 
        window.location.href=""+url+"";
    } 
    i = i -1; 
    st = setTimeout("clock()",1000);  
} 

/*
message     --提示信息内容
styleCssID  --div容器标识(创建的动态浮动层)
time        --跳转等待时间(如3秒或5秒)
redirectUrl --跳转地址(为空时停留在当前页)
showSecond  --是否显示秒表
*/
function ShowExecuteState(message, styleCssID, time, redirectUrl, showSecond){
    if(message=="" | styleCssID=="" | time=="")
        return "";
        
    //创建浮动层    
    document.write(createFloatDiv(styleCssID));
    
    //是否显示秒数
    if(showSecond)
        IntervalCode2(message, styleCssID, time, redirectUrl);
    else
        document.getElementById(styleCssID).innerHTML=message; 
           
    //跳转代码
    window.setInterval("IntervalCode('"+styleCssID+"', '"+redirectUrl+"')",time*1000);  
}

function IntervalCode(styleCssID, url){
    document.getElementById(styleCssID).style.display='none';
    if(url!="")
        location.href=url;        
}

function IntervalCode2(message, styleCssID, time, url){
    var st=null;
    var message1="";
    if(time==0){
      clearTimeout(st);
      IntervalCode(styleCssID,url);
    }    
    //message1+="<br>"+ time/1000 + "秒后跳转到("+url+")";  
    if(url!="")
      message1+=time + "秒后跳转";
      
    time = time -1;   
    st = setTimeout("IntervalCode2('"+message+"', '"+styleCssID+"', '"+time+"', '"+url+"')",1000);
         
    document.getElementById(styleCssID).innerHTML=message+message1;   
}

function createFloatDiv(styleCssID){
    //样式部分--start
    var messageLayer="<style type=\"text/css\">";
    messageLayer+="#"+styleCssID;
    messageLayer+="{ position: absolute; width:200px; height:50px; left:50%; top:50%; margin-left:-100px; margin-top:-25px; ";    
    messageLayer+="line-height:50px; text-align:center; font-size:14px; font-family:'宋体'; background-color:#fff; ";
//    messageLayer+="{ position: absolute; width:200px; left:50%; top:50%; margin-left:-100px; margin-top:-25px; ";    
//    messageLayer+="line-height:50px; text-align:center; font-size:14px; font-family:'宋体'; ";
    
    //样式枚举
    if(styleCssID=="message1")
      messageLayer+="border: solid 3px red;";
    else if(styleCssID=="message2") 
      messageLayer+="border: solid 3px #ccc;";
    else if(styleCssID=="message3") 
      messageLayer+="border: solid 3px #FD900E;"; 
    else
      messageLayer+="border: solid 3px red;";
           
    messageLayer+="}";
    messageLayer+="</style>";
    //样式部分--end
    
    
    //浮动层部分
    messageLayer+="<div id='"+styleCssID+"'></div>";
    return messageLayer;
}


//$(function(){
//    $(".tr_admin").mouseover(function() {
//      $(this).css({ "background-color": "#e7f5fe" });
//    });
//    $(".tr_admin").mouseout(function() {
//      $(this).css({ "background-color": "#fff" });
//    });
//});











