function validate_handytools_form(form)
{
	handytools_email = form.handytools_email.value;
	if (form.handytools_name.value == "")
	{
		alert ("Please fill the name");
		form.handytools_name.focus();
		return false;
	}
	else if (handytools_email == "") 
	{
		alert ("Please fill the email address");
		form.handytools_email.focus();
		return false;
	}
	else if (handytools_email.indexOf('@')<1 || handytools_email.indexOf('@') == handytools_email.length-1)
	{
		alert ("Please fill in the correct email address");
		form.handytools_email.focus();
		return false;
	}
	else
	{
		url="sendhandytools.php?"+getHandyData(form);
		loadXML(url,showStat)
	}
}

function showStat()
{
	var msg="";
	var proceed="";
	var nodes=xdoc.getElementsByTagName("proceed");
	if(nodes[0].childNodes[0])
		proceed=nodes[0].childNodes[0].nodeValue;
	nodes=xdoc.getElementsByTagName("msg");
	if(nodes[0].childNodes[0])
		msg=nodes[0].childNodes[0].nodeValue;
	if(proceed=="Y" && msg=="")
	{
		document.getElementById('handytools_verification').style.display='none';
		document.getElementById('handytools').style.display='';
		return false;
	}
	else
	{
		alert(msg);
	}
}

function getHandyData(form)
{
	var str='';
	for(var i=0;i<form.elements.length;i++)
	{
		var itm=form.elements[i];
		if(itm.name)// && itm.value)
		{   
		    if(itm.type=="radio" || itm.type=="checkbox" ) 
			{
				if(itm.checked)
					str+=itm.name+"="+itm.value+"&";
			}
		    else
				str+=itm.name+"="+itm.value+"&";
		}
	}	
	return(str)
}
function loadXML(url,doFunc)
{
	if (window.XMLHttpRequest)
	{
		xmlhttp=new XMLHttpRequest()
	}
	// code for IE
	else if (window.ActiveXObject)
	{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	else
		alert('Your browser cannot handle this script');
	// xmlhttp.onreadystatechange=getAll;
	
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4)
            if (xmlhttp.status==200)
			{
				xdoc=xmlhttp.responseXML;				
				doFunc();
			}
			else
  			  alert("Problem retrieving XML data:" + xmlhttp.statusText)
	}		
    xmlhttp.open("GET",url,true)
    xmlhttp.send(null)
}
