function DoNotAgree(){
  if (confirm("Are you sure you want to decline the Terms of Service? Click Cancel to continue with registration.")){
    window.location.href="SignIn.asp";
  }
}

function SubmitAccount(){
  var xMsg="";
  if (document.frmCreateAccount.FirstName.value.Trim()=="") xMsg += "\n\t- First Name (required)";
  if (document.frmCreateAccount.LastName.value.Trim()=="") xMsg += "\n\t- Last Name (required)";
  if (!isEmail(document.frmCreateAccount.Email.value.Trim())) xMsg += "\n\t- Email Address (invalid)";
  if (document.frmCreateAccount.Pass1.value != document.frmCreateAccount.Pass2.value){
    xMsg += "\n\t- Password (does not match)";
  }else{
    if (document.frmCreateAccount.Pass1.value.Trim().length < 6){
      xMsg += "\n\t- Password (too short)";
    }
  }
  if (document.frmCreateAccount.SecQuestion.selectedIndex == 0) xMsg += "\n\t- Security Question (not selected)";
  if (document.frmCreateAccount.SecAnswer.value.Trim() == "")  xMsg += "\n\t- Secret Answer (required)";
  if (document.frmCreateAccount.BMonth.selectedIndex == 0) xMsg += "\n\t- Birthday Month (not selected)";
  if (!isInteger2(document.frmCreateAccount.BDay.value.Trim(),false)) xMsg += "\n\t- Birthday Day (invalid)";
  if (!isInteger(document.frmCreateAccount.BYear.value.Trim(),false)) xMsg += "\n\t- Birthday Year (invalid)";
  if (document.frmCreateAccount.ZipCode.value.Trim() == "") xMsg += "\n\t- Zip Code (required)";
  if (xMsg == ""){
    document.frmCreateAccount.tg.value = "RECORDACCOUNT";
    document.frmCreateAccount.submit();
  }else{
    alert("To continue please enter correctly the follow information:\n" + xMsg);
  }
}

function SubmitEditAccount(){
  var xMsg="";
  if (document.frmEditAccount.FirstName.value.Trim()=="") xMsg += "\n\t- First Name (required)";
  if (document.frmEditAccount.LastName.value.Trim()=="") xMsg += "\n\t- Last Name (required)";
  if (!isEmail(document.frmEditAccount.Email.value.Trim())) xMsg += "\n\t- Email Address (invalid)";
  if (document.frmEditAccount.Pass1.value != document.frmEditAccount.Pass2.value){
    xMsg += "\n\t- Password (does not match)";
  }else{
    if (document.frmEditAccount.Pass1.value.Trim().length < 6){
      xMsg += "\n\t- Password (too short)";
    }
  }
  if (document.frmEditAccount.SecQuestion.selectedIndex == 0) xMsg += "\n\t- Security Question (not selected)";
  if (document.frmEditAccount.SecAnswer.value.Trim() == "")  xMsg += "\n\t- Secret Answer (required)";
  if (document.frmEditAccount.BMonth.selectedIndex == 0) xMsg += "\n\t- Birthday Month (not selected)";
  if (!isInteger2(document.frmEditAccount.BDay.value.Trim(),false)) xMsg += "\n\t- Birthday Day (invalid)";
  if (!isInteger(document.frmEditAccount.BYear.value.Trim(),false)) xMsg += "\n\t- Birthday Year (invalid)";
  if (document.frmEditAccount.ZipCode.value.Trim() == "") xMsg += "\n\t- Zip Code (required)";
  if (xMsg == ""){
    document.frmEditAccount.tg.value = "RECORDEDITACCOUNT";
    document.frmEditAccount.submit();
  }else{
    alert("To continue please enter correctly the following information:\n" + xMsg);
  }
}

