function  submitApplyPendingCharges(thisForm)
{
	
	var todayDate = new Date();
   var currentMonth = todayDate.getMonth();
   var currentYear = todayDate.getYear(); 
   currentMonth = currentMonth + 1;
   var currentYear1 = new String(currentYear);
   currentYear1 = currentYear1.substring(2);
   thisForm.zip.value = trim(thisForm.zip.value); 

	if (isBlank(thisForm.cardtype.value))
	   {
		  alert('Select the credit card type.');
		  thisForm.cardtype.focus();
		  return (false);
	   }

     else if(isBlank(thisForm.cardnumber.value))
	   {
		  alert('Enter the credit card number.');
		  thisForm.cardnumber.focus();
		  return (false);
	   }
       //else if (invalidNumber(thisForm.cardnumber.value) )
       //{
           //alert('The credit card number must be numeric within the range 0-9');
           //thisForm.cardnumber.focus();
           //return (false);
       //}
	   //else if (thisForm.cardnumber.value.length < 14 || thisForm.cardnumber.value.length > 16)
	   //{
			//alert("The card number accepts only 14 -16 digits.");
			//thisForm.cardnumber.focus();
			//return (false);
	   //}
	   
	   else if(isBlank(thisForm.month.value))
	   {
		  alert('Enter the expiry month for the credit card.');
		  thisForm.month.focus();
		  return (false);
	   }
	   else if(invalidNumber(thisForm.month.value))
	   {
	 	  alert('Enter a valid expiry month for the credit card.');
		  thisForm.month.focus();
		  return (false);
	   }
	   else if( (thisForm.month.value < 1) || (thisForm.month.value > 12) )
       {
          alert('Enter a valid expiry month for the credit card.');
          thisForm.month.focus();
          return(false);
       }

	  else if(isBlank(thisForm.year.value))
	   {
		  alert('Enter a valid expiry year for the credit card.');
		  thisForm.year.focus();
		  return (false);
	   }

	   else if(invalidNumber(thisForm.year.value))
	   {
		  alert('Enter a valid expiry year for the credit card.');
		  thisForm.year.focus();
		  return (false);
	   }
	   
	   else if((thisForm.year.value) < (parseInt(currentYear1,10)) )
	   {
			alert('Enter a valid expiry year for the credit card.');
			thisForm.year.focus();
			return(false);
	   }


	   else if( ( (thisForm.year.value) ==(parseInt(currentYear1,10)) ) && ( (thisForm.month.value) < (parseInt(currentMonth,10))  ) )
	   {
			  alert('Enter a valid expiry date for the credit card.');
			  thisForm.month.focus();
    		  return (false);
	   } 	
           
      else  if(isBlank(thisForm.billingaddress.value))
	   {
		  alert('Enter a valid billing address.');
		  thisForm.billingaddress.focus();
		  return (false);
	   }
	   else if(inValidAddress(thisForm.billingaddress.value))
	   {
		  alert('Address cannot contain single quotes, double quotes and backward slash.');
		  thisForm.billingaddress.focus();
		  return (false);
	   }
      
	if(isBlank(thisForm.zip.value))
	{
			alert('Enter a valid zip code.');
			thisForm.zip.focus();
			return (false);
	}
	else if(inValidZip(thisForm.zip.value))
	{
			alert('Zip code can contain only characters A - Z, a - z, 0 - 9, -, _ and blank space.') ;
			thisForm.zip.focus();
			return (false);
	}else
	{
	
		thisForm.action = "/ibprof/servlet/IBPPendChargesServlet";
	    thisForm.method = "post";
	    thisForm.submit();
	}
}

function populateUserName(thisForm,check)
{

 var fname = thisForm.first_name.value;
 var lname = thisForm.last_name.value;
 var firname = '';
 var lasname = '' ;
 var ch;
 var userallowed = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

 
     //alert('check1'+thisForm.check1.value);

    if( (check==1) && (thisForm.check1.value=='') )
	{
          
             if((fname!='') && (lname!=''))
		     {

						  thisForm.user_id.value = ' ';
						  
						  for (var loop = 0;loop<fname.length ; loop++)
						  {
							  ch = fname.charAt(loop);
							  if(userallowed.indexOf(ch)!= -1)
							  {  firname = firname + ch; }

						  }

                          if(firname=='' || firname!='')
                          {fname = firname;}						  
							  
						  for (var loop = 0;loop<lname.length ; loop++)
						  {
							  ch = lname.charAt(loop);
							  if(userallowed.indexOf(ch)!= -1)
							  { lasname = lasname + ch; }
						  }

						  if(lasname=='' || lasname!='')
				          {lname = lasname;}
							 
						 

						 fname = fname.toLowerCase();
						 lname = lname.toLowerCase();

						  if(fname.length > 10)
						 {
							  fname = fname.substring(0,10).toLowerCase();
						 }

						 if(lname.length >=10)
						 {
							  lname = lname.substring(0,9).toLowerCase();
						 }

						 if(fname=='' && lname=='')
				         { thisForm.user_id.value = ''; }
						 else
				         {thisForm.user_id.value = fname + "_" + lname;
				          }
						 thisForm.user_id.select();
				
			 }	 

	}// end of check==1
	else if( (check == 2) && (thisForm.check1.value == 1) )
	{
       thisForm.user_id.value = thisForm.user_id.value;
	   thisForm.check1.value = 1;
	   thisForm.user_id.select();

	}
   
}




