function trimAll( strValue ) {
/************************************************
DESCRIPTION: Removes leading and trailing spaces.

PARAMETERS: Source string from which spaces will
  be removed;

RETURNS: Source string with whitespaces removed.
*************************************************/ 
 var objRegExp = /^(\s*)$/;

    //check for all spaces
    if(objRegExp.test(strValue)) {
       strValue = strValue.replace(objRegExp, '');
       if( strValue.length == 0)
          return strValue;
    }
    
   //check for leading & trailing spaces
   objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
   if(objRegExp.test(strValue)) {
       //remove leading and trailing whitespace characters
       strValue = strValue.replace(objRegExp, '$2');
    }
  return strValue;
}
/********page1 validation starts*********/
function registration_validation1()
{
	with(document.registration_form)
	{
	if(!(users[0].checked)&&!(users[1].checked)&&!(users[2].checked))
		{
			alert("Please Choose the User Type");
			return false;
		}
}
//document.getElementById("step1").style.display="none";
//document.getElementById("step2").style.display="";
//document.getElementById("step3").style.display="none";
return true;
}

/* Form 2 validations */

function registration_validationpass()
{
	with(document.registration_form)
	{
		if(trimAll(txt_firstname.value)=="")
			{
				alert("Please Enter Your First name !");
					txt_firstname.focus(); return false;
			}
		else	if(trimAll(txt_lastname.value)=="")
			{
				alert("Please Enter Your Last name !");
					txt_lastname.focus(); return false;
			}
		else	if(trimAll(txtemail.value)=="")
			{
				alert("Please Enter Email Address!");
				txtemail.focus(); return false;
			}
		else if(!(validateEmail(trimAll(txtemail.value))))
			{
				alert("Please Enter valid Email Address!");
				txtemail.select();
				txtemail.focus(); return false;
			}
		else if(txtpassword.value=="")
			{
				alert("Please Enter Password!");
				txtpassword.select();
				txtpassword.focus(); return false;
			}
		else  if(txtpassword.value!="")
			{
				s=txtpassword.value;
				if(s.length<=5)
				{
					alert("Password should be minimum 6 characters!");
					txtpassword.focus();
					txtpassword.select();
					return false;
				}
			}
		if(txtconfirmpassword.value=="")
			{
				alert("Please confirm the entered password!");
				txtconfirmpassword.select();
				txtconfirmpassword.focus(); return false;
			}
		else if (txtpassword.value!=txtconfirmpassword.value)
	   	   {
				alert("Password and Confirm Password does not match");
				txtconfirmpassword.select();
				txtconfirmpassword.focus();
				return false;
			}
			else if(trimAll(txtaddress.value)=="")
	   	   {
				alert("Please enter your address");
			     txtaddress.focus();
				return false;
			}	
			else if(trimAll(txtcity.value)=="")
	   	   {
				alert("Please enter city");
			     txtcity.focus();
				return false;
			}	
			else if(trimAll(txtstate.value)=="")
	   	   {
				alert("Please enter state ");
			     txtstate.focus();
				return false;
			}	
			else if(trimAll(txtzipcode.value)=="")
	   	   {
				alert("Please enter zipcode ");
			     txtzipcode.focus();
				return false;
			}	
			else if(trimAll(txtcountry.value)=="")
	   	   {
				alert("Please select country ");
			     txtcountry.focus();
				 return false;
			}	
			else if(trimAll(txtupgrade_month.value)=="")
	   	   {
				 alert("Please select month ");
			     txtupgrade_month.focus();
				 return false;
			}	
			else	if(txtagree.checked=="")
			{
			  alert("To complete Clipsid registration you have to agree the terms !");
			  return false;
			}

			flag =1;
		
}

return true;
}

/********page3 validation starts*********/

