var transTime = 750;
var fadeOutTime = 1500;
var imagePath = '/gallery2/images/'
var window_format = false;

/**
* Returns get parameters.
*
* If the desired param does not exist, null will be returned
*
* @example value = $.getURLParam("paramName");
*/ 
  function getURLParam(strParamName){
	  var strReturn = "";
	  var strHref = window.location.href;
	  var bFound=false;
	  
	  var cmpstring = strParamName + "=";
	  var cmplen = cmpstring.length;

	  if ( strHref.indexOf("?") > -1 ){
	    var strQueryString = strHref.substr(strHref.indexOf("?")+1);
	    var aQueryString = strQueryString.split("&");
	    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
	      if (aQueryString[iParam].substr(0,cmplen)==cmpstring){
	        var aParam = aQueryString[iParam].split("=");
	        strReturn = aParam[1];
	        bFound=true;
	        break;
	      }
	      
	    }
	  }
	  if (bFound==false) return null;
	  return strReturn;
	}

//$.cookie('PITC_id', '9');
//alert('test cookie'+$.cookie('PITC_id'));
$(document).ready(function(){

	$("#liste_photographes_complet").show(0);
	$("#test").wslide({
		width: 710,
		height: 200,
		autolink: false,
		fade: true,
		duration: 2000
	});
	$("#liste_photographes_complet").hide(0);

	if( getURLParam("open") == 'payment') {
		comp=(setTimeout("tb_show('', '/zencart/index.php?main_page=checkout_payment&KeepThis=true&TB_iframe=true', false);",2000));	

	} else if (getURLParam("open") == 'commande_done') {
		comp=(setTimeout("tb_show('', '/zencart/index.php?main_page=account_history&from=payment&KeepThis=true&TB_iframe=true', false);",2000));

	} else if( getURLParam("open") == 'accueil') {
		comp=(setTimeout("tb_show('', '/zencart/index.php?main_page=about_us&page=accueil&KeepThis=true&TB_iframe=true', false);",1000));		

	} else if( getURLParam("open") == 'facebook1') {
		comp=(setTimeout("tb_show('', '/zencart/index.php?main_page=about_us&page=facebook1&KeepThis=true&TB_iframe=true', false);",2000));
		
	} else if( getURLParam("open") == 'facebook2') {
		comp=(setTimeout("tb_show('', '/zencart/index.php?main_page=about_us&page=facebook2&KeepThis=true&TB_iframe=true', false);",2000));
		
	} else if( getURLParam("open") == 'facebook3') {
		comp=(setTimeout("tb_show('', '/zencart/index.php?main_page=about_us&page=facebook3&KeepThis=true&TB_iframe=true', false);",2000));
		
	} else if( getURLParam("open") == 'facebook4') {
		comp=(setTimeout("tb_show('', '/zencart/index.php?main_page=about_us&page=facebook4&KeepThis=true&TB_iframe=true', false);",2000));
		
	}

});


$(function(){
	var ltie7 = $.browser.msie && /MSIE\s(5\.5|6\.)/.test(navigator.userAgent);
	var ltie6 = $.browser.msie && /MSIE (6\.)/.test(navigator.userAgent);
	if(ltie6) {
		// if not severe bug...
		transTime = 0;
		fadeOutTime = 0;
	}


	initNavigation();	// handles menus
	initMenu();
/*
	gestion_arrondis();
*/
	gestion_menu();
	gestion_menu_image();
	gestion_vote();
	gestion_iframe();
	gestion_panier();

	$.ifixpng('/gallery2/images/pixel.gif');
	$('img[@src$=logo-web-transp.png], img[@src$=20080508-Hotline-Satisfait.png], div#menu_haut_nav_bg').ifixpng();
	
	handleRefreshPageActions();
	comp=(setTimeout("handlePITCAdvert();",2000));
});
	 
	 var  div_hiddelog = false;
	 var criteoselection;
	 /*var  div_hiddenav = false;
	 var  div_hiddepan = true;*/
 	 var  div_show_bloc_artiste_more = false;
	 var div_hiddecomment = true;

