﻿/*
//###########################################################################################################
// Description : Client side Javascript page 
// Author :  JJL, SCS                   Date : 03 April 2009
// Copyright 2009-2012 John Wiley and Sons Ltd
//-----------------------------------------------------------------------------------------------------------
// Change log:	Date        Reference		Author		Description
//-----------------------------------------------------------------------------------------------------------
//              06/04/2009  WO088.R01.P01   JJL,NCS     Condition added to check for password min. and max. length.
//              08/04/2009  WO088.R01.P02   JJL,NCS     Added isValidEmail()
//              24/07/2009  WO091.R01       JJL,NCS     Added ToggleDefault()
//              14/09/2009  WO091.R01.P05   TSL,NCS     Remove ValidateSendingDate()
//              10/05/2011  STORY294        JJL, NCS    Removed European Community VAT message and VAT number reference validation
//              26/07/2011  STORY354        WBO, NCS    Added cvRequiredFieldTitle(),cvRequiredFieldAffiliation(),cvRequiredFieldPaymentOption(),cvRequiredFieldSocietyAssociation()
//              02/08/2011  STORY362        WBO, NCS    Added check for Affiliated Institutions
//              23/10/2011  STORY437        JJL, NCS    Added ValidExtension(), ValidateFileAttachment(),isValidTime(), ValidateStartTime()
//                                                      ValidateEndTime(), isValidDate(), ValidateStartDate(), ValidateEndDate(), ValidateSalutation(), 
//                                                      ValidateAddress(), 
//              23/10/2011  STORY437        JJL, NCS    Amended ValidateEmail()
//              29/11/2011  STORY463        JJL, NCS    Added Client validation function(s) for STORY463
//              27/01/2012  STORY510        JJL, NCS    Added cvValidatePGConferenceFee(), cvValidatePGIndividualMeals(), cvValidatePGAccommodation() for postgraduate conference validations
//###########################################################################################################
*/

// 23/10/2011 STORY437 JJL,NCS Starts
function ValidExtension(filename, valid_ext)
{
    var valid_extensions = "/" + valid_ext + "$/i";
	if(filename) {
		if (eval(valid_extensions).test(filename)){
			return true;
		} else {
			return false;
		}
	} else {
		return true;
	}
}