function setState(thisForm)
{
	if(thisForm.country.value != 'United States of America')
	{
		  thisForm.state.value = "Others";
		  thisForm.state.disabled = true;
	}
	else
	{
		  thisForm.state.value = "Choose a state";
		  thisForm.state.disabled = false;
	}
}




//For Registration process
function confirmSubmit(thisForm)
{




   var i = 0; 
    var radioChecked = 0; 
	for(i=0; i<thisForm.plan_type.length; i++)
	{
           if(thisForm.plan_type[i].checked == true)
		{
			   //alert('checked');
		       radioChecked = 1; 
		}
 
	}
   
   var todayDate = new Date();
   var currentMonth = todayDate.getMonth();
   var currentYear = todayDate.getYear(); 
   currentMonth = currentMonth + 1;
   var currentYear1 = new String(currentYear);
  
   var agt=navigator.userAgent.toLowerCase();

	if (agt.indexOf("msie") != -1){
   currentYear1 = currentYear1.substring(2);
	}else{
	currentYear1 = currentYear1.substring(1);
	}

   
   
  // currentYear1 = currentYear1.substring(2);

     thisForm.zip.value = trim(thisForm.zip.value);
   if (thisForm.first_name.value =='')
   {
	  alert('Enter your first name.');
	  thisForm.first_name.focus();
	  return (false);
   }
   else if (invalidName(thisForm.first_name.value))
   {
	  alert('First name can contain only characters A-Z, a-z and blank space.');
      thisForm.first_name.focus();
	  return (false);
   }
   else if (thisForm.last_name.value == '')
   {
	  alert('Enter your last name.');
	  thisForm.last_name.focus();
	  return (false);
   }
   else if (invalidName(thisForm.last_name.value))
   {
	  alert('Last name can contain only characters A-Z, a-z and blank space.');
	  thisForm.last_name.focus();
	  return (false);
   }
   else if(thisForm.user_id.value =='')
   {  alert('Enter your Username.');
    thisForm.user_id.focus();
	return (false);
   }
    else if( (thisForm.user_id.value.length < 4) || (thisForm.user_id.value.length > 20))
   {
        alert('Username must be between 4 to 20 characters.');
        thisForm.user_id.focus();
        return(false);
   }
   else if(invalidUserName(thisForm.user_id.value))
   {  
	   thisForm.user_id.value = thisForm.user_id.value;
	   thisForm.check1.value = 1;
       populateUserName(thisForm,'2'); 
	   alert('Username can contain only characters a-z, 0-9 and _ (Underscore).');
      // thisForm.user_id.focus();
	   return (false);
   }
    if(isBlank(thisForm.user_passwd.value))
   {  alert('Enter your Password.');
      thisForm.user_passwd.focus();
	  return (false);
   }
   else if (inValidString(thisForm.user_passwd.value))
   {
       alert('Password can contain only characters A-Z, a-z, and 0-9.')
       thisForm.user_passwd.focus();
       return (false);
   }
   else if( (thisForm.user_passwd.value.length < 4) || (thisForm.user_passwd.value.length > 16))
   {
        alert('Password must contain 4 - 16 characters.');
        thisForm.user_passwd.focus();
        return(false);
   }
   /*
   else if (!containsNumeric(thisForm.user_passwd.value))
   {
       alert('The password should contain at least 1 numeric character.')
       thisForm.user_passwd.focus();
       return (false);
   }
   */
   else if(thisForm.user_id.value == thisForm.user_passwd.value)
   {
      alert('Password and Username must be different.');
      thisForm.user_passwd.focus();
      return (false);
   }
   else if(isBlank(thisForm.user_passwd2.value))
   {  alert('Confirm your Password.');
      thisForm.user_passwd2.focus();
	  return (false);
   }
   else if(thisForm.user_passwd2.value != thisForm.user_passwd.value)
   {  alert("Confirm Password must be the same as Password.");
      thisForm.user_passwd2.focus();
     return (false);
   }

   else if( (thisForm.rtype.value=='support')  && !isValidEmailId(thisForm.email.value))
   {
      alert('Enter a valid Email address.');
	  thisForm.email.focus();
	  return(false);
   }
   else if(isBlank(thisForm.phone.value))
   {
	   alert('Enter the phone number.');
	   thisForm.phone.focus();
	   return(false);
   }
   else if(invalidPhoneNumber(thisForm.phone.value))
   {
	   alert('The phone number can contain only characters 0-9, x, X, -, +.');
	   thisForm.phone.focus();
	   return(false);
   }
 
  
  
  else if (radioChecked == 0)
   {
	  
	  alert('Choose a plan.');
	  return (false);
   }
  
  else if(thisForm.textverify.value == '')
  {
       alert('Enter the verification text.');
	   thisForm.textverify.focus();
       return(false);
  }
// no credit card validations has to be done if cardnumber is 5555999944448888, to allow support to create free trial
// accounts without valid cc details

//|| thisForm.rtype.value != 'support'
if(thisForm.cardnumber.value != '5555999944448888')
	{
	  
	    if(isBlank(thisForm.cardtype.value) )
	   {
		  alert('Select the credit card type.');
		  thisForm.cardtype.focus();
		  return (false);
	   }
	   else if(isBlank(thisForm.cardnumber.value))
	   {
		  alert('Enter the credit card number.');
		  thisForm.cardnumber.focus();
		  return (false);
	   }
       else if (invalidNumber(trim(thisForm.cardnumber.value)) )
       {
           alert('The credit card number can contain only numerals 0-9.');
           thisForm.cardnumber.focus();
           return (false);
       }
	   else if (trim(thisForm.cardnumber.value).length < 14 || trim(thisForm.cardnumber.value).length > 16)
	   {
			alert("The card number can contain only 14 -16 digits.");
			thisForm.cardnumber.focus();
			return (false);
	   }
	   else if(isBlank(thisForm.cvv.value))
	   {
		  alert('Enter the CVV number.');
		  thisForm.cvv.focus();
		  return (false);
	   }
	   else if(invalidNumber(thisForm.cvv.value))
	   {
		  alert('CVV can contain only digits 0-9.');
		  thisForm.cvv.focus();
		  return (false);
	   }
	   else if(isBlank(thisForm.month.value))
	   {
		  alert('Enter the expiry month for the credit card.');
		  thisForm.month.focus();
		  return (false);
	   }
	   else if(invalidNumber(thisForm.month.value))
	   {
	 	  alert('Enter a valid expiry month for the credit card.');
		  thisForm.month.focus();
		  return (false);
	   }
	   else if( (thisForm.month.value < 1) || (thisForm.month.value > 12) )
       {
          alert('Enter a valid expiry month for the credit card.');
          thisForm.month.focus();
          return(false);
       }

	  else if(isBlank(thisForm.year.value))
	   {
		  alert('Enter a valid expiry year for the credit card.');
		  thisForm.year.focus();
		  return (false);
	   }

	   else if(invalidNumber(thisForm.year.value))
	   {
		  alert('Enter a valid expiry year for the credit card.');
		  thisForm.year.focus();
		  return (false);
	   }
	   
	   else if((thisForm.year.value) < (parseInt(currentYear1,10)) )
	   {
			alert('Enter a valid expiry year for the credit card.');
			thisForm.year.focus();
			return(false);
	   }


	   else if( ( (thisForm.year.value) ==(parseInt(currentYear1,10)) ) && ( (thisForm.month.value) < (parseInt(currentMonth,10))  ) )
	   {
			  alert('Enter a valid expiry date for the credit card.');
			  thisForm.month.focus();
    		  return (false);
	   } 	
           
      else  if(isBlank(thisForm.address.value))
	   {
		  alert('Enter a valid billing address.');
		  thisForm.address.focus();
		  return (false);
	   }
	   else if(inValidAddress(thisForm.address.value))
	   {
          alert('Address cannot contain single quotes, double quotes and backward slash.');
		  thisForm.address.focus();
		  return (false);
	   }
	  else if(isBlank(thisForm.zip.value))
	   {
		  alert('Enter a valid zip code.');
		  thisForm.zip.focus();
		  return (false);
	   }
	   else if(inValidZip(thisForm.zip.value))
	   {
			       alert('Zip code can contain only characters A - Z, a - z, 0 - 9, -, _ and blank space.') ;
			thisForm.zip.focus();
			return (false);
	   } 
	   else
		{
		   thisForm.cardnumber.value=trim(thisForm.cardnumber.value);
           return true;
		}
	}
   else
   { 
     return true;
   }
}

