function val_Emptytext(txtControl,mailUrl,page)
{	
	var ctrl=document.getElementById(txtControl).value;
	if(ctrl=="")
	{
		//document.getElementById('fade').style.display='block';
		//showalert('login/lightbox_need.php','lightbox_exists','','search','tell_empty_email');
		document.getElementById('emailError').innerHTML="Please Enter the Email ID";
		return false;
	}
	if(ctrl!="")
	{
			var email = ctrl;			
		  	var arr=email.split(",");
			for(var i=0;i<arr.length;i++)
			{
				var email1=arr[i];
				if(!valid_email(email1))
				{
					return false;
				}
				
			}
			document.getElementById('emailError').innerHTML="";
			MultiMailSend(email,mailUrl,page);
			document.getElementById('divloader').style.display = 'block';
			//document.tellafriend.submit();
			//window.location.href="home/templates/tellaFriend.php";
			return true;
	}
}

function valid_email(email)
{
    var RegExp = /^([a-zA-Z0-9_\-\.])+@(([0-2]?[0-5]?[0-5]\.[0-2]?[0-5]?[0-5]\.[0-2]?[0-5]?[0-5]\.[0-2]?[0-5]?[0-5])|((([a-zA-Z\-])+\.)+([a-zA-Z\-])+))$/
    if(RegExp.test(email))
	{
    	return true;
    }
	else
	{
		//document.getElementById('fade').style.display='block';
		//showalert('login/lightbox_need.php','lightbox_exists','','search','tell_invalid_email');
		document.getElementById('emailError').innerHTML="Invalid Email ID...";
        return false;
    }
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
	    {
	    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	    }
	  catch (e)
	    {
	    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	    }
	  }
	return xmlHttp;
}

function MultiMailSend(str,mailUrl,page)
{
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	  
	var url=mailUrl;
	url=url+"?mail="+str+"&page="+page;
	//alert(url);
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=emailSend;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function emailSend()
{
	//alert(xmlHttp.responseText);
	//alert(xmlHttp.readyState);
	//alert(xmlHttp.responseText);
	if (xmlHttp.readyState==4)
	
	{
		
	 	var msg=xmlHttp.responseText;
	//	alert(msg);
		document.getElementById('divloader').style.display = 'none';
		document.getElementById('contentArea').innerHTML = msg;	
		/*document.getElementById('fade').style.display='block';
		showalert('login/lightbox_need.php','home','sendmail','search',msg);*/
		//alert(msg);
		return false;
	}
}