function ValidateFileAttachment(source, args) {
    var xx = trim(document.getElementById(GetClientId("txtfileupload")).value);
    var ext = document.getElementById(GetClientId("hdnUploadExt")).value;
    if ((xx != "") && (!ValidExtension(xx, ext)) ) {
        source.errormessage = "Upload Failed. System supports only " + ext.replace(/\|/g,', ') + " file formats.";
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}

function isValidTime(sText) {
        var reTime = /(20|21|22|23|[01]\d|\d)(([:][0-5]\d){1,2})/;
        return reTime.test(sText);
    }

function ValidateStartTime(source, args)
{
    var x = trim(document.getElementById(GetClientId("txtstarttime")).value);
    if (x.length < 5)
    {
        args.IsValid = false;
    }
    else if (x.replace(":",".") < 0)
    {
        args.IsValid = false;
    }
    else if ((x.length >= 5) && (!isValidTime(x))) {
      args.IsValid = false;
    }
    else {
      args.IsValid = true;
    }
}

function ValidateEndTime(source, args)
{  
    var x1 = trim(document.getElementById(GetClientId("txtstarttime")).value);
    var x2 = trim(document.getElementById(GetClientId("txtendtime")).value);
    
    var dt1 = trim(document.getElementById(GetClientId("txtstartdate")).value);
    var dt2 = trim(document.getElementById(GetClientId("txtenddate")).value);
    
    if (x2.length < 5)
    {
        args.IsValid = false;
    }
    else if (x2.replace(":",".") < 0)
    {
        args.IsValid = false;
    }
    else if ((x2.length >= 5) && (!isValidTime(x2))) {
      args.IsValid = false;
    }
    else if ((dt1 == dt2) && (x1.replace(":",".") - x2.replace(":",".")> 0))
    {
        args.IsValid = false;
        if (!args.IsValid) source.errormessage = "For single day events, the end time cannot occur before the start time.";
    }
    else {
      args.IsValid = true;
    }
}

function isValidDate(sText) {
        var reDate = /(?:0[1-9]|[12][0-9]|3[01])\/(?:0[1-9]|1[0-2])\/(?:19|20\d{2})/;
        return reDate.test(sText);
    }

function IsValidFutureDate(dt1, dt2)
{
         var x= new Date();
        var y= x.getFullYear();
        var m= x.getMonth();
        var d= x.getDate();
        var tdate = new Date(y,m,d);
        
        var ONE_DAY = 1000 * 60 * 60 * 24;
        
        var day1 = dt1.substring(0, 2); 
        var month1 = dt1.substring(3, 5) - 1; // because months in JS start from 0
        var year1 = dt1.substring(6, 10);
        var sdate = new Date(year1, month1, day1);   

        var day2 = dt2.substring(0, 2); 
        var month2 = dt2.substring(3, 5) - 1; // because months in JS start from 0
        var year2 = dt2.substring(6, 10);
        var edate = new Date(year2, month2, day2);
        
        var difference_ms1 = sdate.getTime() - tdate.getTime();
        var difference_ms2 = edate.getTime() - tdate.getTime();
     
        var d1 = (Math.round(difference_ms1/ONE_DAY) +1);
        var d2 = (Math.round(difference_ms2/ONE_DAY) +1);
		
        if (difference_ms1 == difference_ms2)
        {
			if ((d1==d2) && (d1 >0))
			{
				return 0;
			}
			else if (difference_ms1< 0)
            {
				return 2;
            }
        }
        
        if (d1 - d2 >=0) 
        {
            return 1
        }
        else if (((d1  < 0) && (d2  >= 0)) || ((d1 >=0) && (d2  >= 0)))
        { 
            return 0;
        }
        else 
        {
            return 2;
        }
}

function ValidateStartDate(source, args)
{
    var x = trim(document.getElementById(GetClientId("txtstartdate")).value);
    
    if (x.length < 10)
    {
        args.IsValid = false;
    }
    else if ((x.length >= 10) && (!isValidDate(x))) {
      args.IsValid = false;
    }
    else
    {
        args.IsValid = true;
    }   
}

function ValidateEndDate(source, args)
{
    var x1 = trim(document.getElementById(GetClientId("txtstartdate")).value);
    var x2 = trim(document.getElementById(GetClientId("txtenddate")).value);
    //var x3 = trim(document.getElementById(GetClientId("hdnID")).value);
	x2 = x2.replace("dd/mm/yyyy","");
	
	if (x2 == "") 
    {
        args.IsValid = false;
        if (!args.IsValid) source.errormessage = "Please enter End Date.";
    }
    else if (x2.length < 10)
    {
        args.IsValid = false;
        if (!args.IsValid) source.errormessage = "Please enter valid End Date.";
    }
    else if ((x2.length >= 10) && (!isValidDate(x2))) {
      args.IsValid = false;
      if (!args.IsValid) source.errormessage = "Please enter valid End Date.";
    }
    else if (isValidDate(x1))
     {
        var t = IsValidFutureDate(x1,x2);
        if (t==0)
        {
            args.IsValid = true;
        }
        else if (t == 1)
        {
              args.IsValid = false;
              if (!args.IsValid) source.errormessage = "The end date cannot occur before the start date.";
        }
        else if (t == 2)
        {
            args.IsValid = false;
            if (!args.IsValid) source.errormessage = "You cannot submit dates which have passed.";
        }
    }
    else
    {
    
        args.IsValid = true;
    }
}

function ValidateSalutation(source, args)
{
  args.IsValid = document.getElementById(GetClientId("ddlTitle")).value != ""; 
}

function ValidateEventDescription(source, args)
{

  args.IsValid = document.getElementById(GetClientId("ceEvent")).value != ""; 
}

function ValidateAddress(source, args)
{
  args.IsValid = document.getElementById(GetClientId("txtaddress")).value != ""; 
}

function ValidateValidEventDescription(source, args)
{
 x = document.getElementById(GetClientId("ceEvent")).value;
 if (x == "") 
 {
  args.IsValid = true;
 }
 else if (validateHTMLInvalidLetters(x))
 {
  args.IsValid = true;
 }
 else
 { 
 args.IsValid = false;
 }
}
// 23/10/2011 STORY437 JJL,NCS End


// 29/11/2011 JJL,NCS STORY463 Client Validation & methods used for story463 Starts 
function pad2(number) {
     return (number < 10 ? '0' : '') + number
}

function ValidateImagePermission(source, args) {
var x1 = document.getElementById(GetClientId("hdnPrevFilename")).value;

var x2 = document.getElementById(GetClientId("chkImagePermission")).checked;
args.IsValid  = (x1 != "" && x2 == false) ? false : true;

}

function validateHTMLInvalidLetters(x)
{
 return (((x.indexOf("[http") == -1) && (x.indexOf("[a href") == -1) && (x.indexOf("[img") == -1) && (x.indexOf("[https") == -1)) ?  true :  false);
}

function ValidateReview(source, args)
{
     x = trim(document.getElementById(GetClientId("ceReview")).value);
     if (x == "") 
     {
      args.IsValid = false;
     }
     else if (validateHTMLInvalidLetters(x))
     {
      args.IsValid = true;
     }
     else
     { 
     args.IsValid = false;
     }
}

function ValidateSummary(source, args)
{
  args.IsValid = trim(document.getElementById(GetClientId("txtSummary")).value) != ""; 
}


function ValidateReviewerName(source, args)
{
  args.IsValid = trim(document.getElementById(GetClientId("txtreviewerName")).value) != ""; 
}

function ValidateDate(x)
{
    if (x.length < 10)
    {
        return false;
    }
    else if ((x.length >= 10) && (!isValidDate(x))) {
      return false;
    }
    else
    {
        return true;
    } 
}

function ValidateReviewedDate(source, args)
{
    var x = trim(document.getElementById(GetClientId("txtrevieweddate")).value);
    args.IsValid = ValidateDate(x);
     
}

function ValidateEventDate(source, args)
{
    var x = trim(document.getElementById(GetClientId("txteventdate")).value);
    args.IsValid = ValidateDate(x);
     
}

function ValidateNonRequiredEmail(source, args)
{
  var x = trim(document.getElementById(GetClientId("txtemailaddress")).value);

  if (x != "" && x.length < 5 )
  {
   args.IsValid = false;
  }
  else if ((x.length >= 5) && (!isValidEmail(x))) {
      args.IsValid = false;
  }
  else {
      args.IsValid = true;
  }
}
// 29/11/2011 JJL,NCS STORY463 End

// 24/07/2009  WO091.R01  starts
function ValidatePageTitle(source, args) {
    var xx = trim(document.getElementById(GetClientId("txtTitle")).value);
    if (((xx != "") && (xx.length < 2))) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}

function ValidateRequiredFieldsContentUpdate(source, args) {

    var xx1 = trim(document.getElementById(GetClientId("txtTitle")).value);
    var xx2 = trim(document.getElementById(GetClientId("ceContent")).value);

    if ((xx1 != "") && (xx2 != "")) {
        args.IsValid = true;
    }
    else {
        args.IsValid = false;
    }
}
function ValidateRequiredFieldsHomePageContentUpdate(source, args) {
    var xx1 = trim(document.getElementById(GetClientId("ceContentColumn2")).value);
    var xx2 = trim(document.getElementById(GetClientId("ceContentColumn3")).value);

    if ((xx1 != "") && (xx2 != "")) {
        args.IsValid = true;
    }
    else {
        args.IsValid = false;
    }
}

function ToggleDefault(obj, defaultValue) {
    var x = trim(obj.value);
    if (x == "")
 
        obj.value = defaultValue;
    else if (x == defaultValue) 
        obj.value = "";
}

function changeVal(obj, defaultValue) {
    var x = trim(obj.value);

    if (x == defaultValue) {
        obj.value = "";
    }
}

function ValidateAdminSearchTerm(source, args) {
    var xx1 = trim(document.getElementById(GetClientId("txtSearchKey")).value).toLowerCase();
    var xx2 = document.getElementById(GetClientId("ddlFilter")).value.toLowerCase();
    var pnlResult = document.getElementById(GetClientId("pnlResults"));

    if ((((xx1.length == 0) || (xx1 == "enter search term")) && (xx2 == "all")) || (xx1.length > 0)) {
        args.IsValid = true;
        pnlResult.style.visibility = "visible";
    }
    else {
        args.IsValid = false;
        pnlResult.style.visibility = "hidden";
    }
}

function ValidateSearchTerm(source, args) {
    var x = document.getElementById(GetClientId("txtSearchKey")).value.toLowerCase();
    var pnlResult = document.getElementById(GetClientId("pnlResults"));
    
    if ((x.length == 0) || (x=="enter search term")) {
        args.IsValid = false;
        pnlResult.style.visibility = "hidden";
    }
    else {
        args.IsValid = true;
        pnlResult.style.visibility = "visible";
    }
}

function trim(str) {
    return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}
function ValidateRegistrationRequiredFields(source, args) {
    var x1 = trim(document.getElementById(GetClientId("txtcustno")).value);
    var x2 = trim(document.getElementById(GetClientId("txtusername")).value);
    var x3 = trim(document.getElementById(GetClientId("txtpassword")).value);
    var x4 = trim(document.getElementById(GetClientId("txtpassword1")).value);
    var x5 = trim(document.getElementById(GetClientId("txtemailaddress")).value);

    if ((x1 != "") && (x2 != "") && (x3 != "") && (x4 != "") && (x5 != "")) {
        args.IsValid = true;
    }
    else {
        args.IsValid = false;
    }
}
function ValidateInvalidText(source, args) {
    var x1 = document.getElementById(GetClientId("txtcustno")).value;
    var x2 = document.getElementById(GetClientId("txtusername")).value;
    var x3 = document.getElementById(GetClientId("txtpassword")).value;
    var x4 = document.getElementById(GetClientId("txtpassword1")).value;
    var x5 = document.getElementById(GetClientId("txtemailaddress")).value;

    if (((x1.toLowerCase().match("content-type:") == null) && (x1.toLowerCase().match("multipart/alternative") == null) && (x1.toLowerCase().match("content-transfer-encoding") == null)) && ((x2.toLowerCase().match("content-type:") == null) && (x2.toLowerCase().match("multipart/alternative") == null) && (x2.toLowerCase().match("content-transfer-encoding") == null)) && ((x3.toLowerCase().match("content-type:") == null) && (x3.toLowerCase().match("multipart/alternative") == null) && (x3.toLowerCase().match("content-transfer-encoding") == null)) && ((x4.toLowerCase().match("content-type:") == null) && (x4.toLowerCase().match("multipart/alternative") == null) && (x4.toLowerCase().match("content-transfer-encoding") == null)) && ((x5.toLowerCase().match("content-type:") == null) && (x5.toLowerCase().match("multipart/alternative") == null) && (x5.toLowerCase().match("content-transfer-encoding") == null))) {
        args.IsValid = true;
    }
    else {
        args.IsValid = false;
    }
}

function Subscribe_ClientClick() {
    Page_ClientValidate();
    
    if (Page_IsValid) {
        return true;
    }
    else {
        return false;
    }
}

function RequiredFields_ClientValidate(source, args) {
    var txtJnlDiscount = document.getElementById(GetClientId("txtJnlDiscount"));
    var ddlPayCardType = document.getElementById(GetClientId("ddlPayCardType"));
    var ddlMonth = document.getElementById(GetClientId("ddlMonth"));
    var ddlYear = document.getElementById(GetClientId("ddlYear"));
    var txtPayCardVerification = document.getElementById(GetClientId("txtPayCardVerification"));
    var txtCourtesyTitle = document.getElementById(GetClientId("txtCourtesyTitle"));
    var txtFirstName = document.getElementById(GetClientId("txtFirstName"));
    var txtLastName = document.getElementById(GetClientId("txtLastName"));
    var txtDepartment = document.getElementById(GetClientId("txtDepartment"));
    var txtEstablishment = document.getElementById(GetClientId("txtEstablishment"));
    var txtStreet = document.getElementById(GetClientId("txtStreet"));
    var txtTown = document.getElementById(GetClientId("txtTown"));
    var txtState = document.getElementById(GetClientId("txtState"));
    var txtPostCode = document.getElementById(GetClientId("txtPostCode"));
    var ddlCountry = document.getElementById(GetClientId("ddlCountry"));
    var txtEmail = document.getElementById(GetClientId("txtemailaddress"));
    var txtEmailVerify = document.getElementById(GetClientId("txtemailaddress1"));
    var txtTelNo = document.getElementById(GetClientId("txtTelNo"));
    var txtFaxNo = document.getElementById(GetClientId("txtFaxNo"));
    var txtPayCustomerNo = document.getElementById(GetClientId("txtPayCustomerNo"));
    var txtPayCardNumber = document.getElementById(GetClientId("txtPayCardNumber"));
    var txtPayCardHolderName = document.getElementById(GetClientId("txtPayCardHolderName"));
    var txtGstNumber = document.getElementById(GetClientId("txtGstNumber"));
    var radPayOrderType1 = document.getElementById(GetClientId("radPayOrderType1"));
    var radPayOrderType2 = document.getElementById(GetClientId("radPayOrderType2"));
    var divDiscountCodeAccepted = document.getElementById(GetClientId("divDiscountCodeAccepted"));
    var divDiscountCodeInvalid = document.getElementById(GetClientId("divDiscountCodeInvalid"));
    var hdnCountryRegion = document.getElementById(GetClientId("hdnCountryRegion"));

    //Trim entry fields
    txtPayCustomerNo.value = trim(txtPayCustomerNo.value);
    txtJnlDiscount.value = trim(txtJnlDiscount.value);
    txtPayCardNumber.value = trim(txtPayCardNumber.value);
    txtPayCardVerification.value = trim(txtPayCardVerification.value);
    txtPayCardHolderName.value = trim(txtPayCardHolderName.value);
    txtCourtesyTitle.value = trim(txtCourtesyTitle.value);
    txtFirstName.value = trim(txtFirstName.value);
    txtLastName.value = trim(txtLastName.value);
    txtDepartment.value = trim(txtDepartment.value);
    txtEstablishment.value = trim(txtEstablishment.value);
    txtStreet.value = trim(txtStreet.value);
    txtTown.value = trim(txtTown.value);
    txtState.value = trim(txtState.value);
    txtPostCode.value = trim(txtPostCode.value);
    txtEmail.value = trim(txtEmail.value);
    txtTelNo.value = trim(txtTelNo.value);
    txtFaxNo.value = trim(txtFaxNo.value);
    hdnCountryRegion.value = trim(hdnCountryRegion.value);
    if (txtGstNumber != null) txtGstNumber.value = trim(txtGstNumber.value);
    
    if (ddlCountry.value == "" && ddlPayCardType.value == "" && txtPayCardVerification.value == "" &&
        txtPayCardNumber.value == "" && ddlMonth.value == "-1" && ddlYear.value == "-1" &&
        txtPayCardHolderName.value == "" && txtFirstName.value == "" && txtLastName.value == "" &&
        txtStreet.value == "" && txtTown.value == "" && txtState.value == "" &&
        txtPostCode.value == "" && txtEmail.value == "" && txtEmailVerify.value == "") {
        args.IsValid = false;
        document.getElementById(GetClientId("hdnMandatoryBlank")).value = "true";
    }
    else {
        document.getElementById(GetClientId("hdnMandatoryBlank")).value = "false";
        args.IsValid = true;
    }
}

function cvRequiredFieldEmailValidate(source, args) {
    args.IsValid = true;
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    var txtemailaddress = trim(document.getElementById(GetClientId("txtemailaddress")).value);
    if ((x == "false") && ((txtemailaddress == "") || (txtemailaddress.length < 4))) {
        args.IsValid = false;
    }
}


function cvRequiredFieldEmailConfirmValidate(source, args) {
    args.IsValid = true;
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    var txtemailaddress1 = trim(document.getElementById(GetClientId("txtemailaddress1")).value);
    if ((x == "false") && ((txtemailaddress1 == "") || (txtemailaddress1.length < 4))) {
        args.IsValid = false;
    }
}

function cvRequiredFieldStateValidate(source, args) {
    args.IsValid = true;
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    var txtState = trim(document.getElementById(GetClientId("txtState")).value);
    if ((x == "false") && (txtState == "")) {
        args.IsValid = false;
    }
}

function cvRequiredFieldPostCodeValidate(source, args) {
    args.IsValid = true;
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    var txtPostCode = trim(document.getElementById(GetClientId("txtPostCode")).value);
    if ((x == "false") && (txtPostCode == "")) {
        args.IsValid = false;
    }
}

function cvRequiredFieldTownValidate(source, args) {
    args.IsValid = true;
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    var txtTown = trim(document.getElementById(GetClientId("txtTown")).value);
    if ((x == "false") && (txtTown == "")) {
        args.IsValid = false;
    }
}

function cvRequiredFieldAddress1Validate(source, args) {
    args.IsValid = true;
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    var txtStreet = trim(document.getElementById(GetClientId("txtStreet")).value);
    if ((x == "false") && (txtStreet == "")) {
        args.IsValid = false;
    }
}


function cvRequiredFieldLastNameValidate(source, args) {
    args.IsValid = true;
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    var txtLastName = trim(document.getElementById(GetClientId("txtLastName")).value);
    if ((x == "false") && (txtLastName == "")) {
        args.IsValid = false;
    }
}

function cvRequiredFieldFirstNameValidate(source, args) {
    args.IsValid = true;
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    var txtFirstName = trim(document.getElementById(GetClientId("txtFirstName")).value);
    if ((x == "false") && (txtFirstName == "")) {
        args.IsValid = false;
    }
}

function cvRequiredFieldCardCCV(source, args) {
    var xx = trim(document.getElementById(GetClientId("txtPayCardVerification")).value);
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    if ((x == "false") && (xx == "")) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}
function cvRequiredFieldCountryValidate(source, args) {
    var xx = trim(document.getElementById(GetClientId("ddlCountry")).value);
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    if ((x == "false") && (xx == "")) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}
function cvRequiredFieldCardType(source, args) {
    var xx = trim(document.getElementById(GetClientId("ddlPayCardType")).value);
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    if ((x == "false") && (xx == "")) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}
function cvRequiredFieldCardExpiry(source, args) {
    var xx = trim(document.getElementById(GetClientId("ddlMonth")).value);
    var xx1 = trim(document.getElementById(GetClientId("ddlYear")).value);
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    if ((x == "false") && ((xx == -1)||(xx1 == -1))) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}
//26/07/2011  STORY354        WBO, NCS Start
function cvRequiredFieldTitle(source, args) {
    var ddlTitle = document.getElementById(GetClientId("ddlTitle")).selectedIndex;
    if (ddlTitle == 0)
    {
        args.IsValid = false;
    }
}
function cvRequiredFieldAffiliation(source, args) {
    var ddlAffiliation = document.getElementById(GetClientId("ddlAffiliation")).selectedIndex;
    if (ddlAffiliation == 0)
    {
        args.IsValid = false;
    }
}
function cvRequiredFieldPaymentOption(source, args) {
    var rdoOffLine = document.getElementById(GetClientId("rdoOffLine")).checked;
    var rdoOnLine = document.getElementById(GetClientId("rdoOnLine")).checked;
   if (!rdoOffLine && !rdoOnLine)
    {
        args.IsValid = false;
    }
}
function cvRequiredFieldSocietyAssociation(source, args) {
    var rdoC18Member = document.getElementById(GetClientId("rdoC18Member")).Checked;
    var ddlSocietyAssociation = document.getElementById(GetClientId("ddlSocietyAssociation")).selectedIndex;
   if (rdoC18Member && ddlSocietyAssociation==0)
    {
        args.IsValid = false;
    }
}
//26/07/2011  STORY354        WBO, NCS End

//02/08/2011  STORY362        WBO, NCS Start
function cvRequiredAffiliatedInstitution(source, args){
 var txtAffiliation = trim(document.getElementById(GetClientId("txtinstitution")).value);
    if (txtAffiliation == "")
    {
        args.IsValid = false;
    }
}
function cvRequiredAffiliatedInstitution1(source, args){
 var txtAffiliation = trim(document.getElementById(GetClientId("txtinstitution1")).value);
    if (txtAffiliation == "")
    {
        args.IsValid = false;
    }
}
function cvRequiredAffiliatedInstitution2(source, args){
 var txtAffiliation = trim(document.getElementById(GetClientId("txtinstitution2")).value);
    if (txtAffiliation == "")
    {
        args.IsValid = false;
    }
}
function cvRequiredAffiliatedInstitution3(source, args){
 var txtAffiliation = trim(document.getElementById(GetClientId("txtinstitution3")).value);
    if (txtAffiliation == "")
    {
        args.IsValid = false;
    }
}
function cvRequiredAffiliatedInstitution4(source, args){
 var txtAffiliation = trim(document.getElementById(GetClientId("txtinstitution4")).value);
    if (txtAffiliation == "")
    {
        args.IsValid = false;
    }
}
function cvRequiredAffiliatedInstitution5(source, args){
 var txtAffiliation = trim(document.getElementById(GetClientId("txtinstitution5")).value);
    if (txtAffiliation == "")
    {
        args.IsValid = false;
    }
}
function cvRequiredDDLTitle(source, args) {
    var ddlTitle = document.getElementById(GetClientId("ddlMemberTitle")).selectedIndex;
    if (ddlTitle == 0)
    {
        args.IsValid = false;
    }
}
function cvRequiredDDLTitle1(source, args) {
    var ddlTitle = document.getElementById(GetClientId("ddlMemberTitle1")).selectedIndex;
    if (ddlTitle == 0)
    {
        args.IsValid = false;
    }
}
function cvRequiredDDLTitle2(source, args) {
    var ddlTitle = document.getElementById(GetClientId("ddlMemberTitle2")).selectedIndex;
    if (ddlTitle == 0)
    {
        args.IsValid = false;
    }
}
function cvRequiredDDLTitle3(source, args) {
    var ddlTitle = document.getElementById(GetClientId("ddlMemberTitle3")).selectedIndex;
    if (ddlTitle == 0)
    {
        args.IsValid = false;
    }
}
function cvRequiredDDLTitle4(source, args) {
    var ddlTitle = document.getElementById(GetClientId("ddlMemberTitle4")).selectedIndex;
    if (ddlTitle == 0)
    {
        args.IsValid = false;
    }
}
function cvRequiredDDLTitle5(source, args) {
    var ddlTitle = document.getElementById(GetClientId("ddlMemberTitle5")).selectedIndex;
    if (ddlTitle == 0)
    {
        args.IsValid = false;
    }
}
//02/08/2011  STORY362        WBO, NCS End
function CardVerificationMinimum_ClientValidate(source, args) {

    var txtPayCardVerification = trim(document.getElementById(GetClientId("txtPayCardVerification")).value);
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;

    if ((x == "false") && ((txtPayCardVerification == "") || (txtPayCardVerification.length < 3))) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}

function DiscountCodeAlphanumeric_ClientValidate(source, args) {
    args.IsValid = true;

    var txtJnlDiscount = document.getElementById(GetClientId("txtJnlDiscount"));

    txtJnlDiscount.value = trim(txtJnlDiscount.value);

    if (txtJnlDiscount.value != "") {
        if (!isAlphaNumeric(txtJnlDiscount.value)) {
            args.IsValid = false;
        }
    }
}

function CardNumberAlphanumeric_ClientValidate(source, args) {
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    var txtPayCardNumber = trim(document.getElementById(GetClientId("txtPayCardNumber")).value);

    if ((txtPayCardNumber.length > 0) && (!isAlphaNumeric(txtPayCardNumber))) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}

function CardholderNameAlphanumeric_ClientValidate(source, args) {
    args.IsValid = true;

    var txtPayCardHolderName = document.getElementById(GetClientId("txtPayCardHolderName"));

    txtPayCardHolderName.value = trim(txtPayCardHolderName.value);

    if (txtPayCardHolderName.value != "") {
        if (!isAlphaNumericWithPunctuations(txtPayCardHolderName.value)) {
            args.IsValid = false;
        }
    }
}

function WileyRefInvalid_ClientValidate(source, args) {
    args.IsValid = true;

    var txtPayCustomerNo = document.getElementById(GetClientId("txtPayCustomerNo"));
    var radPayOrderType2 = document.getElementById(GetClientId("radPayOrderType2"));

    txtPayCustomerNo.value = trim(txtPayCustomerNo.value);

    if ((radPayOrderType2.checked && txtPayCustomerNo.value == "") || (radPayOrderType2.checked && txtPayCustomerNo.value != "" && isNaN(txtPayCustomerNo.value))) 
    {
            args.IsValid = false;
    }
}


function GstNumberInvalid_ClientValidate(source, args) {
    args.IsValid = true;

    var ddlCountry = document.getElementById(GetClientId("ddlCountry"));
    var txtGstNumber = document.getElementById(GetClientId("txtGstNumber"));
    var radPayGstRegYes = document.getElementById(GetClientId("radPayGstRegYes"));

    if (ddlCountry.options[ddlCountry.selectedIndex].text == "Australia" ||
        ddlCountry.options[ddlCountry.selectedIndex].text == "Canada") {
        txtGstNumber.value = trim(txtGstNumber.value);
        if ((radPayGstRegYes.checked && txtGstNumber.value == "") || (radPayGstRegYes.checked && txtGstNumber.value != "" && isNaN(txtGstNumber.value))) 
        {
                args.IsValid = false;
        }
    }
}

function CardExpiryInvalid_ClientValidate(source, args) {
    args.IsValid = true;

    var ddlMonth = document.getElementById(GetClientId("ddlMonth"));
    var ddlYear = document.getElementById(GetClientId("ddlYear"));

    var currentDate = new Date();
    var currYear = currentDate.getFullYear();
    var currMonth = currentDate.getMonth();

    if (ddlMonth.value != "-1" && ddlYear.value != "-1") {
        
        if (ddlMonth.value <= currMonth+1 &&
            ddlYear.value <= currYear) {
            args.IsValid = false;
        }
    }
}

function CardVerificationInvalid_ClientValidate(source, args) {
    args.IsValid = true;
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    var txtPayCardVerification = trim(document.getElementById(GetClientId("txtPayCardVerification")).value);
    if ((x == "false") && (txtPayCardVerification.length >= 3) && (isNaN(txtPayCardVerification))) {
            args.IsValid = false;
        }
    }

function CardNumberVerificationMinimum_ClientValidate(source, args) {
    args.IsValid = true;
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    var txtPayCardNumber = trim(document.getElementById(GetClientId("txtPayCardNumber")).value);
    if ((x == "false") && (txtPayCardNumber == "")) {
        args.IsValid = false;
    }
}
function CardHolderNameVerificationMinimum_ClientValidate(source, args) {
    args.IsValid = true;
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    var txtPayCardHolderName = trim(document.getElementById(GetClientId("txtPayCardHolderName")).value);
    if ((x == "false") && (txtPayCardHolderName == "")) {
        args.IsValid = false;
    }
}



function ConfirmEmailInvalid_ClientValidate(source, args) {
    args.IsValid = true;

    var txtEmail1 = trim(document.getElementById(GetClientId("txtemailaddress1")).value);
    
    if ((txtEmail1.length >= 4) && (!isValidEmail(txtEmail1))) {
            args.IsValid = false;
        }
}


function EmailInvalid_ClientValidate(source, args) {
    args.IsValid = true;

    var txtEmail = trim(document.getElementById(GetClientId("txtemailaddress")).value);
    
    if ((txtEmail.length >= 4) && (!isValidEmail(txtEmail))) {
            args.IsValid = false;
        }
}

function EmailMismatch_ClientValidate(source, args) {
    args.IsValid = true;

    var txtEmail = trim(document.getElementById(GetClientId("txtemailaddress")).value);
    var txtEmailVerify = trim(document.getElementById(GetClientId("txtemailaddress1")).value);


    if ((txtEmail.length >= 4) && (txtEmailVerify.length >= 4) && isValidEmail(txtEmail) && (txtEmail != txtEmailVerify)) {
                args.IsValid = false;
    }
}

function popUp(URL) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=350,height=450,left = 490,top = 262');");
}