function submitUpgradePlan(thisForm)
{

	 var i = 0; 
    var radioChecked = 0; 
	for(i=0; i<thisForm.plan_type.length; i++)
	{
           if(thisForm.plan_type[i].checked == true)
		{
			   //alert('checked');
		       radioChecked = 1; 
		}
 
	}

   var todayDate = new Date();
   var currentMonth = todayDate.getMonth();
   var currentYear = todayDate.getYear(); 
   currentMonth = currentMonth + 1;
   var currentYear1 = new String(currentYear);
  // currentYear1 = currentYear1.substring(2);

   var agt=navigator.userAgent.toLowerCase();

	if (agt.indexOf("msie") != -1){
   currentYear1 = currentYear1.substring(2);
	}else{
	currentYear1 = currentYear1.substring(1);
	}

	  thisForm.zip.value = trim(thisForm.zip.value);

  if (radioChecked == 0)
   {	  
	  alert('Choose a plan.');
	  return (false);
   }

/*  if(thisForm.plan_type.value == '')
	{
	   alert('Choose a plan.');
	   thisForm.plan_type.focus();
	   return(false);
	}*/
   else if (isBlank(thisForm.cardtype.value))
   {
	  alert('Select the credit card type.');
	  thisForm.cardtype.focus();
	  return (false);
   }

   if(isBlank(thisForm.cardnumber.value))
	   {
		  alert('Enter the credit card number.');
		  thisForm.cardnumber.focus();
		  return (false);
	   }
       //else if (invalidNumber(thisForm.cardnumber.value) )
       //{
           //alert('The credit card number must be numeric within the range 0-9');
           //thisForm.cardnumber.focus();
           //return (false);
       //}
	   //else if (thisForm.cardnumber.value.length < 14 || thisForm.cardnumber.value.length > 16)
	   //{
			//alert("The card number accepts only 14 -16 digits.");
			//thisForm.cardnumber.focus();
			//return (false);
	   //}
	   else if(isBlank(thisForm.cvv.value))
	   {
		  alert('Enter the CVV number.');
		  thisForm.cvv.focus();
		  return (false);
	   }
	   else if(invalidNumber(thisForm.cvv.value))
	   {
		  alert('CVV can contain only digits 0-9.');
		  thisForm.cvv.focus();
		  return (false);
	   }
	   else if(isBlank(thisForm.month.value))
	   {
		  alert('Enter the expiry month for the credit card.');
		  thisForm.month.focus();
		  return (false);
	   }
	   else if(invalidNumber(thisForm.month.value))
	   {
	 	  alert('Enter a valid expiry month for the credit card.');
		  thisForm.month.focus();
		  return (false);
	   }
	   else if( (thisForm.month.value < 1) || (thisForm.month.value > 12) )
       {
          alert('Enter a valid expiry month for the credit card.');
          thisForm.month.focus();
          return(false);
       }

	  else if(isBlank(thisForm.year.value))
	   {
		  alert('Enter a valid expiry year for the credit card.');
		  thisForm.year.focus();
		  return (false);
	   }

	   else if(invalidNumber(thisForm.year.value))
	   {
		  alert('Enter a valid expiry year for the credit card.');
		  thisForm.year.focus();
		  return (false);
	   }
	   
	   else if((thisForm.year.value) < (parseInt(currentYear1,10)) )
	   {
			alert('Enter a valid expiry year for the credit card.');
			thisForm.year.focus();
			return(false);
	   }


	   else if( ( (thisForm.year.value) ==(parseInt(currentYear1,10)) ) && ( (thisForm.month.value) < (parseInt(currentMonth,10))  ) )
	   {
			  alert('Enter a valid expiry date for the credit card.');
			  thisForm.month.focus();
    		  return (false);
	   } 	
           
      else  if(isBlank(thisForm.billingaddress.value))
	   {
		  alert('Enter a valid billing address.');
		  thisForm.billingaddress.focus();
		  return (false);
	   }
	   else if(inValidAddress(thisForm.billingaddress.value))
	   {
		  alert('Address cannot contain single quotes, double quotes and backward slash.');
		  thisForm.billingaddress.focus();
		  return (false);
	   }
	
	  else if(isBlank(thisForm.zip.value))
	   {
		  alert('Enter a valid zip code.');
		  thisForm.zip.focus();
		  return (false);
	   }
	   else if(inValidZip(thisForm.zip.value))
	   {
			alert('Zip code can contain only characters A - Z, a - z, 0 - 9, -, _ and blank space.') ;
			thisForm.zip.focus();
			return (false);
	   }
	   else
	   { 
		    thisForm.cardnumber.value=trim( thisForm.cardnumber.value);
		   return true;
	   }
}



