function hidethumb(imgtarg){
	$(imgtarg).hide();
}


function loadthumb(imgtarg, src){
	$(imgtarg).hide();
	
	var img = new Image();
	$(img).load(function(){
		$(imgtarg).attr("src", src);
		$(imgtarg).fadeIn("slow");
	}).attr("src", src);
	return false;
}

var browserType;

if (document.layers) {browserType = "nn4"}
if (document.all) {browserType = "ie"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {
   browserType= "gecko"
}



function envoieRequete(url, id, isSearchRefreshed, slideShowImages, mode)
{	
	var xhr_object = null;
	var position = id;
	
	if(window.XMLHttpRequest) xhr_object = new XMLHttpRequest();
	else
	if (window.ActiveXObject) xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	
	// On ouvre la requete vers la page désirée
	
	// hack pour encodage ISO
	url = url.replace("?","&");
	url = "scripts/convert.php?url=" + url;	
	
	xhr_object.open("GET", url, true);
	xhr_object.onreadystatechange = function(){
		if ( xhr_object.readyState == 4 )
		{
			// j'affiche dans la DIV spécifiée le contenu retourné par le fichier
			document.getElementById(position).innerHTML = xhr_object.responseText;
			$(document).ready(function(){
				if (isSearchRefreshed=="true")
				{
					for (var i=0;i<=4;i=i+1)
					{
						hidethumb('#img'+i);
						
						$('#txt'+i).hide();						
						$('#txt2'+i).hide();		
																		
						if(document.getElementById('img'+i))
							window.setTimeout("loadthumb('#img"+i+"', document.getElementById('img"+i+"').src);", 100*i);	

						window.setTimeout("$('#txt" + i + "').fadeIn('_default');", 100*i + 150);
						window.setTimeout("$('#txt2" + i + "').fadeIn('_default');", 100*i + 150);
						
					}
				}
				else if (slideShowImages != undefined)
				{
					
					startSlideShow(slideShowImages, mode);
					
					/*$('#content').hide();
					$('#content').fadeIn("slow");*/
				}
			});

		}
	}
	
	// dans le cas du get
	xhr_object.send(null);
	

}

function sendSearchForm(url,id)
{
	url = url + "&idTypeEvent=" + document.getElementById('searchForm').idTypeEvent.value + "&idTypeProduit=" + document.getElementById('searchForm').idTypeProduit.value
	envoieRequete(url,id,"true");
}

function sendNavigation(id)
{
	var page = parseInt(document.getElementById('navigationForm').navigation.value)+1
	location.href = id + "_" + page + ".html";
}

function nothing()
{
}


function startSlideShow(slideShowImages, mode)
{
	var timer;
	var links;
	var navigatorPos;
	var titlePos;
	var titleWidth;
	var titleHeight;
	var titleBackColor;
	var titleColor;
	var titleOpacity;
	
	
	if (mode==0)
	{
		timer = 5000;
		links = "titles";
		navigatorPos = "top-left"; 
		titlePos = "bottom";
		titleWidth = "400px";
		titleHeight = "58px";
		titleOpacity = "0.8";
		titleBackColor = "#000";
		titleColor = "White";
		stopAnim=true;
		navVisible="visible";
		titleVisible=true;
	}
	else
	{
		timer = 3500;
		links = "images";
		navigatorPos = "bottom-left";
		titlePos = "top";
		titleWidth = "160px";
		titleHeight = "250px";
		titleOpacity = "1.0";
		titleBackColor = "#DDD";
		titleColor = "Black";
		stopAnim=true;
		navVisible="visible";
		titleVisible=true;
	}
	
	
	$("#showcase").showcase({
				css: { width: "590px", height: "300px", margin:"0px", padding:"0px" },
				animation: { type: "fade", interval: timer, speed: 500, stopOnHover:stopAnim},
				linksOn: links ,
				images: slideShowImages,
				navigator: { autoHide: true, showNumber: false, position: navigatorPos, orientation: "horizontal", css: { padding:"10px" }, item: {	cssSelected: {	backgroundColor: "#c25618"} } },
				titleBar: { enabled:titleVisible,autoHide: false, position: titlePos, css: { "text-align" : "left", width: titleWidth, height: titleHeight, margin: "10px", backgroundColor: titleBackColor, color: titleColor, fontSize: "16px", fontWeight: "normal", fontStyle: "normal", opacity: titleOpacity } }

			});
}



