

function fp_ie4() {
	var nav = navigator.appVersion.indexOf("MSIE");
	return (nav>0) && (parseInt(navigator.appVersion.substring(nav+5, nav+6)) >= 4);
}

function fp_ns6() {
	return ((navigator.appName == "Netscape") &&
				(parseInt(navigator.appVersion.substring(0, 1)) >= 5));
				
}
function load_width(img_nb){
	
	if(fp_ie4())
		img_nb.width =img_nb.width2;
	else
		img_nb.setAttribute("width",img_nb.getAttribute("width2"));
}
function fp_ShowImg(src,iIndex)
{	
	if(fp_ie4()) {		
		var el = document.images["fpGalleryMainImg"];
		var el2 = document.images["fpGalleryMainImg2"];
		var el3 = document.images["fpGalleryMainImg3"];
		var taille=document.all['fpGalleryListCell'].children.tags("A").length-1;
		
		el.style.visiblity = "hidden";
		el.width2 = src.width_src;
		el.width = 0;
		el.height = src.height_src;
		el.title = src.title;	
		el.src = src.lowsrc;
		
		
		el2.style.visiblity = "hidden";
		el2.width2 = src.width_src2;
		el2.width = 0;
		el2.height = src.height_src2;
		el2.title = src.title;
		el2.src = src.lowsrc2;
		
		el3.style.visiblity = "hidden";
		el3.width2 = src.width_src3;
		el3.width = 0;
		el3.height = src.height_src3;
		el3.title = src.title;
		el3.src = src.lowsrc3;
		
		document.all["fpGalleryCaptionCell"].innerHTML=src.getAttribute("title")
		
		
	} else {
		
		var el = document.getElementById("fpGalleryMainImg");
		var el2 = document.getElementById("fpGalleryMainImg2");
		var el3 = document.getElementById("fpGalleryMainImg3");
		var taille = document.getElementById("fpGalleryListCell").getElementsByTagName("A").length-1;

		el.style.visiblity = "hidden";
		el.setAttribute("src",src.getAttribute("lowsrc"));
		el.setAttribute("width2",src.getAttribute("width_src"));
		el.setAttribute("width",0);
		el.setAttribute("height",src.getAttribute("height_src"));
		el.setAttribute("title",src.getAttribute("title"));		
		
		el2.style.visiblity = "hidden";
		el2.setAttribute("src",src.getAttribute("lowsrc2"));
		el2.setAttribute("width2",src.getAttribute("width_src2"));
		el2.setAttribute("width",0);
		el2.setAttribute("height",src.getAttribute("height_src2"));
		el2.setAttribute("title",src.getAttribute("title"));
		
		el3.style.visiblity = "hidden";
		el3.setAttribute("src",src.getAttribute("lowsrc3"));
		el3.setAttribute("width",0);
		el3.setAttribute("width2",src.getAttribute("width_src3"));
		el3.setAttribute("height",src.getAttribute("height_src3"));
		el3.setAttribute("title",src.getAttribute("title"));
		
		document.getElementById("fpGalleryCaptionCell").innerHTML=  src.getAttribute("title");		
	}

}

