var $G = function(tagName)
			{
				return document.getElementById(tagName);
			};
			
		var $N = function(tagName)
			{
				return document.getElementsByName(tagName);
			};
			
		var $T=function(tagName)
			{
				return document.getElementsByTagName(tagName);
			};
function g(id){return document.getElementById(id);}

function n(name){return document.getElementsByName(name); }

function copyToClipboard(txt) {    
     if(window.clipboardData) {    
             window.clipboardData.clearData();    
             window.clipboardData.setData("Text", txt);   
             alert("复制成功！")  
     } else if(navigator.userAgent.indexOf("Opera") != -1) {    
          window.location = txt; 
          alert("复制成功！")    
     } else if (window.netscape) {    
          try {    
               netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");    
          } catch (e) {    
               alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");    
          }    
          var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);    
          if (!clip)    
               return;    
          var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);    
          if (!trans)    
               return;    
          trans.addDataFlavor('text/unicode');    
          var str = new Object();    
          var len = new Object();    
          var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);    
          var copytext = txt;    
          str.data = copytext;    
          trans.setTransferData("text/unicode",str,copytext.length*2);    
          var clipid = Components.interfaces.nsIClipboard;    
          if (!clip)    
               return false;    
          clip.setData(trans,null,clipid.kGlobalClipboard);    
          alert("复制成功！")    
     }    
} 



//获取文本框值
function getTextValue(id)
{
    var obj=g(id);
    return obj.value.Trim();
}

//获取单选按扭组选定值
function getRadioValue_0(radioObj)
{
        var re='';
        for(var i=0;i<radioObj.length;i++)
        {   
               if(radioObj[i].checked)
               {
                 re=radioObj[i].value;
               }
        } 
        return re;
}

//获取单选按扭组选定值
function getRadioValue(radioName)
{
	var radioObj=n(radioName)
        var re='';
        for(var i=0;i<radioObj.length;i++)
        {   
               if(radioObj[i].checked)
               {
                 re=radioObj[i].value;
               }
        } 
        return re;
}

//设置单选按扭组选定值
function setRadioValue_0(radioObj,v)
{
        if(v=='')
        {return;}
        for(var i=0;i<radioObj.length;i++)
        {   
               if(v=radioObj[i].value)
               {
                 radioObj[i].checked="checked";
               }
        }
}

//设置单选按扭组选定值
function setRadioValue(radioName,v)
{
	var radioObj=n(radioName)
        if(v=='')
        {return;}
        for(var i=0;i<radioObj.length;i++)
        {   
               if(v=radioObj[i].value)
               {
                 radioObj[i].checked="checked";
               }
        }
}

//设置列表框中的值
function setSelectValue(selectName,strValue)
{
    //if (strValue=="") return;
	var objSelect=n(selectName)
    for(i=0;i<objSelect.options.length;i++)
    {
            if(objSelect.options[i].value==strValue)
            {
                   objSelect.options[i].selected=true;
                   break;
            }
    }
}

//获取复选框组选定值
function getCkbValue(ckbName)
{
	var ckbObj=n(ckbName)
        var re='';
        for(var i=0;i<ckbObj.length;i++)
        {   
               if(ckbObj[i].checked)
               {
                 if(re=='')
                 {
                    re=ckbObj[i].value;
                 }
                 else
                 {
                    re=re+"|"+ckbObj[i].value;
                 }
               }
        } 
        return re;
}

//显示/隐藏对象

function showObj(id,type){
    if(type==0)
    {g(id).style.display='none';}
    else
    {g(id).style.display='block';}
}

//加载城市

	function ChangeProvince()
	{
		//var provinceID=$G("Province").value;
		var provinceID=document.getElementById('area').getElementsByTagName('select').item(0).value;
		//var cityLoading=$G("cityLoading");
		var ds=COM.getCity(provinceID).value;
		if(ds!=null)
		{
			//document.getElementById('area').getElementsByTagName('select').item(1).options.add(new Option("tttttt",0)); return;
			//alert(ds.Tables[0].Rows.length);return;
		        //cityLoading.style.display="block";
		        document.getElementById('area').getElementsByTagName('select').item(1).length=0;
        		
		        if(ds!=null && typeof(ds)=="object" && ds.Tables!=null)
		        {
			        for(var i=0;i<ds.Tables[0].Rows.length;i++)
			        {
				        var CityID=ds.Tables[0].Rows[i].areaID;
				        var CityName=ds.Tables[0].Rows[i].areaName;
				        document.getElementById('area').getElementsByTagName('select').item(1).options.add(new Option(CityName,CityID));
			        }
		        }
		        if(ds.Tables[0].Rows.length==0)
		        {
			        document.getElementById('area').getElementsByTagName('select').item(1).options.add(new Option("",0));
		        }
		        //cityLoading.style.display="none";
		}
		else
		{alert("error");}
		
		//test();
	}
	
	/*
	function test()
	{
	    //alert('test');
	    var provinceID=document.getElementById('area').getElementsByTagName('select').item(1).value;
		//var cityLoading=$G("cityLoading");
		var ds=MyAjax.getCity(provinceID).value;
		if(ds!=null)
		{
		        //cityLoading.style.display="block";
		        document.getElementById('area').getElementsByTagName('select').item(2).length=0;
        		
		        if(ds!=null && typeof(ds)=="object" && ds.Tables!=null)
		        {
			        for(var i=0;i<ds.Tables[0].Rows.length;i++)
			        {
				        var CityID=ds.Tables[0].Rows[i].AreaID;
				        var CityName=ds.Tables[0].Rows[i].AreaName;
				        document.getElementById('area').getElementsByTagName('select').item(2).options.add(new Option(CityName,CityID));
			        }
		        }
		        if(ds.Tables[0].Rows.length==0)
		        {
			        document.getElementById('area').getElementsByTagName('select').item(2).options.add(new Option("",0));
		        }
		        //cityLoading.style.display="none";
		}
	}
	*/
	
	//手机
	function chkMobile(strMobile)
	{
	    var reg=/^1[3|5|8]\d{9}$/;
	    if(reg.test(strMobile))
	    {
		    return true;
	    }
	    else
	    {
		    return false;
	    }
	}
	
	//手机或固话
	function chkTel(strTel)
	{
	    var reg=/^1[3|5|8]\d{9}$|^\d{7,8}$/;
	    if(reg.test(strTel))
	    {
		    return true;
	    }
	    else
	    {
		    return false;
	    }
	}
	
	//0或正整数
	function chkInt(strInput)
	{
	    var reg=/^(0|[1-9][0-9]*)$/;
	    if(reg.test(strInput))
	    {
		    return true;
	    }
	    else
	    {
		    return false;
	    }
	}
	
	//获取下拉列表选中项的文本
    function getSelectedText(name){
            var obj=document.getElementById(name);
            for(i=0;i<obj.length;i++){
               if(obj[i].selected==true){
                return obj[i].innerHTML;
               }
            }
    }
	
	//--------------------------------------
function choose(e,tag,n,onStyle,offStyle,more)
{
    for(i=1;i<=n;i++)
    {
        g(tag+'_tit_'+i).className=offStyle;
        g(tag+'_content_'+i).style.display='none';
    }
    e.className=onStyle;
    g(tag+'_content_'+jsright(e.id,1) ).style.display='block';
    
    //var n=jsright(e.id,1);
    if(g(tag+'_more')!=null)
    {
        g(tag+'_more').innerHTML=more;
    }
    
}
function jsright(str,n) 
{ 
var sr=str; 
sr = sr.substring(sr.length-n,sr.length); 
return sr; 
}
	
	

	

	
	