function getXMLHTTP() 
{ 
	//fuction to return the xml http object
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				req = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
    }
	
	
	
function news(email)
{

var email_id=document.getElementById('email').value; 
 

 	var strURL="left_panel.php?email="+email_id;
		
		//alert(strURL);
		var req = getXMLHTTP();
		
		if (req) 
		{ 	req.open("GET", strURL, true);
			req.onreadystatechange = function() 
			{
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200)
					 {						
						var result=req.responseText;	
						//alert(result);						
						 result=parseInt(result);
						 if(result==1)
						 {
						   alert("Thanks for submitting your email...");
						 }
						 else if(result==2)
						 {
							 alert("Unable to submit your email at this moment");
						 }
						 
							
					
					}
					 else
					 {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}	
				
						
			}			
			
			req.send(null);
		}		

}

//script for field validation

function validation()
{
 
 var s=document.panel; 
  
 if(s.email.value=="")
 {
   alert("Please enter email id");
   document.getElementById('email').style.visibility="visible";	
   s.email.focus();
   return false; 
 }
      if(s.email.value.indexOf("@")<1  ||
    	s.email.value.indexOf(".")==-1 ||
    	s.email.value.indexOf(",")!=-1 ||
    	s.email.value.indexOf(" ")!=-1 ||
    	s.email.value.length<6)
  {
     alert("Please enter a valid E-mail address.\n" + "Example: name@gmail.com");
     s.email.focus();
     return false;
  } 
 
 else
 {
 document.getElementById('email').style.visibility="hidden";	
 } 
 return true; 

}
