function subscribeMe()
{
	sName = document.getElementById("sName");
	sEmail = document.getElementById("sEmail");
	sCompany = document.getElementById("sCompany");
	sTel = document.getElementById("sTel");

	if ( sName.value == "" )
	{
	   alert( "Please enter your name." );
	   sName.focus();
	   return false;
	}

	if ( sName.length > 64 )
	{
	   alert( "Sorry but your name should not be longer than 64 characters" );
	   sName.focus();
	   return false;
	}

	if ( sEmail.value == "" )
	{
	   alert( "Please enter your email address." );
	   sEmail.focus();
	   return false;
	}

	if ( ! eCheck( sEmail.value ))
	{
	   return false;
	}

	if ( sEmail.length > 128 )
	{
	   alert( "Maximum number of characters (128) for email exceeded." );
	   sEmail.focus();
	   return false;
	}

	if ( sCompany.value == "" )
	{
	   alert( "Please enter your company name." );
	   sCompany.focus();
	   return false;
	}

	if ( sCompany.length > 128 )
	{
	   alert( "Maximum number of characters (128) for company exceeded." );
    	   sCompany.focus();
	   return false;
	}

	if ( sTel.value == "" )
	{
	   alert( "Please enter your telephone number." );
	   sTel.focus();
	   return false;
	}

	if ( sTel.length > 20 )
	{
	   alert( "Maximum number of characters (20) for telephone exceeded." );
	   sTel.focus();
	   return false;
	}

	url = "a=s&n=" + sName.value + "&e=" + sEmail.value;
	url = url + "&c=" + sCompany.value + "&t=" + sTel.value;

	http.open('get', '/subscribe.php?' + url );
        http.onreadystatechange = handleFormResponse;
        http.send(null);
}

function eCheck( str ) 
{

	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);

	if (str.indexOf(at)==-1)
	{
	   alert("Invalid Email Address");
	   return false;
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
	{
	   alert("Invalid Email Address");
	   return false;
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 
					|| str.indexOf(dot)==lstr)
	{
	    alert("Invalid Email Address");
	    return false;
	}

	if (str.indexOf(at,(lat+1))!=-1)
	{
	    alert("Invalid Email Address");
	    return false;
	}

	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
	{
	    alert("Invalid Email Address");
	    return false;
	}

	if (str.indexOf(dot,(lat+2))==-1)
	{
	    alert("Invalid E-mail ID");
	    return false;
	}
		
	if (str.indexOf(" ")!=-1)
	{
	    alert("Invalid Email Address");
	    return false;
	}

 	return true;
}

