function chrono(champ,jour,mois,annee,heure,minute,seconde) {
 if (document.getElementById && document.getElementById(champ)) {
  var now = new Date()
  var goal = new Date(annee,mois-1,jour,heure,minute,seconde)
  var ts = (goal.getTime() - now.getTime())/1000
  if (ts > 0){
   var j = Math.floor(ts/(3600*24))
   var h = Math.floor((ts-j*24*3600)/3600)
   var m = Math.floor((ts-j*24*3600-h*3600)/60)
   var s = Math.floor(ts-j*24*3600-h*3600-m*60)
   var html = ((j>1)?j+" jours ":(j>0)?j+" Jour ":"")
   + ((h<10)?" 0":" ")+h+"h "
   + ((m<10)?"0":"")+m+"mn "
   + ((s<10)?"0":"")+s+"s "
   document.getElementById(champ).innerHTML = "Plus que " + html + " !"
  }
  else document.getElementById(champ).innerHTML = "Vente terminée !"
 }
}

function get_selected(myinput,myvalue) 
{
for (var i = 0; i < document.getElementById(''+myinput+'').options.length; i++) 
	{
	if(document.getElementById(''+myinput+'').options[i].value ==''+myvalue+'')
		{
		document.getElementById(''+myinput+'').options[i].selected = true;
		}
	}
}

function changeref()
{
	if (document.getElementById('d_options')) 
	{
		if (document.getElementById('d_options').value != '')
		{
				var newoption = document.getElementById('d_options').value;
				newoption = newoption.split(",");
				document.getElementById('ref').innerHTML = newoption[1];
		
				// récupérer la disponibilité de la référence sélectionnée
				for(i=0; i < arr_dispo.length; i++)
				{
					if(arr_dispo[i][0] == newoption[1])
					{
						document.getElementById('dispo').innerHTML = arr_dispo[i][1];
						document.getElementById('d_dispo').value = arr_dispo[i][1];
					}
				}
		}
		else
		{
				document.getElementById('ref').innerHTML = '';
				document.getElementById('dispo').innerHTML = '';
				document.getElementById('d_dispo').value = '';
		}
	}
	else
	{
	document.getElementById('dispo').innerHTML = arr_dispo[0][1];
	document.getElementById('d_dispo').value = arr_dispo[0][1];
	}
	enablebutton();
}

function enablebutton()
{
	if (document.getElementById('d_options'))
	{
		var current_option = document.getElementById('d_options').selectedIndex
		// Si sur "Veuillez Sélectionner"
		if(current_option==0)
		{
		current_option = current_option - 0
		}
		else
		{
		current_option = current_option - 1
		}
	}
	else
	{
		current_option = 0
	}
	
	if(arr_dispo[current_option][2] == 'disable')
	{
		document.getElementById('caddieb').disabled = true;
		document.getElementById('caddieb').style.color = '#CCCCCC';
		document.getElementById('dispo').style.color = '#FF0000';
		document.getElementById('dispo').style.fontWeight = 'bold';
		
	}
	else
	{
		document.getElementById('caddieb').disabled = false;
		document.getElementById('caddieb').style.color = '#FFFFFF';
		document.getElementById('dispo').style.color = '';
		document.getElementById('dispo').style.fontWeight = 'normal';
	}

	if (document.getElementById('d_options'))
	{
		if(document.getElementById('d_options').selectedIndex==0)
		{
			document.getElementById('caddieb').disabled = false;
			document.getElementById('caddieb').style.color = '#FFFFFF';
			document.getElementById('dispo').style.color = '';
			document.getElementById('dispo').style.fontWeight = 'normal';
		}
	}
}

function popup(myurl,myname,mywidth,myheight,myoptions) {
    var window_top = (screen.height-myheight)/2;
    var window_left = (screen.width-mywidth)/2;
   	var mywindow = window.open(''+ myurl + '',''+ myname + '','width=' + mywidth + ',height=' + myheight + ',top=' + window_top + ',left=' + window_left + ',' + myoptions + '');
    mywindow.focus();
}

function newsletterpop(mydata) {
    var window_top = (screen.height-100)/2;
    var window_left = (screen.width-100)/2;
   	var mywindow = window.open('newsletter_post.php?email='+ mydata + '','popnews','width=400,height=220,top=' + window_top + ',left=' + window_left + '','');
    mywindow.focus();
	}
	
	
	
var winh = 0;
var winw = 0;

function getwinsize() {
	if (document.body && document.body.clientHeight) 
		{
			winh = document.body.clientHeight;
			winw = document.body.clientWidth;
		}
	
	if (document.documentElement && document.documentElement.clientHeight) 
		{
			winh = document.documentElement.clientHeight;
			winw = document.documentElement.clientWidth;
       	}
	//alert('larg='+winw+' haut='+winh);
}

function show360(myheight)
	{
	if(document.getElementById)
		{
		getwinsize()
		document.getElementById("p360").style.width = '100%';
		document.getElementById("p360").style.height = winh*2+'px';
		document.getElementById("p360").style.left = '0px';
		document.getElementById("p360").style.top = '0px';
		document.body.style.overflow = "hidden";
		window.scrollTo(0,0)
		}
		if (myheight==315)
		{
			document.getElementById("swf").style.marginTop = (winh-315)/2+'px';
			document.getElementById("swf").style.marginLeft = (winw-420)/2+'px';
			document.getElementById("swf").style.width = '420px';		
			document.getElementById("swf").style.height = '333px';
		}
		else
		{
			document.getElementById("swf").style.marginTop = (winh-420)/2+'px';
			document.getElementById("swf").style.marginLeft = (winw-315)/2+'px';
			document.getElementById("swf").style.width = '315px';		
			document.getElementById("swf").style.height = '438px';
		}
		document.getElementById("p360").style.display = '';
		document.getElementById("swf").style.display = '';
	}

function close360()
	{
	if(document.getElementById)
		{
		document.getElementById("p360").style.display = 'none';
		document.getElementById("swf").style.display = 'none';
		document.body.style.overflow = "";
		}
	}
	
function postform(formname)
{
	
	document.forms[""+formname+""].action = 'contact_post_aspam.asp';
	document.forms[""+formname+""].submit();
}

function hidedisc()
	{
	if(document.getElementById)
		{
		document.getElementById("disc_bg").style.display = 'none';
		document.getElementById("disc_content").style.display = 'none';
		document.body.style.overflow = "";
		}
	}

function showdisclaimer()
{
	if(document.getElementById)
		{
		getwinsize()
		document.getElementById("disc_bg").style.width = '100%';
		document.getElementById("disc_bg").style.height = winh*2+'px';
		document.getElementById("disc_bg").style.left = '0px';
		document.getElementById("disc_bg").style.top = '0px';
		document.getElementById("disc_content").style.marginTop = (winh-510)/2+'px';
		document.getElementById("disc_content").style.marginLeft = (winw-526)/2+'px';
		document.getElementById("disc_content").style.left = '0px';
		document.getElementById("disc_content").style.top = '0px';
		document.body.style.overflow = "hidden";
		window.scrollTo(0,0)
		}
}