function registration_validationpay()
{
	with(document.registration_form)
	{
		if(crd_type.selectedIndex==0)
			{
				alert("Please Choose your Card Type!")
				crd_type.focus();
				return false
			}  
		else if(txtbilling_cardno.value=="")
			{
				alert("Please Enter Card No!");
				txtbilling_cardno.focus(); return false;
			}
		else if(crd_secure_no.value=="")
			{
				alert("Please Enter Card Security No!");
				crd_secure_no.focus(); return false;
			}
		else if(name_of_card.value=="")
			{
				alert("Please Enter Name as on the Card!");
				name_of_card.focus(); return false;
			}
		else if(txtbilling_month.value=="")
			{
				alert("Please Select Month!");
				txtbilling_month.focus(); return false;
			}
		 else if(txtbilling_year.value=="")
			{
			alert("Please Select Year!");
			txtbilling_year.focus(); return false;
			}
		 else if(txtbilling_firstname.value=="")
			{
			alert("Please Enter First Name!");
			txtbilling_firstname.focus(); return false;
			}
		 else if(txtbilling_lastname.value=="")
			{
			alert("Please Enter Last Name!");
			txtbilling_lastname.focus(); return false;
			}
		  else if(txtbilling_address1.value=="")
			{
			alert("Please Enter Address1!");
			txtbilling_address1.focus(); return false;
			}
		  else if(txtbillling_city.value=="")
			{
			alert("Please Enter City!");
			txtbillling_city.focus(); return false;
			}
		 else if(txtbillling_state.value=="")
			{
			alert("Please Enter State!");
			txtbillling_state.focus(); return false;
			}
		  else if(txtbillling_zipcode.value=="")
			{
			alert("Please Enter Zipcode!");
			txtbillling_zipcode.focus(); return false;
			}
		 else if(txtbilling_country.value=="")
			{
			alert("Please Select Country!");
			txtbilling_country.focus(); return false;
			}
//	   txtstepmode.value="step6";
	}
document.getElementById("step1").style.display="none";
document.getElementById("step2").style.display="none";
document.getElementById("step3").style.display="none";
document.getElementById("step4").style.display="none";
return true;
}


/**********RESET BUTTON VALIDATION********* START *****/

function reset_button1()
{
	with(document.registration_form)
	{
		txtfirstname.value="";
		txtlastname.value="";
		txtgender.value="";
		txtage.value="";
	}
return true;
}

/**********RESET BUTTON VALIDATION********* END *****/

/**********RESET BUTTON2 VALIDATION********* START *****/

function reset_button2()
{
	with(document.registration_form)
	{
		txtaddress1.value="";
		txtaddress2.value="";
		txtcity.value="";
		txtstate.value="";
		txtzipcode.value="";
		txtphonenumber.value="";

	}
return true;
}

/**********RESET BUTTON2 VALIDATION********* END *****/


/**********RESET BUTTON6 VALIDATION********* START *****/

function reset_button6()
{
	with(document.registration_form)
	{
	txtbilling_cardno.value="";
	txtbilling_month.value="";
	txtbilling_year.value="";
	txtbilling_firstname.value="";
	txtbilling_lastname.value="";
	txtbilling_address1.value="";
	txtbillling_address2.value="";
	txtbillling_city.value="";
	txtbillling_state.value="";
	txtbillling_zipcode.value="";
	txtbilling_phonenumber.value="";
	txtbilling_country.value="";
	}
	$status = "customers";
}
/**********RESET BUTTON6 VALIDATION********* END *****/


function validateEmail( strValue) 
	{
				var objRegExp  = /^[a-z0-9]([a-z0-9_\-\.]*)@([a-z0-9_\-\.]*)(\.[a-z]{2,3}(\.[a-z]{2}){0,2})$/i;
				return objRegExp.test(strValue);
	}

function display_photo()
	{
				document.image.src=document.registration_form.txtphoto.value;
				document.registration_form.txtcurrentphoto.value=document.registration_form.txtphoto.value;
	}
function show_help(h_id)
	{
		if(document.getElementById(h_id).style.display=="none")
			{		
				document.getElementById(h_id).style.display="";				
			}
			else
			{
				document.getElementById(h_id).style.display="none";				
			}
	}