//For Edit profile process
function editprofileSubmit(thisForm)
{
     

     if (thisForm.firstname.value =='')
     {
		 alert('Enter your first name.');
		 thisForm.firstname.focus();
		 return (false);
     }
     else if (invalidName(thisForm.firstname.value))
     {
		alert('First name can contain only characters A-Z, a-z and blank space.');
		thisForm.firstname.focus();
		return (false);
     }
     else if (thisForm.lastname.value == '')
     {
		alert('Enter your last name.');
		thisForm.lastname.focus();
		return (false);
     }
     else if (invalidName(thisForm.lastname.value))
     {
		alert('Last name can contain only characters A-Z, a-z and blank space.');
		thisForm.lastname.focus();
		return (false);
     }


    else if(!isBlank(thisForm.password.value))
     {
		 if (inValidString(thisForm.password.value))
		 {
			 alert('Password can contain only characters A-Z, a-z, and 0-9.')
			 thisForm.password.focus();
			 return (false);
		 }
		 else if( (thisForm.password.value.length < 4) || (thisForm.password.value.length > 16))
		 {
			  alert('Password must contain 4 - 16 characters.');
		  
			  thisForm.password.focus();
			  return(false);
		 }
		 /*
		 else if (!containsNumeric(thisForm.password.value))
		 {
			 alert('Password should have atleast one numeric character (0-9)')
		  
			 thisForm.password.focus();
			 return (false);
		 }
		 */
		 else if(thisForm.password1.value != thisForm.password.value)
		 {  alert("Confirm Password must be the same as Password.");
			thisForm.password1.focus();
			return (false);
		 }

		 else if(!isValidEmailId(thisForm.email.value))
		 {
				alert('Enter a valid email address.');
				thisForm.email.focus();
				return(false);
		 }
		 else if(isBlank(thisForm.phone.value))
		 {
			   alert('Enter the phone number.');
			   thisForm.phone.focus();
			   return(false);
		}

		else if(invalidPhoneNumber(thisForm.phone.value))
		 {
			   alert('The phone number can contain only characters 0-9, x, X, -, +.');
			   thisForm.phone.focus();
			   return(false);
		}
		else
		{
		   return true;
		}
     }      
	 //the down will get execute when the password & confirm password is blank 
     else if(!isValidEmailId(thisForm.email.value))
     {
			alert('Enter a valid email address.');
			thisForm.email.focus();
			return(false);
     }
     else if(isBlank(thisForm.phone.value))
     {
     	   alert('Enter your phone number.');
	       thisForm.phone.focus();
	       return(false);
    }

	else if(invalidPhoneNumber(thisForm.phone.value))
     {
     	   alert('The phone number can contain only characters 0-9, x, X, -, +.');
	       thisForm.phone.focus();
	       return(false);
    }
    else
    {
       return true;
    }
}

