	var totrows;
	totrows=1;	
	function addRecipients(){
		
		obj_tbody = document.getElementById("recipients");
		var insertrows;
		insertrows=document.email_this.recipientno.value;
		if(totrows>insertrows){
			for(i=totrows;i>insertrows;i--)
			{		
				obj_tbody.deleteRow(-1);
				obj_tbody.deleteRow(-1);
				obj_tbody.deleteRow(-1);
				obj_tbody.deleteRow(-1);
			}			
		}
		else{
			for(i=totrows;i<insertrows;i++)
			{		
				tr = obj_tbody.insertRow(-1);
					td = tr.insertCell(-1);		
					td.innerHTML = '<img src="././images/pixel.gif" height="5">';
					td.colSpan="3";

				tr = obj_tbody.insertRow(-1);
					td = tr.insertCell(-1);		
					td.align="right";
					td.innerHTML = "Recipient's Name:";
					td = tr.insertCell(-1);		
					td.innerHTML = '<img src="././images/pixel.gif" width="10" height="1">';
					td = tr.insertCell(-1);		
					td.innerHTML = '<input type="text" name="recipientName[]" style="width:200px"/>';

				tr = obj_tbody.insertRow(-1);
					td = tr.insertCell(-1);		
					td.innerHTML = '<img src="././images/pixel.gif" height="5">';
					td.colSpan="3";
				
				tr = obj_tbody.insertRow(-1);
					td = tr.insertCell(-1);		
					td.align="right";
					td.innerHTML = "Recipient's Email:";
					td = tr.insertCell(-1);		
					td.innerHTML = '<img src="././images/pixel.gif" width="10" height="1">';
					td = tr.insertCell(-1);		
					td.innerHTML = '<input type="text" name="recipientEmail[]" style="width:200px"/>';
			}		
		}
		totrows=insertrows;
		//alert(totrows);
	}


function validate_email_this()
{
	var i=0;
	/*for(i=0;i<document.email_this.recipientno.value;i++){
		if(document.email_this.recipientName[i].value==""){
		   alert('Please enter recipient name');
		   document.email_this.recipientName[i].focus();
		   return false;
		}
		
		if(document.email_this.recipientEmail[i].value==""){
		   alert('Please enter recipient email');
		   document.email_this.recipientEmail[i].focus();
		   return false;
		}else if(isEmail(document.email_this.recipientEmail[i].value) == false){
		   document.email_this.recipientEmail[i].focus();
		   return false;
		}
	}*/
	dml=document.forms['email_this'];
	len = dml.elements.length;
	for( i=0 ; i<len ; i++){
		if (dml.elements[i].name=='recipientName[]'){
			if (dml.elements[i].value==""){
				alert("Enter the recipient Name");
				dml.elements[i].focus();
				return false;                       
			}
		}
		if (dml.elements[i].name=='recipientEmail[]'){
			if (dml.elements[i].value==""){
				alert("Enter the recipient Email");
				dml.elements[i].focus();
				return false;                       
			}else if(isEmail(dml.elements[i].value) == false){
			   dml.elements[i].focus();
			   return false;
			}
		}
	}

	if(document.getElementById("senderNameId").value==''){
	   alert('Please enter your name');
	   document.getElementById("senderNameId").focus();
	   return false
	}

	if(document.getElementById("senderEmailId").value==''){
	   alert('Please enter email id');
	   document.getElementById("senderEmailId").focus();
	   return false
	} else {

		if(isEmail(document.getElementById("senderEmailId").value) == false){
			document.getElementById("senderEmailId").focus();
			return false;
		}
	}

	if(document.getElementById("subjectId").value==''){
	   alert('Please enter subject');
	   document.getElementById("subjectId").focus();
	   return false
	}

	if(document.getElementById("messageId").value==''){
	   alert('Please enter message');
	   document.getElementById("messageId").focus();
	   return false
	}

	if(document.email_this.security_code.value==''){
	   alert('Please enter security code');
	   document.email_this.security_code.focus();
	   return false
	}else if(document.email_this.security_code.value!=document.email_this.varcode.value){
	   alert('Please enter valid security code');
	   document.email_this.security_code.focus();
	   return false
    }

	
	return true		
}

/*  FUNCTION FOR EMAIL VALIDATION   */ 

function isEmail(emailStr1)
		{
			var emailPat=/^(.+)@(.+)$/
			var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
			var validChars="\[^\\s" + specialChars + "\]"
			var quotedUser="(\"[^\"]*\")"
			var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
			var atom=validChars + '+'
			var word="(" + atom + "|" + quotedUser + ")"
			var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
			var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")

			var matchArray=emailStr1.match(emailPat)
			if (matchArray==null) 
			{
				alert("Email address seems incorrect (check @ and .'s)")
                
				return false
			}
			
			var user=matchArray[1]
			var domain=matchArray[2]
			if (user.match(userPat)==null) 
			{
				alert("The username doesn't seem to be valid.")
                
				return false
			}

			var IPArray=domain.match(ipDomainPat)
			if (IPArray!=null) 
			{
				  for (var i=1;i<=4;i++)
				  {
					if (IPArray[i]>255)
					{
						alert("Destination IP address is invalid!")
                        
						return false
					}
				  }	    
				  return true
			}

			var domainArray=domain.match(domainPat)
			if (domainArray==null) 
			{
				alert("The domain name doesn't seem to be valid.")
                
				return false
			}

			var atomPat=new RegExp(atom,"g")
			var domArr=domain.match(atomPat)
			var len=domArr.length
			if (domArr[domArr.length-1].length<2 || 
				domArr[domArr.length-1].length>3)
			{
			   alert("The address must end in a three-letter domain, or two letter country.")
               
			   return false
			}

			if (len<2)
			{
			   var errStr="This address is missing a hostname!"
               
			   alert(errStr)
			   return false
			}	
			return true
}

/*   EMAIL VALIDATION FUNCTION ENDS   */


function share(s) {
	var u = escape(window.location);
	var t = escape(document.title);
	var l = u;
	if(s=='digg'){		
		window.open('http://digg.com/submit?title=' + t + '&url=' + u, s);		
	}
	
	if(s=='yahoo'){		
		window.open('http://myweb2.search.yahoo.com/myresults/bookmarklet?title=' + t + '&u=' + u, s);		
	}
	
	if(s=='delicious'){		
		window.open('http://del.icio.us/post?title=' + t + '&url=' + u, s);		
	}

	if(s=='technorati'){		
		window.open('http://www.technorati.com/faves?add=' + u, s);		
	}

	if(s=='stumbleupon'){		
		window.open('http://www.stumbleupon.com/submit?title=' + t + '&url=' + u, s);		
	}

	if(s=='google'){		
		window.open('http://www.google.com/bookmarks/mark?op=add&title=' + t + '&bkmk=' + u, s);		
	}	
}

function playaudio(movie){
window.open('http://www.robinsharma.com/content_files/AudioBookReviews/'+movie, 'audio', 'width=150,height=100,scrollbars=no,left=300,top=200');
}

function regenerateCode(){
	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var string_length = 4;
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	document.email_this.varcode.value=randomstring;
	document.getElementById('captcha').src="scripts/captcha1.php?text="+randomstring;
}
