function chkmail(emailid)
{
	
	//var emailid=document.getElementById("emailid").value;
	//alert(emailid);
	var at="@";
	var dot=".";
	var lat=emailid.indexOf(at);
	var lemailid=emailid.length;
	var ldot=emailid.indexOf(dot);
	

	if(emailid=="")
	{
		alert("Please enter your e-mail id ");
	}

	if(emailid.length > 0) 
	{

		if (lat==-1 || lat==0 || lat==lemailid)
		{
		   	alert("Please enter a valid e-mail id");
		   	emailid = "";
		   	
		   	return false;
		}
		if (ldot==-1 || ldot==0 || ldot==lemailid)
		{
		    	alert("Please enter a valid e-mail id");
			 emailid = "";
		   	 
		    	return false;
		}
		if (emailid.indexOf(at,(lat+1))!=-1)
		{
		   	alert("Please enter a valid e-mail id");
			emailid = "";
		    	
		    	return false;
		}

		if (emailid.substring(lat-1,lat)==dot || emailid.substring(lat+1,lat+2)==dot)
		{
		    	alert("Please enter a valid e-mail id");
			emailid = "";
		    	
		    	return false;
		}

		if (emailid.indexOf(dot,(lat+2))==-1)
		{
		    	alert("Please enter a valid e-mail id");
			 emailid = "";
		    	
		    	return false;
		}

		if (emailid.indexOf(" ")!=-1)
		{
		    	alert("Please enter a valid e-mail id");
	         	emailid = "";
		    	
			return false;
		}
			
		return true;
		
	}



}



function chkfrndmail()
{


		mailto=trim(document.getElementById('txtemailto').value);
       	mailfrom=trim(document.getElementById('txtemailfrom').value);
		note=trim(document.getElementById('txtMsg').value);	
		
				
                if(mailfrom.length<=0)
                {
                      alert("Please enter your email id");
                      document.getElementById('txtemailfrom').focus();
                      return false;
                }
				else if(!chkmail(mailfrom))
                {        
		      		
					document.getElementById('txtemailfrom').focus();
					return false;
                }
				//else if(mailto.length<=0 )
              // {
                     // alert("Please Enter Your Friend's Email id");
                     // document.getElementById('txtemailto').focus();
                     // return false;
               // }else if(!chkmail(mailfrom))
               // {        
		      		//return false;
                //}else if(!chkmail(mailto))
                ///{        
       
					//return false;
               // }else
				//{
					
					
					
					var temp = new Array();
				    temp = mailto.split(',');
					var i=0;
					for(i=0;i<temp.length;i++)
					{
						
						if(temp[i].length<=0 )
              			{
							  alert("Please enter your friend's e-mail id");
							  document.getElementById('txtemailto').focus();
							  return false;
						}else if(!chkmail(temp[i]))
						{
							   document.getElementById('txtemailto').focus();
							  return false;
							  
						}
						
					}

					document.invitefrm.submit();
				//}

	
}



function checkdesc()
{

	msg=trim(document.getElementById('txtmsg').value);

	if(msg.length<=0)
        {
            alert("Please enter your comments");
            document.getElementById('msg').focus();
            return false;
        }
	else
	{
		xajax_adminmessageupdate(xajax.getFormValues("adminfrm"));
		
	}
}	
/*
function alert(content)
{
	document.getElementById('insidealert').innerHTML = content;
	document.getElementById('insidealert').className = "show";
	document.getElementById('alert').className = "show";
	
}*/
function limitLength(sourceField, counterField, max) 
{
	//alert( sourceField.value.substring(0, max));
        if (sourceField.value.length > max)
            sourceField.value = sourceField.value.substring(0, max);
			//alert(sourceField.value);
        else
            counterField.value = max - sourceField.value.length;
}

function submitresource()
{
		var securitycode=trim(document.getElementById("security_code").value); 
		if (trim(document.getElementById("webtitle").value) == "")
        {
            alert ("Please enter the website title");
            document.getElementById("webtitle").focus();
            return false;
        }

        if (trim(document.getElementById("webtitle").value).length < 5)
        {
            alert ("Website Title should contains atleast 5 characters.");
            document.getElementById("webtitle").focus();
            return false;
        }
        
        var iChars = "!@#$%^&*()+=-[]\\\';,/{}|\":<>?";
        var title = trim(document.getElementById("webtitle").value);
        
        for (var i = 0; i < title.length; i++) 
        {  
            if (iChars.indexOf(title.charAt(i)) != -1) 
            { 
                alert ("Invalid Website Title"); 
                document.getElementById("webtitle").focus(); 
                return false; 
            }
        }
		
		if (trim(document.getElementById("weburl").value) == "")
        {
            alert ("Please enter a wesite url");
            document.getElementById("weburl").focus();
            return false;
        }

        if (checkUrl(document.getElementById("weburl").value) == false)
        {
            alert ("Please enter a valid website url");
            document.getElementById("weburl").focus();
            return false;
        }
		
		if (trim(document.getElementById("txtDescription").value) == false)
        {
            alert ("Please enter the description");
            document.getElementById("txtDescription").focus();
            return false;
        }

        if (trim(document.getElementById("txtDescription").value).length < 25)
        {
            alert ("Description should contains atleast 25 characters");
            document.getElementById("txtDescription").focus();
            return false;
        }
         if (document.getElementById("cboCategory").selectedIndex == 0)
        {
            alert ("Please select the Category");
            document.getElementById("cboCategory").focus();
            return false;
        }
		
		
		var webmail=trim(document.getElementById("webemail").value);
		if(!chkmail(webmail))
		{
		return false;
		}
		
		if (trim(document.getElementById("weblink").value) == "")
        {
            alert ("Please enter the Link Page");
            document.getElementById("weblink").focus();
            return false;
        }
		if(securitycode.length==0)
        {
            alert("Please enter the given security code");
            document.getElementById('security_code').focus();
            return false;  
        }
		
		
		
document.resourcefrm.submit();
       

}

 function checkUrl(url) 
    {
        //if (/http(s)?:\/\/([\\w-]+\\.)+[\\w-]+(/[\\w- ./?%&=]*)?/.test(url))
        if (/^(https?):\/\/+(www\.)?[A-Za-z0-9\-\.]{3,}\.[A-Za-z0-9]{1,}$/.test(url))
        {            
            return true;
        }
        
        return false;
    }