//For Edit profile process
function editprofileSubmit_ajax(thisForm)
{
     
     //alert("11111111111111");
     if (thisForm.firstname.value =='')
     {
		 alert('Enter your first name.');
		 thisForm.firstname.focus();
		 return (false);
     }
     else if (invalidName(thisForm.firstname.value))
     {
		alert('First name can contain only characters A-Z, a-z and blank space.');
		thisForm.firstname.focus();
		return (false);
     }
     else if (thisForm.lastname.value == '')
     {
		alert('Enter your last name.');
		thisForm.lastname.focus();
		return (false);
     }
     else if (invalidName(thisForm.lastname.value))
     {
		alert('Last name can contain only characters A-Z, a-z and blank space.');
		thisForm.lastname.focus();
		return (false);
     }


    else if(!isBlank(thisForm.password.value))
     {
		 if (inValidString(thisForm.password.value))
		 {
			 alert('Password can contain only characters A-Z, a-z, and 0-9.')
			 thisForm.password.focus();
			 return (false);
		 }
		 else if( (thisForm.password.value.length < 4) || (thisForm.password.value.length > 16))
		 {
			  alert('Password must contain 4 - 16 characters.');
		  
			  thisForm.password.focus();
			  return(false);
		 }
		 /*
		 else if (!containsNumeric(thisForm.password.value))
		 {
			 alert('Password should have atleast one numeric character (0-9)')
		  
			 thisForm.password.focus();
			 return (false);
		 }
		 */
		 else if(thisForm.password1.value != thisForm.password.value)
		 {  alert("Confirm Password must be the same as Password.");
			thisForm.password1.focus();
			return (false);
		 }

		else if(!isValidEmailId(thisForm.email.value))
		 {
				alert('Enter a valid email address.');
				thisForm.email.focus();
				return(false);
		 }
		 else if(isBlank(thisForm.phone.value))
		 {
			   alert('Enter your phone number.');
			   thisForm.phone.focus();
			   return(false);
		}

		else if(invalidPhoneNumber(thisForm.phone.value))
		 {
			   alert('The phone number can contain only characters 0-9, x, X, -, +.');
			   thisForm.phone.focus();
			   return(false);
		}
		/**
		else
		{
		   return true;
		} */
		else
		{
			showLayer();
		 STREAMNET.editProfile.submitData();
		 return(false);
		}
     }      
	 //the down will get execute when the password & confirm password is blank 
     else if(!isBlank(thisForm.password1.value) && isBlank(thisForm.password.value))
		 {  
		    alert('Enter your Password.');
			thisForm.password.focus();
			return (false);
		 }
		 
		else if(!isValidEmailId(thisForm.email.value))
     {
			alert('Enter a valid email address.');
			thisForm.email.focus();
			return(false);
     }
     else if(isBlank(thisForm.phone.value))
     {
     	   alert('Enter your phone number.');
	       thisForm.phone.focus();
	       return(false);
    }

	else if(invalidPhoneNumber(thisForm.phone.value))
     {
     	   alert('The phone number can contain only characters 0-9, x, X, -, +.');
	       thisForm.phone.focus();
	       return(false);
    }
   /**
   else
    {
       return true;
    } */
	else
		{
		showLayer();
		 STREAMNET.editProfile.submitData();
		 return(false);
		}
}
	





