﻿function DispWinLoading()
{
    if(document.getElementById("DivLoading"))
    {
        var _obj = document.getElementById("DivLoading");
        _obj.style.top = document.body.scrollTop;
        _obj.style.left = document.body.clientWidth-(document.body.clientWidth - 778)/2 - 100;
        _obj.style.display = "block";
    }
}

function HidWinLoading()
{
     if(document.getElementById("DivLoading"))
    {
        document.getElementById("DivLoading").style.display = "none";
    }
}

function GoSearch()
{
    if(document.getElementById("Top1_txtSearchText")&&document.getElementById("btnSearch"))
    {
        var objtxtSearchText = document.getElementById("Top1_txtSearchText");
        var objbtnSearch = document.getElementById("btnSearch");
        var objddlSearchType = document.getElementById("top1_ddlSearchType");        
        if(Trim(objtxtSearchText.value)=="")
        {
            alert("请输入搜索内容！");
            objtxtSearchText.focus();
        }
        else
        {
            window.location = "/search.aspx?type=" + objddlSearchType.value + "&keywords=" + encodeURI(objtxtSearchText.value);
        }
    }
}
function LTrim(str)
{
    var whitespace = new String(" \t\n\r");
    var s = new String(str);    
    if (whitespace.indexOf(s.charAt(0)) != -1){
        var j=0, i = s.length;
        while (j < i && whitespace.indexOf(s.charAt(j)) != -1){
            j++;
        }
        s = s.substring(j, i);
    }
    return s;
}
function RTrim(str){
    var whitespace = new String(" \t\n\r");
    var s = new String(str);
    if (whitespace.indexOf(s.charAt(s.length-1)) != -1)
    {
        var i = s.length - 1;
        while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
        {
            i--;
        }
        s = s.substring(0, i+1);
    }
    return s;
}
function Trim(str){
    return RTrim(LTrim(str));
}

function IsMail(mail){
    return(new RegExp(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/).test(mail));
}

function IsVadCode(code){
   return new RegExp(/^[A-Za-z0-9]+$/).test(code);
}
function IsVadNum(code){
   return new RegExp(/^[0-9]+$/).test(code);
}

function openWin(url,name,w,h)
 {
    var x=(window.screen.width-w)/2;
	var y=(window.screen.height-h)/2;
	var win=window.open(url,name,'toolbar=0,location=0,status=0,top='+y+',left='+x+',width='+w+',height='+h );
	win.focus();
	
	return win;
 }