﻿//-----------------------------------------------------------------------------
// Fichier JS principal
// Pour le moment, y a pas grand chose, mais il serait bien de rassembler tous
// les trucs éparpillés au même endroit.
// Et surtout, virer tout ce qui ne sert plus à rien !!
//
// Dernière MAJ : 30/10/07
//-----------------------------------------------------------------------------

function info_popup(el, titre, lien){
    var pos = findPos(el);
    var win = new Window(
        {
            className : "alphacube",
            title : "Information",
            top : pos.y + 15, left : pos.x - 50, width : 250, height : 120,
            url : lien,
            showEffectOptions : {duration : 1.5}
        }
    )
    win.show();
}

//ouvrir une fenetre javascript
function ML_popup(el){
    var titre = el.title;
    var lien = el.href;
    var pos = findPos(el);
    var win = new Window(
        {
            className : "alphacube",
            title : "Détails du produit : " + titre,
            top : pos.y -100, left : pos.x - 550, width : 550, height : 20,
            url : lien,
            onComplete : function(){
                this.show();
                this.updateHeight();
            }
        }
    )
    //win.show();
    win.setAjaxContent(lien, win.options, true, true);
    return false;
}

//récupérer la position d'un élément
function findPos(el) {
	var x = y = 0;
	if (el.offsetParent) {
		x = el.offsetLeft;
		y = el.offsetTop;
		while(el = el.offsetParent) {
			x += el.offsetLeft;
			y += el.offsetTop;
		}
	}
	return {'x':x, 'y':y};
}

//function pour ajouter des caracteres d'echapement
function addslashes(ch) {
    ch = ch.replace(/\\/g,"\\\\")
    ch = ch.replace(/\'/g,"\\'")
    ch = ch.replace(/\"/g,"\\\"")
    return ch
}

// Ouverture d'un pop-up en cliquant sur une offre
function OpenPopup(url, name, mywidth, myheight) {
    name = "";
	window.open(url, name, 'height='+myheight+', width='+mywidth+', resizable=yes, scrollbars=yes, toolbar=yes, menubar=yes, status=yes, location=yes');
}

//modif pour ne plus avoir de bar d'outils
function OpenPopup(url, name, mywidth, myheight, toolbar) {
    name = "";
	window.open(url, name, 'height='+myheight+', width='+mywidth+', resizable=yes, scrollbars=yes, toolbar='+toolbar+', menubar='+toolbar+', status=yes, location='+toolbar);
}
