function emailform_validation()
{
	var error = null;
	
	// Creating flags and assigning it with 'False' 
	var isFriendemailCorrect = false;
	var isYouremailCorrect = false;
	var isTextAreaCorrect = false;


	var friendmail = document.email.recipient.value.split(',');
	var errorFlag = 0;
	var fromemail = document.email.from.value;



	if (friendmail == '')	{ // if value is empty, systen will disaplay error
		document.getElementById("Error_empty_friend").style.display = 'block';
		document.getElementById("Error_valid_mail").style.display = 'none';
		document.getElementById("Error_max_friend").style.display = 'none';
		isFriendemailCorrect = false;
	}else if (friendmail.length > 3){	// if more than 3 emails , systen will disaplay error
		document.getElementById("Error_max_friend").style.display = 'block';
		document.getElementById("Error_empty_friend").style.display = 'none'
		document.getElementById("Error_valid_mail").style.display = 'none';
		isFriendemailCorrect = false;
	}else{	
		// if not empty and less than or equal to 3, system will validate the email format
		for (y = 0; y < friendmail.length; y++)
		{
			if (!(validateEmail(friendmail[y]))){
				errorFlag = 1;	// incase of error in any one of the given email, system will set errorFlag = 1 and break the loop
				break;
			}
		}

		// For any email with error format, system will throw error
		if (errorFlag == 1){
			document.getElementById("Error_empty_friend").style.display = 'none'
			document.getElementById("Error_valid_mail").style.display = 'block';
			document.getElementById("Error_max_friend").style.display = 'none';
			isFriendemailCorrect = false;
		}else{	// if everything is correct system will set the flag wtih 'True'
			document.getElementById("Error_empty_friend").style.display = 'none'
			document.getElementById("Error_valid_mail").style.display = 'none';
			document.getElementById("Error_max_friend").style.display = 'none';
			isFriendemailCorrect = true;
		}
	}
	

	if (fromemail == ''){ // if value is empty, systen will disaplay error
		document.getElementById("Error_Empty_your").style.display = 'block';
		document.getElementById("Error_valid_yourmail").style.display = 'none';
		isYouremailCorrect = false;
	}else if (!(validateEmail(fromemail))){ // if invali format, systen will disaplay error
		document.getElementById("Error_Empty_your").style.display = 'none';
		document.getElementById("Error_valid_yourmail").style.display = 'block';
		isYouremailCorrect = false;
	}else{ // if valid and non-empty system will assign 'True' value
		document.getElementById("Error_Empty_your").style.display = 'none';
		document.getElementById("Error_valid_yourmail").style.display = 'none';
		isYouremailCorrect = true;
	}


	if (document.email.comment.value.length > 150){ // Check for 150 characters
		document.getElementById("Error_comment").style.display = 'block';
		isTextAreaCorrect = false;
	}else{
		document.getElementById("Error_comment").style.display = 'none';
		isTextAreaCorrect = true;
	}
    
    // if all the values are correct, system will submit the form, else return false value
		if ((isFriendemailCorrect) && (isYouremailCorrect) && (isTextAreaCorrect)) 
        {
            document.getElementById("hid_articlehead").value=document.getElementById("articleHead").innerHTML;
            document.getElementById("hid_articleParagraph").value=document.getElementById("EmailParagraph").innerHTML;
			document.forms['email'].submit();
		}else {
			return false;
		}

}

function trim(s)
{
	return s.replace(/^\s+|\s+$/, '');
}

function validateEmail(data)
{
	var error = "";
	var tfld = trim(data);
	// var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
	var emailFilter = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/;
	var illegalChars = /[\(\)\#\<\>\,\;\:\\\"\[\]]/;
	
	
	if (data == "")
	{
	return false;
	}
	else if (!emailFilter.test(tfld))
	{
	return false;
	}
	else if (data.match(illegalChars))
	{
	return false;
	}
	else
	{
	return true;
	}
}

// Code for Industry page Box alignment
$(document).ready(function() {
	$('.industry_cat_container').each(function(i){
        var index=parseInt(i)+1;
         if(index%2==0)
                 {
                     $(this).after($('<div style="clear:both;"></div>'));
                 }
    });
	
});