function initMenu(){
	if (!app_is_safari) {
		$('#m_navigation').corner("round 9px");
		$('#m_panier').corner("round 9px");
	} else {
		transTime = 0;
	}

	$('#voir_collage_360').click(function () {
		$("#contrecollage").hide();
		$("#contrecollage_360").show();
		var so = new SWFObject("/gallery2/images/pitc_rotate_308.swf", "Vue360", "308", "231", "9.0.28.0", "ffffff");
		so.addParam("flashVars","path=/gallery2/images/ptcc-308/");
		so.addParam("play","true");
		so.addParam("quality","hight");
		so.addParam("wmode", "transparent");
		so.addParam("allowScriptAccess","always");
		so.write("ptcc_wrapper");
	}); 
	$('#voir_collage_img').click(function () {
		$("#contrecollage_360").hide();
		$("#contrecollage_img").show();
	}); 
	$('#retour_collage').click(function () {
		$("#contrecollage_360").hide();
		$("#contrecollage").show();
	}); 
	$('#retour_collage_360').click(function () {
		$("#contrecollage_img").hide();
		$("#contrecollage_360").show();
	}); 

	$('#voir_collage_grand_360').click(function () {
		$("#contrecollage_grand").hide();
		$("#contrecollage_grand_360").show();
		var so = new SWFObject("/gallery2/images/pitc_rotate_308.swf", "Vue360", "308", "231", "9.0.28.0", "ffffff");
		so.addParam("flashVars","path=/gallery2/images/gdcc-308/");
		so.addParam("play","true");
		so.addParam("quality","hight");
		so.addParam("wmode", "transparent");
		so.addParam("allowScriptAccess","always");
		so.write("gdcc_wrapper");
	}); 
	$('#voir_collage_grand_img').click(function () {
		$("#contrecollage_grand_360").hide();
		$("#contrecollage_grand_img").show();
	}); 
	$('#retour_collage_grand_360').click(function () {
		$("#contrecollage_grand_img").hide();
		$("#contrecollage_grand_360").show();
	}); 
	$('#retour_collage_grand').click(function () {
		$("#contrecollage_grand_360").hide();
		$("#contrecollage_grand").show();
	}); 
	$('#voir_cadre_petit_360').click(function () {
		$("#encadre_petit").hide();
		$("#encadre_petit_360").show();
		var so = new SWFObject("/gallery2/images/pitc_rotate_308.swf", "Vue360", "308", "231", "9.0.28.0", "ffffff");
		so.addParam("flashVars","path=/gallery2/images/ptca-308/");
		so.addParam("play","true");
		so.addParam("quality","hight");
		so.addParam("wmode", "transparent");
		so.addParam("allowScriptAccess","always");
		so.write("ptca_wrapper");
	}); 
	$('#voir_cadre_petit_img').click(function () {
        $("#encadre_petit_360").hide();
        $("#encadre_petit_img").show();
        });
	$('#retour_cadre_petit_360').click(function () {
        $("#encadre_petit_img").hide();
        $("#encadre_petit_360").show();
	});
	$('#retour_cadre_petit').click(function () {
        $("#encadre_petit_360").hide();
        $("#encadre_petit").show();
	});
	$('#voir_cadre_grand_360').click(function () {
		$("#encadre_grand").hide();
		$("#encadre_grand_360").show();
		var so = new SWFObject("/gallery2/images/pitc_rotate_308.swf", "Vue360", "308", "231", "9.0.28.0", "ffffff");
		so.addParam("flashVars","path=/gallery2/images/ptca-308/");
		so.addParam("play","true");
		so.addParam("quality","hight");
		so.addParam("wmode", "transparent");
		so.addParam("allowScriptAccess","always");
		so.write("gdca_wrapper");
	}); 
	$('#voir_cadre_grand_img').click(function () {
        $("#encadre_grand_360").hide();
        $("#encadre_grand_img").show();
        });
	$('#retour_cadre_grand_360').click(function () {
        $("#encadre_grand_img").hide();
        $("#encadre_grand_360").show();
	});
	$('#retour_cadre_grand').click(function () {
        $("#encadre_grand_360").hide();
        $("#encadre_grand").show();
	});

	/* Gestion des pages sans images */
	if  ($('#imagearea').css('top')=='-1px') {
		$('#imagearea').attr("style","margin: auto; top: 30px; position: relative;").append("<div id='noImage'>Désolé, votre recherche<br/>ne renvoie pas de résultats.<img src='/gallery2/images/detective-L400.gif'/></div>");
		$('#menu_haut_nav_bg').css('visibility','hidden');
		$('#menu_haut_nav').css('visibility','hidden');
		$('#menu_action').css('visibility','hidden');
	}
}

function close_MenuBas(force) {	
	if(force == undefined) {
		force = (div_hiddemenu_bas) ? 1 : 0;
	}

	if (force == 1) {	
		//image_zoom(0);
		pageTracker._trackPageview('/navigation/thumb-show');
		$('#titlebar').show(transTime);
		$('#close_menu_bas').animate({ bottom : 90 }).find('img').attr('src',imagePath + 'PITC_Button_MenuDown.gif');
		//$('#tell_friend').animate({ bottom : 115});
		$('#tell_friend_page').animate({ bottom : 120});
		div_hiddemenu_bas = false;
		//alert('show bas, force'+force);
	} else {		
		//image_zoom(1);
		pageTracker._trackPageview('/navigation/thumb-hide');
		$('#titlebar').hide(transTime);
		$('#close_menu_bas').animate({ bottom : 0 }).find('img').attr('src',imagePath + 'PITC_Button_MenuUp.gif');
		//$('#tell_friend').animate({ bottom : 0});
		$('#tell_friend_page').animate({ bottom : 5});	
		div_hiddemenu_bas = true;
		//alert('close bas force'+force);
	}	

	// force reload central et store menu places
	image_show(image_index);	
	registerNavigation();
}


function close_MenuGauche(force) {	
	
		
	if(force == undefined) {
		force = (div_hidde) ? 1 : 0;
	}
	
	if (force == 1) {
		$('#options').show(transTime);
		//$('#opts').animate({ left: "201px", height: "102px" }).attr('src',imagePath + 'PITC_Button_MenuLeft.gif');
		div_hidde = false;
		//alert('show gauche force'+force);
	} else {
		$('#options').hide(transTime);
		//$('#opts').animate({ left: "0px", height: "102px" }).attr('src',imagePath + 'PITC_Button_MenuRight.gif');
		//$(' .liste_complement_panier').hide(transTime);
		show_ProductCart(0);
		$(' .liste_search').hide(transTime);
		div_hidde = true;
		//alert('hide gauche force'+force);
	}
	
	// force reload central et store menu places
	image_show(image_index);
	registerNavigation();
}

/* Modif DC */
function close_MenuNav(force) {
	
	if(force == undefined) {
		force = (div_hiddenav) ? 1 : 0;
	}
	
	if (force == 1) {
		//$(this).hide();
		$('#close_navigation').show(transTime);
		$('#searchPICT').show(transTime);
		$('#findPICT').show(transTime); /* ONEBLOCK HU */
		$('#selectionPICT').show(transTime); /* ONEBLOCK HU */		
		/* Modif DC */
		$('#triangle_search').attr("src","/gallery2/images/PITC_triangle_bas.gif");
/* ONEBLOCK HU
		$('#triangle_find').attr("src","/gallery2/images/PITC_triangle.gif");
		$('#triangle_selection').attr("src","/gallery2/images/PITC_triangle.gif");
		$('#findPICT').hide(transTime);
		$('#selectionPICT').hide(transTime);
ONEBLOCK HU */
		div_hiddefind = true;
		div_hiddeselect = true;
		
		openBlock('panier', 0);

		/* Modif DC */
		$('#triangle_panier').attr("src","/gallery2/images/PITC_triangle.gif");

		//$(' .liste_complement_panier').hide(transTime);
		show_ProductCart(0);
		div_hiddenav = false;
		div_hiddepan = true;
	} else {
		$('#close_navigation').hide(transTime);
/* ONEBLOCK HU
		$('#searchPICT').hide(transTime);
		$('#triangle_search').attr("src","/gallery2/images/PITC_triangle.gif");		 
ONEBLOCK HU */
		div_hiddenav = true;
		 
	}
	registerNavigation();
}

