/* Javascripts utilisés sur le site
 * Mettez l'ensemble de vos fonctions générique javascript ici
 * 
 * La liaison avec les page se fait à l'aide du code ci-dessous :
 * <script type="text/javascript" src="css-js/scripts.js"></script>
 */

/* menu mooFX
********************/
function montre(id) {
	var myStretch = document.getElementsByClassName('stretch');
	var myStretcher = document.getElementsByClassName('stretcher');
	var myAccordion = new fx.Accordion(myStretch, myStretcher, {opacity: false});
	myAccordion.showThisHideOpen(myStretcher[id]);
}

/* clearOnFocus
********************/
function clearOnFocus(el){
	var toClear = document.getElementById(el);
	if(!toClear) return;
	toClear.onfocus = function(){
		this.value="";
		this.onfocus = null;
	};
}

/* swapPic
********************/
function swapPic(){
	document.getElementById("bigpict").src = this;
}

function initSwapPic(){
	var swapZone = document.getElementById("picsprod");
	if(!swapZone) return;
	var triggers = swapZone.getElementsByTagName("a");
	for (var i=0; i<triggers.length; ++i){
		triggers[i].onclick = function(){ return false; };
		triggers[i].onmouseover = swapPic;
	}
}

/* anchors
********************/
function initAnchors(){
	var anchors = document.getElementById("contenuTexte").getElementsByTagName("a");
	for (var i=0; i<anchors.length; ++i){
		if (anchors[i].rel == "external") anchors[i].onclick=external;
	}
}

function external(){
	window.open(this);
	return false;
}

/* init
********************/
window.onload = function(){
	clearOnFocus("inputrecherche");
	clearOnFocus("qte");
	montre();
	initSwapPic();
	initAnchors();
};
