function isNull(aStr)
{
   var index;
   for (index=0; index < aStr.length; index++)
		   if (aStr.charAt(index) != ' ')
				   return false;
   return true;
}

//For checking invalid E-Mail address

function isEmail(aStr)
       {
               var reEmail=/^[0-9a-zA-Z_\.-]+\@[0-9a-zA-Z_\.-]+\.[0-9a-zA-Z_\.-]+$/;
               if(!reEmail.test(aStr))
               {
                       return false;
               }
               return true;
       }

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}
<!------------------------------ ADD New Additional Paper ----------------------------->
function addNewPaper()
{
	counter = document.addProductForm.counter.value;
	counter = parseInt(document.addProductForm.counter.value) + 1;
	mydiv=document.getElementById("newPaper");
	newsubdiv=document.createElement("div");
	newsubdiv.id="div"+counter;
	mytable=document.getElementById("newtable");
	
	newdes ='<div class="row sep"><div class="col_2"><label for="project_description_1">Description'+ newsubdiv.id +':</label><textarea cols="20" rows="5" name="paper_description[]" id="paper_ta_'+newsubdiv.id+'" ></textarea></div><div class="col_3"><a href="javascript:void(1)" onclick="javascript:delPaperDiv('+counter+')" class="delete"><span>Delete</span></a></div></div>';
	newsubdiv.innerHTML=newdes;
	mydiv.appendChild(newsubdiv);
	alert(mytable);

	tinyMCE.execCommand('mceAddControl', false, "paper_ta_"+newsubdiv.id);
	document.addProductForm.counter.value=counter;
	
}

function delPaperDiv(x){
	mydiv=document.getElementById("newPaper");
	counter = document.addProductForm.counter.value;
	document.addProductForm.counter.value=counter-1;
	mydiv.removeChild(document.getElementById("div"+x));

}

//------------------------ New popup window ----------------------------------
var win = null;
	function NewWindow(mypage,myname,w,h,scroll){
		LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
		settings =
		'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
		win = window.open(mypage,myname,settings)
	}


//------------------------ Validation for contact us page ----------------------------------

function contactValidate()
 {

		if(document.sendMessage.visiter_name.value=="")
		{
			  alert("Enter Name!");
			  document.sendMessage.visiter_name.focus();
			  return false
		}

		  if(document.sendMessage.visiter_email.value=="")
		{
			 alert("Enter the  E-mail Address!");
			 document.sendMessage.visiter_email.focus();
			 return false
		}
		if(!isEmail(document.sendMessage.visiter_email.value))
		{
			alert("Please enter a valid E-mail Address!");
			document.sendMessage.visiter_email.focus();
			return false;
		} 

		if(document.sendMessage.visiter_phone.value=="")
		{
		  
			alert("Enter Your Phone Number!");
			document.sendMessage.visiter_phone.focus();
			return false;
		}

		if(document.sendMessage.message_description.value=="")
		{
		  
			alert("Message area should not be blank!");
			document.sendMessage.message_description.focus();
			return false;
		}
		
		 return true;
}
//--------------------------------------------- Inquiry validation ---------------------------------------------------

function inquiryValidate()
 {

		if(document.sendInquiry.cust_name.value=="")
		{
			  alert("Enter Name!");
			  document.sendInquiry.cust_name.focus();
			  return false
		}
		
		  if(document.sendInquiry.cust_email.value=="")
		{
			 alert("Enter the  E-mail Address!");
			 document.sendInquiry.cust_email.focus();
			 return false
		}
		if(!isEmail(document.sendInquiry.cust_email.value))
		{
			alert("Please enter a valid E-mail Address!");
			document.sendInquiry.cust_email.focus();
			return false;
		} 

		if(document.sendInquiry.cust_phone.value=="")
		{
		  
			alert("Enter Your Phone Number!");
			document.sendInquiry.cust_phone.focus();
			return false;
		}
		if(isNaN(document.sendInquiry.cust_phone.value))
		{
		  	alert("Enter Number Only!");
			document.sendInquiry.cust_phone.focus();
			return false;
		}
		if(isNaN(document.sendInquiry.cust_alt_phone.value))
		{
		  	alert("Enter Number Only!");
			document.sendInquiry.cust_alt_phone.focus();
			return false;
		}

		if(document.sendInquiry.cust_comment.value=="")
		{
		  
			alert("Enter Comments!");
			document.sendInquiry.cust_comment.focus();
			return false;
		}
		
		 return true;
}


//---------------------------------------- Admin Login Validation From Front End -------------------------------
function checkForm(){
		
		email = document.form1.email.value;
		
		if(email == ''){
			alert ('Email is Blank!!');
			return false;
		}
		if (email.indexOf ('@') == -1 || email.indexOf('.') == -1){
			alert ('Email is Wrong!!');
			return false;			
		}
		
	 }
//----------------------------------------- Search Form Validation ------------------------------------------------
function changeInput(str){

	if(str=='searchFrm'){
		if(document.searchForm.keyword.value=="")
			{
				  alert("Enter Keyword!");
				  document.searchForm.keyword.focus();
				  return false;
			}else{
				document.searchForm.submit();
				return false;
			}
	}else if(str=='resetFrm'){
		document.searchForm.reset();
	}
}