function close_MenuFind(force) {
	
	if(force == undefined) {
		force = (div_hiddefind) ? 1 : 0;
	}

	if (force == 1) {
		//$(this).hide();
		$('#close_navigation_find').show(transTime);
		$('#findPICT').show(transTime);
		$('#triangle_find').attr("src","/gallery2/images/PITC_triangle_bas.gif");
/* ONEBLOCK HU
		$('#triangle_search').attr("src","/gallery2/images/PITC_triangle.gif");
		$('#triangle_selection').attr("src","/gallery2/images/PITC_triangle.gif");
		$('#searchPICT').hide(transTime);
		$('#selectionPICT').hide(transTime);
ONEBLOCK HU */
		div_hiddenav = true;
		div_hiddeselect = true;

		openBlock('panier', 0);
		$('#triangle_panier').attr("src","/gallery2/images/PITC_triangle.gif");
				
		//$(' .liste_complement_panier').hide(transTime);
		show_ProductCart(0);
		div_hiddefind = false;
		div_hiddepan = true;
	} else {
		$('#close_navigation_find').hide(transTime);
/* ONEBLOCK HU
		$('#findPICT').hide(transTime);
ONEBLOCK HU */
		div_hiddefind = true;

	}
	registerNavigation();
}

function close_MenuSelect(force){
	
	if(force == undefined) {
		force = (div_hiddeselect) ? 1 : 0;
	}

	if (force == 1) {
		$('#close_navigation_selection').show(transTime);
		$('#selectionPICT').show(transTime);
		$('#triangle_selection').attr("src","/gallery2/images/PITC_triangle_bas.gif");
/* ONEBLOCK HU
		$('#triangle_search').attr("src","/gallery2/images/PITC_triangle.gif");
		$('#triangle_find').attr("src","/gallery2/images/PITC_triangle.gif");
		$('#searchPICT').hide(transTime);
		$('#findPICT').hide(transTime);
ONEBLOCK HU */
		div_hiddenav = true;
		div_hiddefind = true;
		
		openBlock('panier', 0);
		$('#triangle_panier').attr("src","/gallery2/images/PITC_triangle.gif");
		
		show_ProductCart(0);
		div_hiddeselect = false;
		div_hiddepan = true;
	} else {
		$('#close_navigation_selection').hide(transTime);
/* ONEBLOCK HU
		$('#selectionPICT').hide(transTime);
ONEBLOCK HU */
		div_hiddeselect = true;

	}
	registerNavigation();
	
}

function close_MenuPanier(force) {

	if(force == undefined) {
		force = (div_hiddepan) ? 1 : 0;
	}

	if (force) {
		openBlock('panier');
		/* Modif DC */
		$('#triangle_panier').attr("src","/gallery2/images/PITC_triangle_bas.gif");
	}
	else {
		openBlock('panier', 0);
		/* Modif DC */
		$('#triangle_panier').attr("src","/gallery2/images/PITC_triangle.gif");
	}
	registerNavigation();
}

function close_Zoom(force){

	var ltie6 = $.browser.msie && /MSIE (6\.)/.test(navigator.userAgent);
	
	if(force == undefined) {
		force = (div_hiddezoom) ? 1 : 0;
	}

	if (force) {
		div_hiddezoom = false;
		$('.artiste_action_img').attr('src', function() {
			return  $(this).attr('src').replace('_on','_off');
		});
		if (zoom_hover == 0) {
			$('#menu_haut_nav').hide(0); 
			$('#menu_haut_nav_bg').hide(0);
		}
		if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
			$("body","html").css({height: "100%", width: "100%"});
			$("html").css("overflow","hidden");
			if (document.getElementById("vote_HideSelect") === null) {
				$("body").append("<iframe id='vote_HideSelect'></iframe><div id='vote_overlay'></div>");
			}
		}else{//all others
			if(document.getElementById("TB_overlay") === null){
				$("body").append("<div id='vote_overlay'></div>");
			}
		}

		if(tb_detectMacXFF()){
			$("#vote_overlay").addClass("zoom_overlayMacFFBGHack");
		}else{
			$("#vote_overlay").addClass("zoom_overlayBG");
		}
		image_show(image_index);
		$("#imagearea").css("z-index","102");
		$("#tell_friend_page").css("z-index","103").animate({ bottom : 5});
		$("#menu_action").hide(0);
		$('#img_zoom').html('Quitter');
		$('#img_zoom').attr('Title', 'Quitter le mode plein ecran');
		$('.menu_haut_artiste').css("z-index","102").css('color','#CCCCCC').css('top','50%').css('margin-top','-80px');
		$('.artiste_titre').css('background-image','none');
		$('.menu_haut_artiste_bottom').css('background-image','none');
		$('.more').css('background','none').css('color','#CCCCCC');
		$('.menu_haut_artiste_bottom .centre > a').each( function () {
				$(this).css('color', '#FF6600');
			});
/*
		$('.artiste_produit').css('color', '#CCCCCC');
*/
		$('#menu_haut_titre').css("z-index","102");
		$('#menu_haut_titre').css("position","absolute");
		$('#menu_haut_titre').css("left","0");
		$('#piclens_badge').css('display','block');
		
		if (!ltie6){
			$("#imagearea").mouseover(function(){
				if(zoom_hover == 0) {
					zoom_hover = 1;
					$("#menu_haut_nav").fadeIn(0);
					$("#menu_haut_nav_bg").fadeIn(0);
					registerNavigation();
				}
			}).mouseout(function(){
				if(zoom_hover == 1) {
					zoom_hover = 0;
					setTimeout("if (!div_hiddezoom && !zoom_hover) {$('#menu_haut_nav').fadeOut(fadeOutTime); $('#menu_haut_nav_bg').fadeOut(fadeOutTime);}",100);
					registerNavigation();
				}
			});
		}
		
	} else {
		div_hiddezoom = true;
		$('.artiste_action_img').attr('src', function() {
			return  $(this).attr('src').replace('_off','_on');
		});
		image_show(image_index);
		$("#menu_action").show(0);
		$('#img_zoom').html('Zoom');
		$('#img_zoom').attr('Title', 'Passer en mode plein ecran');
		/*$("#boutton_vote").attr("style","");*/
		$('#vote_overlay,#vote_HideSelect').trigger("unload").unbind().remove();
		$("#imagearea").css("z-index","");
		$("#imagearea").unbind();
		$('.menu_haut_artiste').attr("style","");
		$('.menu_haut_artiste_bottom').attr("style","");
		$('.menu_haut_artiste_bottom .centre > a').each( function () {
				$(this).attr("style","");
			});
		$('.artiste_titre').attr("style","");
		$("#tell_friend_page").css("z-index","").animate({ bottom : 120});
		$("#menu_haut_titre").css("z-index","");
		$("#menu_haut_titre").css("position","");
		$("#menu_haut_titre").css("left","");
		$('.more').attr("style","");
		$('#piclens_badge').css('display','none');

	}

	registerNavigation();
}

