	 
		function showMailForm(articleId){
		

		    
			mailForm = document.getElementById("cms.component.emailForm");
			
			if (mailForm.style.visibility == "visible"){
				mailForm.style.visibility = "visible";
			}
			else{
				mailForm.style.visibility = "visible";
				 document.getElementById("articleIdEmail").value = articleId+"";
			}
		}
		
		  function divHide()
	      {
          document.getElementById("cms.component.emailForm").style.visibility="hidden";
	      }
		  function clearData()
			  {
				  
			 document.getElementById("mailTo").value="";
			 document.getElementById("mailFrom").value="";
			 document.getElementById("frdName").value="";
			 document.getElementById("yourName").value="";
             
		      }

	
		function sendEmail(articleId,mailTo,mailFrom,frdName,yourName)
		{
			
			document.getElementById("cms.component.emailForm")
			
			//var req2=null;
			
			//return true;
			var to=mailTo;
			var from=mailFrom;
		

			if (window.XMLHttpRequest) 
	           {
              //    Tries to create a new request object and XMLHttpRequest is the type of request object
		          req2= new XMLHttpRequest();
               } 
	           else if (window.ActiveXObject) 
	           {
                  //	Tries to create a new request object but in a way that works on IExplorer
	                 req2 = new ActiveXObject('Microsoft.XMLHTTP');
	           }	

				req2.onreadystatechange = processReqChangeForEmail;
				var strparams="to="+to+"&from="+from+"&articleId="+articleId+"&frdName="+frdName+"&yourName="+yourName;
				
				var url="/cms/components/emailArticle/emailArticleSend.jsp?"+strparams;
				//alert("url="+url);
				req2.open('POST', url, true);
               //   alert("url2="+url);
				
				req2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				req2.send(strparams);	
				showMailForm(articleId);
		}

		function processReqChangeForEmail()
		{
			// when readystate is set to 4 ,the server is done with the request'
		    if (req2.readyState == 4) 
			{
			// server sends status of 200 when everything is ok
			    if (req2.status == 200) 
				{
					//alert('req2.responseText='+req2.responseText);
					var httpreq=req2.responseText;
					
					//alert("httpreq="+httpreq);
						if(httpreq.match("sent=false")=='sent=false')
							alert("Please login first.. ");
						else
							alert("Mail sent successfully");
							window.close();
				}
			}
		}
		
		
		/*Email Validation*/
		
		function validate_email(field)
		{	
			var mailTo = document.getElementById("mailTo").value;
		   var mailFrom = document.getElementById("mailFrom").value;
		    field = field+"";
			//alert("Email For Validation : "+field);
		    apos=field.indexOf("@");
		    dotpos=field.lastIndexOf(".");
			if(mailFrom==""){
		    alert("please enter your e-mail address");
			document.getElementById("mailFrom").focus();
		    return false;
		    }else if(mailFrom!="" && mailTo==""){
			alert("Please enter your friend's e-mail address")
			document.getElementById("mailTo").focus();
		    return false;
		    }
			
		   else if (apos<1||dotpos-apos<2) 
		    {
			  //alert("Not a valid e-mail address!");
			  
			  return false;
			}
		    else
		    {
		    return true;
		    }  
		}

		function blankEmail(){
		var mailTo = document.getElementById("mailTo").value;
		var mailFrom = document.getElementById("mailFrom").value;
		if(mailFrom==""){
		alert("please fill your e-mail address");
		return false;
		}else if(mailFrom!="" && mailTo==""){
			alert("Please fill  your frienf e-mail address")
				return false;
		}
		else{
			return true;
		}

		}



		function validateForm(btnObj, articleId)
		{
			//alert("validation" +articleId);
			//var docForm=btnObj.form;
			//var elemnts = docForm.elements;
			var isValid = false;
			document.getElementById("cms.component.emailForm")
			var mailTo = document.getElementById("mailTo").value;
			var mailFrom = document.getElementById("mailFrom").value;
			var yourName = document.getElementById("yourName").value;
			var frdName = document.getElementById("frdName").value;
            var articleId= document.getElementById("articleIdEmail").value;
			//alert(yourName)
			//alert(frdName)
           var splitValues=mailTo.split(",");
			for(var i=0;i< splitValues.length;i++)
			{
				isValid = validate_email(splitValues[i]);
				//if(!isValid)
				//{
					//document.getElementById("mailTo").focus();
				//	return ;
				//}
				if(!isValid)
				{
					alert("please check the To email entered");
					return ;
					//sendEmail(articleId,mailTo,mailFrom,frdName,yourName);
					//clearData();
					
				}
			}
			isValid = validate_email(mailFrom);
			if(!isValid)
			{
				alert("Mail from is not a valid email"); 
				//document.getElementById("mailFrom").focus();
				return ;
			}
            sendEmail(articleId,mailTo,mailFrom,frdName,yourName);
     		  
		}

