var Utils = new Object();

Utils.trim = function( text )
{
  if (typeof(text) == "string")
  {
    return text.replace(/^\s*|\s*$/g, "");
  }
  else
  {
    return text;
  }
}


Utils.isEmail = function( email )
{
  var reg1 = /([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)/;

  return reg1.test( email );
}



var handleSuccess2 = function(o){
	
	if(o.responseText !== undefined){
		
		var iweburl=document.getElementById("weburl");
		var iemail=document.getElementById("ns_email");
		if(o.responseText=='y')
		{
			alert("you have successfully send your message to us");
			//iemail.value="";
			//window.location.replace(iweburl.value);
		}else{
			alert("there are a system error, please try it again");
		}

	}
};

var handleFailure2 = function(o){
	YAHOO.log("The failure handler was called.  tId: " + o.tId + ".", "info", "example");

	alert("there are a system error, please try it again");
};

var callback2 =
{
  success:handleSuccess2,
  failure:handleFailure2,
  argument:['foo','bar']
};


function mycontact()    
{

	
	var idquestion=document.getElementById("idquestion");
	var idname=document.getElementById("idname");
	var iemail=document.getElementById("idemail");
	var idmessage=document.getElementById("idmessage");

	var iweburl=document.getElementById("weburl");
		


	if(idname.value=="")
	{
		alert("Please enter your name");
		idname.focus();
		//scroll(0,200)
		return false;
	}
	
	if(iemail.value==""||Utils.isEmail(iemail.value)==false)
	{
		alert("Please enter valid email address");
		iemail.focus();
		//scroll(0,200)
		return false;
	}
	
	
	if(idmessage.value=="")
	{
		alert("Please enter your message");
		idmessage.focus();
		return false;
	}

	

	var sUrl = iweburl.value+"/contactus_db.php?action=signup";
	var postData = "question="+idquestion.value+"&name="+idname.value+"&email="+iemail.value+"&dmessage="+idmessage.value;

	var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback2, postData);
	

}