function isAlphaNumericWithPunctuations(str) {
    var re = /[^a-zA-Z0-9 \.\?\!\:\;\-\_\#\%\|\&\*\+\~\^\<\>\=\@\(\)\[\]\'\"\/\,\{\}]/g;
    if (re.test(str)) return false;
    return true;
}

function isAlphaNumeric(str) {
    var re = /[^a-zA-Z0-9 ]/g;
    if (re.test(str)) return false;
    return true;
}

function CheckAmendSubscription() {
    Page_ClientValidate();

    if (Page_IsValid) {
        //Only execute when all client validation has done.
        var boolAdmin = document.getElementById(GetClientId("hdnMemberAdmin")).value.toLowerCase();
        if (boolAdmin == "false") {
            var t = document.getElementById(GetClientId("chkchgsub")).checked;
            if (!t) {
                var x = confirm("Do you want to also update your subscription information?");
                if (x) {
                    document.getElementById(GetClientId("chkchgsub")).checked = true;
                }
            }
        }
        return true;
    }
    else {
        return false;
    }
}

function ValidateRequiredFieldsMemberUpdate(source, args) {
    var xx1 = trim(document.getElementById(GetClientId("txtfirstname")).value);
    var xx2 = trim(document.getElementById(GetClientId("txtsurname")).value);
    var xx3 = trim(document.getElementById(GetClientId("txtaddress1")).value);
    var xx4 = trim(document.getElementById(GetClientId("txttown")).value);
    var xx5 = trim(document.getElementById(GetClientId("ddlCountry")).value);
    var xx6 = trim(document.getElementById(GetClientId("txtemailaddress")).value);
    var xx7 = trim(document.getElementById(GetClientId("txtpassword")).value);
    var xx8 = trim(document.getElementById(GetClientId("txtpassword1")).value);
    var xx = document.getElementById(GetClientId("hdnMemberType")).value;

    if (xx == "e") {
        xx7 = "       ";
        xx8 = "       ";
    }
    if ((xx1 == "") && (xx2 == "") && (xx3 == "") && (xx4 == "") && (xx5 == 0) && (xx6 == "") && (xx7 == "") && (xx8 == "")) {
        document.getElementById(GetClientId("hdnMandatoryBlank")).value = "true";
        args.IsValid = false;
    }
    else {
        document.getElementById(GetClientId("hdnMandatoryBlank")).value = "false";
        args.IsValid = true;
    }
}

function ValidateMemberUpdateFirstname(source, args) {
    var xx = trim(document.getElementById(GetClientId("txtfirstname")).value);
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    if ((x=="false") && (xx == "")) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}


function ValidateMemberUpdateSurname(source, args) {
    var xx = trim(document.getElementById(GetClientId("txtsurname")).value);
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    if ((x == "false") && (xx == "")) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}

function ValidateMemberUpdateAddress1(source, args) {
    var xx = trim(document.getElementById(GetClientId("txtaddress1")).value);
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    if ((x == "false") && (xx == "")) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}

function ValidateMemberUpdateTown(source, args) {
    var xx = trim(document.getElementById(GetClientId("txttown")).value);
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    if ((x == "false") && (xx == "")) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}

function ValidateMemberUpdateCountry(source, args) {
    var xx = trim(document.getElementById(GetClientId("ddlCountry")).value);
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    if ((x == "false") && (xx == 0)) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}

function ValidateMemberUpdateEmailLength(source, args) {
    var xx = trim(document.getElementById(GetClientId("txtemailaddress")).value);
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    if ((x == "false") && ((xx == "") ||(xx.length < 4))) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}

function ValidatePasswordLength(source, args) {
    var xx = trim(document.getElementById(GetClientId("txtpassword")).value);
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    if ((x == "false") && ((xx == "") || (xx.length < 6))) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}


function ValidateConfirmPasswordLength(source, args) {
    var xx = trim(document.getElementById(GetClientId("txtpassword1")).value);
    var x = document.getElementById(GetClientId("hdnMandatoryBlank")).value;
    if ((x == "false") && ((xx == "") || (xx.length < 6))) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}


function CheckEmail(source, args) {
    var x = trim(document.getElementById(GetClientId("txtemailaddress")).value);
    var memID = trim(document.getElementById(GetClientId("hdnMemberId")).value);
    var postBody = "{email:'" + x + "', memberID:'" + memID + "'}";

    new Ajax.Request('/WebService/validators.asmx/ValidateMemberEmail',
	  {
	      postBody: postBody,
	      asynchronous: false,
	      method: 'post', contentType: 'application/json; charset=utf-8', dataType: "json",
	      onSuccess: function(transport) {
	          var json = transport.responseText.evalJSON(true);
	          var response = json.d;
	          if (response == 0) {
	              args.IsValid = true;
	          }
	          else {
	              args.IsValid = false;
	          }
	      },
	      onFailure: function() {
	          args.IsValid = false;
	      }
	  });
}


// 24/07/2009  WO091.R01  ends

function SetPageDefaultTrue()
{
       for(i = 0; i < document.forms[0].elements.length; i++)
        {
            elm = document.forms[0].elements[i];
            if (elm.type == "textarea") 
            {
               elm.value = ' ';
            }
        }
}
    
    
function checkMaxLen(txt,maxLen) 
{
        try
        {
            if(txt.value.length > (maxLen-1)) 
            {
                var cont = txt.value;
                txt.value = cont.substring(0,(maxLen -1));
                return false;
            };
         }
         catch(e)
         {}
}


function isValidEmail(txt_email) {
    var emailFilter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;    
    //var emailFilter = /^\w+([-+.!#$%&'*/=?^`{|}~]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)+$/;    
    
    return emailFilter.test(txt_email);
}

function ValidateEmail(source, args)
{
  // 08/04/2009   WO088.R01.P02   JJL,NCS    Added condition to validate email
  var x = trim(document.getElementById(GetClientId("txtemailaddress")).value);
  //23/10/2011  STORY437 starts
  if (x == "")
  {
   args.IsValid = false;
   if (!args.IsValid) source.errormessage = "Please enter Email.";
  }
  else
  {
      if (x.length < 5 )
      {
       args.IsValid = false;
      }
      else if ((x.length >= 5) && (!isValidEmail(x))) {
          args.IsValid = false;
      }
      else {
          args.IsValid = true;
      }
  }
  //23/10/2011  STORY437 End
}
function ValidatePassword(source, args)
{
  // 06/04/2009   WO088.R01.P01   JJL,NCS    Condition added to check for password min. and max. length.
  var x = trim(document.getElementById(GetClientId("txtpassword")).value);
  if ((x.length > 0) && (x.length < 6)) {
      args.IsValid = false;
  }
  else {
      args.IsValid = true;
  }
}


function ValidateConfirmEmail(source, args)
{
    // 08/04/2009   WO088.R01.P02   JJL,NCS    Added condition to validate email
    var x = trim(document.getElementById(GetClientId("txtemailaddress1")).value);
    if ((x.length > 0) && (!isValidEmail(x))) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}


function ValidateConfirmPassword(source, args)
{
  // 06/04/2009   WO088.R01.P01   JJL,NCS    Condition added to check for password min. and max. length.
  var x = trim(document.getElementById(GetClientId("txtpassword1")).value);
  if ((x.length > 0) && (x.length < 6)) {
      args.IsValid = false;
  }
  else {
      args.IsValid = true;
  }
}

function ValidateCompareEmail(source, args)
{
  var e1 = document.getElementById(GetClientId("txtemailaddress")).value;
  var e2 = document.getElementById(GetClientId("txtemailaddress1")).value;
  if ((e1 != "") && (e2 != ""))
  {  
    args.IsValid = e1 == e2;
  }
  else
  {
  args.IsValid = true;
  }
}

function ValidateComparePassword(source, args)
{
  var p1 = trim(document.getElementById(GetClientId("txtpassword")).value);
  var p2 = trim(document.getElementById(GetClientId("txtpassword1")).value);
  if ((p1.length >= 6) && (p2.length >= 6))
  {  
    args.IsValid = p1 == p2;
  }
  else
  {
  args.IsValid = true;
  }
}

function ValidateTitle(source, args)
{
  args.IsValid = document.getElementById(GetClientId("txttitle")).value != ""; 
}
function ValidateFirstname(source, args)
{

  args.IsValid = document.getElementById(GetClientId("txtfirstname")).value != ""; 
}
function ValidateLastname(source, args)
{
  args.IsValid = document.getElementById(GetClientId("txtlastname")).value != ""; 
}

function ValidateAddress1(source, args)
{
  args.IsValid = document.getElementById(GetClientId("txtaddress1")).value != ""; 
}

function ValidateAddress2(source, args)
{
  args.IsValid = document.getElementById(GetClientId("txtaddress2")).value != ""; 
}
function ValidatePostCode(source, args)
{
  args.IsValid = document.getElementById(GetClientId("txtpostcode")).value != ""; 
}

function ValidateTitle(source, args)
{
  args.IsValid = document.getElementById(GetClientId("txttitle")).value != ""; 
}

function ValidateDescription(source, args)
{
  args.IsValid = document.getElementById(GetClientId("txtdescription")).value != "";
}
function ValidateChairpersonEmail(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtemail")).value != "";
}
function ValidateEmail1(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtemail1")).value != "";
}
function ValidateEmail2(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtemail2")).value != "";
}
function ValidateEmail3(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtemail3")).value != "";
}
function ValidateEmail4(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtemail4")).value != "";
}
function ValidateEmail5(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtemail5")).value != "";
}
function ValidateEmail6(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtemail6")).value != "";
}
function ValidateMemberTitle1(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtmembertitle1")).value != "";
}
function ValidateMemberTitle2(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtmembertitle2")).value != "";
}
function ValidateMemberTitle3(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtmembertitle3")).value != "";
}
function ValidateMemberTitle4(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtmembertitle4")).value != "";
}
function ValidateMemberTitle5(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtmembertitle5")).value != "";
}
function ValidateMemberTitle6(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtmembertitle6")).value != "";
}
function ValidateFirstName1(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtfirstname1")).value != "";
}
function ValidateFirstName2(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtfirstname2")).value != "";
}
function ValidateFirstName3(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtfirstname3")).value != "";
}
function ValidateFirstName4(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtfirstname4")).value != "";
}
function ValidateFirstName5(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtfirstname5")).value != "";
}
function ValidateFirstName6(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtfirstname6")).value != "";
}
function ValidateLastName1(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtlastname1")).value != "";
}
function ValidateLastName2(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtlastname2")).value != "";
}
function ValidateLastName3(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtlastname3")).value != "";
}
function ValidateLastName4(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtlastname4")).value != "";
}
function ValidateLastName5(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtlastname5")).value != "";
}
function ValidateLastName6(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtlastname6")).value != "";
}
function ValidatePTitle1(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtptitle1")).value != "";
}
function ValidatePTitle2(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtptitle2")).value != "";
}
function ValidatePTitle3(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtptitle3")).value != "";
}
function ValidatePTitle4(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtptitle4")).value != "";
}
function ValidateAbstract1(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtabstract1")).value != "";
}
function ValidateAbstract2(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtabstract2")).value != "";
}
function ValidateAbstract3(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtabstract3")).value != "";
}
function ValidateAbstract4(source, args) {
    args.IsValid = document.getElementById(GetClientId("txtabstract4")).value != "";
}

function ValidateEmailTitleRequired(source, args) {

    var emailTitle = trim(document.getElementById(GetClientId("emailtitle")).value);
    if (emailTitle == "")
    {
        args.IsValid = false;
    }
}
function ValidateEmailTitleMinimum(source, args) {
    var emailTitle = trim(document.getElementById(GetClientId("emailtitle")).value);
    if (emailTitle.length != "" && emailTitle.length < 2)
    {
        args.IsValid = false;
    }
}
function ValidateEmailTypeRequired(source, args) {
    var chkEBulletin = document.getElementById(GetClientId("chkeBulletin")).checked;
    var chkCustomEmail = document.getElementById(GetClientId("chkCustomEmail")).checked;
    if (!chkCustomEmail && !chkEBulletin)
    {
        args.IsValid = false;
    }
    
}
function ValidateEmailContentRequired(source, args) {
var emailContent = trim(document.getElementById(GetClientId("emailcontent")).value);
    
    if (emailContent=="")
    {
        args.IsValid = false;
    }
}
function ValidateEmailContentMax(source, args) {
    var emailContent = document.getElementById(GetClientId("emailcontent")).value;
    if (emailContent.length > 15000)
    {
        args.IsValid = false;
    }
}
function ValidateSendingDateSyntax(source, args) {
var date_now = new Date();
    var date_sending ;
    var send_year = document.getElementById(GetClientId("startyear")).value;
    var send_month = document.getElementById(GetClientId("startmonth")).value;
    var send_day = document.getElementById(GetClientId("startday")).value;
    //alert(send_year+'/'+send_month+'/'+send_day);
//    if (document.getElementById("ctl00_ctl00_ContentPlaceHolderBSECSMaster_ContentPlaceHolderMainMaster_startyear").selectedIndex > 0 && document.getElementById("ctl00_ctl00_ContentPlaceHolderBSECSMaster_ContentPlaceHolderMainMaster_startmonth").selectedIndex > 0 && document.getElementById("ctl00_ctl00_ContentPlaceHolderBSECSMaster_ContentPlaceHolderMainMaster_startday").selectedIndex > 0)
//    {
//        args.IsValid = false;
//        return;
//    }
    if (!isDate(send_day+'/'+send_month+'/'+send_year) && !isNaN(send_year) && !isNaN(send_day) && !isNaN(send_month))
    {
        args.IsValid = false;
    }
}
/* ----------------- */
/**
 * DHTML date validation script for dd/mm/yyyy. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}


function validateInteger( strValue ) {
 var objRegExp  = /(^-?\d\d*$)/;

  //check for integer characters
  return objRegExp.test(strValue);
}


function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
//		alert("The date format should be : dd/mm/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
//		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
//		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
//		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
//		alert("Please enter a valid date")
		return false
	}
return true
}

function ValidateForm(){
	var dt=document.frmSample.txtDate
	if (isDate(dt.value)==false){
		dt.focus()
		return false
	}
    return true
 }


/*  -----------------*/

function cvValidateRequiredTitle(source, args) {
    //var txttitle = document.getElementById("ctl00_ctl00_ContentPlaceHolderBSECSMaster_ContentPlaceHolderMainMaster_txtTitle").value;
    var txttitle = document.getElementById(GetClientId("txtTitle")).value;
    //alert('client side validation');
    if (txttitle == "")
    {
        args.IsValid = false;
    }
}
function cvValidateRequiredFirstname(source, args) {
    //var txtfirstname = document.getElementById("ctl00_ctl00_ContentPlaceHolderBSECSMaster_ContentPlaceHolderMainMaster_txtFirstname").value;
    var txtfirstname = document.getElementById(GetClientId("txtFirstname")).value;
    if (txtfirstname == "")
    {
        args.IsValid = false;
    }
}
function cvValidateRequiredSurname(source, args) {
    //var txtsurname = document.getElementById("ctl00_ctl00_ContentPlaceHolderBSECSMaster_ContentPlaceHolderMainMaster_txtSurname").value;
    var txtsurname = document.getElementById(GetClientId("txtSurname")).value;
    if (txtsurname == "")
    {
        args.IsValid = false;
    }
}
function cvValidateRequiredOrganisation(source, args) {
    var txtorganisation = document.getElementById(GetClientId("txtOrganisation")).value;//document.getElementById("ctl00_ctl00_ContentPlaceHolderBSECSMaster_ContentPlaceHolderMainMaster_txtOrganisation").value;
    if (txtorganisation == "")
    {
        args.IsValid = false;
    }
//    else if (!isAlphaNumeric(txtorganisation))
//    {
//        args.IsValid = false;
//    }
}
function cvValidateRequiredAddress1(source, args) {
    var txtaddress1 = document.getElementById(GetClientId("txtAddress1")).value;
    if (txtaddress1 == "")
    {
        args.IsValid = false;
    }
}
function cvValidateRequiredAddress2(source, args) {
    var txtaddress2 = document.getElementById(GetClientId("txtAddress2")).value;
    if (txtaddress2 == "")
    {
        args.IsValid = false;
    }
}
function cvValidateRequiredPostCode(source, args) {
    var txtpostcode = document.getElementById(GetClientId("txtPostcode")).value;
    if (txtpostcode == "")
    {
        args.IsValid = false;
    }
}
function cvValidateRequiredCountry(source, args) {
    var ddlcountry = document.getElementById(GetClientId("ddlCountry")).selectedIndex;
    if (ddlcountry == 0)
    {
        args.IsValid = false;
    }
}
function cvValidateRequiredEmail(source, args) {
    var txtemail = document.getElementById(GetClientId("txtEmailAddress")).value;
    args.IsValid = true;
    if (txtemail == "")
    {
        args.IsValid = false;
    }
    if (!isValidEmail(txtemail))
    {
        args.IsValid = false;
    }
}
function cvValidateSameEmail(source, args) {
    var txtemail = document.getElementById(GetClientId("txtEmailAddress")).value;
    var txtemailconfirm = document.getElementById(GetClientId("txtEmailAddressConfirm")).value;
    
    if (txtemail != "" && txtemailconfirm != txtemail)
    {
        args.IsValid = false;
    }
}
function cvValidateMembership(source, args) {
    var chkbsecsmember = document.getElementById(GetClientId("rdoBSECSMember")).checked;
    var chkc18member = document.getElementById(GetClientId("rdoC18Member")).checked;
    var chknonmember = document.getElementById(GetClientId("rdoNonMember")).checked;
    if (!chkbsecsmember && !chkc18member && !chknonmember)
    {
        args.IsValid = false;
    }
}
function cvValidateAssociation(source, args) {
    var chkc18member = document.getElementById(GetClientId("rdoC18Member")).checked;
    var txtassociation = document.getElementById(GetClientId("txtSocietyAssociation")).value;
    if (chkc18member && txtassociation == "")
    {
        args.IsValid = false;
    }
//    else if (chkc18member && !isAlphaNumeric(txtassociation))
//    {
//        args.IsValid = false;
//    }
}
function cvValidateConferenceFee(source, args) {
    var chkdiscountedconffee = document.getElementById(GetClientId("rdoDiscountedConfFee")).checked;
    var chkregularconffee = document.getElementById(GetClientId("rdoRegularConfFee")).checked;
    if (!chkdiscountedconffee && !chkregularconffee)
    {
        args.IsValid = false;
    }
}

function cvValidateCompanion(source, args) {
    var chktwinnonpaying = document.getElementById(GetClientId("rdoTwinNotPaying")).checked;
    var chktwinpaying = document.getElementById(GetClientId("rdoTwinPaying")).checked;    
    if (chktwinnonpaying || chktwinpaying)
    {
        var txtcompanion = document.getElementById(GetClientId("txtCompanionName")).value;
    }  
    if ((chktwinnonpaying || chktwinpaying) && txtcompanion == "")
    {
        args.IsValid = false;
    }  
    else if ((chktwinnonpaying || chktwinpaying) && !isAlphaNumeric(txtcompanion))
    {
        args.IsValid = false;
    }
    else if ((chktwinnonpaying || chktwinpaying) && txtcompanion != "" && !isAlphaNumeric(txtcompanion))
    {
        args.IsValid = false;
    }
}
function cvValidateCompanionEmail(source, args) {
    var chktwinnonpaying = document.getElementById(GetClientId("rdoTwinNotPaying")).checked;
    var chktwinpaying = document.getElementById(GetClientId("rdoTwinPaying")).checked;
    var txtcompanionemail = document.getElementById(GetClientId("txtCompanionEmail")).value;
    if ((chktwinnonpaying || chktwinpaying) && (txtcompanionemail == "" || !isValidEmail(txtcompanionemail)))
    {
        args.IsValid = false;
    } 
}
function cvValidateIndividualMeals(source, args) {
    var chktwinnonpaying = document.getElementById(GetClientId("rdoSelectMeals")).checked;
    var chkmeal1 = document.getElementById(GetClientId("chkDinner5Jan")).checked;
    var chkmeal2 = document.getElementById(GetClientId("chkBreakfast6Jan")).checked;
    var chkmeal3 = document.getElementById(GetClientId("chkLunch6Jan")).checked;
    var chkmeal4 = document.getElementById(GetClientId("chkBreakfast7Jan")).checked;
    var chkmeal5 = document.getElementById(GetClientId("chkLunch7Jan")).checked;
    var chkmeal6 = document.getElementById(GetClientId("chkAnnualDinner")).checked;
    if (chktwinnonpaying && !chkmeal1 && !chkmeal2 && !chkmeal3 && !chkmeal4 && !chkmeal5 && !chkmeal6)
    {
        args.IsValid = false;    
    }    
}

/* 27/01/2012 JJL,NCS STORY510 Starts */
function cvValidatePGConferenceFee(source, args) {
    var rdoRegularConfFeeAndDinner = document.getElementById(GetClientId("rdoRegularConfFeeAndDinner")).checked;
    var rdoRegularConfFee = document.getElementById(GetClientId("rdoRegularConfFee")).checked;
    if (!rdoRegularConfFee && !rdoRegularConfFeeAndDinner)
    {
        args.IsValid = false;
    }
}

function cvValidatePGIndividualMeals(source, args) {
    var chknomeal = document.getElementById(GetClientId("chkNoMealsRequired")).checked;
    var chkallmeal = document.getElementById(GetClientId("chkAllMealsIncluded")).checked;
    var chkmeal2 = document.getElementById(GetClientId("rdoMeals13th")).checked;
    var chkmeal3 = document.getElementById(GetClientId("rdoMeals14th")).checked;
    if (!chknomeal && !chkallmeal && !chkmeal2 && !chkmeal3)
    {
        args.IsValid = false;    
    }    
}

function cvValidatePGAccommodation(source, args) {
    var chknoaccomm = document.getElementById(GetClientId("chkNoAccommodation")).checked;
    var chkacc13th = document.getElementById(GetClientId("chkAccommodation13th")).checked;
    var chkacc14th = document.getElementById(GetClientId("chkAccommodation14th")).checked;
    if (!chknoaccomm && !chkacc13th && !chkacc14th)
    {
        args.IsValid = false;    
    }    
}
/* 27/01/2012 JJL,NCS STORY510 End */

function cvValidateSpecialRequirementsMax(source, args) {
    var txtspecialrequirements = document.getElementById(GetClientId("txtSpecialRequirements")).value;
    if (txtspecialrequirements.length > 1000)
    {
        args.IsValid = false;    
    }    
}

function cvValidateSpecialDietMax(source, args) {
    var txtspecialdiet = document.getElementById(GetClientId("txtSpecialDiet")).value;
    if (txtspecialdiet.length > 1000)
    {
        args.IsValid = false;    
    }    
}
function cvValidateSpecialDietCharacters(source, args) {
    var txtspecialdiet = document.getElementById(GetClientId("txtSpecialDiet")).value;
    if (!isAlphaNumericWithPunctuations(txtspecialdiet))
    {
        args.IsValid = false;    
    }  
}
function cvValidateSpecialRequirementsCharacters(source, args) {
    var txtspecialrequirements = document.getElementById(GetClientId("txtSpecialRequirements")).value;
    if (!isAlphaNumericWithPunctuations(txtspecialrequirements))
    {
        args.IsValid = false;    
    } 
}
function ValidateEmailTitleCharacters(source, args) {
    var txtemailtitle = document.getElementById(GetClientId("emailtitle")).value;
    if (txtemailtitle !="" && !isAlphaNumeric(txtemailtitle))
    {
        args.IsValid = false;    
    } 
}


//29/11/2011 JJL,NCS STORY463 Starts
function GetTimeAndTimezoneAbbr(ccode) {
    var arrayTimezoneInfo = {
	"AF" : "AFT" ,"AL" : "CET" ,"DZ" : "CET" ,"AD" : "CET" ,"AO" : "WAT" ,"AI" : "AST" ,"AQ" : "WST" ,"AG" : "AST" ,"AR" : "ART" ,"AM" : "AMT" ,"AW" : "AST" ,"AU" : "CST" ,"AT" : "CET" ,"AZ" : "AZT" ,
	"BS" : "EST" ,"BH" : "AST" ,"BD" : "BST" ,"BB" : "AST" ,"BY" : "EET" ,"BE" : "CET" ,"BZ" : "CST" ,"BJ" : "WAT" ,"BM" : "AST" ,"BT" : "BTT" ,"BO" : "BOT" ,"BA" : "CET" ,"BW" : "CAT" ,"BR" : "BRT" ,
	"GB" : "GMT" ,"IO" : "IOT" ,"BN" : "BNT" ,"BG" : "EET" ,"BF" : "GMT" ,"BI" : "CAT" ,"KH" : "ICT" ,"CM" : "WAT" ,"CA" : "MST" ,"CV" : "CVT" ,"KY" : "EST" ,"CF" : "WAT" ,"TD" : "WAT" ,"CL" : "CLT" ,
	"CN" : "CST" ,"CX" : "CXT" ,"CC" : "CCT" ,"CO" : "COT" ,"KM" : "EAT" ,"CD" : "WAT" ,"CG" : "WAT" ,"CK" : "CKT" ,"CR" : "CST" ,"CI" : "GMT" ,"HR" : "CET" ,"CU" : "CST" ,"CY" : "EET" ,"CZ" : "CET" ,
	"DK" : "CET" ,"DJ" : "EAT" ,"DM" : "AST" ,"DO" : "AST" ,"TL" : "TLT" ,"EC" : "ECT" ,"EG" : "EET" ,"SV" : "CST" ,"GQ" : "WAT" ,"ER" : "EAT" ,"EE" : "EET" ,"ET" : "EAT" ,"FK" : "FKT" ,"FO" : "WET" ,
	"FJ" : "FJT" ,"FI" : "EET" ,"FR" : "CET" ,"GF" : "GFT" ,"PF" : "GAMT" ,"TF" : "CET" ,"GA" : "WAT" ,"GM" : "GMT" ,"GE" : "GET" ,"DE" : "CET" ,"GH" : "GMT" ,"GI" : "CET" ,"GR" : "EET" ,"GL" : "GMT" ,
	"GD" : "AST" ,"GP" : "AST" ,"GU" : "ChST" ,"GT" : "CST" ,"GG" : "GMT" ,"GN" : "GMT" ,"GW" : "GMT" ,"GY" : "GYT" ,"HT" : "EST" ,"HN" : "CST" ,"HK" : "HKT" ,"HU" : "CET" ,"IS" : "GMT" ,"IN" : "IST" ,
	"ID" : "WIT" ,"IR" : "IRST" ,"IQ" : "AST" ,"IE" : "GMT" ,"IM" : "GMT" ,"IL" : "IST" ,"IT" : "CET" ,"JM" : "EST" ,"JP" : "JST" ,"JE" : "EST" ,"JO" : "EET" ,"KZ" : "ALMT" ,"KE" : "EAT" ,"KI" : "LINT" ,
	"KP" : "KST" ,"KR" : "KST" ,"KW" : "AST" ,"KG" : "KGT" ,"LA" : "ICT" ,"LV" : "EET" ,"LB" : "EET" ,"LS" : "SAST" ,"LR" : "GMT" ,"LY" : "EET" ,"LI" : "CET" ,"LT" : "EET" ,"LU" : "CET" ,"MO" : "CT" ,
	"MK" : "CET" ,"MG" : "EAT" ,"MW" : "CAT" ,"MY" : "MYT" ,"MV" : "MVT" ,"ML" : "GMT" ,"MT" : "CET" ,"MH" : "MHT" ,"MQ" : "AST" ,"MR" : "GMT" ,"MU" : "MUT" ,"YT" : "EAT" ,"MX" : "CST" ,"FM" : "YAPT" ,
	"MD" : "EET" ,"MC" : "CET" ,"MN" : "HOVT" ,"ME" : "CET" ,"MS" : "AST" ,"MA" : "WET" ,"MZ" : "CAT" ,"MM" : "MMT" ,"NA" : "WAT" ,"NR" : "NRT" ,"NP" : "NPT" ,"NL" : "CET" ,"AN" : "AST" ,"NC" : "NCT" ,
	"NZ" : "NZDT" ,"NI" : "CST" ,"NE" : "WAT" ,"NG" : "WAT" ,"NU" : "NUT" ,"NF" : "NFT" ,"MP" : "ChST" ,"NO" : "CET" ,"OM" : "GST" ,"PK" : "PKT" ,"PW" : "PWT" ,"PS" : "EET" ,"PA" : "EST" ,"PG" : "PGT" ,
	"PY" : "PYT" ,"PE" : "PET" ,"PH" : "PHT" ,"PN" : "PST" ,"PL" : "CET" ,"PT" : "WET" ,"PR" : "AST" ,"QA" : "AST" ,"RE" : "RET" ,"RO" : "EET" ,"RU" : "ANAT" ,"RW" : "CAT" ,"AS" : "SST" ,"WS" : "SST" ,
	"SM" : "CET" ,"ST" : "GMT" ,"SA" : "AST" ,"SN" : "GMT" ,"RS" : "CET" ,"SC" : "SCT" ,"SL" : "GMT" ,"SG" : "SGT" ,"SK" : "CET" ,"SI" : "CET" ,"SB" : "SBT" ,"SO" : "EAT" ,"ZA" : "SAST" ,"GS" : "GST" ,
	"ES" : "CET" ,"LK" : "LKT" ,"BL" : "CST" ,"SH" : "GMT" ,"KN" : "AST" ,"LC" : "AST" ,"MF" : "AST" ,"PM" : "PMST" ,"VC" : "AST" ,"SD" : "EAT" ,"SR" : "SRT" ,"SJ" : "CET" ,"SZ" : "SAST" ,"SE" : "CET" ,
	"CH" : "CET" ,"SY" : "EET" ,"TW" : "CST" ,"TJ" : "TJT" ,"TZ" : "EAT" ,"TH" : "ICT" ,"TG" : "GMT" ,"TK" : "TKT" ,"TO" : "TOT" ,"TT" : "AST" ,"TN" : "CET" ,"TR" : "EET" ,"TM" : "TMT" ,"TC" : "EST" ,
	"TV" : "TVT" ,"UG" : "EAT" ,"UA" : "EET" ,"AE" : "GST" ,"US" : "EST" ,"UY" : "UYST" ,"UZ" : "UZT" ,"VU" : "VUT" ,"VA" : "CET" ,"VE" : "VET" ,"VN" : "ICT" ,"VG" : "AST" ,"VI" : "AST" ,"WF" : "WFT" ,
	"EH" : "WET" ,"YE" : "AST" ,"ZM" : "CAT" ,"ZW" : "CAT" };
    var currentTime = new Date()
    var hours = currentTime.getHours()
    var minutes = currentTime.getMinutes()
	var TimeAndtimezoneabbr = "";
        for (key in arrayTimezoneInfo)
	{
		if (key == ccode)
		{
			TimeAndtimezoneabbr = pad2(hours) + ':' + pad2(minutes) + ' ' + arrayTimezoneInfo[key];
			break 
		}
	}
	return TimeAndtimezoneabbr;
}
//29/11/2011 JJL,NCS STORY463 End

