/**
 * @author ajubert
 */
checkModalboxOverflow = function(){
    if ($('MB_window').getHeight() > document.viewport.getHeight()) {
        $('MB_content').setStyle({
            'height': (document.viewport.getHeight() - 40) + 'px'
        });
        Modalbox.resizeToContent();
    }
}
jQuery(document).ready(function(){
    // Création des liens modalbox
    var modalboxlinks = $$(".modalboxlink");
    if (modalboxlinks.size()) {
        modalboxlinks.invoke('observe', 'click', function(evt){
            if (Modalbox) {
                Modalbox.show(this.href, {
                    title: this.title,
                    closeValue:CloseStringValue+" &times;",
                    closeString:CloseStringValue,
                    width: 920,
                    params: {
                        'ajax': true
                    },
                    afterLoad: checkModalboxOverflow
                });
                Event.stop(evt);
            }
        })
    }
    // Création des liens popup
    var popuplinks = $$(".popuplink");
    if (popuplinks.size()) {
        popuplinks.invoke('observe', 'click', function(evt){
            if (Modalbox) {
                Modalbox.show(this.href, {
                    title: this.title,
                    closeValue:CloseStringValue+" &times;",
                    closeString:CloseStringValue,
                    width: 640,
                    params: {
                        'ajax': true
                    },
                    afterLoad: checkModalboxOverflow
                });
                Event.stop(evt);
            }
        })
    }
	// Création des liens type target
    var targetlinks = $$(".targetlink");
    if (targetlinks.size()) {
        targetlinks.invoke('writeAttribute', 'target', 'targetlink');
    }
    // Ajout des attributs target aux liens de navigation (car invalide en XHTML)
    if ($('bloglink')) 
        $('bloglink').writeAttribute('target', 'bloglink');
    if ($('midprolink')) 
        $('midprolink').writeAttribute('target', 'midprolink');
});
var keywordsFocus = function(el){
    if (el.value == DefaultSearchTextValue) {
        el.value = '';
    }
}
var keywordsBlur = function(el){
    if (el.value == '') {
        el.value = KeywordFieldValue;
    }
}
/* Chargement dynamique de l'image produit */
var swapProductZoom = function(url){
    var div_zoom = $$(".zoom div.main");
    if (div_zoom.size()) {
        div_zoom[0].setStyle({
            'background': 'url(' + url + ') no-repeat center'
        });
    }
}