function ValidateAccount(){
  var xMsg="";
  if (!isEmail(document.frmValidateAccount.Email.value.Trim())) xMsg += "\n\t- Email Address (invalid)";
  if (document.frmValidateAccount.CRCCode.value.length != 20) xMsg += "\n\t- 20-digits Secret Code (invalid)";
  if (xMsg == ""){
    document.frmValidateAccount.tg.value = "VALIDATEACCOUNT";
    document.frmValidateAccount.submit();
  }else{
    alert("To continue please enter correctly the following information:\n" + xMsg);
  }
}

function ReSendValidateEmail(iCode){
  window.open("/Services/USRINT/ResendValidation.asp?UID=" + iCode, "RESEND","menubar=0,resizable=0,scroll=0,width=450,height=150");
}

function SignIn(){
  var xMsg = "";
  if (!isEmail(document.frmSignInAccount.Email.value)) xMsg += "\n\t- Email Address (invalid)";
  if (document.frmSignInAccount.Password.value=="") xMsg += "\n\t- Password";
  if (xMsg == ""){
    document.frmSignInAccount.tg.value="SIGNINACCOUNT";
    document.frmSignInAccount.submit();
  }else{
    alert("To continue please enter correctly the following information:\n" + xMsg);
  }
}

function SignOut(){
  window.location.href='/Services/USRINT/SignOut.asp';
}

function ChangeCountry(iCode){
  switch(iCode){
    case 0:
      //document.frmAddStore.tg.value = "ADDSTORE";
      //document.frmAddStore.submit();
      document.frmSubscribe.tg.value = "SUBSCRIPTION";
      document.frmSubscribe.submit();
      break;
  }
}

function ChangeCountryEdit(iCode){
  switch(iCode){
    case 0:
      //document.frmAddStore.tg.value = "ADDSTORE";
      //document.frmAddStore.submit();
      document.frmsaveedit.tg.value = "EDITCARD";
      document.frmsaveedit.submit();
      break;
  }
}

function ChangeSTRUpload(){
  var xFF = document.frmAddStore.CH_LOGO.checked;
  if (xFF){
    document.frmAddStore.btnUpload.disabled = false;
  }else{
    document.frmAddStore.btnUpload.disabled = true;
  }
}

function ChangeSTRView(){
  var xFF = document.frmAddStore.CH_PROFILE.checked;
  if (xFF){
    document.frmAddStore.CH_MESSAGE.disabled = false;
  }else{
    document.frmAddStore.CH_MESSAGE.disabled = true;
  }
}

function SaveStore(){
  var xMsg = "";
  if (document.frmAddStore.StoreName.value.Trim()=="") xMsg += "\nStore Name";
  if (document.frmAddStore.StoreDomain.value.Trim()=="") xMsg += "\nDomain";
  if (xMsg == ""){
    document.frmAddStore.tg.value = "SAVESTORE";
    document.frmAddStore.submit();
  }else{
    alert("To continue please enter correctly the following information:\n" + xMsg);
  }
}



function MyNewsAddSubscription(){
  window.location.href="MyNews.asp?tg=SUBSCRIPTION&Source=MyNews";
}

function UpgradeSubscription(iSID){
  window.location.href = "MySubscriptions.asp?tg=UPGRADE&sid=" + iSID;
}

function PaySubscription(iSID){
  window.location.href = "MySubscriptions.asp?tg=SETPAYMENT&sid=" + iSID + "&source=mynews";
}

function ChangeSubscription(iSID){
  window.location.href = "MySubscriptions.asp?tg=CHANGE&sid=" + iSID;
}

function PrintInvoice(iPayID){
  window.open ("MyBalance.asp?tg=PRINTINVOICE&Pid=" + iPayID,"PrintInvoiceFriendly","menubar=1,scrollbars=1,resizable=1,width=600,height=550");
}

function ON_PayNewCard(){
  document.frmSetPayment.CardType.disabled = false;
  document.frmSetPayment.CardNumber.disabled = false;
  document.frmSetPayment.NameOnCard.disabled = false;
  document.frmSetPayment.CardExpires.disabled = false;
  document.frmSetPayment.CardCVV2.disabled = false;
  document.frmSetPayment.BillName.disabled = false;
  document.frmSetPayment.BillAddress.disabled = false;
  document.frmSetPayment.BillCity.disabled = false;
  document.frmSetPayment.BillState.disabled = false;
  document.frmSetPayment.BillZipCode.disabled = false;
  document.frmSetPayment.BillCountry.disabled = false;
  document.frmSetPayment.BillPhone.disabled = false;
}