function setBlockPanier(open) {
	
	if(open == undefined) open = 1;
	if(open) {
		close_MenuGauche(1);

		// hide cancel icon
	//$('#open_panier span').css('display', 'block');
	$('#menu_panier').show(transTime);
	$('#checkoutButtons').show(transTime);
		
	div_hiddepan = false;
	} else {
		$('#checkoutButtons').hide(transTime);
		$('#menu_panier').hide(transTime);
		// hide cancel icon
		//$('#open_panier span').css('display', 'none');			
		div_hiddepan = true;
	}
	
}


function openBlock(bloc, open) {
	
	if(open == undefined) open = 1;
	
	if(bloc == 'panier') {
		
		if(open) {
			close_MenuGauche(1);

			// hide cancel icon
		setBlockPanier(open);		
		
		$('#searchPICT').hide(transTime);
		$('#findPICT').hide(transTime);
		$('#selectionPICT').hide(transTime);
		$('#block_LoginForm').hide(transTime);
			
		/*
		$('#close_login').hide()			
		$('#close_navigation').hide();
		
		$('#open_login').show(transTime)
		$('#open_navigation').show(transTime);
		*/
		$('.liste_search').hide(transTime);
	
		div_hiddenav = true;
		div_hiddefind = true;
		div_hiddeselect = true;
		div_hiddepan = false;
		div_hiddelog = true;

		$('#triangle_search').attr("src","/gallery2/images/PITC_triangle.gif");
/* ONEBLOCK HU
		$('#triangle_find').attr("src","/gallery2/images/PITC_triangle.gif");
		$('#triangle_selection').attr("src","/gallery2/images/PITC_triangle.gif");
ONEBLOCK HU */
		$('#triangle_panier').attr("src","/gallery2/images/PITC_triangle_bas.gif");

		} else {
			setBlockPanier(open);			
		}
		//alert('open bloc pannier');
	} else if(bloc == 'navigation') {
		$('#close_navigation').show(transTime);
		$('#searchPICT').show(transTime);		
		openBlock('panier', 0);
		
		
		//$(' .liste_complement_panier').hide(transTime);
		show_ProductCart(0);
		div_hiddenav = false;
		div_hiddepan = true;

	}
	/* Modif DC */
	else if(bloc == 'navigation_find') {
		$('#close_navigation_find').show(transTime);
		$('#findPICT').show(transTime);		
		openBlock('panier', 0);
		
		
		//$(' .liste_complement_panier').hide(transTime);
		show_ProductCart(0);
		div_hiddefind = false;
		div_hiddepan = true;

	} else if(bloc == 'navigation_selection') {
		$('#close_navigation_selection').show(transTime);
		$('#selectionPICT').show(transTime);		
		openBlock('panier', 0);
		
		
		//$(' .liste_complement_panier').hide(transTime);
		show_ProductCart(0);
		div_hiddeselect = false;
		div_hiddepan = true;

	}

}


function close_ProductCart() {
	show_ProductCart(0);
}
function close_panier_ProductCart() {
	show_panier_ProductCart(0);
}


function show_ProductCart(off) {
	if(off == 0) {
		$('#liste_complement_panier').hide(transTime);
		$('#liste_complement_panier').html('');
		$('#product_overlay,#product_HideSelect').trigger("unload").unbind().remove();
		$("#produits").hide();
		window_format = false;
//		$('#checkoutButtons').hide(transTime);
	} else {
		$('#liste_complement_panier').show(transTime);
//alert('die cart prod');
		show_panier_ProductCart(0);
//		$('#checkoutButtons').show(transTime);
	}
}

function show_panier_ProductCart(off) {
	if(off == 0) {
		$('#detail_produit_panier').hide(transTime);
		$('#detail_produit_panier').html('');
//alert('die cart prod');
	} else {
		$('#detail_produit_panier').show(transTime);
		show_ProductCart(0);
//		$('#checkoutButtons').show(transTime);
	}

}

function setFullScreen() {
	 	if(!div_hidde || !div_hiddemenu_bas) {
		close_MenuBas(0);
		close_MenuGauche(0);
 	} else {
		close_MenuBas(1);
		close_MenuGauche(1); 		
 	}
}

