function LTrim(s)
{
    for(var i=0;i<s.length;i++)
        if(s.charAt(i)!=' ')
            return s.substring(i,s.length);
    return "";
}

function RTrim(s)
{
	for(var i=s.length-1;i>=0;i--)
		if(s.charAt(i)!=' ')
		    return s.substring(0,i+1);
    return "";
}

function Trim(s)
{
	return RTrim(LTrim(s));
}

function checkAllFormInput(theForm)
{
	var str="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,./'[]{}`1234567890-=\~!@#$%^&*()_+|?><:";
	if (Trim(theForm.xm.value) =="")
	{
		alert("请输入您的中文姓名！");
		theForm.xm.focus();
		return(false);
	}
	if(Trim(theForm.tel.value)=="")
	{
		alert("请输入正确的电话号码！");
		theForm.tel.focus();
		return(false);
	}
	if (Trim(theForm.add.value) =="")
	{
		alert("请输入详细地址！");
		theForm.add.focus();
		return(false);
	}
	var d=theForm.add.value.substr(0,1);
	var e=theForm.add.value.substr(1,1);
	if(str.indexOf(d)>-1||str.indexOf(e)>-1)
	{
		alert("详细地址必须填写中文!");
		theForm.add.focus();
		return(false);
	}
	var d=theForm.xm.value.substr(0,1);
	var e=theForm.xm.value.substr(1,1);
	if(str.indexOf(d)>-1||str.indexOf(e)>-1)
	{
		alert("姓名必须填写中文!");
		theForm.xm.focus();
		return(false);
	}
	if (Trim(theForm.post.value) =="")
	{
		alert("请输入邮编!");
		theForm.post.focus();
		return(false);
	}
	if (theForm.txtcontent.value == "")
	{
		alert("请输入留言内容!");
		theForm.ly.focus();
		return(false);
	}
	return true;
}
//
function menuControl()
{
	hiddenAllSpan();
	var numID=Math.floor(Math.random()*3)+1;
	showOneSpan(numID);
}

//显示一个
function showOneSpan(obj)
{
	var s = "menu_" + obj;
	document.getElementById(s).style.display = "";
}

//隐藏所有的span
function hiddenAllSpan()
{
	for(var i=1; i<=3; i++)
	{
		var s = "menu_" + i;
		document.getElementById(s).style.display = "none";
	}
}


function sel(theinput)
{
  if(document.getElementById("txtcontent").value!="")
     document.getElementById("txtcontent").value+="\n"+theinput
  else
	 document.getElementById("txtcontent").value=theinput
}
