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					
	}
	function isValidURL(obj) 
	{ 
		var v = new RegExp(); 
		v.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+[A-Za-z0-9-_%&\?\/.=]"); 
		if (!v.test(obj))
			return false; 
		else
			return true;
	} 
function fnsubmit()
{
	var story=document.exform.txtStory
    var guidelines=document.exform.chk_submission_guidelines
	var captcha=document.exform.security_code
	var emailID=document.exform.email
	var name=document.exform.submission_author
	var link=document.exform.txtLink
	var desc=document.exform.txtdesc 
	var reci=document.exform.txtReci
	var title=document.exform.txtTitle
	var titlelink=document.exform.txtWebSite 
	var description = trim(document.exform.txtdesc.value);
	if ((name.value==null)||(name.value=="")){
		alert("Please enter Name")
		name.focus()
		return false
	}
	if(emailID.value!='')
	{
		if (echeck(emailID.value)==false){
			emailID.value=""
			emailID.focus()
			return false
		}
	}
	if ((link.value==null)||(link.value=="")){
		alert("Please enter Website")
		link.focus()
		return false
	}
	if (isValidURL(link.value)==false){
		alert("Invalid Website")
		link.value=""
		link.focus()
		return false
	}
	if ((title.value==null)||(title.value=="")){
		alert("Please enter Title for your link")
		title.focus()
		return false
	}
	if ((titlelink.value==null)||(titlelink.value=="")){
		alert("Please enter URL of your link")
		titlelink.focus()
		return false
	}
	if (isValidURL(titlelink.value)==false){
		alert("Invalid URL of your link")
		titlelink.value=""
		titlelink.focus()
		return false
	}
	if ((desc.value==null)||(desc.value=="")){
		alert("Please enter Link Description")
		desc.focus()
		return false
	}
	if ((desc.value!=null)||(desc.value!="")){
		if(description.length > 255) 
		{
			alert("Maximum 255 Characters are allowed")
			desc.focus()
			return false
		}
	}
	if ((reci.value==null)||(reci.value=="")){
		alert("Please enter Reciprocal Link")
		reci.focus()
		return false
	}
	if (!guidelines.checked){
		alert("Please check submission guidelines")
		guidelines.focus()
		return false
	}
	else
	{
		document.exform.page_action.value='add';
		document.exform.action="book_uploads.php";
		document.exform.submit();
	}      			
	return true
}
