// JavaScript Document
function trim(inputString)
{
	inputString=inputString.replace(/^\s+/g,"");
	inputString=inputString.replace(/\s+$/g,"");
	return inputString;
}

function isEmail (value)
{
	var theStr=value;
	var atIndex = theStr.indexOf('@');
	var dotIndex = theStr.indexOf('.', atIndex);
	var flag = true;
	theSub = theStr.substring(0, dotIndex+1)

	if ((atIndex < 1)||(atIndex != theStr.lastIndexOf('@'))||(dotIndex < atIndex + 2)||(theStr.length <= theSub.length))
	{
		//alert("Invalid E-mail ID");
		flag = false;
	}
	else
	{ 
		flag = true;
	}
	return(flag);
}

function confirm_form()
{
	var c_email=trim(document.confirm_form.email.value);	
	//var photo_status=trim(document.confirm_form.mthumnail.value);
	
	if(c_email!="")
	{
		if (!isEmail(c_email))
		{
		alert("E-mail is not correct");
		document.confirm_form.email.focus();
		return false;
		}
	}
	
		
}

function show_div(id)
  {
    if(id==1)
	 {
	  document.getElementById('correct_id').style.display="none";
	 }
	 else
	 {
	   document.getElementById('correct_id').style.display="block";
	 }
  }
///////////////////////BUSINESS FORM JAVA SCRIPT//////////////////////////////////////////

function businessform()
{
	var c_email=trim(document.businessform.email.value);	
	var photo_status=trim(document.businessform.mthumnail.value);
	alert('dfasdfs');
	return false;
	if(document.businessform.name.value=="")
	{
		alert("Name should not be blank!.");
		document.businessform.name.focus();
		return false
	}
	//======== Check user Password should not be blank ======
	if(c_email=="")
	{
		alert("Email should not be blank!.");
		document.businessform.email.focus();
		return false
	}
	
	
	if(c_email!="")
	{
		if (!isEmail(c_email))
		{
		alert("E-mail is not correct");
		document.businessform.email.focus();
		return false;
		}
	}
	
	if(photo_status!="")
	{
		var str=document.businessform.mthumnail.value;
		var ss;
		ss=1 + str.lastIndexOf(".");
		 var ext =str.substr(ss);
		ext=ext.toLowerCase();
		if (!(ext == "gif" || ext == "jpg" || ext == "jpeg"))
		 {
			alert("You can only upload .gif or .jpg image.");
			document.businessform.mthumnail.value="";
			document.businessform.mthumnail.focus();
			return false;
		 }
	}
	
}
/////////////////NEW REGISTRATION///////////////////////////////////////////////

function newuserform()
{
	
	
	
	var userName	=trim(document.new_form.new_username.value);
	var Password	=trim(document.new_form.new_password.value);
	
	//=== Check user name should not be blank ================
	if(userName=="")
	{
		alert("User name should not be blank!.");
		document.new_form.new_username.focus();
		return false
	}
	//======== Check user Password should not be blank ======
	if(Password=="")
	{
		alert("Password should not be blank!.");
		document.new_form.new_password.focus();
		return false
	}
	//alert(document.frmadmin.password.value.length)
	if(document.new_form.new_password.value.length <=4)
	{
		alert("Password length should not be less then 5 !.");
		document.new_form.new_password.focus();
		return false
	}
	
}
////////////////////////////LOGIN SECTION JAVA SCRIPT////////////////////////////////

function infovalidate()
{
	var userName	=trim(document.frmadmin.username.value);
	var Password	=trim(document.frmadmin.password.value);
	
	//=== Check user name should not be blank ================
	//alert(userName);
	if(userName=="" || userName=="USERNAME")
	{
		alert("User name should not be blank!.");
		document.frmadmin.username.focus();
		return false
	}
	//======== Check user Password should not be blank ======
	if(Password=="" || Password=="PASSWORD")
	{
		alert("Password should not be blank!.");
		document.frmadmin.password.focus();
		return false
	}
	
}
function element_empty(element)
	   {
			if(element.name=="username")
			{
				if(element.value==" USERNAME")
					{			
						element.value='';
					}
					
	       }
		   if(element.name=="password")
			{
				if(element.value==" PASSWORD")
					{			
						element.value='';
					}
					
	       }								
		}
	function element_fill_empty(element)
		{
		  if(element.name=="username")
			{	
				if(element.value=="")
					{			
						element.value=' USERNAME';
					}
		    }
		if(element.name=="password")
			{	
				if(element.value=="")
					{			
						element.value=' PASSWORD';
					}
		    }
		}	