function fp_ScrollLeft() {
	
	if (fp_ie4()) {
		var el = document.all["fpGalleryListCell"];
		var coll = el.children.tags("A");
		var count = 20;
		if (coll) {
			for (i=1;i<coll.length;i++) {
				if (coll(i).style.display != "none") {
					coll(i-1).style.display = "inline";
					break;	
				}
			}
			for (i=0;i<coll.length;i++) {
				if (coll(i).style.display != "none") {
					var images = coll[i].children.tags("img");
					count = count + 20 + images[0].width;
					
					if (count > widthLength)				
						coll(i).style.display = "none";
				}
			}
			if ((el.scrollWidth - 5) >= el.clientWidth) {
				var btn = document.all["fpGalleryRightBtn"]
				if (btn && rightdisabled) {
					rightdisabled = false;
					te = btn.src
					btn.src = btn.lowsrc
					btn.lowsrc = te
				}
			}
			if (coll(0).style.display != "none") {
				var btn = document.all["fpGalleryLeftBtn"]
				if (btn && !leftdisabled) {
					leftdisabled = true;
					te = btn.src;
					btn.src = btn.lowsrc;
					btn.lowsrc = te;
				}
			}
		}
	}
	else{
		var el = document.getElementById("fpGalleryListCell");
		var coll = el.getElementsByTagName("A");
		var count = 20 ;
		if (coll) {
			for (i=1;i<coll.length;i++) {
				if (coll[i].style.display != "none") {
					coll[i-1].style.display = "inline";
					break;	
				}
			}		
			for (i=0;i<coll.length;i++) {
				if (coll[i].style.display != "none") {
					var images = coll[i].getElementsByTagName("img");
					count = count/1 + 20 + images[0].getAttribute("width")/1;
					if (count/1 > widthLength/1)
						coll[i].style.display = "none";				
				}
			}
			if ((el.scrollWidth - 5) >= el.clientWidth) {
				var btn =  document.getElementById("fpGalleryRightBtn");
				if (btn && rightdisabled) {
					rightdisabled = false;
					te = btn.getAttribute("src");
					btn.setAttribute("src", btn.getAttribute("lowsrc"));
					btn.setAttribute("lowsrc",te);
				}
			}
			if (coll[0].style.display != "none") {
				var btn = document.getElementById("fpGalleryLeftBtn");
				if (btn && !leftdisabled) {
					leftdisabled = true;
					te = btn.getAttribute("src");
					btn.setAttribute("src", btn.getAttribute("lowsrc"));
					btn.setAttribute("lowsrc",te);
				}
			
			}
		}
	}
}

function fp_ScrollRight() {
	
	if (fp_ie4()) {
		var el = document.all["fpGalleryListCell"];
		if (!rightdisabled)
		{
			var coll = el.children.tags("A");
			if (coll) {
			    var state = 0;
				var count = 20;
		
				for (i=0;i<coll.length;i++) {
					if (state == 0)
					{
						if (coll(i).style.display != "none") {
							coll(i).style.display = "none";	
							state = 1;
						}
					}
					else{
						var images = coll[i].children.tags("img");
						count = count + 20 + images[0].width;
						if (count < widthLength-50)
							coll(i).style.display = "inline";
						else
							coll(i).style.display = "none";
					}
				}
			}
		
			var btn = document.all["fpGalleryRightBtn"];
			if (btn && coll(coll.length - 1).style.display != "none") {
				rightdisabled = true;
				te = btn.src;
				btn.src = btn.lowsrc;
				btn.lowsrc = te;
			}
			
			var btn = document.all["fpGalleryLeftBtn"];
			if (btn && leftdisabled) {
				te = btn.src;
				btn.src = btn.lowsrc;
				btn.lowsrc = te;
				leftdisabled = false;
			}
		}		
	}
	else {
		var el = document.getElementById("fpGalleryListCell");
		if (!rightdisabled)
		{
			var coll = el.getElementsByTagName("A");
			if (coll) {
			    var state = 0;
				var count = 20;
		
				for (i=0;i<coll.length;i++) {
					if (state == 0)
					{
						if (coll[i].style.display != "none") {
							coll[i].style.display = "none";	
							state = 1;
						}
					}
					else{
						var images = coll[i].getElementsByTagName("img");
						count = count/1 + 20 + images[0].getAttribute("width")/1;
						if (count/1 < widthLength/1-50)
							coll[i].style.display = "inline";
						else
							coll[i].style.display = "none";
					}
				}
			}
		
			var btn = document.getElementById("fpGalleryRightBtn");
			if (btn && coll[coll.length - 1].style.display != "none") {
				rightdisabled = true;
				te = btn.getAttribute("src");
				btn.setAttribute("src", btn.getAttribute("lowsrc"));
				btn.setAttribute("lowsrc",te);
			}
			
			var btn = document.getElementById("fpGalleryLeftBtn");
			if (btn && leftdisabled) {
				te = btn.getAttribute("src");
				btn.setAttribute("src", btn.getAttribute("lowsrc"));
				btn.setAttribute("lowsrc",te);
				leftdisabled = false;
			}
		}	
	}
}
