// JavaScript Document

function sizy(index){
	var img = document.getElementById('img'+index);
	var titre = document.getElementById('titre'+index);
	var txt = document.getElementById('txt'+index);
	var top = img.style.top;
	var left = img.style.left;
	var nb = top.length;
	var nb2 = left.length;
	var top2 = parseInt(top.substring(0,(nb-2)));
	var left2 = parseInt(left.substring(0,(nb-2)));
	if(top != "0px"){
	top2 = top2 - 5;
	img.style.top = top2+'px';
	titre.style.top = top2+'px';
	txt.style.top = top2+'px';
	}
	if(left != "0px"){
	left2 = left2 - 5;
	img.style.left = left2+'px';
	titre.style.left = left2+'px';
	txt.style.left = left2+'px';
	}
	
	var i = titre.style.fontSize;
	i = parseInt(i.substring(0,(nb-2)));
	i++;
	if(i<44){titre.style.fontSize = i+'px';}
	
	var j = txt.style.fontSize;
	j = parseInt(j.substring(0,(nb-2)));
	j++;
	if(j<12){txt.style.fontSize = j+'px';}
	
	if((top2 != 0)||(left2 != 0)){setTimeout("sizy("+index+");",1);}
}

function sizy2(index){
	var img = document.getElementById('img'+index);
	var height = img.offsetHeight;
	var width = img.offsetWidth;
	if(height != 360){
	height = parseInt(height) + 5;
	img.style.height = height+'px';}
	if(width != 320){
	width = parseInt(width) + 5;
	img.style.width = width+'px';
	}
	if((height != 360)||(width != 320)){setTimeout("sizy2("+index+");",1);}
}

function gauche(){
	input = document.getElementById('clic');
	input2 = document.getElementById('image');
	if(input.value == 1){
	input.value = 0;
	show = document.getElementById('img_produit_img');
	var voir = show.style.left;
	var taille = show.offsetWidth;
	taille = taille-320;
	taille = taille+"px";
	voir = voir.substring(0, voir.length);
	//alert(taille);
	//alert(voir);
	if(voir != "-"+taille){
		voir = voir.substring(0, voir.length-2);
		taille = taille.substring(0, taille.length-2);
		//alert(taille);
		//alert(voir);
		input2.value = parseInt(input2.value)+1;
		var posi = input2.value;
		posit(posi);
		gauche2(320,0,1,parseInt(voir));
		}
	else{input = document.getElementById('clic');input.value = 1;}
	}
}

function gauche2(index,ino,t,voir){
	if(index != ino){
		show = document.getElementById('img_produit_img');
		ino = ino+20;
		voir = voir-20;
		show.style.left = voir+"px";
		setTimeout("gauche2("+index+","+ino+","+t+","+voir+");",t);
		}
	else{input = document.getElementById('clic');input.value = 1;}
}



function droite(){
	input = document.getElementById('clic');
	input2 = document.getElementById('image');
	if(input.value == 1){
	input.value = 0;
	show = document.getElementById('img_produit_img');
	var voir = show.style.left;
	var taille = show.offsetWidth;
	//alert(taille);
	//alert(voir);
	if(voir != "0px"){
		voir = voir.substring(0, voir.length-2);
		//alert(taille);
		//alert(voir);
		input2.value = parseInt(input2.value)-1;
		var posi = input2.value;
		posit(posi);
		droite2(320,0,1,parseInt(voir));
		}
	else{input = document.getElementById('clic');input.value = 1;}
	}
}

function droite2(index,ino,t,voir){
	if(index != ino){
		show = document.getElementById('img_produit_img');
		ino = ino+20;
		voir = voir+20;
		show.style.left = voir+"px";
		setTimeout("droite2("+index+","+ino+","+t+","+voir+");",t);
		}
	else{input = document.getElementById('clic');input.value = 1;}
}

function position(){
	show = document.getElementById('img_produit_img');
	points = document.getElementById('points');
	if(points){
		var point = show.offsetHeight;
		//alert(point);
		point = point - 29;
		points.style.top = point+"px";
	}
}

function posit(index){
	show = document.getElementById('p'+index);
	var i=1;
	city = document.getElementById('p'+i);
		while(city){
			city.style.display = "none";
			i++;
			city = document.getElementById('p'+i);
		}
		show.style.display = "block";
}


/*********************************/
/*** FONCTIONS ZOOM DOUBLE-TAP ***/
/*********************************/

function zoom(){
	var el = document.getElementById('viewport');
	var isscale = document.getElementById('isscale');
	if(el && isscale){
		var initscale = (isscale.value==0 )? 3 : 1 ;
		el.setAttribute("content", "width=320, user-scalable=yes, maximum-scale=3.8, initial-scale = "+initscale, false);
		isscale.value = (isscale.value==0 )? 1 : 0 ;
		//alert(initscale);
	}
}

function showtext(){
	var txt1 = document.getElementById('txt1');
	txt1.style.display = 'none';
}