function gestion_menu() {
	$('#block_LoginForm').hide();

	if ($('#options').size() == 0) return false; 
/*	 var  div_hidde = false;
	 var  div_hiddelog = false;
	 var  div_hiddenav = false;
	 var  div_hiddepan = true;
 	 var  div_hiddemenu_bas = false;
 	 var  div_show_bloc_artiste_more = false;*/
  	 

	// masquer ou afficher tout le menu de gauche
	//$('#opts').click( function () {
	//	close_MenuGauche();
	//	return false;
	//});
	
	// masquer ou afficher le menu login
	$('#close_login').click( function () {
		if (!div_hiddelog) {
			$(this).hide();
			$('#open_login').show();
			$('#block_LoginForm').hide(transTime);
			
			
			div_hiddelog = true;
		}
		
		return false;
	});
	$('#open_login').click( function () {
		if (div_hiddelog) {
			
			
			$('#block_LoginForm').show(transTime);
			//$('.liste_complement_panier').hide(transTime);
			show_ProductCart(0);
			$(' .liste_search').hide(transTime);
			$(' #searchPICT').hide(transTime);
			
			$('#menu_panier').each(function() {
				$(this).hide(transTime);
				$('#close_panier').hide();
				$('#open_panier').show(transTime);
			});
			
			div_hiddelog = false;
			div_hiddepan = true;
		}
		else {
			$('#block_LoginForm').hide(transTime);
			div_hiddelog = true;
		}
		return false;
	});

	
	// masquer ou afficher le menu Navigation
	$('#open_navigation').click( function () {
		close_MenuNav();
		return false;
	});
	
/* ONEBLOCK HU
	// masquer ou afficher le menu Navigation_Find
	$('#open_navigation_find').click( function () {
		close_MenuFind();
		return false;
	});
	// masquer ou afficher le menu Navigation_Selection
	$('#open_navigation_selection').click( function () {
		close_MenuSelect();
		return false;
	});
ONEBLOCK HU */

	// masquer ou afficher le panier
	
	$('#open_panier').click( function () {
		close_MenuPanier();
		return false;
	});
	
	// masquer ou afficher tous le menu du bas
	$('#close_menu_bas').click( function () {

		close_MenuBas();
		return false;
	});
	
	// masquer ou afficher tous les menus
	$('#close_all').click( function () {
		setFullScreen();
		
		// force reload central
		image_show(image_index);

		return false;
	});
	
	
	$('.bloc_artiste').mouseover( function () {
		//$(this).css('width','230px');
//		topOffset = $(this).attr('height');
		if(!div_show_bloc_artiste_more) {
			$(this).find('div').each( function () {
				if($(this).hasClass('resume')) {
					$(this).hide(0);				
				} else {
					$(this).show(0);
//					$(this).css('top',)
				}
			});
		div_show_bloc_artiste_more = true;
		}
	}).mouseout(function () {		
	if(div_show_bloc_artiste_more) {
		$(this).find('div').each( function () {
			if($(this).hasClass('more') || $(this).hasClass('lien') ) {
				$(this).hide(0);				
			} else {
				$(this).show(0);
			}
		});
		div_show_bloc_artiste_more = false;
		//$(this).css('width','');
		}
	});
	
	$('#div_commander').mouseover(function () {
		$('#div_commander span').show(0);
	}).mouseout(function () {
		$('#div_commander span').hide(0);
	}).click(function () {
		//$(' .liste_complement_panier').show(transTime);
	})
	;
	
/*	$('#menu_haut3').mouseover(function () {
		$('#livraison_noel_info').show();
	}).mouseout(function () {
		$('#livraison_noel_info').hide();		
	});
*/
	var ouvert_m_action = false  
	$('#b_menu_action').click( function () {
		if (ouvert_m_action) {
			$(this).find('img').attr('src',imagePath + 'PITC_Button_ContextMenu.gif');
			$('#m_menu_action').hide(transTime);
			ouvert_m_action = false;
		}
		else {
			$(this).find('img').attr('src',imagePath + 'cancel.gif');
			$('#m_menu_action').show(transTime);
			ouvert_m_action = true;
		}
		return false;
		
	});

	$('#img_zoom').click( function () {
		/*if (div_hiddemenu_bas) {
			close_MenuBas(1);
		} else {
			close_MenuBas(0);
		}*/
		div_hiddezoom ? pageTracker._trackPageview("/navigation/zoom-in") : pageTracker._trackPageview("/navigation/zoom-out"); // TRACKING - Modifs HU
		close_Zoom();
		return false;		
	});

	
	// === VISITE PERSONNALISEE ===
	// ============================
	$('#visite_perso').click( function () {
		id = 'visite_perso_page';
		$('.liste_search').each(function () {
			if (this.id != id)
				$(this).hide(transTime);
		});
		$('#visite_perso_page').show(transTime);
	});
	
	$('#visite_perso_page_styles > a.val').click(function () {
			$(this).toggleClass('on');
			return false;	
	});
	
	$('#visite_perso_page_couleurs > a.val').click(function () {
			$(this).toggleClass('on');
			return false;	
	});
	
	$('#visite_perso_page .annuler').click( function () {
		$('#visite_perso_page').hide(transTime);
	});

	$('#visite_perso_page .submitSearch').click( function () { 
		$('#visite_perso_page').hide(transTime);
		liste = "";
		$('#visite_perso_page_styles > a.val').each(function () {			
			if ($(this).hasClass('on')){
				if (liste =="") {sep = "";}
				else {sep = ", ";}
				liste = liste  + sep + $(this).html();
			}
		});
		$('#visite_perso_page_couleurs > a.val').each(function () {			
			if ($(this).hasClass('on')){
				if (liste =="") {sep = "";}
				else {sep = ", ";}
				liste = liste  + sep + $(this).html();
			} 
		});

		if (liste == "") {
			window.location = $('#submitVisitePerso').attr('href');
		}
		else {
			$('#visite_perso').addClass('on').find('span').html(' : '+liste);
			clearSearchCriteria();
			criteoselection = true;
			SubmitSearch();
		}
			
		return false;

	});

	// === COMMENTAIRES ===
	// ====================
	$('.linkcomment').click( function () {
		div_hiddecomment = false;
		image_show(image_index);
		$('#imagearea').css('z-index','102');
		$('#menu_action').hide(0);
		$('#menu_haut_nav').hide(0);
		$('#menu_haut_nav_bg').hide(0);
	});

	// === PHOTOGRAPHES ===
	// ====================
	$('#liste_photographes').click( function () {
		id = 'liste_photographes_complet';
		$('.liste_search').each(function () {
			if (this.id != id)
				$(this).hide(transTime);
		});
		//$('.liste_complement_panier').hide(transTime);

		$('#liste_photographes_complet').show(transTime);
	});

	$('#liste_photographes_complet .annuler').click( function () {
		$('#liste_photographes_complet').hide(transTime);
		return false;
	});

	// === GALERIES ===
	// ================
	$('#liste_galeries').click( function () {
		id = 'liste_galeries_complet';
		$('.liste_search').each(function () {
			if (this.id != id)
				$(this).hide(transTime);
		});
		$('#liste_galeries_complet').show(transTime);		
	});

	$('#liste_galeries_complet .annuler').click( function () {
		$('#liste_galeries_complet').hide(transTime);
		return false;
	});

	// === TELL-A-FRIEND ===
	// =====================

	$('#idtellafriend').ajaxForm();

	$('#tell_friend').click( function () {
		id = 'tell_friend_page';
		reset();
		$('#taf_report').hide();
		taf_ouvert = true;
		$('#tell_friend_page').show(transTime); 
	});
	$('#tell_friend_page .annuler').click( function () {
		close_tellafriend();
	});
	$('#tell_friend_page .envoyer').click( function () {
		validate();
	});

	// === Incitation au vote ===
	// =====================	
	/* */
	$('#lien_voter_page .annuler,#savoir_plus').click( function () {
		close_incitation();
	});
	$('#sans_message').click( function () {
		arret_message = 1;
		close_incitation();
	});
	
	
}

