//  this function checks the given string is empty or not
//  and return true or false accordingly.
	function is_empty(str)
	{
  		 str=trim(str);
		 if ((str.length==0)||(str==null))
			return true;
		 return false;
	}
// End of is_empty Function
	
	function trim(inputString) 
	{
	   // Removes leading and trailing spaces from the passed string. Also removes
	   // consecutive spaces and replaces it with one space. If something besides
	   // a string is passed in (null, custom object, etc.) then return the input.
	   if (typeof inputString != "string") { return inputString; }
	   var retValue = inputString;
	   var ch = retValue.substring(0, 1);
	   while (ch == " ") { // Check for spaces at the beginning of the string
		  retValue = retValue.substring(1, retValue.length);
		  ch = retValue.substring(0, 1);
	   }
	   ch = retValue.substring(retValue.length-1, retValue.length);
	   while (ch == " ") { // Check for spaces at the end of the string
		  retValue = retValue.substring(0, retValue.length-1);
		  ch = retValue.substring(retValue.length-1, retValue.length);
	   }
	   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
		  retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
	   }
	   return retValue; // Return the trimmed string back to the user
	} // Ends the "trim" function


//############## registration form(sign up) validation start here

function fun1()  /// Avoiding space entry in password field
{ 
var name=document.getElementById('fld_password').value; 
document.getElementById('fld_password').value=name.replace(/^(?:\s)*/g,'').replace(/(?:\s)*$/g,'');
}


function check()  // form fields validation
{
if(document.getElementById('fld_email').value=="")
	{

     alert("Please enter email address.");
	 document.getElementById('fld_email').focus();
	 return false;
    }

	if(!is_email(document.getElementById('fld_email').value))
	{

     alert("Please enter a valid email address.");
	 document.getElementById('fld_email').focus();
	 return false;
    }


	if(document.getElementById('fld_password').value=="")
	{

     alert("Please enter password.");
	 document.getElementById('fld_password').focus();
	 return false;
    }


	if(document.getElementById('fld_password').value.length < 6)
	{

     alert("Password must be minimum of 6 digits.");
	 document.getElementById('fld_password').focus();
	 return false;
    }


	if(document.getElementById('fld_cpassword').value=="")
	{

     alert("Please enter confirm password.");
	 document.getElementById('fld_cpassword').focus();
	 return false;
    }

	if(document.getElementById('fld_password').value != document.getElementById('fld_cpassword').value)
	{

     alert("Password and confirm password must be same.");
	 document.getElementById('fld_cpassword').focus();
	 return false;
    }

   if(is_empty(document.getElementById('fld_name').value))
	{

     document.getElementById('fld_name').value="";
     alert("Please enter name.");
	 document.getElementById('fld_name').focus();
	 return false;
    }

}
//################ registration form(sign up) validation end here

//##### Login Form validation script start here.

function lgnvalid()
{
if(document.getElementById('username').value=="")
	{

     alert("Please enter your email address.");
	 document.getElementById('username').focus();
	 return false;
    }

	if(!is_email(document.getElementById('username').value))
	{

     alert("Please enter a valid email address.");
	 document.getElementById('username').focus();
	 return false;
    }


	if(document.getElementById('password').value=="")
	{

     alert("Please enter your password.");
	 document.getElementById('password').focus();
	 return false;
    }


	if(document.getElementById('password').value.length < 6)
	{

     alert("Password must be minimum of 6 digits.");
	 document.getElementById('password').focus();
	 return false;
    }

}
//### Login form validation script end here.

//### Validation of project name when project created without name.
function projectname()
{
if(is_empty(document.createproject.project_name.value))
{
document.createproject.project_name.value="";
alert("Please enter project name.");
document.createproject.project_name.focus();
return false;
	
}
}



