﻿// JS on NewsLetter user control

function GetMailID() {
  //debugger;
  try {
    var emailid = jQuery('#txtEmailID').val();
    if (emailid == "") {
      alert("Please enter email id ");
    }
    if (emailid != "") {
      if (!CheckEmailID(emailid)) {
        alert("Please enter email id in proper format ");
      }
      else {
        var managerObj = $find("ctl00_RadAjaxManagerGeneric");
        managerObj.ajaxRequest("NewsLetter" + "," + emailid);
        jQuery('#txtEmailID').val('');
      }
    }
  } catch (e) {
    log('error in GetMailID:', e);
  }

}
function CheckEmailID(emailAddress) {
  try {
    var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
    return pattern.test(emailAddress);
  }
  catch (e) {
    log('error in CheckEmailID:', e);
  }
}

function ClearText() {
  try {
    if (jQuery('#txtEmailID')[0].className == 'isgtxtemaillrg') {
      jQuery('#txtEmailID')[0].className = 'isgtxtemaillrg1';
      jQuery('#txtEmailID').val('');
    }
  }
  catch (e) {
    log('error in ClearText:', e);
  }
}


function ClearDefaultText() {
  try {
    if (jQuery('#txtEmailID').val() == 'Enter your email address here') {
      jQuery('#txtEmailID').val("");
    }
  }
  catch (e) {
    log('error in ClearDefaultText:', e);
  }
}



function CheckText() {
  try {
    if (jQuery('#txtEmailID').val() == '') {
      jQuery('#txtEmailID')[0].className = 'isgtxtemaillrg';
      jQuery('#txtEmailID').val('Enter your email address here');
    }
  }
  catch (e) {
    log('error in CheckText:', e);
  }
}

function ShowMessage(infoText) {

  try {
    jQuery("#msg").html(infoText);
    setTimeout(function () {
      jQuery("#msg").slideUp(2000, function () {
        jQuery("#msg").attr('style', 'display:none');
      });
    }, 4000);
  }
  catch (e) {
    log('error in ShowMessage:', e);
  }
}

function ShowinfomsgDiv() {
  jQuery("#msg").attr('style', 'display:block');
}

//win a holiday
function cbAgree_ClientValidate(source, args) {
  //args.IsValid = document.getElementById('<%= cbAgree.ClientID %>').checked;

  if (jQuery('#cbAgree').is(':checked')) {
    args.IsValid = true;
  }
  else {
    args.IsValid = false;
  }
}