function close_incitation() {

	$('#lien_voter_page').hide(transTime);
	var divSrc = document.getElementById('bouton_vote_copie');
	var divDest = document.getElementById('boutton_vote');
	switch_div(divSrc,divDest);
	window_vote = false;
	$('#vote_overlay,#vote_HideSelect').trigger("unload").unbind().remove();
	$('#imagearea').css('z-index','');
	$('#imagearea').css('left',decalage_init);
	$('#imagearea > a').css('cursor','pointer');
	$('#imagearea > a').attr('title','Ajouter au panier');
	$('#menu_action').css('visibility','visible');
	$('#menu_haut_nav').css('visibility','visible');
	$('#menu_haut_nav_bg').css('visibility','visible');
}

function gestion_menu_image() {

	if ($('#thumbs').size ==0) return false;
	
	$('#thumbs > a ').click( function () { 
		$('#thumbs > a ').each(function () {
			$(this).removeClass('on');
		});
		$(this).addClass('on');
		return false;
	});
	
	$('#prev_b').click(function () {
		div_hiddezoom ? pageTracker._trackPageview('/navigation/prev') : pageTracker._trackPageview('/navigation/prev-in-zoom');
		image_prev();	
	}); 
	
	$('#next_b').click(function () {
		div_hiddezoom ? pageTracker._trackPageview('/navigation/next') : pageTracker._trackPageview('/navigation/next-in-zoom');
		image_next();	
	}); 	
	
	$('#next_img').mouseover(function () {
	//alert('mous over'+$(this).attr('src'));
		$(this).attr('src', function() {
				return  $(this).attr('src').replace('_off','_on');
			});
	}).mouseout(function () {
		$(this).attr('src', function() {
				return  $(this).attr('src').replace('_on','_off');
			});
	});
	$('#prev_img').mouseover(function () {
		$(this).attr('src', function() {
				return  $(this).attr('src').replace('_off','_on');
			});
	}).mouseout(function () {
		$(this).attr('src', function() {
				return  $(this).attr('src').replace('_on','_off');
			});
	});

}


function gestion_vote() {
	var ltie6 = $.browser.msie && /MSIE (6\.)/.test(navigator.userAgent);	
	if ($('#menu_haut3').size ==0) {
		return false;
	}
		// MODIF JC
		$('.b_nav').mouseover(function () {
			$(this).children().attr('src', function() {
					if (ltie6) {
						return $(this).attr('src').replace('_off', '_on');
					} else {
						return $(this).attr('src').replace('_off.gif', '_on.png');
					}
				});
			
		}).mouseout(function () {
			$(this).children().attr('src', function() {
					if (ltie6) {
						return $(this).attr('src').replace('_on', '_off');
					} else {
						return $(this).attr('src').replace('_on.png', '_off.gif');
					}
				});
			});
}

// now directly with iframe ThickBox
function gestion_iframe() {
/*	if ($('#apropo_auteur').size() == 0 || $('#popup_details').size() == 0) return false;

	$('#apropo_auteur').click( function () {
		$('#popup_details').show();
	});
	$('#info_box').click( function () {
		$('#popup_details').show();
		return false
	});
	$('#CheckOut').click( function () {
		$('#popup_details').show();
		return false
	});
	
	$('#aide_lien').click( function () {
		$('#popup_details').show();
		return false
	});
	
	
	$('#close_iframe').click(function () { 
		$('#popup_details').hide(0);
	});
*/
}