function submitEditCC(thisForm)
{

   var todayDate = new Date();
   var currentMonth = todayDate.getMonth();
   var currentYear = todayDate.getYear(); 
   currentMonth = currentMonth + 1;
   var currentYear1 = new String(currentYear);
   currentYear1 = currentYear1.substring(2);
     thisForm.zip.value = trim(thisForm.zip.value);
	if (isBlank(thisForm.cardtype.value))
	   {
		  alert('Select the credit card type.');
		  thisForm.cardtype.focus();
		  return (false);
	   }

     else if(isBlank(thisForm.cardnumber.value))
	   {
		  alert('Enter the credit card number.');
		  thisForm.cardnumber.focus();
		  return (false);
	   }
       //else if (invalidNumber(thisForm.cardnumber.value) )
       //{
           //alert('The credit card number must be numeric within the range 0-9');
           //thisForm.cardnumber.focus();
           //return (false);
       //}
	   //else if (thisForm.cardnumber.value.length < 14 || thisForm.cardnumber.value.length > 16)
	   //{
			//alert("The card number accepts only 14 -16 digits.");
			//thisForm.cardnumber.focus();
			//return (false);
	   //}
	   
	   else if(isBlank(thisForm.month.value))
	   {
		  alert('Enter the expiry month for the credit card.');
		  thisForm.month.focus();
		  return (false);
	   }
	   else if(invalidNumber(thisForm.month.value))
	   {
	 	  alert('Enter a valid expiry month for the credit card.');
		  thisForm.month.focus();
		  return (false);
	   }
	   else if( (thisForm.month.value < 1) || (thisForm.month.value > 12) )
       {
          alert('Enter a valid expiry month for the credit card.');
          thisForm.month.focus();
          return(false);
       }

	  else if(isBlank(thisForm.year.value))
	   {
		  alert('Enter a valid expiry year for the credit card.');
		  thisForm.year.focus();
		  return (false);
	   }

	   else if(invalidNumber(thisForm.year.value))
	   {
		  alert('Enter a valid expiry year for the credit card.');
		  thisForm.year.focus();
		  return (false);
	   }
	   
	   else if((thisForm.year.value) < (parseInt(currentYear1,10)) )
	   {
			alert('Enter a valid expiry year for the credit card.');
			thisForm.year.focus();
			return(false);
	   }


	   else if( ( (thisForm.year.value) ==(parseInt(currentYear1,10)) ) && ( (thisForm.month.value) < (parseInt(currentMonth,10))  ) )
	   {
			  alert('Enter a valid expiry date for the credit card.');
			  thisForm.month.focus();
    		  return (false);
	   } 	
           
      else  if(isBlank(thisForm.billingaddress.value))
	   {
		  alert('Enter a valid billing address.');
		  thisForm.billingaddress.focus();
		  return (false);
	   }
	   else if(inValidAddress(thisForm.billingaddress.value))
	   {
		  alert('Address cannot contain single quotes, double quotes and backward slash.');
		  thisForm.billingaddress.focus();
		  return (false);
	   }
      
	if(isBlank(thisForm.zip.value))
	{
			alert('Enter a valid zip code.');
			thisForm.zip.focus();
			return (false);
	}
	else if(inValidZip(thisForm.zip.value))
	{
			alert('Zip code can contain only characters A - Z, a - z, 0 - 9, -, _ and blank space.') ;
			thisForm.zip.focus();
			return (false);
	}
	else
	 {
            // thisForm.action="/ibprof/servlet/IBPEditCCServlet";
			//thisForm.method="post";
			//thisForm.submit();
			return (true);
	 }
	 
}


// for default focus
function focusEmail(thisForm) 
{ 	
   thisForm.email.focus();	
}

