function initialisation() {

	// Header
	document.getElementById("submit_search_btn").onclick = function() { document.search_form.submit(); };
	document.getElementById("submit_newsletter_btn").onclick = function() { document.newsletter_form.submit(); };
	document.getElementById("submit_recommande_btn").onclick = function() { document.recommande_form.submit(); };
	
	document.getElementById("newsletter_box").onfocus = function() {
		if (document.newsletter_form.newsletter_box.value == "Votre email ...") document.newsletter_form.newsletter_box.value = "";
	};
	document.getElementById("newsletter_box").onblur = function() {
		if (document.newsletter_form.newsletter_box.value == "") document.newsletter_form.newsletter_box.value = "Votre email ...";
	};
	
	document.getElementById("recommande_box").onfocus = function() { document.recommande_form.recommande_box.value = ""; };
	document.getElementById("recommande_box").onblur = function() { document.recommande_form.recommande_box.value = "Son email ..."; };
	
	// Espace client
	if (document.getElementById("login_box") != null) document.getElementById("login_box").onfocus = function() {
		if (document.login_form.login_box.value == "Mon email client") document.login_form.login_box.value = "";
	};
	if (document.getElementById("login_box") != null) document.getElementById("login_box").onblur = function() {
		if (document.login_form.login_box.value == "") document.login_form.login_box.value = "Mon email client"; 
	};
	
	if (document.getElementById("pwd_box") != null) document.getElementById("pwd_box").onfocus = function() {
		if (document.login_form.pwd_box.value == "passe") document.login_form.pwd_box.value = "";
	};
	if (document.getElementById("pwd_box") != null) document.getElementById("pwd_box").onblur = function() {
		if (document.login_form.pwd_box.value == "") document.login_form.pwd_box.value = "passe";
	};
	
	if (document.getElementById("submit_login_btn") != null) document.getElementById("submit_login_btn").onclick = function() { document.login_form.submit(); };
	
	// Ajout rapide
	if (document.getElementById("ajoutRapideSubmit") != null) document.getElementById("ajoutRapideSubmit").onclick = function() { document.addRapidePanier_form.submit(); };
	
	// Login commande
	if (document.getElementById("submit_loginCom_btn") != null) document.getElementById("submit_loginCom_btn").onclick = function() { document.loginCom_form.submit(); };
	
	// Inscription
	if (document.getElementById("livDiffOui_radio") != null) document.getElementById("livDiffOui_radio").onclick = function() { showBlock('livBlock'); };
	if (document.getElementById("livDiffNon_radio") != null) document.getElementById("livDiffNon_radio").onclick = function() { hideBlock('livBlock'); };
	
	if (document.getElementById("pro_radio") != null) document.getElementById("pro_radio").onclick = function() { showBlock('proBlock'); };
	if (document.getElementById("pub_radio") != null) document.getElementById("pub_radio").onclick = function() { hideBlock('proBlock'); };
	
	// Categ
	if (document.getElementById("marque_select") != null) document.getElementById("marque_select").onchange = function() {
		var link = document.getElementById("marque_select");
		window.location = "categ.php?" + link.options[link.selectedIndex].value;
	};
	
	if (document.getElementById("tri_select") != null) document.getElementById("tri_select").onchange = function() {
		var link = document.getElementById("tri_select");
		window.location = "categ.php?" + link.options[link.selectedIndex].value;
	};
	
	// Recherche
	if ( document.getElementById("submit_search2_btn") != null ) document.getElementById("submit_search2_btn").onclick = function() { document.search2_form.submit(); };
}

function writeFlashPromo(pro) {
	document.write(' <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="565" height="230">');
	document.write(' <param name="movie" value="./includes/conteneur_promos.swf?pro=' + pro + '">');
	document.write(' <param name="quality" value="high">');
	document.write(' <param name="wmode" value="transparent"> ');
	document.write(' <embed src="./includes/conteneur_promos.swf?pro=' + pro + '" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="565" height="230"></embed></object>');
}

function writeFlashEphemeride() {
	document.write(' <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="197" height="228">');
	document.write(' <param name="movie" value="./includes/ephemeride.swf">');
	document.write(' <param name="quality" value="high">');
	document.write(' <param name="wmode" value="transparent"> ');
	document.write(' <embed src="./includes/ephemeride.swf" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="197" height="228"></embed></object>');
}

function writeFlashFraisDePort() {
	document.write(' <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="197" height="275">');
	document.write(' <param name="movie" value="./includes/infoports.swf">');
	document.write(' <param name="quality" value="high">');
	document.write(' <param name="wmode" value="transparent"> ');
	document.write(' <embed src="./includes/infoports.swf" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="197" height="275"></embed></object>');
}

function showBlock(blockId) {
	document.getElementById(blockId).style.display = "block";
}

function hideBlock(blockId) {
	document.getElementById(blockId).style.display = "none";
}


var step = 15;
var interval = 5;
var curLarge = null;
var curSmall = null;
var scaleInterval = null;

function scale(curImg, imgGroupName) {
	if(scaleInterval) return;
	var imgList = document.getElementsByName(imgGroupName);
	if(!curLarge)
		curLarge = imgList[0];
	if(curImg != curLarge) {
		curSmall = curImg;
		scaleInterval = window.setInterval("stepScale()", interval);
	}
}

function stepScale() {
	smallWidth = curSmall.getAttribute('width');
	smallHeight = curSmall.getAttribute('height');
	largeWidth = curLarge.getAttribute('width');
	largeHeight = curLarge.getAttribute('height');
	
	if(smallWidth < 180) {
		curSmall.setAttribute('width', parseInt(smallWidth) + step);
		curSmall.setAttribute('height', parseInt(smallHeight) + step);
		curLarge.setAttribute('width', parseInt(largeWidth) - step);
		curLarge.setAttribute('height', parseInt(largeHeight) - step);
	}
	else {
		window.clearInterval(scaleInterval);
		scaleInterval = null;
		curLarge = curSmall;
	}
}

function roll(link, img) {
	link.src = img;
}

window.onload = function() {
	initialisation();
}

