
function refuser_touche_entree(event, function_to_launch_instead)
{
    // Compatibilité IE / Firefox
    if (!event && window.event) event = window.event;
    
    // IE
    if (event.keyCode == 13)
	{
        event.returnValue = false;
        event.cancelBubble = true;
		if (function_to_launch_instead!='') eval(function_to_launch_instead);
    }
    // DOM
    if (event.which == 13)
	{
        event.preventDefault();
        event.stopPropagation();
		if (function_to_launch_instead!='') eval(function_to_launch_instead);
    }
	
}

var chronos=new Array()
var chrono_index=0

function add_chrono(id,nb_seconde)
{
	chronos[chrono_index]=new Array(id,nb_seconde)
	chrono_index++
}

function start_chronos()
{
	var jour=0, heure=0, minute=0, seconde=0, html=''
	if (chrono_index>0)
	{
		for (i=0;i<chrono_index;i++)
		{
			chronos[i][1]--
			
			seconde=chronos[i][1]
			jour=Math.floor(seconde/86400)
			seconde=seconde-jour*86400
			heure=Math.floor(seconde/3600)
			seconde=seconde-heure*3600
			minute=Math.floor(seconde/60)
			seconde=seconde-minute*60
			
			if (jour>0) html=jour+'j '+heure+'h '+minute+'m '+seconde+'s '
			else if (heure>0) html=heure+'h '+minute+'m '+seconde+'s '
			else if (minute>0) html=minute+'m '+seconde+'s '
			else if (seconde>0) html=seconde+'s '
			else window.location.reload()

			document.getElementById('chrono'+chronos[i][0]).innerHTML=html
		}
		setTimeout("start_chronos()", 1000);
	}
}

function produit_zoom_image(id,width)
{
	//document.getElementById('produit_img_zoom').src='img_produit/'+(id%10)+'/L/'+id+'.jpg'
	//document.getElementById('loupe').style.width=Math.round(width*456/1000)
	
	html='<a href="img_produit/'+(id%10)+'/XL/'+id+'.jpg" rel="lytebox[produit]" title="'+produit_libelle+' - &copy; 2010 we-art-together.fr">'
	html+='<img src="img_produit/'+(id%10)+'/L/'+id+'.jpg" border="0" id="produit_img_zoom" width="'+Math.round(width*456/1000)+'">'
	html+='<div id="loupe" style="width: '+Math.round(width*456/1000)+'px;"></div></a>'
	
	document.getElementById('produit_zoom').innerHTML=html
	initLytebox()
}

function produit_switch_onglet(id)
{
	document.getElementById('produit_onglet'+id+'_content').className='on'
	document.getElementById('produit_onglet'+(1-id)+'_content').className='off'
	
	document.getElementById('produit_onglet'+id).className='produit_on'
	document.getElementById('produit_onglet'+(1-id)).className='produit_off'
}

function page_previous()
{
	window.history.back();
}

function page_next()
{
	window.history.forward();
}

function imprime_page()
{
	if (typeof(window.print)!='undefined') window.print();
}

var txt_size=0.95
var txt_size_min=0.85
var txt_size_max=1.95

function font_up()
{
	txt_size+=0.1
	if (txt_size>txt_size_max) txt_size=txt_size_max
	document.getElementById('produit_content').style.fontSize=txt_size+'em'
	document.getElementById('produit_content').style.lineHeight=(txt_size+0.55)+'em'
}

function font_down()
{
	txt_size-=0.1
	if (txt_size<txt_size_min) txt_size=txt_size_min
	document.getElementById('produit_content').style.fontSize=txt_size+'em'
	document.getElementById('produit_content').style.lineHeight=(txt_size+0.55)+'em'
}


// POPUP HomePage
var popup_width=600
var popup_height=400

function toggle(div_id)
{
	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' ) el.style.display = 'block';
	else el.style.display = 'none';
}

function blanket_size(popUpDivVar)
{
	if (typeof window.innerWidth != 'undefined') viewportheight = window.innerHeight;
	else viewportheight = document.documentElement.clientHeight;

	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) blanket_height = viewportheight;
	else if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) blanket_height = document.body.parentNode.clientHeight;
		 else blanket_height = document.body.parentNode.scrollHeight;

	var blanket = document.getElementById('blanket');
	blanket.style.height = blanket_height + 'px';
	var popUpDiv = document.getElementById(popUpDivVar);
	popUpDiv_height=(blanket_height-popup_height)/2;
	popUpDiv.style.top = popUpDiv_height + 'px';
}

function window_pos(popUpDivVar)
{
	if (typeof window.innerWidth != 'undefined') viewportwidth = window.innerHeight;
	else viewportwidth = document.documentElement.clientHeight;

	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) window_width = viewportwidth;
	else if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) window_width = document.body.parentNode.clientWidth;
		 else window_width = document.body.parentNode.scrollWidth;

	var popUpDiv = document.getElementById(popUpDivVar);
	window_width=(window_width-popup_width)/2;
	popUpDiv.style.left = window_width + 'px';
}

function popup(windowname)
{
	var active_open_close=readCookie('hp_alerte')
	
	if (active_open_close==null)
	{
		createCookie('hp_alerte',1,0)
		active_open_close=1
	}
	
	if (active_open_close<3)
	{
		blanket_size(windowname);
		window_pos(windowname);
		toggle('blanket');
		toggle(windowname);	
	}
	
	createCookie('hp_alerte',parseInt(active_open_close)+1,0)
}

// =======================================
// COOKIE
// =======================================

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

