﻿/// <reference path="jquery-1.2.6.js"/>
Validators.init("error-input");

// tracking
$(function() {
    if (typeof (newsletterID) != "undefined") {
        var initialNewsletterValue = $('#' + newsletterID).attr("checked");
        var initialHcpValue = $('#' + hcpId).attr("checked");

        if (typeof (btnSubmitUpdate) != "undefined") {
            $('#' + btnSubmitUpdate).click(function() {
                var actualNewsletterValue = $('#' + newsletterID).attr("checked");
                var actualHcpValue = $('#' + hcpId).attr("checked");
                trackUpdate(initialNewsletterValue, actualNewsletterValue, initialHcpValue, actualHcpValue);

            });
        }
        /*
        if (typeof (btnSubmitRegister) != "undefined") {
        $('#' + btnSubmitRegister).click(function() {
        var actualNewsletterValue = $('#' + newsletterID).attr("checked");
        var actualHcpValue = $('#' + hcpId).attr("checked");
        trackUpdate(initialNewsletterValue, actualNewsletterValue, initialHcpValue, actualHcpValue);

            });
        }
        */
    }

    if (typeof (policyID) != "undefined") {
        $('#' + policyID).click(function() {
            if ($('#' + policyID).attr("checked")) {
                $('#' + textPolicyID).val($('#' + policyID).attr("checked"));
            }
            else {
                $('#' + textPolicyID).val('');
                $('#' + policyID, 'span').attr("class", "");
            }
        });
    }

    if (typeof (newsletterID) != "undefined" && typeof (optOutReasonId) != "undefined") {
        $('#' + newsletterID).click(function() {
            if ($('#' + newsletterID).attr("checked")) {
                $('#' + optOutReasonId).hide();
            }
            else {
                $('#' + optOutReasonId).show();
            }
        });
    }

});

function ToggleJobTitle(IsYes) {
    if (IsYes) {
        $("#" + businessPanelId).hide();
        $("#" + healthcarePanelId).show();
    }
    else {
        $("#" + healthcarePanelId).hide();
        $("#" + businessPanelId).show();
    }
}

// validate firstname is entered
function ValidateRequiredFirstName(source, args) {
    //alert('required firstname');
    args.IsValid = Validators.requiredField(firstNameId);
}

// validate firstname is alpha numeric field
function ValidateRegexFirstName(source, args) {
    //alert('regex firstname');
    args.IsValid = Validators.validateAlphaNum(firstNameId);
}

// validate lastname is entered
function ValidateRequiredLastName(source, args) {
    //alert('required lastname');
    args.IsValid = Validators.requiredField(lastNameId);
}

// validate lastname is alpha numeric field
function ValidateRegexLastName(source, args) {
    //alert('regex lastname');
    args.IsValid = Validators.validateAlphaNum(lastNameId);
}

// validate email address has been entered
function ValidateRequiredEmail(source, args) {
    //alert('required email');
    args.IsValid = Validators.requiredField(emailId);
}

// validate email is in the correct format
function ValidateRegexEmail(source, args) {
    //alert('regex email');
    args.IsValid = Validators.validateEmail(emailId);
}

// validate the password is formatted correctly
function ValidatePassword(source, args) {
    //alert('valid password');
    args.IsValid = Validators.validatePassword(passwordId);
}

// validate the password is formatted correctly
function ValidateRequiredPassword(source, args) {
    //alert('required password');
    args.IsValid = Validators.requiredField(passwordId);
}

// compare password fields
function ComparePass(source, args) {
    //alert('compare password');
    args.IsValid = Validators.comparePasswords(passwordId, confirmPasswordId);
}

// validate country has been selected
function ValidateRequiredCountry(source, args) {
    //alert('validate country')
    args.IsValid = Validators.requiredField(countryId);
}

// validate privacy checkbox
function ValidatePrivacyChecked(source, args) {
    args.IsValid = $('#' + textPolicyID).val();
    Validators.toggleClass(args.IsValid, "policy-checkbox-container");
}