function OFF_PayNewCard(){
  document.frmSetPayment.CardType.disabled = true;
  document.frmSetPayment.CardNumber.disabled = true;
  document.frmSetPayment.NameOnCard.disabled = true;
  document.frmSetPayment.CardExpires.disabled = true;
  document.frmSetPayment.CardCVV2.disabled = true;
  document.frmSetPayment.BillName.disabled = true;
  document.frmSetPayment.BillAddress.disabled = true;
  document.frmSetPayment.BillCity.disabled = true;
  document.frmSetPayment.BillState.disabled = true;
  document.frmSetPayment.BillZipCode.disabled = true;
  document.frmSetPayment.BillCountry.disabled = true;
  document.frmSetPayment.BillPhone.disabled = true;
}

function PChangeCountry(iCode){
  switch(iCode){
    case 0:
      //document.frmAddStore.tg.value = "ADDSTORE";
      //document.frmAddStore.submit();
      document.frmSetPayment.tg.value = "SETPAYMENT";
      document.frmSetPayment.submit();
      break;
  }
}

function CancelPayment(){
  var iSource = document.frmSetPayment.source.value;
  switch(iSource){
    case "": window.location.href="MySubscriptions.asp";
      break;
    case "MYNEWS": window.location.href="MyNews.asp";
      break;
  }
}

function GetPayment(){
  var xMsg = "";
  var iCards = document.frmSetPayment.PaymentCounter.value;
  var xSW1 = false;
  for (i=1; i<=iCards; i++){
      xSW1 = xSW1 || (document.frmSetPayment.CCard[i].checked);
  }
  if (!xSW1){
    xMsg += "\n Credit Card (unselected)";
  }else{
    if (!document.frmSetPayment.CardType.disabled){
      if (document.frmSetPayment.CardType.selectedIndex == 0) xMsg += "\n- Card Type (unselected)";
      if (!isCCardValid(document.frmSetPayment.CardNumber.value.Trim())) xMsg += "\n- Card Number (invalid)";
      if (document.frmSetPayment.NameOnCard.value.Trim()=="") xMsg += "\n- Name On Card (empty)";
      if (!isCardExpires(document.frmSetPayment.CardExpires.value.Trim())) xMsg += "\n- Card Expiration (invalid)";
      if (!isCVV2Valid(document.frmSetPayment.CardCVV2.value.Trim())) xMsg += "\n- Card CVV2 (invalid)";
      if (document.frmSetPayment.BillName.value.Trim()=="") xMsg += "\n- Billing Client Name (empty)";
      if (document.frmSetPayment.BillAddress.value.Trim()=="") xMsg += "\n- Billing Address (empty)";
      if (document.frmSetPayment.BillCity.value.Trim()=="") xMsg += "\n- Billing City (empty)";
      if (document.frmSetPayment.BillState.value.Trim()=="") xMsg += "\n- Billing State (empty)";

      if (document.frmSetPayment.Val_ZipCode.value == "true")
      { if (document.frmSetPayment.BillZipCode.value.Trim()=="") xMsg += "\n- Billing ZipCode (empty)";
      }
      if (document.frmSetPayment.BillCountry.value.Trim()=="") xMsg += "\n- Billing Country (empty)";
      if (document.frmSetPayment.BillPhone.value.Trim()=="") xMsg += "\n- Billing Phone (empty)";
    }
  }
  if (xMsg == ""){
    document.frmSetPayment.tg.value = "SAVEPAYMENT";
    document.frmSetPayment.submit();
  }else{
    alert("To continue please enter the following information: \n" + xMsg);
  }
  
  
}

function ResetPassword(){
  window.open ("ResetPassword.asp","","width=410, height=170");
}