//For Feedback Form
function confirmFeedback(thisForm) 
{ 
   if(thisForm.validateEmail.value!='true')
	{

   
   //if(!isValidEmailId(thisForm.email.value) && thisForm.invEmail.value != "true" && thisForm.validateEmail.value != "true")
   if(!isValidEmailId(trim(thisForm.email.value)))
   {
      
	  alert('Enter a valid email address.');
      thisForm.email.focus();
      return(false);
   } 
   else if(thisForm.user_id.value!='' && invalidUserName(trim(thisForm.user_id.value))) 
	{
	   alert("Username can contain only characters a-z, 0-9 and _ (Underscore).");
	   thisForm.user_id.focus();
	   return false;

	}
  else if((thisForm.invUser.value=="too") && isBlank(trim(thisForm.user_id.value))) 
   {  
	  alert("Enter the Username associated with this IBackup Professional account to identify it.");
      thisForm.user_id.focus();
	  return false; 
   } 
  else if((thisForm.invUser.value=="too") && (invalidUserName(trim(thisForm.user_id.value))))
   {
	  alert('Username can contain only characters a-z, 0-9 and _ (Underscore).');
      thisForm.user_id.focus();
	  return false;
   }
   else if( (thisForm.phone.value!='') && (invalidSecurityPhNum(thisForm.phone.value)))
   {
	   thisForm.phone.focus();
	   alert('The phone number can contain only characters 0-9, x, X, -, +, ( ).');
	   return(false);
   }
   
  else if((thisForm.os.value=='choose'))
   {
     alert('Select the Operating System.');
     //thisForm.os_others.focus();
     thisForm.os.focus();
     return (false);   
   }
   else if((thisForm.os.value=='Others') && (thisForm.os_others.value==''))
   {
     alert('Specify the Operating System.');
     //thisForm.os_others.focus();
     thisForm.os_others.focus();
     return (false);   
   }
   else if( (thisForm.issue.value=='') || (thisForm.issue.value=='choose') )
	{
	   alert('Choose your Issue.');
	   thisForm.issue.focus();
	   return (false);   
	}
	else if( (thisForm.issue.value=='Others') && (thisForm.otherinfo.value=='') )
	{
	   thisForm.otherinfo.focus();
	   alert('Enter your problem/query/comments.');
	   return (false);   
	}

	if(thisForm.invEmail.value=="true")
	{
	   STREAMNET.prof.emailVerifySyn(thisForm);
	   return(false);
	}

    
    { 
		thisForm.user_id.value = checkAndReplace(thisForm.user_id.value);
		thisForm.phone.value = checkAndReplace(thisForm.phone.value);
		thisForm.email.value = checkAndReplace(thisForm.email.value);
		thisForm.os_others.value = checkAndReplace(thisForm.os_others.value);
		thisForm.otherinfo.value = checkAndReplace(thisForm.otherinfo.value);
		return true ;
    }
	}
	else
	{
		return false;
	}
	
}


//For Cancellation process
function confirmCancel(thisForm)
{

   if(isBlank(thisForm.username.value))
   {
      alert('Enter Username or email address.');
      thisForm.username.focus();
      return (false);
   }

   if(thisForm.username.value.indexOf('@')!=-1)
	{
       if(!isValidEmailId(thisForm.username.value))
		{
		   alert('Enter a valid email address.');
 		   thisForm.username.focus();
	       return (false);

		}
	}

	if(thisForm.username.value.indexOf('@')==-1)
	{
		if(invalidUserName(thisForm.username.value))
		{
			alert('Enter a valid Username.');
			thisForm.username.focus();
	        return (false);
		}

	}
   if(isBlank(thisForm.password.value))
   {
     // alert('Enter the password used to sign up for the partner program with IBackup Professional.');
	 alert('Enter the password.');
      thisForm.password.focus();
      return (false);
   }
   else if (inValidString(thisForm.password.value))
   {
       alert('Password can contain only characters A-Z, a-z, and 0-9.')
       thisForm.password.focus();
       return (false);
   }
   else if( (thisForm.password.value.length < 4) || (thisForm.password.value.length > 16))
   {
        alert('Password must contain 4 - 16 characters.');
        thisForm.password.focus();
        return(false);
   }
	else   if (thisForm.REASON.value =='')
	{
		thisForm.REASON.focus();
		alert('Select a reason for canceling your IBackup Professional account.');
		return (false);
	}

	else    if ( (thisForm.REASON.value =='Others') && (thisForm.OTHERREASON.value ==''))
	{
		thisForm.OTHERREASON.focus();
		alert('Enter your Comments.');
		return (false);
	}


   if( (thisForm.email.value!='') && (!isValidEmailId(thisForm.email.value)) )
   {
      thisForm.email.focus();
	  alert('Enter a valid email address.');
      return(false);
   }
   else
   {
      
  	  thisForm.REASON.value = checkAndReplace(thisForm.REASON.value);
	  thisForm.OTHERREASON.value = checkAndReplace(thisForm.OTHERREASON.value);
	  return true ;
   }

}














function isBlank(Str)
 {
   while(''+Str.charAt(0)==' ')
   Str=Str.substring(1,Str.length);
   while(''+Str.charAt(Str.length-1)==' ')
   Str=Str.substring(0,Str.length-1);
   if (Str == '')
   { return(true);
   }
   else
   { return(false);
   };
 }



function invalidName(Str)
 {
     var alloweduser = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ";

     for(var count = 0; count < Str.length; count++)
     {
        if(alloweduser.indexOf(Str.substring(count, count + 1)) == -1)
        {
            return(true);
        }
     };

 }



function containsNumeric(Str)
 {
	 var alloweduser = "0123456789";
         var totcount = 0;
	 for(var count = 0; count < Str.length; count++)
	 {
		if(alloweduser.indexOf(Str.substring(count, count + 1)) != -1)
		{
		  totcount++;
		}
	 };

	 if(totcount!=0)
	 {
	   return(true);
	 }
     return(false);
 }







function isValidEmailId(email)
 {
	if (email == null)
	{
		return(false);
	}
	else if(email == '')
	{
		return(false) ;
	}
	else if ( (trim(email).indexOf('@') == -1) ||
			  (trim(email).indexOf('@') == 0) ||
			  (trim(email).indexOf('@') == (trim(email).length-1) ||  trim(email).indexOf('@',(trim(email).indexOf('@')+1))!=-1))
	{
		return(false);
	}
	else if (hasSpecChar(email))
	{
		return(false) ;
	}
	else
	{
		return(true) ;
	};
 }





