/**
* @fileOverview Js for affiliate register
*/
$(document).ready(function(){
    Whl.UA.initData();
    $('#submitBtn').click(function(event) {       
        if (Validate()) {
            $("#aForm").get(0).submit();
        }
        
    });
    $('#resetBtn').click(function(event) {
        $('#aForm').get(0).reset();
    });
    var country = Whl.getCookie('aff-country');
    if (country != null && country != '') {
        $('#aff-country').val(country);
    }
    $('#showHint').dialog({title: 'Help', bgiframe: false, autoOpen: false, height: 'auto', width: 300,
        buttons: {
            Close: function(){
                $('#showHint').dialog('close');
            }}
    });
    $(".showHintPass").click(function(){
        $("#showHint").show().dialog('open');
    });
});

/**
* Validate data
*
* @returns {Boolean}
*/
function Validate()
{
    var fields = [];
    fields.push(['cname',{blank:'Please enter the name.'}]);
    fields.push(['pname',{blank:'Please enter the contact person name.'}]);
    fields.push(['aff-location',{blank:'Please enter the address.'}]);
    fields.push(['aff-country',{blank:'Please enter the country.'}]);   
    fields.push(['email',{blank:'Please enter the email.', email:'Please enter the valid email.'}]);
    fields.push(['phone',{blank:'Please enter the phone.'}]);
    fields.push(['url',{blank:'Please enter the url.', domain:'Please enter the valid url.'}]);
    fields.push(['linkplace',{blank:'Please enter the place of link.'}]);
    fields.push(['validation',{blank:'Please enter the valid validation number.'}]);
    fields.push(['uxTerms', function(){               
                if(!$('#uxTerms').attr('checked'))
                    return false;
                return true;
    }, 'Please read and check the Affiliate terms & conditions.']);
    return Whl.validate(fields);
}