function initOptionsLabelRadio(cible, type) {
	
	if(type == 'label') {
		nom_radio = cible.prev().attr('name');
		//alert('clic radio on '+nom_radio);
	
		cible.prev().parent().parent().find(':radio').each(function () {
			if ($(this).attr('name') == nom_radio)
				$(this).next().removeClass('on');
		});
		cible.addClass('on');

	} else {
		nom_radio = cible.attr('name');
	
		cible.parent().parent().find('label').each(function () {
			//alert('check radio'+$(this).attr('for'));
			$(this).removeClass('on');
		});
		cible.next().addClass('on');
		
		cible = cible.next();
	}
	
	var px2show = cible.html().split('(');
	px2show = px2show[1].split(')');
	px2show = px2show[0];
	$('#prix').html(px2show);

	if (window_format) {
		var valy = cible.html().split('x');
		var valx = valy[1].split(' cm');
		
		$("#produits_img").width(2*valx[0]).height(2*valy[0]).css("margin-top",-valy[0]-1).css("margin-left",-valx[0]-1);
		
		var quatretiers=0;
		var car=0;

		var pos = (valy[0]>valx[0]) ? 0 : 1;
		
		if (pos){
		var car = ((valx[0]/valy[0])<1.1) ? 1 : 0;
		if (!car){
			var quatretiers = ((valx[0]/valy[0])<=1.4) ? 1 : 0;
		}
		}
		else {
		var car = ((valy[0]/valx[0])<1.1) ? 1 : 0;
		if (!car){
			var quatretiers = ((valy[0]/valx[0])<=1.4) ? 1 : 0;
		}
		}
	
		var product_type = cible.prev().attr("value");
		$(".desc_produit").hide();
	
		$("#cadre_bois").css("border","6px solid #fff").css("background-color","rgb(255,255,255)");
		$("#produits_img").css("border","1px solid #fff");
		var img_addr = $("#thumbs > .on > img").attr("src");
		$("#produits_img").attr("src",img_addr);
		switch (product_type) {
			case "12":
				$("#cadre_bois").css("border","3px solid #fff").css("background-color","rgb(255,255,255)");
				$("#contrecollage").show();
				nombre_tirage = 1 + data_numero[image_index][12] + data_numero[image_index][15];
				break;
			case "15":
				$("#encadre_petit").show();
				nombre_tirage = 1 + data_numero[image_index][12] + data_numero[image_index][15];
				if (pos){
					$("#cadre_bois").width(82).height(58).css("margin-top","-29px").css("margin-left","-41px");
				}
				else {
					$("#cadre_bois").width(58).height(82).css("margin-top","-41px").css("margin-left","-29px");
				}
				$("#cadre_bois").css("border","3px solid #000").css("background-color","rgb(255,255,240)");
				$("#produits_img").css("border","1px solid #ccc");
				break;
			case "13":
				$("#contrecollage").show();
				nombre_tirage = 1 + data_numero[image_index][10] + data_numero[image_index][13] + data_numero[image_index][18];
				break;
			case "10":
				$("#tirage").show();
				nombre_tirage = 1 + data_numero[image_index][10] + data_numero[image_index][13] + data_numero[image_index][18];
				break;
			case "14":
				$("#contrecollage").show();
				nombre_tirage = 1 + data_numero[image_index][14] + data_numero[image_index][11];
				var img_addr = $("#imagearea > #image > img").attr("src");
				$("#produits_img").attr("src",img_addr);
				break;
			case "11":
				$("#tirage").show();
				nombre_tirage = 1 + data_numero[image_index][14] + data_numero[image_index][11];
				var img_addr = $("#imagearea > #image > img").attr("src");
				$("#produits_img").attr("src",img_addr);
				break;
			case "16":
				$("#contrecollage_grand").show();
				nombre_tirage = 1 + data_numero[image_index][16];
				var img_addr = $("#imagearea > #image > img").attr("src");
				$("#produits_img").attr("src",img_addr);
				break;	
			case "18":
                        	$("#encadre_grand").show();
                        	nombre_tirage = 1 + data_numero[image_index][10] + data_numero[image_index][13] + data_numero[image_index][18];
                		if (pos){
					if (car){
						$("#cadre_bois").width(78).height(78).css("margin-top","-39px").css("margin-left","-39px");
					}
					else if (quatretiers){
						$("#cadre_bois").width(98).height(78).css("margin-top","-39px").css("margin-left","-39px");
					}
					else {
                                        	$("#cadre_bois").width(118).height(78).css("margin-top","-39px").css("margin-left","-59px");
                              }
				}
                        else {
                              if (car) {
						$("#cadre_bois").width(78).height(78).css("margin-top","-39px").css("margin-left","-39px");
					}
					else if (quatretiers){
                              	$("#cadre_bois").width(78).height(98).css("margin-top","-39px").css("margin-left","-39px");
                              }
					else {
						$("#cadre_bois").width(78).height(118).css("margin-top","-59px").css("margin-left","-39px");
                              }
				}
				$("#cadre_bois").css("border","6px solid #000").css("background-color","rgb(255,255,240)");
				$("#produits_img").css("border","1px solid #ccc");
                        	break;
			default:
				break;
		}
		$("#img_tirage").html("Edition limit&eacute;e : tirage num&eacute;ro " + nombre_tirage + " sur 200<br/>Accompagn&eacute; d'un certificat d'authenticit&eacute;");	
	}
}

function gestion_productCart() {

	if ($('#liste_complement_panier').size == 0) return false;
	//alert('gestion prod cart');
	 
	/* on masque tous les boutton radio */ 
	
	//$('input:radio').css('visibility','hidden');
	
	$('#productCart').find('label').click( function () {
		initOptionsLabelRadio($(this), 'label');
	});
	$('#productCart').find(':radio').click( function () {
		initOptionsLabelRadio($(this), 'radio');
	});

	$('#productCart_cart').find('label').click( function () {
		initOptionsLabelRadio($(this), 'label');
	});
	$('#productCart_cart').find(':radio').click( function () {
		initOptionsLabelRadio($(this), 'radio');
	});
}