function trim(Str)
 {
   if (!(isBlank(Str)))
   {
	  while(''+Str.charAt(0)==' ')
	  Str=Str.substring(1,Str.length);
	  while(''+Str.charAt(Str.length-1)==' ')
	  Str=Str.substring(0,Str.length-1);
	  return(Str);
   }
   else
   { return ('');
   };
 }



 function hasSpecChar(Str)
 {
	var alloweduser = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_@.-";

	 for(var count = 0; count < Str.length; count++)
	 {
		if(alloweduser.indexOf(Str.substring(count, count + 1)) == -1)
		{
		  return(true);
		}

	 };
	 return(false);
 }




 function inValidString(Str)
 {
	 var alloweduser = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

	 for(var count = 0; count < Str.length; count++)
	 {
		if(alloweduser.indexOf(Str.substring(count, count + 1)) == -1)
		{
		  return(true);
		}

	 };
	 return(false);
 }



 function invalidNumber(Str)
 {
	 var alloweduser = "0123456789";
         var totcount = 0;
	 for(var count = 0; count < Str.length; count++)
	 {
		if(alloweduser.indexOf(Str.substring(count, count + 1)) == -1)
		{
		  totcount++;
		}
	 };
	 if(totcount!=0)
	 {
	   return(true);
	 }
   return(false);
 }


 function invalidPhoneNumber(Str)
 {
	 var alloweduser = "0123456789- xX+";
         var totcount = 0;
	 for(var count = 0; count < Str.length; count++)
	 {
		if(alloweduser.indexOf(Str.substring(count, count + 1)) == -1)
		{
		  totcount++;
		}
	 };
	 if(totcount!=0)
	 {
	   return(true);
	 }
   return(false);
 }


function invalidUserNameNew(Str)
 {
	 var alloweduser = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";

	 for(var count = 0; count < Str.length; count++)
	 {
		if(alloweduser.indexOf(Str.substring(count, count + 1)) == -1)
		{
			return(true);
		}
	 }
 }


 function invalidUserName(Str)
 {
	 var alloweduser = "abcdefghijklmnopqrstuvwxyz0123456789_";

	 for(var count = 0; count < Str.length; count++)
	 {
		if(alloweduser.indexOf(Str.substring(count, count + 1)) == -1)
		{
			return(true);
		}
	 }
 }

function inValidZip(Str)
 {
	 var alloweduser = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_- ";
         var totcount = 0;
	 for(var count = 0; count < Str.length; count++)
	 {
		if(alloweduser.indexOf(Str.substring(count, count + 1)) == -1)
		{
		  totcount++;
		}

	 };
	 if(totcount!=0)
	 {
	   return(true);
	 }
	 return(false);
 }



/*function inValidAddress(Str)
 {
	 var alloweduser = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_ ,#- ()/";
         var totcount = 0;
	 for(var count = 0; count < Str.length; count++)
	 {
		if(alloweduser.indexOf(Str.substring(count, count + 1)) == -1)
		{
		  totcount++;
		}

	 };
	 if(totcount!=0)
	 {
	   return(true);
	 }
	 return(false);
 }*/
function invalidSecurityPhNum(Str)
{
	 var alloweduser = "0123456789- xX+";
         var totcount = 0;
	 for(var count = 0; count < Str.length; count++)
	 {
		if(alloweduser.indexOf(Str.substring(count, count + 1)) == -1)
		{
		  totcount++;
		}
	 };
	 if(totcount!=0)
	 {
	   return(true);
	 }
   return(false);
 }

function inValidAddress(Str)
{
   if( (Str.indexOf('"') != -1)  ||	(Str.indexOf('\'') != -1) || (Str.indexOf('\\') != -1) )
   { return(true);
   }
   else
   { return (false);
   }
}


function checkAndReplace(str)
{
	var ch ='';
	var j;
	
	if(str=='')
	{
		return '';
	}
	else
	{
	
		for(var i=0;i<str.length;i++)
		{
			
			j = 0;
			if(str.charAt(i)=='\'')
			{
				j++;
			}

			if(str.charAt(i)=='<')
			{
				j++;
			}

			if(str.charAt(i)=='>')
			{
				j++;
				
			}

			if(str.charAt(i)=='(')
			{
				j++;
				
			}

			if(str.charAt(i)==')')
			{
				j++;
				
			}

			if(str.charAt(i)=='%')
			{
				j++;
				
			}
			if(str.charAt(i)=='+')
			{
				j++;
				
			}

			if(str.charAt(i)=='"')
			{
				j++;
				
			}

			if(str.charAt(i)=='&')
			{
				j++;
				
			}

			if(j == 0)
			{
				ch = ch + str.charAt(i);
			}
			j = 0;
			
		}
	}

	return ch;
}

