var idTimeOut;
function addP(id, val, autoSubmit) {
	var obj = document.getElementById(id);
	if (parseInt(obj.value) > 0 || val > 0) {
    obj.value = parseInt(obj.value) + val;	
	}
	if (isNaN(parseInt(obj.value)))obj.value = 0;
 
	if (autoSubmit) {
		clearTimeout(idTimeOut);
		idTimeOut = setTimeout('submitPanier()', 2000);	
	}
}

function submitPanier() {
	document.getElementById('colonneDroiteForm').submit();
}

function swap(obj, src) {
	if (obj) {
		obj.src = src;
	}
}

/*********/
/* COVER */
/*********/
var popupCover = null;
var timeoutCover = null;
function ownWindowOpen(url, name, feature) {
	showCover();
	if (feature) {
		if (feature.indexOf('resizable') == -1) feature += ",resizable";
		if (feature.indexOf('scrollbars') == -1) feature += ",scrollbars";
		if (feature.indexOf('modal') == -1) feature += ",modal";
	} else {
		feature = "resizable,scrollbars,modal";
	}
	if (!name) name = 'POPUP';
	popupCover = window.open(url, name, feature);
	timeoutCover = window.setInterval('intervalCover()', 500);
	return false;
}

function intervalCover() {
	if (!popupCover || popupCover.closed) {
		window.clearInterval(timeoutCover);
		hideCover();
	}
}
function coverFocus(evt) {
    YAHOO.util.Event.stopEvent(evt);
    if (popupCover) popupCover.focus();
}
function showCover() {
    YAHOO.util.Dom.setStyle(document.body, "opacity", 0.5);
    document.body.style.backgroundColor = "#ddd";
    document.body.style.cursor = "wait";
    YAHOO.util.Event.addListener(document, 'click', coverFocus);
}
function hideCover() {
	YAHOO.util.Dom.setStyle(document.body, "opacity", "1");
	document.body.style.backgroundColor = "";
	document.body.style.cursor = "";
	YAHOO.util.Event.removeListener(document, 'click', coverFocus);
}


function AfficherPopup(cpt)
{
    var element1 = document.getElementById('popupFam_'+cpt);
    if (element1) {
    	element1.style.visibility = "visible";
    }
}
function AfficherPopupProduit(cpt)
{
    var element1 = document.getElementById('popupProduit_'+cpt);
    if (element1) {
    	element1.style.visibility = "visible";
    }
}
function AfficherAccesRayon(cpt)
{
    var element1 = document.getElementById('accesRayon_'+cpt);
    if (element1) {
    	element1.style.visibility = "visible";
    }
}
function CacherPopup(cpt)
{
    var element1 = document.getElementById('popupFam_'+cpt);
    if (element1) {
    	element1.style.visibility = "hidden";
    }
}
function CacherPopupProduit(cpt)
{
    var element1 = document.getElementById('popupProduit_'+cpt);
    if (element1) {
    	element1.style.visibility = "hidden";
    }
}
function CacherAccesRayon(cpt)
{
    var element1 = document.getElementById('accesRayon_'+cpt);
    if (element1) {
    	element1.style.visibility = "hidden";
    }
}

/************************/
/* Adresse livraison	*/
/************************/
function modifAdresseLivraison(){
	alert('Une commande est en cours avec cette adresse, pour tout changement d\'adresse pour cette commande, merci de prendre contact avec notre service client');
}