function gestion_panier() {

	 gestion_productCart();
	//on masque tous les pannier
	//$('.liste_complement_panier').hide();
	show_ProductCart(0);
	show_ProductCart(0);
	
	$('.lien_panier').each(function () {
	
	}).click(function () {
		$('.liste_search').hide(transTime);
		
		/*
		class_name = this.id;		
		$('.liste_complement_panier').each( function () {
			if (!$(this).hasClass(class_name))
				$(this).hide(transTime);
		});*/
		show_ProductCart(1);
			
/*		$('.' + class_name).show(transTime).find('a').each(function() {
			$(this).click( function () {
				$('.' + class_name).hide(transTime);
				return false;
			});
		});
*/	
		return false;
	});
	
	
	$('#voir_pannier').mouseover(function () {
		$(this).attr('src', function() {
				return  $(this).attr('src').replace('_off','_on');
			});
	}).mouseout(function () {
		$(this).attr('src', function() {
				return  $(this).attr('src').replace('_on','_off');
			});
	}).click(function () {
		close_MenuGauche(1); 		
		openBlock('panier');
		$('#triangle_panier').attr("src","/gallery2/images/PITC_triangle_bas.gif");
		return false;
		});
	
	$('#b_ajout_paniers').mouseover(function () {
		$(this).attr('src', function() {
				return  $(this).attr('src').replace('_off','_on');
			});
		
	}).mouseout(function () {
		$(this).attr('src', function() {
				return  $(this).attr('src').replace('_on','_off');
			});
	});	

	$('#menu_action').click(function () {
		openChoixFormat();	
		return false;
	});

	$('.artiste_produit').click(function () { 
		openChoixFormat();	
		return false;
	});

/*	$('#CheckOut').click(function () { 
		alert('on check out !');
		return false;
	});*/
}

function gestion_arrondis() {	
	/*$('#options').nifty("transparent ");
	$('.liste_complement_panier').nifty("transparent");*/
}

function openChoixFormat() {
	// TRACKING - Modifs HU
	//alert("/formats");
	pageTracker._trackPageview("/formats");


	window_format = true;
	// Ouverture de la nouvelle interface prix et produits
	if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
		$("body","html").css({height: "100%", width: "100%"});
		$("html").css("overflow","hidden");
		if (document.getElementById("vote_HideSelect") === null) {
			$("body").append("<iframe id='product_HideSelect'></iframe><div id='product_overlay'></div>");
		}
	}else{//all others
		if(document.getElementById("TB_overlay") === null){
			$("body").append("<div id='product_overlay'></div>");
		}
	}

	if(tb_detectMacXFF()){
		$("#product_overlay").addClass("product_overlayMacFFBGHack");
	}else{
		$("#product_overlay").addClass("product_overlayBG");
	}

	var img_title = $("#menu_haut .block-Show .artiste_titre").html();
	$("#img_title").html(img_title);
	var nombre_tirage = 1 + data_numero[image_index][12] + data_numero[image_index][15];
	$("#img_tirage").html("Edition limit&eacute;e : tirage num&eacute;ro " + nombre_tirage + " sur 200<br/>Accompagn&eacute; d'un certificat d'authenticit&eacute;");

	var img_addr = $("#thumbs > .on > img").attr("src");
	$("#produits_img").attr("src",img_addr);

	$("#produits").show();
	$("img[@src$=png]").ifixpng();

	$(".desc_produit").hide();
	$("#contrecollage_img").hide();
	$("#contrecollage").show();

	var imgx = $("#imagearea > #image > img").width();
	var imgy = $("#imagearea > #image > img").height();
	$("#produits_img").height("").width("");
	if ((imgx-imgy)>=0) {
		$("#produits_img").height(2*24);
		$("#cadre_bois").width(88).height(58).css("margin-top","-29px").css("margin-left","-44px");
	} else {
		$("#produits_img").width(2*24);
		$("#cadre_bois").width(58).height(88).css("margin-top","-44px").css("margin-left","-29px");
	}
	var valxinit = $("#produits_img").width();
	var valyinit = $("#produits_img").height();
	$("#cadre_bois").css("border","3px solid #fff").css("background-color","rgb(255,255,255)");
	$("#produits_img").css("border","1px solid #fff");

	$("#produits_img").width(valxinit).height(valyinit).css("margin-top",Math.floor(-valyinit/2-1)).css("margin-left",Math.floor(-valxinit/2-1));

	// va cherche rle contenu � afficher en ajax
	getProductCart(data_productIdList[image_index], 0);

	$('.liste_search').hide(transTime);
		
	show_ProductCart(1);

}
function reset() {
	document.tellafriend.name.value="";
	document.tellafriend.email.value="";
	document.tellafriend.fmail1.value="";
	document.tellafriend.fmail2.value="";
	document.tellafriend.fmail3.value="";
}

function validate() {

	if (document.tellafriend.fmail1.value.length==0) {
	alert("Oups! vous n'avez pas rempli l'adresse de votre ami");
	return false;
	}
	
	if (document.tellafriend.email.value.length==0) {
	alert("Oups! vous n'avez pas rempli votre adresse e-mail");
	return false;
	}
	if (document.tellafriend.name.value.length==0) {
	alert("Oups! vous n'avez pas entre votre nom");
	return false;
	}
	
	//document.tellafriend.submit();
	//return true;
	$('#idtellafriend').ajaxSubmit();
	$('#taf_report').show();
	setTimeout("close_tellafriend()",2500);	
	
	return false;
}

function close_tellafriend() {
	$('#tell_friend_page').hide(transTime);
	taf_ouvert = false;
}

function ganalytics() { 
	pageTracker._trackPageview("/ajout-panier");
	if (!div_hiddezoom) {
		close_Zoom(0);
	}	
}
