
function numchar(str, x)
{
 var count;
 count=0;
   for(i=0; i<=(str.length -1); i++)
     {
       if (str.charAt(i)==x)
       {
         count++;
       }
      }
        return count;
}

 
 
 
function message_validate(f)
{
   if (f.message.value=="Type your message here"  )
    { 
     f.message.value="";
     }
}
 
function emailOK()
{
 	if ( (document.getElementById("email").value.length<5) || (numchar(document.getElementById("email").value," ") >0) || (numchar(document.getElementById("email").value, "@")!=1)||(numchar(document.getElementById("email").value, ".")==0) )
   	{
     		return true;   //wrong email address
  	} else 
     	{ 
      		 return false;
      	}
}

function submit_form()
 { 
	missinginfo ="";

if (document.getElementById("lname").value.length<2)
   {
    missinginfo += "\n Enter your Last name";
    }

if (document.getElementById("fname").value.length<2)
   {
    missinginfo += "\n Enter your First name";
    }    

 if ( (document.getElementById("new_email").value.length<5) || (numchar(document.getElementById("new_email").value," ") >0) || (numchar(document.getElementById("new_email").value, "@")!=1)||(numchar(document.getElementById("new_email").value, ".")==0) )
   {
      missinginfo +="\n Wrong Email address";
  } 

if(document.getElementById("password1").value.length<5 )
   {
     missinginfo += "\n Login Password must be 6 - 10 letters";
    
   }

if(document.getElementById("password1").value.length!=document.getElementById("password2").value.length)
   {
     missinginfo += "\n Password and Repeated passwords must be the same";
   }

if ((!document.getElementById("credit").checked) && (!document.getElementById("paypal").checked))
   {
     missinginfo += "\n You have to choose subscription";
   }

if(!document.getElementById("accept").checked)
   {
     missinginfo += "\n You have to accept our terms and conditions";
   }
     
if (missinginfo != "") {
missinginfo ="_____________________________\n" +
"You failed to correctly fill in your:\n" +
missinginfo + "\n_____________________________" +
"\nPlease re-enter and submit again!";
alert(missinginfo);
return false;
}
else
{
 return true;
} 

       
} 
 
     
 

function submit_form2()
{
  missinginfo = "";

  if (emailOK())
  {
	
	 missinginfo += "\n   -  Wrong email address. Please specify email";

  }

   if(document.getElementById("password").value.length<5 )
   {
     missinginfo += "\n   -  Login Password must be 5 - 10";
    
   }


   
if (missinginfo != "") {
missinginfo ="_____________________________\n" +
"You failed to correctly fill in your:\n" +
missinginfo + "\n_____________________________" +
"\nPlease re-enter and submit again!";
alert(missinginfo);
return false;
}
else
{
 return true;
} 
   
   
} 

