
function ProcessAffiliateLogin()
{
  var formObj=document.forms["affiliateForm"];
  var loginId=formObj.loginId.value.trim();
  var password=formObj.password.value.trim();  

  if ((loginId=="") || (password=="")) {
    DisplayMessage("notice", 3000, "#ffffff", "Please fill out the required details.");
    return;
  } 

  formObj.submit();
}

function ExecuteAction(actionRequired)
{
  var formObj=document.forms["affiliateForm"];
 
  formObj.affiliate_action.value=actionRequired;
  formObj.submit();
}

function ValidateURL(url)
{
  var urlRegxp = /^(http:\/\/www|https:\/\/www|ftp:\/\/www|www){1}\.(\w+)((\-(\w+))*)\.(\w){2,3}((\W\w+)*)?$/;
  if (urlRegxp.test(url)) {
    return true;
  } else {
    return false;
  }
}

function VerifyApplication()
{
  var formObj=document.forms["affiliateApplication"];

  var warningMessages=new Array();
  warningMessages['personalName']='Please fill out your name.';
  warningMessages['personalEmail']='Please fill out your email.';
//   warningMessages['personalPhone']='Please fill out the your telephone number.';
//   warningMessages['personalCity']='Please fill out your city.';
//   warningMessages['personalState']='Please fill out your state.';
//   warningMessages['personalZip']='Please fill out your zip code.';
  warningMessages['websiteURL']='Please fill out the URL.';
  warningMessages['websiteVisitors']='Please fill out the number of visitors.';

  /*Make sure all form fields have been filled out*/
  var formEl=VerifyForm(formObj,warningMessages);
  if (formEl) {
    DisplayMessage("notice", 3000, "#ffffff", warningMessages[formEl]);
    return;
  }

//   if (formObj.personalAddress.value.trim()=="") {
//     DisplayMessage("notice", 3000, "#ffffff", "Please fill out your address");
//     return;
//   }

//   if (formObj.websiteDescription.value.trim()=="") {
//     DisplayMessage("notice", 3000, "#ffffff", "Please fill out the description");
//     return;
//   }

  if (!ValidEmail(formObj.personalEmail.value.trim())) {
    DisplayMessage("notice", 3000, "#ffffff", "Please fill out a valid email.");
    return;
  }

  if (!ValidateURL(formObj.websiteURL.value.trim())) {
    DisplayMessage("notice", 3000, "#ffffff", "Please fill out a valid URL.");
    return;
  }

  if (formObj.username.value.trim()=="") {
    DisplayMessage("notice", 3000, "#ffffff", "Please choose a username.");
    return;
  }

  if (formObj.password.value.trim()=="") {
    DisplayMessage("notice", 3000, "#ffffff", "Please choose a password.");
    return;
  }

   if (formObj.password.value.trim().length<6) {
    DisplayMessage("notice", 3000, "#ffffff", " Password must be between 6 and 8 digits or charaters long.");
    return;
  }

  if (formObj.password.value.trim().length>8) {
    DisplayMessage("notice", 3000, "#ffffff", " Password must be between 6 and 8 digits or charaters long.");
    return;
  }



  if (formObj.confirm_password.value.trim()=="") {
    DisplayMessage("notice", 3000, "#ffffff", "Your password entries did not match.");
    return;
  }

  if (formObj.password.value.trim()!=formObj.confirm_password.value.trim()) {
    DisplayMessage("notice",3000, "#ffffff", "Your password entries did not match.");
    return;
  }
 
  if (formObj.agreementAcknowledged.checked==0) {
    DisplayMessage("notice", 3000, "#ffffff", "You need to comply with the Agreement Acknowledgement to proceed.");
    return;
  } 

  

  

  formObj.submit();
}


function ProcessLoginUpdate() 
{

  var formObj=document.forms["affiliateForm"];
  var password=formObj.current_password.value.trim(); 
  var newPassword=formObj.new_password.value.trim();
  var newConfirmPassword=formObj.confirm_new_password.value.trim(); 

  if (password=="") {
    DisplayMessage("notice", 3000, "#ffffff", "Please fill out the current password.");
    return;
  } 

  if (newPassword=="") {
    DisplayMessage("notice", 3000, "#ffffff", "Please choose a new password.");
    return;
  }

  if (newConfirmPassword=="") {
    DisplayMessage("notice", 3000, "#ffffff", "Your password entries did not match.");
    return;
  }

  if (newPassword!=newConfirmPassword) {
    DisplayMessage("notice", 3000, "#ffffff", "Your password entries did not match.");
    return;
  }
  formObj.submit();

}

