﻿/*Required for validating the ColorMatch Quiz Radio Button List and CheckBox List*/
function ValidateOptionList(src, arg) {
    var validator = document.getElementById(src.SourceID);
    var chk = document.getElementById(src.ControlID);
    var chkLista = chk.getElementsByTagName("input");
    for (var i = 0; i < chkLista.length; i++) {
   if (chkLista[i].checked) {
   arg.IsValid = true;
   return;
   }
}
arg.IsValid = false;
    /*arg.IsValid = false;*/
}

function ValidateShade(divID) {
    if (divID == "step1") {
        divID = "step1content";
    }
    else if (divID == "step2") {
        divID = "step1content";
    }
    else if (divID == "step3") {
        divID = "step2content";
     }
     else if (divID == "step4") {
        divID = "step3content";
    }
    var selectedItems = $("#" + divID + " input:checked");
    var formOutput="";
    $.each(selectedItems, function(i) {
        formOutput += $(this).attr("name") + ": " + $(this).val() + "; ";
    });
    if (formOutput == "") {
        return false;
    }
    else {
        return true;
    }
}

function ValidateAllShades() {
    if ((ValidateShade("step1content")) && (ValidateShade("step2content")) && (ValidateShade("step3content")) && (ValidateShade("step4content"))) {
        $('#errorStep4').hide();
         $('.errorcnt-box4').hide();
        testFormSubmit();
        return true;
    }
    else {
       // alert('Select a value');
        $('#errorStep4').show();
        $('.errorcnt-box4').show();
        return false;
    }
}
function DobClientValidation(source, args) {

    var monthCtrl = document.getElementById(source.MONTHCTRL);
    //var dayCtrl = document.getElementById(source.DAYCTRL);
    var yearCtrl = document.getElementById(source.YEARCTRL);
    //var txtDOBCtrl = document.getElementById(source.DOBCTRL);
    var month = monthCtrl.options[monthCtrl.selectedIndex].value;
   // var day = 1;
    var year = yearCtrl.options[yearCtrl.selectedIndex].value;

    if (month != 'Month' && year != 'Year') {
        args.IsValid = true;
        //txtDOBCtrl.value = day + '/' + month + '/' + year;

    }
    else
        args.IsValid = false;
}
function StateClientValidation(source, args) {

    var stateCtrl = document.getElementById(source.STATECTRL);
    var state = stateCtrl.options[stateCtrl.selectedIndex].value;


    if (state != 'state') {
        args.IsValid = true;
    }
    else
        args.IsValid = false;
}

function TipCategoryValidation(source, args) {
    var CategoryCtrl = document.getElementById(source.CATEGORYCTRL);
    var Category = CategoryCtrl.options[CategoryCtrl.selectedIndex].value;

   if (Category != '0') {
        args.IsValid = true;
    }
    else
        args.IsValid = false;
}

function TipDisclaimerValidation(source, args) {
    var Ctrl = document.getElementById(source.CTRL);
    if (Ctrl.checked) {
        args.IsValid = true;
    }
    else {
        args.IsValid = false;
    }
}

function TipLengthValidation(source, args) {
    var Ctrl = document.getElementById(source.CTRL);
    if (Ctrl.value.length > source.LEN) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}




