window.addEvent('domready', function(){
    var validation = new FormCheck('main-form', {
        display : {
            errorsLocation : 1,
            indicateErrors : 1,
            showErrors: 0,
            keepFocusOnError: 0,
            checkValueIfEmpty: 1,
            tipsPosition: 'right',
            flashTips : true,
            fadeDuration : 500
        },
        'onValidateSuccess': function(){
            showExit = 0;
        }
    });

    if (Browser.Engine.trident === true) {
        if (document.id('submit-button')) {
            document.id('submit-button').addEvent('click', function(){
                if (validation.isFormValid()) {
                    showExit = 0;
                    document.id('main-form').submit();
                } else {
                    document.id('main-form').fireEvent('submit');
                }
            });
        }
    }
    
    document.getElements('a.popup').each(function(el){
        el.addEvent('click', function(e){
            Event.preventDefault(e);
            
            popUp(el.get('href'));
        });
    });
});

window.addEvent('load', function(){
    if (document.id('first_name')) {
        document.id('first_name').focus();
    }
});

function popUp(URL) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=300,left = 500,top = 500');");
}
