// Common namespace
if(typeof Common == 'undefined')
    Common = {}

Builder.dump();

Common.ajouter_favori = function(texte,url) {
    if (window.sidebar){
        window.sidebar.addPanel(texte, url,"");
    } else if ( document.all ){
        window.external.AddFavorite(url, texte);
    }
}

Common.displayCode = function() {
    $('codeRequest').style.display = 'none';
    $('codeResponse').style.display = 'block';

    if($('bulle1')!=null) {
        $('bulle1').style.display = 'none';
        $('bulle2').style.display = 'block';
    }
}

Common.setCurrentTab = function(tab,cleans) {
    $(tab).addClassName("current");

    for(var i=0;i<cleans.length;i++ ) {
        $(cleans[i]).removeClassName("current");
    }
}

Common.changeDivContent = function(div_id, target_url,afterFunc) {
    var url = target_url;
    new Ajax.Updater(div_id, url );

    if(afterFunc) afterFunc();
}

Common.testCode = function (frm,field){
    if(field == ''){
        alert('Veuillez inserer le code de réduction !');
    }else frm.submit();
}

Common.is_numeric = function (num){
    var exp = new RegExp("^[0-9-.]+$","g");
    return exp.test(num);
}

Common.testValue = function (val,mp,cd){
    if(mp == '') mp = 0;
    if(Common.is_numeric(val) && (Common.is_numeric(mp))){
        document.frmsteptwo.submit();
    } else {
        if(cd == '') alert('Date d\'expiration du code : Veuillez choisir une date pour l\'expiration du code');
        if(val == '') alert('Valeur de la réduction : \nUtiliser le point comme séparateur de décimal \n et/ou taper uniquement des chiffres')
        if(mp!=='' && !Common.is_numeric(mp)) alert('Minimum achat : Veullez mettre un chiffre seulement')
    }
} 