function contactErrorDecorator() {};

contactErrorDecorator.prototype = {
    start : function() {
        var errorUl = $('div#contact-form ul.jforms-error-list');
        if (errorUl.length == 0) {
            $('div#contact-form').prepend('<ul class="jforms-error-list"></ul>');
        } else {
            $('ul.jforms-error-list').html('');
        }
        $('ul.jforms-error-list').hide();
    },
    addError : function(control, messageType) {
        var message='';
        if (messageType == 1) {
            message = control.errRequired;
        } else if(messageType == 2) {
            message = control.errInvalid;
        } else {
            message = "Error on '"+control.label+"' field";
        }
        var item = '<li>'+message+'</li>';
        $('ul.jforms-error-list').append(item);
    },
    end : function() {
        var errorUl = $('div#contact-form ul.jforms-error-list');
        if (errorUl.length == 1) {
            errorUl.show();
            if (location.href.match('#contact-form') != null) {
                location.href = location.href;
            } else {
                location.href+= '#contact-form';
            }
        }
    }
};


function subscribeErrorDecorator() {};

subscribeErrorDecorator.prototype = {
    start : function() {
        var errorUl = $('div#signup-form ul.jforms-error-list');
        if (errorUl.length == 0) {
            $('div#signup-form').prepend('<ul class="jforms-error-list"></ul>');
        } else {
            $('ul.jforms-error-list').html('');
        }
        $('ul.jforms-error-list').hide();
    },
    addError : function(control, messageType) {
        var message='';
        if (messageType == 1) {
            message = control.errRequired;
        } else if(messageType == 2) {
            message = control.errInvalid;
        } else {
            message = "Error on '"+control.label+"' field";
        }
        var item = '<li>'+message+'</li>';
        $('ul.jforms-error-list').append(item);
    },
    end : function() {
        var errorUl = $('div#signup-form ul.jforms-error-list');
        if (errorUl.length == 1) {
            errorUl.show();
            if (location.href.match('#signup-form') != null) {
                location.href = location.href;
            } else {
                location.href+= '#signup-form';
            }
        }
    }
};


$(document).ready(function() {
    $('#video-bt a').click(function() {
        $('<object width="504" height="380">	<param name="allowfullscreen" value="true" />	<param name="allowscriptaccess" value="always" />	<param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=1991479&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" />	<embed src="http://vimeo.com/moogaloop.swf?clip_id=1991479&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="504" height="380"></embed></object>').modal({persist: true, closeTitle: 'Fermer'});
        return false;
    });
});
