//获取对象
function Object(objName)
{
	var obj =null;
	
	try
	{
	 	obj = document.forms[0].elements[objName];
	}
	catch(e)
	{
	}
		
	if (obj=="undefined" || obj== null)
	{
		try
		{
			obj = document.getElementById(objName);
		}
		catch(e)
		{
			
			if (obj=="undefined" || obj== null)
			{
				obj = document.getElementByName(objName);
			}
		}
	}
	
	//alert(obj);
	
	return  obj;
}

function addCookie(name,value,expireDays)
{
	var cookieString=name+"="+escape(value);
		
	//判断是否设置过期时间
	if(expireDays>0)
	{
		var myDate=new Date();
		myDate.setTime(myDate.getTime()+expireDays*3600*1000*24); // 转换为毫秒
		cookieString=cookieString+";expires="+myDate.toGMTString();
	}
		document.cookie=cookieString;
}
	
function getCookie(name)
{	
	var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
	
	//alert(arr[2]);
     if(arr != null) return unescape(arr[2]); return "";
}

function deleteCookie(name)
{
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
   	var cval=getCookie(name);
    if(cval!=null) 
    {
    	document.cookie= name + "="+cval+";expires="+exp.toGMTString();
    }
}

	//通过xmlhttp取值，返回字符串
function getHtmlStringByXmlhttp1(url)
{
	if(url==null)
	{
		alert("没有指定URL地址。");
		return "";
	}
	 
	
	try
    {
        xmlhttp = new XMLHttpRequest();  //尝试创建 XMLHttpRequest 对象，除 IE 外的浏览器都支持这个方法。
    }
    catch (e)
    {
        try
        {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");  //使用较新版本的 IE 创建 IE 兼容的对象（Msxml2.XMLHTTP）
        }
        catch (e)
        {
            try
            {
              xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); //使用较老版本的 IE 创建 IE 兼容的对象（Microsoft.XMLHTTP）。
            }
            catch (failed)
            {
                  xmlhttp = false;  //如果失败则保证 request 的值仍然为 false。
                  alert("error");
                  return "";
            }
        }
    }
    
    xmlhttp.open("POST",url,false);
	xmlhttp.send();
	return xmlhttp.responseText;
}	

//检查中英文字符串长度，汉字算2个字符
function strLen(str)
{
	return str.replace(/[^\x00-\xff]/g,"**").length;
}


