﻿// JScript 文件
function SelectAll(tempControl)
{
    //将除头模板中的其它所有的CheckBox取反 

     var theBox=tempControl;
      xState=theBox.checked;    

     elem=theBox.form.elements;
     for(i=0;i<elem.length;i++)
     if(elem[i].type=="checkbox" && elem[i].id!=theBox.id)
      {
           if(elem[i].checked!=xState)
                 elem[i].click();
     }
}

function SelectCheck(tempControl)
{
     var theButton=tempControl;
     elem=theButton.form.elements;
     
     for(i=0;i<elem.length;i++)
     {
        if(elem[i].type=="checkbox" && elem[i].id!="headbox")
        {
           if(elem[i].checked)
           {
                return true;
           }
        }
     }
     
     alert('提示：请先选择要处理的业务!');
     return false;
}

function SettleFormsCheck(objForm)
{
    
    var selectflg=false;
    var elem=objForm.elements;
     
     for(i=0;i<elem.length;i++)
     {
        if(elem[i].type=="checkbox" && elem[i].id!="headbox")
        {
           if(elem[i].checked||elem[i].disabled)
           {
               selectflg=true;
           }
        }
     }     
     if(selectflg==false)
     {
        alert('提示：请先选择要处理的业务!');
        return false;
     }
     
     for(i=0;i<elem.length;i++)
     {
        if(elem[i].type=="text" && elem[i].className=="tbx_seach")
        {
           if(elem[i].value=="")
           {
                if(confirm("客户签名未完全输入，是否忽略？"))
                {
                    return true;
                }
                else
                {
                    alert('提示：请输入客户签名!');
                    elem[i].focus();
                    return false;
                }
           }
        }
     }     
     
     return true;
}

function SelectCheck1(objForm)
{
     var elem=objForm.elements;
     
     for(i=0;i<elem.length;i++)
     {
        if(elem[i].type=="checkbox" && elem[i].id!="headbox")
        {
           if(elem[i].checked)
           {
                return true;
           }
        }
     }
     
     alert('提示：请先选择要处理的业务!');
     return false;
}


function SetScroll()
{
    var obj;
    obj=document.getElementById("messageview");
    if(obj!=null)
    {
      obj.scrollTop=obj.scrollHeight;  
    }
}

function openNew(obj,h,w)
{
    window.open (obj, "newwindow", "height="+h+",width="+w+",toolbar=no, menubar=no,resizable=yes,location=no,scrollbars=yes")
}

function openCNew(obj)
{
    window.open (obj, "newwindow", "height=300,width=720,toolbar=no, menubar=no,resizable=yes,location=no,scrollbars=yes")
}


function showdemo(n,m,str)
{
    for (i=1;i<=m;i++)
	{
        if (i==n)
		{
	        document.getElementById(str+i).style.display = 'block';
		}
	    else
		{
		    document.getElementById(str+i).style.display = 'none';
		}
    }
}

function setvalue(str,value,type)
{
    if(type=="innerHTML")
    {
        document.getElementById(str).innerHTML=value;
    }
    else
    {
        document.getElementById(str).value=value;
    }
}

function selecttype(id,str,value)
{
    document.forms[0].timetype[id].checked=true;
    document.getElementById(str).innerHTML=value;
}

function changestyle(object,info)
{
if (object.value==info)
	{
	object.value=''
	object.style.color="#000033"
	}
}

function revertstyle(object,info)
{
if (object.value=='')
	{
	object.value=info
	object.style.color="#CCCCCC"
	}
}

function revertstylebyid(str,info)
{
var obj=document.getElementById(str);
if (obj.value=='')
	{
	obj.value=info
	obj.style.color="#CCCCCC"
	}
}


//验证用户名
function isLoginName(tmpname)
{
    var patrn=/^[\u4e00-\u9fa5|0-9|a-z|A-Z|\.@_]{6,20}$/;
    if (!patrn.exec(tmpname))
    {
        return false;
    }
    else
    {
        return true;
    }
}

//验证密码
function isPassword(tmppwd)
{
    var patrn=/^[0-9a-zA-Z_]{6,15}$/;
    if (!patrn.exec(tmppwd))
    {
        return false;
    }
    else
    {
        return true;
    }
}


//固定电话+手机验证
function isPhone(str)
{
    var patrn=/(^[0-9]{3,4}-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^([0-9]{3,4})[0-9]{3,8}$)|(^0{0,1}(13|15)[0-9]{9}$)/;
    if (!patrn.exec(str))
    {
        return false;
    }
    else
    {
        return true;
    }
}

//验证固定电话
function isTel(str)
{
    var patrn=/(^[0-9]{3,4}-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^([0-9]{3,4})[0-9]{3,8}$)/;
    if (!patrn.exec(str))
    {
        return false;
    }
    else
    {
        return true;
    }
}

//验证手机号码
function isMobile(str)
{
    var patrn=/(^0{0,1}(13|15)[0-9]{9}$)/;
    if (!patrn.exec(str))
    {
        return false;
    }
    else
    {
        return true;
    }
}

//验证E-Mail
function isMail(str)
{
    //var patrn=/^[_a-z0-9\-\.]+@([_a-z0-9\-]+\.)+[a-z0-9]{2,3}$/;
    var patrn=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
    if (!patrn.exec(str))
    {
        return false;
    }
    else
    {
        return true;
    }
}

//网路打印
function preview()
{
	bdhtml=window.document.body.innerHTML;
	sprnstr="<!--startprint-->";
	eprnstr="<!--endprint-->";
	prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);
	prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
	window.document.body.innerHTML=prnhtml;
	window.print();
}