/* swap
********************/
var swapList = new Array();

function initSwap(){
	var pureText = document.getElementById("puretext");
	if(!pureText) return;
	var triggers = pureText.getElementsByTagName("h2");
	var targets = pureText.getElementsByTagName("div");
	var loopI = (triggers.length>=targets.length)?(triggers.length):(targets.length);
	for (var i=0; i<loopI; ++i){
		swapList.push([triggers[i], targets[i]]);
		triggers[i].onclick = swap;
		triggers[i].style.cursor = "pointer";
		targets[i].style.height = "0";
		targets[i].style.overflow = "hidden";
	}
}

function swap(){
	for (var i=0; i<swapList.length; ++i){
		if (swapList[i][0]==this){
			(swapList[i][1].style.height !== 'auto')?(swapList[i][1].style.height = 'auto'):(swapList[i][1].style.height = '0');
		}else{
			swapList[i][1].style.height = '0';
		}
	}
}

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

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

function initSwapPic(){
	var swapZone = document.getElementById("imgprod");
	if(!swapZone) var swapZone = document.getElementById("plusimgprod");
	if(!swapZone) return;
	var triggers = swapZone.getElementsByTagName("a");
	for (var i=0; i<triggers.length; ++i){
		if(triggers[i].id == "popmore"){
			triggers[i].onclick = function(){
				var popup = window.open('plusdimages.php','pics','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=no,width=440,height=550,left=50,top=50');
				return false;
			};
		} else {
			triggers[i].onclick = function(){ return false; };
			triggers[i].onmouseover = swapPic;
		}
	}
}

/* flowScroll
********************/
function flowScroll(goLeft){
	//alert(goLeft+" * "+index);
	var offset = (goLeft)?-2:2;
	var flowCut = document.getElementById("flowcut" + index);
	flowCut.scrollLeft += offset;
}
function initFlowScroll(){
	var i = 0;
	while (document.getElementById("flow" + i))
	{
		var flow = document.getElementById("flow" + i);
		if(!flow) return;
		strFunction1 = "flowScroll(true)";
		strFunction2 = "flowScroll(false)";
		//alert(strFunction1);
		eval("document.getElementById(\"defilgauche" + i + "\").onmouseover = function(){this.src = 'images/charte/fleche-gauche-over.jpg'; index = " + i +"; scrollDirection = setInterval(strFunction1, 7); };");
		eval("document.getElementById(\"defildroite" + i + "\").onmouseover = function(){this.src = 'images/charte/fleche-droite-over.jpg'; index = " + i +"; scrollDirection = setInterval(strFunction2, 7); };");
		//alert(document.getElementById("defilgauche" + i).onmouseover.toString());
		document.getElementById("defilgauche" + i).onmouseout = function(){this.src = 'images/charte/fleche-gauche.jpg'; clearInterval(scrollDirection); };
		document.getElementById("defildroite" + i).onmouseout = function(){this.src = 'images/charte/fleche-droite.jpg'; clearInterval(scrollDirection); };
		var items = flow.getElementsByTagName("table");
		//nWidth = 0;
		//for (j = 0; j < items.length; j++)
			//nWidth = parseInt(nWidth) + parseInt(document.getElementById('flowtable0' + j).offsetWidth) + 1;
		flow.style.width = items.length*125 + "px";
		//flow.style.width = parseInt(nWidth + 5) + "px";
		//alert(nWidth);
		//alert(flow.style.width);
		i++;
	}
}
/* init
********************/
function InitPageForFlowScroll(){
	initFlowScroll();
	initSwapPic();
	initSwap();
};

