function checkfun(id,msgstr){
	if(document.getElementById(id).value==""){
		document.getElementById(id).focus();
		if(msgstr!=""){
			alert(msgstr);
		}
		return false;
	}else{
		return true;
	}
}

function checkradio(inputname){
	var radiovalue="";
	var obj=document.getElementsByName(inputname);
	for(i=0;i<obj.length;i++){
		if(obj[i].checked){
			radiovalue=obj[i].value;
			break;
		}
	}
	return radiovalue;
}

function checkemail(email){
	if(email.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1){
		return true;
	}else{
		return false;	
	}
}

function selected(theinput,thevalue){
	if(thevalue!=''){
		var obj=document.getElementById(theinput);
		var len=obj.length;
		for(i=0;i<len;i++){
			if(obj.options[i].value==thevalue){
				obj.options[i].selected=true;
			}
		}
	}
}

function checked(theinput,thevalue){
	if(thevalue!=''){
		var obj=document.getElementsByName(theinput);
		var len=obj.length;
		for(i=0;i<len;i++){
			if(obj[i].value==thevalue){
				obj[i].checked=true;
			}
		}
		
	}
}

//var asiXHTTP=null;

function asiAjax(containerid,method,url,poststr){
	//var m=Math.random();
	//url=url+"&m="+m;
	var asiXHTTP;
	try{
		asiXHTTP=new XMLHttpRequest();
	}catch (e){
		try{
			asiXHTTP=new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				asiXHTTP=new ActiveXObject("Microsoft.XMLHTTP");
			}catch(e){
				//alert("Your browser does not support AJAX");
				return false;
			}
		}
	}
	
	asiXHTTP.open(method,url,true);
	if(method=="post"){
		asiXHTTP.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	}
	asiXHTTP.send(poststr);
	
	asiXHTTP.onreadystatechange=function(){
		if(asiXHTTP.readyState==4){
			document.getElementById(containerid).innerHTML=asiXHTTP.responseText;
		}else{
			document.getElementById(containerid).innerHTML="Data Loading...";
		}
	}
}


function GetCookie(c_name)
{
	if (document.cookie.length > 0)
	{
		c_start = document.cookie.indexOf(c_name + "=")
		if (c_start != -1)
		{
			c_start = c_start + c_name.length + 1;
			c_end   = document.cookie.indexOf(";",c_start);
			if (c_end == -1)
			{
				c_end = document.cookie.length;
			}
			return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	return null
}

function SetCookie(c_name,value,expiredays)
{
	var exdate = new Date();
	exdate.setDate(exdate.getDate() + expiredays);
	document.cookie = c_name + "=" +escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString())+";path=/"; //使设置的有效时间正确。增加toGMTString()
}


function maxinput(inputid,maxnum){
	var thevalue=document.getElementById(inputid).value;
	if(thevalue.length>maxnum){
		document.getElementById(inputid).value=thevalue.substring(0,maxnum);
	}
}

