﻿// JScript File

$('input[highlight]').each(function() {
    if($(this).attr('highlight') == 1)
        highlight($(this),1);
});

$('#error-body').css('height','20px');

$('#div-buttons input').click(function() {
    var rc = 0;
    var $elements = $('#login input');
    $elements.each(function(index) {
        rc = rc + validateField($(this).attr('id'));
    });
    if(rc > 0) {
        $('#error-msg').html('Please enter your username/password.');
        $('#error-body').css('height','20px');
        $('.div-error').show();
    }
    tmp = validateRadioButtons('terms-required','sTerms'); //terms
    if(tmp==1 && rc!=0) {
        $('#error-msg').append('<br /><span style="padding-left: 20px;">Please read Terms and Conditions.</span>');
        $('#error-body').css('height','40px');
    }
    else if(tmp==1) {
        $('#error-msg').html('Please read Terms and Conditions.');    
        $('#error-body').css('height','20px');
        $('.div-error').show();
    }
    rc = rc + tmp;
    if(validateRadioButtons('adult-required','sAdult') > 0 && rc ==0) {
        $('#error-msg').html('Open only to adult smokers 18 years old or <span style="padding-left: 20px;">&nbsp;</span>older residing in the Philippines.');    
        $('#error-body').css('height','40px');
        window.location = 'AgeRestricted.aspx'; // redirect to under 18
        return false; }
    if(rc==0)
        return true;
    return false;
});

$rel = $('.div-error').attr('rel');
if ($rel == 1)
    $('.div-error').show();
else if ($rel > 1) {
    $('.div-error').show();
    $('#error-body').css('height',$rel+'px'); }