Index: /extensions/Autosize/autosize.inc.php
===================================================================
--- /extensions/Autosize/autosize.inc.php	(revision 22359)
+++ /extensions/Autosize/autosize.inc.php	(revision 22360)
@@ -31,4 +31,17 @@
 	} //function cl_autosize_admin
 
+	/**************************
+	 * loc_begin_picture       *
+	***************************/
+	static public function init_0(){
+		global  	$events ;
+		$hasContent=(empty($content) )?'false':'true';
+		if(empty($events)) $events = (object) '';
+		$events->ligne=40;
+		$events->event +=1;
+		$events->function="init_0";
+		$events->content=$hasContent;
+		self::AfficheDebug();
+	}
 
 	/**************************
@@ -36,15 +49,16 @@
 	**************************/
 	static public function autosize_calcContent($content,$element_info){
-		global $conf,$page, $template,$picture,$user;
+	  global $conf,$page, $template,$picture,$user;
 		global $defined_types,$pictureSelType,$pictureMap ,$pictureDeriv ,$liste_type,$SRC_IMG;
-		global $autosize_parametres,$user_status;
+		global $autosize_parametres,$user_status,$events,$error_message,	$imgSizeWH; 
 		//==============================================================================
-		global $DEBUG_autosize,$infos_message,$error_message;
-		if(preg_match("|event|", $DEBUG_autosize, $val))  $infos_message =  "autosize_calcContent, " ;
-		if(!realpath($element_info['path'])) return $content;
-
+		global $infos_message,$error_message;
 		$ma_page=isset($page['body_id'])?$page['body_id']:"" ;
 		if ($ma_page !='thePicturePage') return ;
-		$default_size =  $conf['derivative_default_size'];
+		if(!realpath($element_info['path'])){$error_message .= "Error path";};
+		//==========================================================
+		$current = $template->get_template_vars('current');
+		if (!isset($current)) return ;		
+    $default_size =  $conf['derivative_default_size'];
 		//============================================================
 		$types = array_intersect(array_keys(ImageStdParams::get_defined_type_map()), array("Autosize","SelMaxi"));
@@ -57,25 +71,12 @@
 			unset (  $_COOKIE['autosize_reload']) ;
 		}
-		//=============================================================
+
+		//==============================================================
+		$autosize_parametres = cl_autosize_Get_Options();	
 		self::get_cookies();
-		if(preg_match("|test|", $DEBUG_autosize, $val)) {
-			$infos_message .= "#65 autosize_calcContent: <br>";
-			if ( isset($_COOKIE['pwg_id']) ) unset ($_COOKIE['pwg_id']) ;
-			$infos_message .=  "SESSION:"  . cl_print_var($_SESSION) ;
-			$infos_message .=  "COOKIE:"  . cl_print_var($_COOKIE) ;
-			$infos_message .=  "GET:"  . cl_print_var($_GET) ;
-			$infos_message .= "POST:"  . cl_print_var($_POST) ;
-      $infos_message .= "SERVER:"  . cl_print_var($_SERVER["HTTP_HOST"]) ;
-			$infos_message .= "$pictureDeriv $pictureSelType $pictureMap ";
-		}
-		//===================================================================
-		$current = $template->get_template_vars('current');
-		if (!isset($current)) return ;
-		//===============================================================
-		global $imgSizeWH;
+		//=============================================================		
 		$derivative = $current['src_image'] ;
 		$imgSizeWH = $derivative->get_size();
 		$SRC_IMG    = $derivative->get_url();
-
 		$picture['current']['scaled_width']=$imgSizeWH[0];
 		$picture['current']['scaled_height']= $imgSizeWH[1];
@@ -83,174 +84,148 @@
 		$picture['current']['image_url']=$SRC_IMG;
 		$picture['current']['thumbnail']=$SRC_IMG;
-
+		$hasContent=(empty($content) )?'false':'true';
 		//==============================================================
-		$autosize_parametres = cl_autosize_Get_Options();
+		if(empty($events)) $events= (object) '';
+		$events->ligne=89;
+		$events->event +=1;
+		$events->function="autosize_calcContent";
+		$events->content=$hasContent;
+		self::AfficheDebug();
 		return false ;
 	}//calc_content ;
-
-
-
 	/*********************
 	 * INIT
 	*********************/
-	static public function init_3(){
-		global $DEBUG_autosize,$infos_message,$error_message;
-		if(preg_match("|event|", $DEBUG_autosize, $val))  $infos_message .=  "init_3, " ;
-
-	}
+
 	static public function init_1($content, $image)
 	{
 		global $conf, $template, $page;
-		global $DEBUG_autosize,$infos_message,$error_message;
+		global $theContainerHeight,$theContainerWidth;
+		global $theMainImageWidth,$theMainImageHeight ;
+		global $infos_message,$error_message;
 		if(!realpath($image['path'])) return $content;
-		if(preg_match("|event|", $DEBUG_autosize, $val))  $infos_message .=  "init_1, " ;
-		if(!isset($conf['AS_panorama'])) return $content;
-		if(  !is_array($conf['AS_panorama']) )			return $content;
-		$asp = & $conf['AS_panorama'];
-		if(!isset($asp['in_mode_360'])) $asp['in_mode_360']="";
-		if(!isset($asp['in_mode_180'])) $asp['in_mode_180']="";
-		if ( !stristr($image['name'], $asp['in_mode_360']) and !stristr($image['name'], $asp['in_mode_180']) ) return $content;
-		$asp['min_viewport_width']=$_COOKIE['windowWidth'] -$_COOKIE['theImageLeft']-$_COOKIE['theImageRight'];
-		$asp['viewport_height']=$_COOKIE['windowHeight']-130 ;
-		$asp['start_position']= 10;
-	}
+		if(  isset($conf['AS_panorama'])  && is_array($conf['AS_panorama']))		{
+			$asp = & $conf['AS_panorama'];
+			if(!isset($asp['in_mode_360'])) $asp['in_mode_360']="";
+			if(!isset($asp['in_mode_180'])) $asp['in_mode_180']="";
+			if ( !stristr($image['name'], $asp['in_mode_360']) and !stristr($image['name'], $asp['in_mode_180']) ) return $content;
+			$asp['min_viewport_width']=$_COOKIE['windowWidth'] -$_COOKIE['theContainerLeft']-$_COOKIE['theContainerRight'];
+			$asp['viewport_height']=$_COOKIE['windowHeight']-130 ;
+			$asp['start_position']= 10;
+		}
+		if ( strstr( $content,"iframe")||strstr($content,"charlie" )){
+			$ncount=1;
+			$pattern = array();
+			$pattern[0] = '/width\:(.*)(\d+)px/';$replacement[0] = ""; // style charlie
+			$pattern[1] = '/height\:(.*)(\d+)px/';$replacement[1] = "";
+			$pattern[2] = '/width=\"(\d+)\"/';$replacement[2] = ' ';
+			$pattern[3] = '/height=\"(\d+)\"/';$replacement[3] = ' ';
+			$pattern[4] = '/WIDTH=\"(\d+)\"/';$replacement[4] = ' ';
+			$pattern[5] = '/HEIGHT=\"(\d+)\"/';$replacement[5] = ' ';		
+
+			// raz dimensions
+		$content=  preg_replace($pattern, $replacement, $content);
+		$remplace=" width='100%' height='".  $theMainImageHeight ."' ";
+			//<!-- /charlie_flvstreamer.tpl -->
+ 
+			if (strstr($content,"charlie" )){
+         global $charlie;
+          if(isset($charlie)){
+          //  $theMainImageWidth=   $charlie['video_default_width'] ;
+          //   $theMainImageHeight = $charlie['video_default_height'];
+          }
+
+				$content=str_replace( "<object" , "<object " . $remplace ,$content );
+				$content=str_replace( "<embed" ,  "<embed " . $remplace ,$content );
+				$content=str_replace( 'id="video"',"id='theMainImage_vid'  " .$remplace  ,$content,$ncount);
+				$content=str_replace( '<video"',"<video id='theMainImage_vid' " .$remplace  ,$content,$ncount);
+			}else{
+				$content=str_replace( "<iframe" ,  "<iframe id='iframe' " .$remplace   ,$content,$ncount);
+			}
+	 
+			$content= "<div id='theMainImage' style='border:5px solid red'>". $content . "</div>";
+
+		}
+    
+		global $events;
+		$hasContent=(empty($content) )?'false':'true';
+		if(empty($events)) $events= (object) '';
+		$events->ligne=151;
+		$events->event +=1;
+		$events->function="init_1";
+		$events->content=$hasContent;
+		self::AfficheDebug();
+		return $content;
+	}//init_1
 	/*********************/
 	static public function init($content,$element_info){
-		global $template,$version,$icon_path,$page,$picture,$conf;
-		global $user,$Css,$css_slideshow,$css_display,$liste_type;
-		global $has_pamoorama,$pictureSelType,$pictureDeriv,$pictureMap;
+    global $template,$user,$conf;
+	  global $version,$icon_path,$page,$picture;
+		global $Css,$css_slideshow,$css_display,$liste_type;
+		global $pictureSelType,$pictureDeriv,$pictureMap;
 		global $warnings_message;
-
 		global $set_miniature,$imgSizeWH;
-		global $theImageHeight,$theImageWidth,$theImageLeft,$theImageTop,$windowWidth,$windowHeight,$theMainImageSize;
-		//=======================================================
-		global $has_pamoorama  ;
-		global $DEBUG_autosize,$infos_message,$error_message;
-		if(!realpath($element_info['path'])) return $content;
-		if(preg_match("|event|", $DEBUG_autosize, $val))  $infos_message .=  "init, " ;
-
-		$has_pamoorama = isset($template->files['pamooramics_content'])?"true":"false";
-		$theme=$user['theme'];
-
+		global $theContainerHeight,$theContainerWidth;
+		global $theMainImageWidth,$theMainImageHeight ;
+		global $theContainerLeft,$theContainerTop,$windowWidth,$windowHeight,$theMainImageSize;
+    
+		//=======================================================		
+    if(!realpath($element_info['path'])) return $content;
+    $theme=$user['theme'];
 		$Css = self::css($theme."-rules.css");
 		$css_slideshow=isset($Css['.Autosize']['slideshow'])?$Css['.Autosize']['slideshow']:"yes";
 		$css_display= isset($Css['.Autosize']['display'])?$Css['.Autosize']['display']:"block";
 		$default_size =  $conf['derivative_default_size'];
-		//============================================================
-		self::get_cookies();
-		//==============================================================
-		if(preg_match("|test|", $DEBUG_autosize, $val)) {
-			$infos_message .= "#133 <br>Init:SESSION:"  . cl_print_var($_SESSION) ;
-			if ( isset($_COOKIE['pwg_id']) ) unset ($_COOKIE['pwg_id']) ;
-			$infos_message .= "GET:"  . cl_print_var($_GET) ;
-			$infos_message .= "POST:"  . cl_print_var($_POST) ;
-			$infos_message .= "$pictureDeriv $pictureSelType $pictureMap ";
-			$infos_message .= cl_print_var($template,true);
-		}
-		$autosize_parametres = cl_autosize_Get_Options();
 		//=====================================================================
 		$current = $template->get_template_vars('current');
 		//=== Zone affichage ==
-		$windowWidth=$_COOKIE['windowWidth'] ;
-		$windowHeight=$_COOKIE['windowHeight'] ;
-
-		$theImageTop= isset($_COOKIE['theImageTop'])?$_COOKIE['theImageTop']:0;
-		$theImageLeft=isset($_COOKIE['theImageLeft'])?$_COOKIE['theImageLeft']:0;
-
-		$theImageRight=isset($_COOKIE['theImageRight'])?$_COOKIE['theImageRight']:0;
-		$theImageBottom=isset($_COOKIE['theImageBottom'])?$_COOKIE['theImageBottom']:0;
-
-
-		$theImageMargeWidth=isset($_COOKIE['theImageMargeWidth']) ? $_COOKIE['theImageMargeWidth']:0;
-		$theImageMargeHeight=isset($_COOKIE['theImageMargeHeight'])?$_COOKIE['theImageMargeHeight']:0;
-
-		$theImageMargeHeight -= 2;
-		if(isset($_COOKIE['theImageWidth'])){
-			$theImageWidth=    $_COOKIE['theImageWidth'];
-			$theImageHeight=  $_COOKIE['theImageHeight'] ;
-		}
-		$theImageWidth=    $windowWidth -  $theImageLeft - $theImageMargeWidth;
-		$theImageHeight=   $windowHeight - $theImageTop  - $theImageMargeHeight ;
+		if( !isset($_COOKIE['windowWidth']   ) ||
+				!isset($_COOKIE['windowHeight']  ) ){
+			 return ;
+		}else{
+			$windowWidth = $_COOKIE['windowWidth'] ;
+			$windowHeight = $_COOKIE['windowHeight'] ;
+		}		
+    //=========================================================================================================
+		$theContainerMargeWidth = isset($_COOKIE['theContainerMargeWidth']) ? $_COOKIE['theContainerMargeWidth']:0;
+		$theContainerMargeHeight = isset($_COOKIE['theContainerMargeHeight'])?$_COOKIE['theContainerMargeHeight']:0;
+
+		$theContainerWidth =   isset($_COOKIE['theContainerWidth'])?$_COOKIE['theContainerWidth']:$windowWidth-$theContainerMargeWidth;
+		$theContainerHeight =  isset($_COOKIE['theContainerHeight'])?$_COOKIE['theContainerHeight']:$windowHeight-$theContainerMargeHeight;
+
+		$theContainerTop= isset($_COOKIE['theContainerTop'])?$_COOKIE['theContainerTop']:0;
+		$theContainerLeft=isset($_COOKIE['theContainerLeft'])?$_COOKIE['theContainerLeft']:0;
+
+		$theContainerRight=isset($_COOKIE['theContainerRight'])?$_COOKIE['theContainerRight']:$theContainerWidth;
+		$theContainerBottom=isset($_COOKIE['theContainerBottom'])?$_COOKIE['theContainerBottom']:$theContainerHeight;
+ 
+		$theMainImageWidth = isset($_COOKIE['theMainImageWidth'])?$_COOKIE['theMainImageWidth']:$theContainerWidth;
+		$theMainImageHeight = isset($_COOKIE['theMainImageHeight'])?$_COOKIE['theMainImageHeight']:$theContainerHeight ;
 
 		if (isset($element_info['is_gvideo']) && $element_info['is_gvideo'] ){
-			$pictureDeriv=$default_size;
-
+			$pictureDeriv = $default_size;
 		}else{
-
-
 			$retour = self::get_min_max() ;
-
-			$theMainImageSize = $retour->get_size();
-			$theMainImageWidth=   isset($_COOKIE['theMainImageWidth'])?$_COOKIE['theMainImageWidth']:$theMainImageSize[0];
-			$theMainImageHeight=   isset($_COOKIE['theMainImageHeight'])?$_COOKIE['theMainImageHeight']:$theMainImageSize[1] ;
-
-			if($theImageHeight!=0 && $theImageWidth!=0){
-				$pictureDeriv=$retour->type ;
+			$theMainImageSize =   $retour->get_size();
+			$theRealImageWidth =  $theMainImageSize[0];
+			$theRealImageHeight = $theMainImageSize[1] ;
+
+
+			if($theContainerHeight!=0 && $theContainerWidth!=0){
+				$pictureDeriv = $retour->type ;
 			}else{
-				$pictureDeriv=$default_size;
-			}
-		}
-
-		if(preg_match("|test|", $DEBUG_autosize, $val)) {
-			$infos_message .=  "#208 <br>Init:SESSION:"  . cl_print_var($_SESSION) ;
-
-			if ( isset($_COOKIE['pwg_id']) ) unset ($_COOKIE['pwg_id']) ;
-			$infos_message .=  "Init: COOKIE:"  . cl_print_var($_COOKIE) ;
-			$infos_message .=  "GET:"  . cl_print_var($_GET) ;
-			$infos_message .=  "POST:"  . cl_print_var($_POST) ;
-			$infos_message .=("#201: ".$DEBUG_autosize);
-		}
-		$pattern = array();
-		if($has_pamoorama=="true"){
-			if(preg_match("|c1|", $DEBUG_autosize, $val)) echo  $theImageWidth . "x" . $theImageHeight ;
-			$pattern[0] = '/width\:(.*)(\d+),/';$replacement[0] = 'width:  '.$theImageWidth.' ,';
-			if(($theImageWidth!=0)){
-				$content=  preg_replace($pattern, $replacement, $content);
-			}
-			if(preg_match("|c1|", $DEBUG_autosize, $val)) {
-				echo "<!-- " . $theImageWidth . "x" . $theImageHeight . " " .cl_print_var($content) ." -->";
-				self::Fin_php("#211: " . $DEBUG_autosize);
-			}
-			return  $content;
-		}
-		if(isset($_GET['map'])){
-			return  $content;
-		}
-		$pattern[0] = '/width\:(.*)(\d+)px/';$replacement[0] = 'width:100% ';
-		$pattern[1] = '/height\:(.*)(\d+)px/';$replacement[1] = 'height:100% ';
-		$pattern[2] = '/width=\"(\d+)\"/';$replacement[2] = ' ';
-		$pattern[3] = '/height=\"(\d+)\"/';$replacement[3] = ' ';
-
-		if ( strstr( $content,"iframe")||strstr($content,"charlie" )){
-
-			$pictureSelType="Autosize";
-			$pictureDeriv=$conf['derivative_default_size'];
-
-			$_COOKIE['picture_sel_type']=$pictureSelType;
-			$_COOKIE['picture_deriv']=$pictureDeriv;
-
-			$ncount=1;
-			if (strstr($content,"charlie" )){
-				$content=str_replace( "<object" , "<object id='theMainImage_obj' name='theMainImage' "  ,$content,$ncount);
-				$content=str_replace( "<embed" ,  "<embed id='theMainImage_emb' name='theMainImage' "  ,$content,$ncount);
-				$content=str_replace( 'id="video"',"id='theMainImage_vid'  name='theMainImage' " ,$content,$ncount);
-				$content=str_replace( '<video"',"<video id='theMainImage_vid'  name='theMainImage' " ,$content,$ncount);
-			}else{
-				$content=str_replace( "<iframe" ,  "<iframe id='iframe' name='theMainImage' "  ,$content,$ncount);
-			}
-			$content=  preg_replace($pattern, "", $content);
-
-			$content= "<div id='theMainImage' style='height:".$theImageHeight."px  ;width:".$theImageWidth."px '>". $content . "</div>";
-			$content= "<style>#theImageAndInfos{height:auto;width:auto;position:relative}
-					#theImage{height:auto;align:center;text-align:center;position:relative}
-					#theMainImage{height:auto;align:center;text-align:center;position:static}
-					#charlie{display:none }
-					#iframe{display:none }
-					</style>".$content;
-			return  $content;
-		}
-
-		$content=  preg_replace($pattern, "", $content);
-
+				$pictureDeriv = $default_size;
+			}
+		}		
+ 
+ $hasContent=( empty($content) )?"false":'true';
+		self::save_cookies();
+		//===============================================================================
+		global  	$events ;
+		$events->ligne=210;
+		$events->event +=1;
+		$events->function="INIT";
+		$events->content= $hasContent;
+		self::AfficheDebug();
 		return  $content;
 	}//INIT
@@ -264,46 +239,44 @@
 		global $infos_message;
 		//content = photo
-
 		//=====================================================================
 		global  $has_pamoorama,$pictureSelType,$pictureDeriv;
-		global $DEBUG_autosize;
-		if(preg_match("|event|", $DEBUG_autosize, $val)) $infos_message .= "init2, ";
+		global $theContainerHeight,$theContainerWidth;$theContainerLeft;
+		global $theContainerTop,$windowWidth,$windowHeight,$theMainImageSize;
+    		global $theMainImageWidth,$theMainImageHeight ;
+    //=====================================================================
 		if(!realpath($element_info['path'])) return $content;
-		global $theImageHeight,$theImageWidth,$theImageLeft,$theImageTop,$windowWidth,$windowHeight,$theMainImageSize;
 		//-- si Autosize correction redim ---------------
 		$current = $template->get_template_vars('current');
 		if (!isset($current)) return ;
-		if($pictureSelType!="Autosize") return $content ;
-		$pattern =Array('/width=\"(\d+)\"/','/height=\"(\d+)\"/');
-		$replacement = Array('',"style='height:".$theImageHeight."px'");
-		$replacement = Array('',"");
-		$content= preg_replace($pattern, $replacement, $content);
-		if( $has_pamoorama=="true") return $content ;
-
-		if( !preg_match("|c1|", $DEBUG_autosize, $val) ) return $content ;
-		//************************  c1 ***************************************
-		echo "theMainImageWidth :" . $theMainImageSize[0] . " X " . $theMainImageSize[1]  . "<br >";
-		echo "theImageWidth :" . $theImageWidth . " X " . $theImageHeight . "<br >";
-		echo $infos_message."<br />";
-		$Ratio = $theMainImageSize[0]/$theMainImageSize[1];
-
-		$nh = intval($theImageWidth / $Ratio)  ;
-		$nw = intval($theImageHeight * $Ratio) ;
-
-		echo $nw . "x " . $nh ."<br />";
-
-		if($theMainImageSize[0] < $nw){
-			echo "HEIGHT " .$theImageHeight . "  WIDTH " .  $nw."<br />";
-		}
-		if($theMainImageSize[1] <  $nh ){
-			echo "HEIGHT " . $nh  . "  WIDTH " .  ($theImageWidth)."<br />";
-		}
-
-		$content=  $content . $pictureDeriv . " " .$pictureSelType;
-		echo "<div style='color:white;position:absolute;left:0;top:0;width:".$windowWidth ."px;height:" .$windowHeight."px;background-color:blue'>";
-		echo "left:".$theImageLeft."px;top:".$theImageTop."px;width:".$theImageWidth ."px;height:" .$theImageHeight."px;";
-		echo "<div style='position:absolute;left:".$theImageLeft."px;top:".$theImageTop."px;width:".$theImageWidth ."px;height:" .  $theImageHeight."px;background-color:green;'>";
-		self::Fin_php("#305 : " . $content + $DEBUG_autosize);
-
+		$has_pamoorama = isset($template->files['pamooramics_content'])?"true":"false";		
+		$pattern = array();$replacement = array();
+		$hasContent=(empty($content) )?'false':"true";
+    if($hasContent=="true"){   
+		  if($has_pamoorama=="true"){
+			  $pattern[0] = '/width\:(.*)(\d+),/';$replacement[0] = 'width:  '. $theMainImageWidth .', ' ;
+			  if(($theContainerWidth!=0)){
+				  $content=  preg_replace($pattern, $replacement, $content,1 );
+			  }
+		  }else
+        if(	 preg_match("|\<!-- \/charlie_|", $content, $val) ) {
+           $pattern[0] = '/\<br.\/>/';$replacement[0] = '' ;
+          $content=  preg_replace($pattern, $replacement, $content  );
+      }
+        else      
+        if($pictureSelType == "Autosize") {
+			    $pattern =Array('/width=\"(\d+)\"/','/height=\"(\d+)\"/' );
+			    $replacement = Array('',"style='height:".$theMainImageHeight."px'; " );
+          $content= preg_replace($pattern, $replacement, $content);        
+		  } 
+    }
+    
+
+		global  	$events ;
+		$events->ligne=247;
+		$events->event +=1;
+		$events->function="INIT2";
+		$events->content=$hasContent;
+		self::AfficheDebug();
+		return  $content;
 	} //INIT2
 	/***************************
@@ -314,12 +287,12 @@
 		include_once ( "include/functions_cookie.inc.php");
 		global $ma_page,$user,$element_info,$infos_message,$DEBUG_autosize;
-		global $pictureDeriv,$pictureSelType,$pictureMap;
+		global $pictureDeriv,$pictureSelType,$pictureMap,$autosize_parametres;
 		global $conf;
 		$set_miniature = "<!DOCTYPE html><html><head>
-		<meta http-equiv='content-type' content='text/html; charset=UTF-8'/>
-		<script type='text/javascript' src='themes/default/js/jquery.min.js'></script>
-		<script type='text/javascript' src='plugins/Autosize/js/autosizeDetect.js'></script>
-		<script type='text/javascript' src='plugins/Autosize/js/autosize.cookie.js'></script>
-		<script type='text/javascript' src='themes/default/js/plugins/jquery.ajaxmanager.js'></script>";
+				<meta http-equiv='content-type' content='text/html; charset=UTF-8'/>
+				<script type='text/javascript' src='themes/default/js/jquery.min.js'></script>
+				<script type='text/javascript' src='plugins/Autosize/js/autosizeDetect.js'></script>
+				<script type='text/javascript' src='plugins/Autosize/js/autosize.cookie.js'></script>
+				<script type='text/javascript' src='themes/default/js/plugins/jquery.ajaxmanager.js'></script>";
 		$set_miniature .= "<script type='text/javascript' src='plugins/Autosize/js/autosize_ajax.js' id='autosize_ajax' >  </script >";
 		$set_var = "<script type='text/javascript'>\n var COOKIE_PATH =  '".cookie_path()."';\n";
@@ -329,4 +302,5 @@
 			$set_var .= " var reload =  'true';\n";
 		}
+		$set_var .= " var DEBUG_autosize =  '". $DEBUG_autosize . "';\n";
 		$set_var .= " var ret_id =  '". $id_ret . "';\n";
 		$set_var .= " var mapage =  '". $ma_page . "';\n";
@@ -337,59 +311,26 @@
 		$set_var .= " </script >";
 		$autoscript="</head>
-		<body onload=on_load() style='background-color:black;color:white;font-size:30px' >
-		please wait, loading($id_ret)... <div>";
-		$default_size =  $conf['derivative_default_size'];
+		<body style='background-color:black;color:white;font-size:30px' >";
+
+		$autoscript.="<div> please wait, loading($id_ret)...<img src='themes/default/images/ajax-loader-big.gif' > <div>";
 		//=======================================================================
-		$pictureSelType = pwg_get_session_var('picture_sel_type',$default_size);
-		$pictureDeriv = pwg_get_session_var('picture_deriv',$default_size);
-		$pictureMap = pwg_get_session_var('picture_map',$default_size);
-		//=======================================================================
-		$autosize_parametres = cl_autosize_Get_Options();
-		$userst= $user['status']."_enabled" ;
-		$userst=$autosize_parametres-> $userst;
-		$usertype= $user['status']."_type" ;
-		$usertype = $autosize_parametres->$usertype;
-		if($userst=='off'){
-
-		}else{
-			if($usertype!="Autosize" && $usertype!="SelMaxi" ){
-				$pictureSelType = $usertype;
-				$pictureDeriv = $usertype;
-			}else if($autosize_parametres->defaut_type=="off"){
-				$pictureSelType = pwg_get_session_var('picture_sel_type',"SelMaxi");
-			}else {
-				$pictureSelType = pwg_get_session_var('picture_sel_type',"Autosize");
-			}
-		}
-		$autoscript.="$pictureSelType</div></body></html>";
+		$autoscript.="<div>$pictureSelType</div></body></html>";
 		//============================================================
-		self::save_cookies();
+		//self::save_cookies();
 		if( !isset($_COOKIE['picture_deriv'])  ){
 			echo "INIT <pre>";
 			print_r($_COOKIE);
-			self::Fin_php("#369:  No COOKIE['picture_deriv'] ".$DEBUG_autosize);
-		}
-
-		if(preg_match("|vue_init|", $DEBUG_autosize, $val)) {
-			$infos_message.="Reload: $userst <br> $usertype <br> autosize_parametres:"  . cl_print_var($autosize_parametres) ;
-			if ( isset($_COOKIE['pwg_id']) ) unset ($_COOKIE['pwg_id']) ;
-			echo "Reload: SESSION:"  . cl_print_var($_SESSION) ;
-			echo "Reload: COOKIE:"  . cl_print_var($_COOKIE) ;
-			echo "GET:"  . cl_print_var($_GET) ;
-			echo "POST:"  . cl_print_var($_POST) ;
-			self::Fin_php("#379: ".$DEBUG_autosize);
-		}
-
-		$infos_message.="Reload: $userst <br> $usertype <br> autosize_parametres:"  . cl_print_var($autosize_parametres) ;
-		if(!preg_match("|aff_init|", $DEBUG_autosize, $val)) {
-			$infos_message="";
-		}
+			self::Fin_php("#310:  No COOKIE['picture_deriv'] ");
+		}
+		//=========================================================================
 		echo $set_miniature ;
 		echo $set_var ;
 		echo $autoscript;
 		if (!isset($_COOKIE['autosize_reload'])  ){
-			self::Fin_php("#390:  Initialisation ".$DEBUG_autosize);
-		}			
-	}
+			self::Fin_php("#319:  Initialisation ".$DEBUG_autosize);
+		}
+	//	die();
+	}
+ 
 
 	/************************
@@ -399,14 +340,10 @@
 		global $user,$page,$template,$cl_plugin,$cl_version;
 		global  $has_pamoorama,$css_slideshow;
-		global $pictureSelType,$pictureDeriv,$infos_message,$conf;
-		global $DEBUG_autosize;
-		if(preg_match("|event|", $DEBUG_autosize, $val)) {
-			$infos_message .= "cl_autosize_script_1, " ;
-		} ;
+		global $pictureSelType,$pictureDeriv,$infos_message,$conf,$autosize_parametres;
 		$ma_page=isset($page['body_id'])?$page['body_id']:"" ;
 		if ($ma_page !='thePicturePage') return ;
 		if ( $has_pamoorama=="false" ) return ;
 		if ($page['slideshow']){
-			//==== mise à l'échelle ===
+			//==== mise à l'�chelle ===
 			$current = $template->get_template_vars('current');
 			$default_size =  $conf['derivative_default_size'];
@@ -417,8 +354,8 @@
 				$model=$default_size;
 			}
-      if(!isset($current['derivatives'][$model])){
-      $model=$default_size;
-      }
-      
+			if(!isset($current['derivatives'][$model])){
+				$model=$default_size;
+			}
+
 			$selected_derivative =  $current['derivatives'][$model];
 			$template->append('current', array(
@@ -428,11 +365,9 @@
 
 		}
-
-
-
 		$template->set_filenames(array('autosize_init'=>AUTOSIZE_PATH_ABS. "template/conflit.tpl" ) );
-		$autosize_parametres =	 cl_autosize_Get_Options() ;
+
 		$theme=$user['theme'];
 		//==============================================================================
+		global $DEBUG_autosize;
 		$template->assign(
 				array(
@@ -450,9 +385,11 @@
 				)
 		);
-		if( preg_match("|c2|", $DEBUG_autosize, $val) ){
-			self::Fin_php( "449: " . $DEBUG_autosize);
-			return $content ;
-
-		}
+		global  	$events ;
+    $hasContent=(empty($content))?'false':"true";
+		$events->ligne=373;
+		$events->event +=1;
+		$events->function="cl_autosize_script_1";
+		$events->content=$hasContent ;
+		self::AfficheDebug();
 
 		return $template->parse( 'autosize_init', false);
@@ -464,41 +401,42 @@
 	 * cl_autosize_script_2()
 	**************************************/
-	static public function cl_autosize_script_2()
-	{
-		global $css_slideshow;
-		global $pictureSelType,$pictureDeriv,$infos_message;
+	static public function cl_autosize_script_2()	{
+		global  $css_slideshow;
+		global  $pictureSelType,$pictureDeriv,$infos_message;
 		global  $template,$user,$conf,$picture ,$page, $cl_plugin,$cl_version,$known_script ;
-
 		global  $has_pamoorama;
-		global $DEBUG_autosize;
-		if(preg_match("|event|", $DEBUG_autosize, $val)) {
-			$infos_message .= "cl_autosize_script_2, ";
-		} ;
 		$ma_page=isset($page['body_id'])?$page['body_id']:"" ;
 		if ($ma_page !='thePicturePage') return ;
-
 		$theme=$user['theme'];
-		if ($has_pamoorama=="false" ) return ;
-		if ($css_slideshow == "no" and isset($_GET['slideshow'])) return ;
-		$AUTOSIZE_PATH = dirname(__FILE__).'/';
-		//=====================================================================
-		$template->assign(
-				array(
-						'cl_version' => $cl_version ,
-						'name' => $cl_plugin['name'] ,
-						'ma_page' =>	$ma_page,
-						'theme' => $theme  ,
-						'DEBUG_autosize' => $DEBUG_autosize   ,
-						'AUTOSIZE_PATH' => AUTOSIZE_PATH
-				)
-		);
-		$autoscript="<script type='text/javascript'>
-				/* cl_autosize_script_2 */
-				if (typeof (save_framework) == 'function')
-				save_framework('".$ma_page."');
-
-						</script>";
-		$template->append('footer_elements',$autoscript);
-
+		if ($has_pamoorama == "true" ) {
+			if ($css_slideshow != "no" || !isset($_GET['slideshow'])) {
+				$AUTOSIZE_PATH = dirname(__FILE__).'/';
+				//=====================================================================
+				global $DEBUG_autosize;
+				$template->assign(
+						array(
+								'cl_version' => $cl_version ,
+								'name' => $cl_plugin['name'] ,
+								'ma_page' =>	$ma_page,
+								'theme' => $theme  ,
+								'DEBUG_autosize' => $DEBUG_autosize   ,
+								'AUTOSIZE_PATH' => AUTOSIZE_PATH
+						)
+				);
+				$autoscript="<script type='text/javascript'>
+						/* cl_autosize_script_2 */
+						if (typeof (save_framework) == 'function')
+						save_framework('".$ma_page."');
+								</script>";
+				$template->append('footer_elements',$autoscript);
+			}
+		}
+		global  	$events ;
+    $hasContent=(empty($content) )?'false':'true';
+		$events->ligne=433;
+		$events->event +=1;
+		$events->function="cl_autosize_script_2";
+		$events->content=$hasContent ;
+		self::AfficheDebug();
 		return ;
 	}// function cl_autosize_script_2
@@ -509,35 +447,31 @@
 	static public function cl_autosize_script_3() {
 		global  $has_pamoorama,$template,$page,$infos_message;
-		global $DEBUG_autosize;
-		if(preg_match("|event|", $DEBUG_autosize, $val)) {
-			$infos_message .= "cl_autosize_script_3, ";
-		} ;
 		$ma_page=isset($page['body_id'])?$page['body_id']:"" ;
 		if ($ma_page !='thePicturePage') return ;
-
-			
 		$template->func_combine_script(array('id'=>'my_script_2',
 				'path'=> AUTOSIZE_PATH.'js/JScript.js',
 				'require' => 'jquery'),
 				$template->smarty);
-
 		$template->func_combine_css(array('id'=>'autosize.css',
 				'path'=> AUTOSIZE_PATH.'css/autosize.css'
 		));
-
-
 		$autoscript="<script type='text/javascript'>
 				var COOKIE_PATH = '".cookie_path()."' ;
 						</script>";
 		$template->append('footer_elements',$autoscript);
-		if ($has_pamoorama=="false" ) return ;
-
-		$autoscript="<script type='text/javascript'>
-				if (typeof (Ajout_Ajax) == 'function')
-				Ajout_Ajax();
-				</script>";
-		$template->append('footer_elements',$autoscript);
-
-			
+		if ($has_pamoorama=="true" ) {
+			$autoscript="<script type='text/javascript'>
+					if (typeof (Ajout_Ajax) == 'function')
+					Ajout_Ajax();
+					</script>";
+			$template->append('footer_elements',$autoscript);
+		}
+		global  	$events ;
+    $hasContent=(empty($content) )?'false':'true';
+		$events->ligne=467;
+		$events->event +=1;
+		$events->function="cl_autosize_script_3";
+		$events->content=$hasContent ;
+		self::AfficheDebug();
 		return ;
 	}// function cl_autosize_script_3
@@ -561,12 +495,14 @@
 		global $autosize_parametres,$user_status;
 		global  $has_pamoorama,$pictureSelType,$pictureDeriv;
-		global $DEBUG_autosize;
+			
 		global $css_slideshow,$css_display;
-		if(preg_match("|event|", $DEBUG_autosize, $val)) {
-			$infos_message .=  "cl_autosize_affiche, " ;
-		} ;
+
 		$ma_page=isset($page['body_id'])?$page['body_id']:"" ;
-		if ($ma_page !='thePicturePage') return ;
+		if ($ma_page !='thePicturePage')    return ;
 		//============================================================
+    		global  	$events ;
+		$events->ligne=506;
+		$events->event +=1;
+		$events->function="cl_autosize_affiche";
 		self::save_cookies();
 
@@ -574,12 +510,4 @@
 			$set_miniature = self::cl_autosize_nofile($set_miniature) ;
 			$set_miniatures= explode("script",$set_miniature);
-			if(preg_match("|noGen|", $DEBUG_autosize, $val)) {
-				if(count($set_miniatures)> 1 )
-					$infos_message .= "PictureDeriv:" . $pictureDeriv. ' miniature:' . cl_print_var( $set_miniature);
-					
-			}else {
-
-
-			} ;
 			$template->append('footer_elements',$set_miniature);
 		}
@@ -601,16 +529,6 @@
 			return ;
 		}
-		if($pictureSelType == $pictureDeriv ) {
-			if(preg_match("|event|", $DEBUG_autosize, $val)) {
-				cl_aff_infos_plus();
-			} ;
-
-		}
-
 		if (defined('GMAPS_VERSION')) $gmaps_function="true";
 		else $gmaps_function="false" ;
-
-
-
 		$template->set_filenames(array('autosize_content_header'=> $file ));
 		$template->assign(	array( AUTOSIZE_PATH,$AUTOSIZE_PATH,
@@ -664,20 +582,11 @@
 		}
 			
-
-		if(preg_match("|vue_cookies|", $DEBUG_autosize, $val)) {
-
-			$pictureSelType=$_COOKIE['picture_sel_type'];
-			$pictureDeriv=$_COOKIE['picture_deriv'];
-			$infos_message .= "cl_autosize_affiche: $pictureSelType  <--> $pictureDeriv \n" ;
-
-		}
-
-		if(preg_match("|test|", $DEBUG_autosize, $val)) {
-			$infos_message .= "#683 <br>cl_autosize_affiche:_COOKIE:"  . cl_print_var($_COOKIE) ;
-			$pictureMap=$_COOKIE['picture_map'];
-			$infos_message .= "<br />SelType:" . $pictureSelType."; pictureDeriv:".$pictureDeriv ."; pictureMap:".$pictureMap;
-
-			self::Fin_php("#676: ".$DEBUG_autosize);
-		}
+	
+		$events->ligne=584;
+    $hasContent=(empty($content) )?'false':'true';
+		//$events->event +=1;
+		$events->function="cl_autosize_affiche";
+		$events->content=$hasContent ;
+		self::AfficheDebug();
 		cl_aff_infos_plus();
 		return $template->parse( 'autosize_content', false);
@@ -855,8 +764,7 @@
 	static public function get_min_max(){
 		global $liste_type,$img_all,$set_miniature,$template,$infos_message,$error_message,$has_pamoorama ;
-		global $theImageWidth,$theImageHeight,$pictureSelType,$pictureDeriv ;
+		global $theMainImageWidth,$theMainImageHeight,$theContainerWidth,$theContainerHeight;
+		global $pictureSelType,$pictureDeriv ;
 		global $DEBUG_autosize;
-
-
 		$current = $template->get_template_vars('current');
 		$liste_type="";
@@ -865,5 +773,4 @@
 		$defined_types = array_keys(ImageStdParams::get_defined_type_map());
 		foreach($defined_types as $type){
-
 			if($type!="Autosize" && $type!="SelMaxi" ){
 				$last_derivative= $type ;
@@ -871,5 +778,4 @@
 				$i++;
 			}
-
 		}
 		;
@@ -897,4 +803,8 @@
 		// Liste mini maxi
 		//=============================================
+		 
+		if(preg_match("|get_infos|", $DEBUG_autosize, $val))
+			$infos_message .= "<br> get_min_max() $theMainImageWidth,$theMainImageHeight,$theContainerWidth,$theContainerHeight <br>" ;
+
 		foreach ($img_all as $img_select){
 
@@ -912,9 +822,7 @@
 				$nofile++ ;
 				if(preg_match("|get_infos|", $DEBUG_autosize, $val))
-					$infos_message .=$nofile ." " ;
-			}
-			if(preg_match("|get_minfos|", $DEBUG_autosize, $val))
-				$infos_message .=$img_url . " " . $max_crop ." -> " . $img_type . " " . print_r($imgWH,true). " <br >";
-
+					$infos_message .= " File: $nofile  <br>" ;
+			}
+				
 			if(file_exists(PHPWG_ROOT_PATH.$img_url)){
 			} // if file
@@ -944,5 +852,5 @@
 			$liste_type[$img_type]=$img_type.",".$img_url.",".$imgWH[0] .",".$imgWH[1] ;
 			if( $img_type==$pictureSelType){
-				if(preg_match("|get_minfos|", $DEBUG_autosize, $val))     $infos_message .= $pictureSelType . " <--> " . $img_type ."<br >";
+				if(preg_match("|get_infos|", $DEBUG_autosize, $val))     $infos_message .= $pictureSelType . " <--> " . $img_type ."<br >";
 
 				$SelType_image->type=$img_type;
@@ -961,14 +869,14 @@
 
 			}
-
-			if($has_pamoorama==true)
-				$test= ($imgWH[1] >  $theImageHeight)  ;
-			else
-				$test= ($imgWH[1] >  $theImageHeight  && $imgWH[0] >  $theImageWidth);
+		 	$test=$imgWH[1] >=  $theMainImageHeight;
+			 if($has_pamoorama!=true){
+				$test=( $imgWH[0] >=  $theMainImageWidth) && $test;		
+			 }
+		 		//===================================================
 			if($theImage_maxi==0)
-				if( $test  ){
-				$theImage_maxi=1;
-				$maxi_image->type =   $img_type;
-				$img_type=$img_select->get_type();
+				if( $test==true  ){
+						$theImage_maxi=1;
+						$maxi_image->type =   $img_type;
+						$img_type=$img_select->get_type();
 				if($img_type=="Original")
 					$maxi_image = $last_image;
@@ -985,5 +893,13 @@
 				$mini_image->url  =  $mini_image->get_path();
 			}
-
+			if(preg_match("|get_infos|", $DEBUG_autosize, $val)){
+				if (($imgWH[1] >= $theMainImageHeight))  $infos_message .="<span style='color:red'>";
+			
+				$infos_message .= ($imgWH[1] >= $theMainImageHeight)."  Maxi:" . $maxi_image->url 
+			                 . " ---------- ImageUrl: $img_url " 
+			                 . $max_crop ." -> " . $img_type . " <br>" 
+			                 	. print_r($imgWH,true). " <br >";
+				if ($test)  $infos_message .="</span >";				
+				}
 		} // for
 		//================================================
@@ -992,5 +908,4 @@
 		$imgSizeWH  =  $img_select->src_image->get_size();
 		$liste_type["Original"]="Original".",".$img_url.",".$imgSizeWH[0] .",".$imgSizeWH[1] ;
-			
 
 		$retour=(object)'' ;
@@ -1024,6 +939,8 @@
 		}
 
-		if(preg_match("|get_infos|", $DEBUG_autosize, $val))
-			$infos_message .=$pictureSelType . " -> " . $retour->type . " : "  . $retour->url  ."<br >";
+		if(preg_match("|get_minfos|", $DEBUG_autosize, $val))
+			$infos_message .= $pictureSelType . " -> " . $retour->type . " : "  .
+		                        $retour->url  .
+		                 cl_print_var($retour->get_size()) .  "<br >";
 
 		return $retour ;
@@ -1049,5 +966,5 @@
 		//=== verification fichiers absents ===
 		global $infos_message,$error_message;
-		global $theImageHeight,$theImageWidth,$theImageLeft,$theImageTop,$windowWidth,$windowHeight,$theMainImageSize;
+		global $theContainerHeight,$theContainerWidth,$theContainerLeft,$theContainerTop,$windowWidth,$windowHeight,$theMainImageSize;
 		global  $pictureDeriv;
 		$ok=false ;
@@ -1119,31 +1036,37 @@
 	****************************/
 	static public  function  get_cookies(){
-		global $pictureDeriv,$pictureSelType,$pictureDeriv,$pictureMap,$DEBUG_autosize;
+		global $pictureDeriv,$pictureSelType,$pictureDeriv,$pictureMap,$conf,$autosize_parametres,$user;		
+		 	$userst		= $user['status']."_enabled" ;
+		 	$userst		=	$autosize_parametres->  $userst ;
+		 	$usertype	= $user['status']."_type" ;
+			$default_size =  $conf['derivative_default_size'];			
+			$usertype = $autosize_parametres->$usertype ;
+			$pictureSelType =$default_size ;
+			if($userst==$user['status']."_enabled" ){
+			
+			}else{
+				if($usertype!="Autosize" && $usertype!="SelMaxi" ){
+				
+				}else if($autosize_parametres->defaut_type=="off"){
+					$pictureSelType = pwg_get_session_var('picture_sel_type',"SelMaxi");
+				}else {
+					$pictureSelType = pwg_get_session_var('picture_sel_type',"Autosize");
+				}
+			}
+
 		if(!isset($_COOKIE['picture_deriv'])){
-			$pictureDeriv= pwg_get_session_var('picture_deriv');
-			$pictureSelType = pwg_get_session_var('picture_sel_type');
-			$pictureMap = pwg_get_session_var('picture_map') | $pictureDeriv;
-		}else{
-			$pictureDeriv = $_COOKIE['picture_deriv'];
-			$pictureSelType = isset( $_COOKIE['picture_sel_type'])?$_COOKIE['picture_sel_type']:$pictureDeriv;
-			$pictureMap =  isset($_COOKIE['picture_map'])?$_COOKIE['picture_map']:$pictureDeriv;
-		}
-		$_COOKIE['picture_sel_type']=$pictureSelType;
-		$_COOKIE['picture_deriv']=$pictureDeriv;
-		$_COOKIE['picture_map']=$pictureMap;
-		if(!isset($_COOKIE['picture_deriv'] )){
-			if(preg_match("|test_1|", $DEBUG_autosize, $val)) {
-				$infos_message .= "not COOKIE['picture_deriv'] -> reload(): <br>";
-				self::Fin_php("#1133 autosize_calcContent:" . $DEBUG_autosize );
-			}
-			unset($_COOKIE['autosize_reload']);
-		}
-		if (!isset($_COOKIE['autosize_reload'])  ){
-			if(preg_match("|test_2|", $DEBUG_autosize, $val)) {
-				$infos_message .= "not COOKIE['autosize_reload'] -> reload(): <br>";
-				self::Fin_php("#1140 autosize_calcContent:" . $DEBUG_autosize);
-			}
-			self::reload("#1142");
-		}
+			$pictureDeriv   = pwg_get_session_var('picture_deriv',$default_size);
+			$pictureSelType = pwg_get_session_var('picture_sel_type',$pictureSelType);
+			$pictureMap     = pwg_get_session_var('picture_map') | $pictureDeriv;
+		}
+	
+			$pictureDeriv   =  isset( $_COOKIE['picture_deriv']) ? $_COOKIE['picture_deriv']:$pictureDeriv;
+			$pictureSelType =  isset( $_COOKIE['picture_sel_type'])?$_COOKIE['picture_sel_type']:$pictureSelType;
+			$pictureMap     =  isset($_COOKIE['picture_map'])?$_COOKIE['picture_map']:$pictureDeriv;
+		self::save_cookies();		
+		if(   !isset($_COOKIE['picture_deriv'] ))
+			  unset($_COOKIE['autosize_reload']);
+		if (!isset($_COOKIE['autosize_reload'])  )
+			self::reload("#1044");			
 	}
 	/***************************
@@ -1152,35 +1075,95 @@
 	static public  function  save_cookies(){
 		global $pictureDeriv,$pictureSelType,$pictureDeriv,$pictureMap;
-
-		pwg_set_session_var('picture_deriv',$pictureDeriv);
+		pwg_set_session_var('picture_deriv',   $pictureDeriv);
 		pwg_set_session_var('picture_sel_type',$pictureSelType);
-		pwg_set_session_var('picture_map',$pictureDeriv);
+		pwg_set_session_var('picture_map',     $pictureDeriv);
 		//============================================================
 		setcookie( 'picture_sel_type',
-		$pictureSelType,
-		time()+5,
-		cookie_path()
+								$pictureSelType,
+								time()+10,
+								cookie_path()
 		);
 		//=============================================================
 		setcookie( 'picture_map',
-		$pictureDeriv,
-		time()+5,
-		cookie_path()
+								$pictureDeriv,
+								time()+10,
+								cookie_path()
 		);
 		//============================================================
 		setcookie( 'picture_deriv',
-		$pictureDeriv,
-		time()+5,
-		cookie_path()
+		           $pictureDeriv,
+		           time()+10,
+		           cookie_path()
 		);
-		$_COOKIE['picture_sel_type']=$pictureSelType;
-		$_COOKIE['picture_deriv']=$pictureDeriv;
-		$_COOKIE['picture_map']=$pictureDeriv;
-	}
-
-	static public function Fin_php($message_){
+		$_COOKIE['picture_sel_type'] = $pictureSelType;
+		$_COOKIE['picture_deriv']    = $pictureDeriv;
+		$_COOKIE['picture_map']      = $pictureDeriv;
+	}
+	//=========================================================
+	static function AfficheDebug(){
+		global $DEBUG_autosize,$infos_message,$error_message,$events,$autosize_parametres;
+		global $theContainerWidth, $theContainerHeight ,$theMainImageWidth,$theMainImageHeight ;
+		if(empty($events)) $events= (object) '';
+		if ( isset($_COOKIE['pwg_id']) ) unset ($_COOKIE['pwg_id']) ;
+		//$infos_message .=  cl_print_var($events) ;
+		if($events->event==2){
+			if(preg_match("|help|", $DEBUG_autosize, $val)){
+				$infos_message .=  "<span style='color:blue'>HELP<br>";
+				$infos_message .="get_infos  <br>";
+				$infos_message .="event <br>";
+				$infos_message .="cookies_x <br>";
+				$infos_message .="session_x<br>";
+				$infos_message .="theMainImage_x -> theMainImage size<br>";
+				$infos_message .="c1_x -> theContainer size<br>";
+				$infos_message .="test_x -> GET,POST,SERVER<br>";
+				$infos_message .="noresize  <br>";
+				$infos_message .="newreload <br>";
+				$infos_message .="parametres <br>";
+				$infos_message .="end_x -> Fin<br>";
+				$infos_message .=  "</span>";
+			}
+			if(preg_match("|cookies|", $DEBUG_autosize, $val)  && !preg_match("|cookies_|", $DEBUG_autosize, $val) )
+				$infos_message .=  "COOKIE:$events->function[$events->event]"  . cl_print_var($_COOKIE) ;
+				
+		if(preg_match("|newreload|", $DEBUG_autosize, $val)) {
+			unset($_COOKIE['autosize_reload']);			 
+			return ;
+		}
+		if(preg_match("|parametres|", $DEBUG_autosize, $val))
+			$infos_message .= "$events->function[$events->event]" .  cl_print_var($autosize_parametres);
+		}
+		if(preg_match("|event|", $DEBUG_autosize, $val)){
+			$infos_message .=  "<span style='color:red'>$events->function</span> [$events->event] $events->content, " ;
+		}
+		if(preg_match("|cookies_$events->event|", $DEBUG_autosize, $val))
+			$infos_message .=  "COOKIE:$events->function[$events->event]"  . cl_print_var($_COOKIE) ;
+		if(preg_match("|session_$events->event|", $DEBUG_autosize, $val))  $infos_message .=  "SESSION:"  . cl_print_var($_SESSION) ;
+		if(preg_match("|theMainImage_$events->event|", $DEBUG_autosize, $val)) {
+			$infos_message .=  "theMainImage:".$theMainImageWidth."x".$theMainImageHeight;
+		}
+
+		if(preg_match("|c1_$events->event|", $DEBUG_autosize, $val)) {
+			$infos_message .="theContainerWidth Infos: " . $theContainerWidth . " x " . $theContainerHeight . " I1: " . $theMainImageWidth ." x ".$theMainImageHeight ;
+		}
+
+		if(preg_match("|test_$events->event|", $DEBUG_autosize, $val)) {
+			$infos_message .= "$events->function: <br>";
+			$infos_message .=  "GET:"  . cl_print_var($_GET) ;
+			$infos_message .= "POST:"  . cl_print_var($_POST) ;
+			$infos_message .= "SERVER:"  . cl_print_var($_SERVER["HTTP_HOST"]) ;
+
+		}
+
+		if(preg_match("|end_$events->function|", $DEBUG_autosize, $val)) {
+			self::Fin_php("#1099: " . $DEBUG_autosize);
+		}
+
+
+	}
+	//=========================================================
+	static public function Fin_php($message_,$reload = true ){
 		global  $infos_message;
-		echo "End :".$message_."<br>";
-		die($infos_message);
+		echo $infos_message."<br>";
+		die("End :".$message_."<br>");
 	}
 	//==================================================
Index: /extensions/Autosize/css/autosize.css
===================================================================
--- /extensions/Autosize/css/autosize.css	(revision 22359)
+++ /extensions/Autosize/css/autosize.css	(revision 22360)
@@ -10,6 +10,4 @@
    }
 #theImage img{ 
- 
- 
  
 }
Index: /extensions/Autosize/include/affiche.php
===================================================================
--- /extensions/Autosize/include/affiche.php	(revision 22359)
+++ /extensions/Autosize/include/affiche.php	(revision 22360)
@@ -12,18 +12,10 @@
 $cookies="' x '"; 
 global $imgSizeWH ;
-if(isset($_COOKIE['windowHeight'])){
-$windowHeight=$_COOKIE['windowHeight'];
-$windowWidth=$_COOKIE['windowWidth'];
-}else{
-$windowHeight=600;
-$windowWidth=800;
-}
-global $size ;
-
-if(!isset($imgSizeWH)){
- $imgSizeWH[0]=100;
-$imgSizeWH[1]=100;
-}
- 
+global  	$events ,$windowHeight , $windowWidth;
+global $size ; 
+global $DEBUG_autosize;
+		global $autosize_parametres,$user_status;
+		global  $has_pamoorama,$pictureSelType,$pictureDeriv;
+//===========================================================================
 $size=	array(
             'src_img_h' => $imgSizeWH[1],
@@ -32,11 +24,31 @@
             'window_width' => $windowWidth
           );
-   
-       
+if($imgSizeWH[1]==0){
+          print_r($size);
+          }
+          $ratio=$imgSizeWH[0]/$imgSizeWH[1]; 
+	if(preg_match("|fin_affiche|", $DEBUG_autosize, $val)){
+echo "<pre>";
+echo $DEBUG_autosize.$infos_message."
+";
+print_r(explode(",","$infos_message"));
+print_r($events);
+
+ echo  $pictureDeriv . " " . $pictureDeriv . " " . $pictureSelType;
+
+echo "WH: " . $windowHeight . "x " .$windowWidth;
+print_r($imgSizeWH);
+	print_r($_COOKIE);
+
+
+die();
+}       
+
+
   $my_path = AUTOSIZE_PATH_ABS;
   $theme=$user['theme'];
   
   $user_status = $user['status'] ;
-                   $template->assign( array( 
+  $template->assign( array( 
                    'AUTOSIZE_PATH_ABS' => AUTOSIZE_PATH_ABS,
                    'ROOT_URL' => ROOT_URL,
@@ -56,8 +68,4 @@
     }  
  $autosize_parametres = cl_autosize_Get_Options();
- //===========================================
-$COOKIE_PATH= cookie_path() ;
- global $DEBUG_autosize;
-
           $user_type= get_user_status($user_status)."_type";
           $user_type=  $autosize_parametres->$user_type ;  
@@ -68,4 +76,9 @@
               $ideal_size[1]=$imgSizeWH[1];
           }
+
+ //===========================================
+$COOKIE_PATH= cookie_path() ;
+
+
 
  $slide_show = isset($page['slideshow'])?$page['slideshow']:false;
@@ -85,5 +98,5 @@
             'slide_show' => $slide_show,
              
-            'ratio' =>$imgSizeWH[0]/$imgSizeWH[1] ,   
+            'ratio' =>$ratio ,   
               
             'webmaster_type' => array(
Index: /extensions/Autosize/js/Affiche_script.js
===================================================================
--- /extensions/Autosize/js/Affiche_script.js	(revision 22359)
+++ /extensions/Autosize/js/Affiche_script.js	(revision 22360)
@@ -7,9 +7,10 @@
 	 **************************************************************************/
   jQuery(document).ready(function (jQuery) {
+
     var Type_Img = "";
     var theImg = "";
-    var Zone_image = "";
+    var Zone_image = {};
+    // expire= x *24*60*60*1000
     var OptionsCookie = jQuery.extend({}, { path: '/', expires: 1 });
-
     /***************************************************************************
     * test_theme("mont,pur") ...
@@ -25,24 +26,49 @@
     **************************************************************************/
     Save_cookies = function (parametres) {
+
+      if (!parametres) {
+        jQuery.cookie('windowHeight', jQuery(window).height(), OptionsCookie);
+        jQuery.cookie('windowWidth', jQuery(window).width(), OptionsCookie);
+        jQuery.cookie('picture_deriv', options.pictureDeriv, OptionsCookie);
+        jQuery.cookie('picture_sel_type', options.pictureSelType, OptionsCookie);
+        jQuery.cookie('picture_map', options.pictureMap || options.pictureDeriv, OptionsCookie);
+        return;
+      }
       parametres.windowHeight = jQuery(window).height();
       parametres.windowWidth = jQuery(window).width();
+      if (parametres.windowHeight) jQuery.cookie('windowHeight', parametres.windowHeight, OptionsCookie);
+      if (parametres.windowWidth) jQuery.cookie('windowWidth', parametres.windowWidth, OptionsCookie);
+      if (parametres.pictureDeriv) jQuery.cookie('picture_deriv', parametres.pictureDeriv, OptionsCookie);
+      if (parametres.pictureSelType) jQuery.cookie('picture_sel_type', parametres.pictureSelType, OptionsCookie);
+      if (parametres.pictureMap) jQuery.cookie('picture_map', parametres.pictureMap || parametres.pictureDeriv, OptionsCookie);
+
+      if (!Zone_image.container) return;
+
+      if (Zone_image.container.height) {
+        parametres.theContainerWidth = Zone_image.container.width;
+        parametres.theContainerHeight = Zone_image.container.height;
+      }
+      if (Zone_image.image.height) {
+        parametres.theMainImageWidth = Zone_image.image.width;
+        parametres.theMainImageHeight = Zone_image.image.height;
+      }
+      // if (infos_theMainImage.src == "none") return;
+      // if (!theImg.src.match(RegExp(Zone_image.name, "gi"))) return;
       try {
-        if (parametres.pictureDeriv) jQuery.cookie('picture_deriv', parametres.pictureDeriv, OptionsCookie);
-        if (parametres.pictureSelType) jQuery.cookie('picture_sel_type', parametres.pictureSelType, OptionsCookie);
-        if (parametres.pictureMap) jQuery.cookie('picture_map', parametres.pictureMap, OptionsCookie);
+        if (Zone_image.path) jQuery.cookie('img_calc', Zone_image.path, OptionsCookie);
         if (parametres.imgSrc) jQuery.cookie('img_src', parametres.imgSrc, OptionsCookie);
+        if (parametres.theContainerHeight) jQuery.cookie('theContainerHeight', parametres.theContainerHeight, OptionsCookie);
+        if (parametres.theContainerWidth) jQuery.cookie('theContainerWidth', parametres.theContainerWidth, OptionsCookie);
+
         if (parametres.theMainImageHeight) jQuery.cookie('theMainImageHeight', parametres.theMainImageHeight, OptionsCookie);
         if (parametres.theMainImageWidth) jQuery.cookie('theMainImageWidth', parametres.theMainImageWidth, OptionsCookie);
-        if (parametres.theImageHeight) jQuery.cookie('theImageHeight', parametres.theImageHeight, OptionsCookie);
-        if (parametres.theImageWidth) jQuery.cookie('theImageWidth', parametres.theImageWidth, OptionsCookie);
-        if (parametres.windowHeight) jQuery.cookie('windowHeight', parametres.windowHeight, OptionsCookie);
-        if (parametres.windowWidth) jQuery.cookie('windowWidth', parametres.windowWidth, OptionsCookie);
-        if (parametres.theImageTop) jQuery.cookie('theImageTop', parametres.theImageTop, OptionsCookie);
-        if (parametres.theImageLeft) jQuery.cookie('theImageLeft', parametres.theImageLeft, OptionsCookie);
-        if (parametres.theImageRight) jQuery.cookie('theImageRight', parametres.theImageRight, OptionsCookie);
-        if (parametres.theImageBottom) jQuery.cookie('theImageBottom', parametres.theImageBottom, OptionsCookie);
-        if (parametres.theImageMargeZone) {
-          jQuery.cookie('theImageMargeWidth', parametres.theImageMargeZone.width, OptionsCookie);
-          jQuery.cookie('theImageMargeHeight', parametres.theImageMargeZone.height, OptionsCookie);
+
+        if (parametres.theContainerTop) jQuery.cookie('theContainerTop', parametres.theContainerTop, OptionsCookie);
+        if (parametres.theContainerLeft) jQuery.cookie('theContainerLeft', parametres.theContainerLeft, OptionsCookie);
+        if (parametres.theContainerRight) jQuery.cookie('theContainerRight', parametres.theContainerRight, OptionsCookie);
+        if (parametres.theContainerBottom) jQuery.cookie('theContainerBottom', parametres.theContainerBottom, OptionsCookie);
+        if (parametres.theContainerMargeZone) {
+          if (parametres.theContainerMargeZone.width) jQuery.cookie('theContainerMargeWidth', parametres.theContainerMargeZone.width, OptionsCookie);
+          if (parametres.theContainerMargeZone.height) jQuery.cookie('theContainerMargeHeight', parametres.theContainerMargeZone.height, OptionsCookie);
         }
       } catch (e) {
@@ -56,4 +82,7 @@
     Get_cookies = function () {
       parametres = {
+        windowHeight: jQuery.cookie('windowHeight'),
+        windowWidth: jQuery.cookie('windowWidth'),
+
         pictureDeriv: jQuery.cookie('picture_deriv'),
         pictureMap: jQuery.cookie('picture_map'),
@@ -64,15 +93,12 @@
         theMainImageWidth: jQuery.cookie('theMainImageWidth'),
 
-        windowHeight: jQuery.cookie('windowHeight'),
-        windowWidth: jQuery.cookie('windowWidth'),
-
-        theImageHeight: jQuery.cookie('theImageHeight'),
-        theImageWidth: jQuery.cookie('theImageWidth'),
-        theImageTop: jQuery.cookie('theImageTop'),
-        theImageLeft: jQuery.cookie('theImageLeft'),
-        theImageBottom: jQuery.cookie('theImageBottom'),
-        theImageRight: jQuery.cookie('theImageRight'),
-        theImageMargeZone: { width: jQuery.cookie('theImageMargeWidth'),
-          height: jQuery.cookie('theImageMargeHeight')
+        theContainerHeight: jQuery.cookie('theContainerHeight'),
+        theContainerWidth: jQuery.cookie('theContainerWidth'),
+        theContainerTop: jQuery.cookie('theContainerTop'),
+        theContainerLeft: jQuery.cookie('theContainerLeft'),
+        theContainerBottom: jQuery.cookie('theContainerBottom'),
+        theContainerRight: jQuery.cookie('theContainerRight'),
+        theContainerMargeZone: { width: jQuery.cookie('theContainerMargeWidth'),
+          height: jQuery.cookie('theContainerMargeHeight')
         }
 
@@ -86,5 +112,5 @@
     **************************************************************************/
     Get_type_img = function (e) {
-      // ====== détection du type d'images ======   
+      // ====== détection du type d'images ======
       if (jQuery("#charlie").length > 0) {
         Type_Img = "charlie";
@@ -94,24 +120,23 @@
       } else if (jQuery("#pamoorama").length > 0) {
         Type_Img = "pamoorama";
+        theMainImage_Id = "#pamoorama";
         options.valide = true;
-        infos_pamoorama = jQuery("#pamoorama").infos({ absolute: true });
-
       } else if (jQuery("#map").length > 0 || jQuery("#mapPicture").length > 0) {
         Type_Img = "map";
       } else if (jQuery("#Panorama").length) {
         Type_Img = "panorama";
-      } else if ((jQuery("#theImage" + " iframe").length + jQuery("#theImage" + " object").length + jQuery("#theImage" + " embed").length) > 0) {
-
-        if (jQuery("#theImage" + " object").length > 0) {
+      } else if ((jQuery(theImage_id + " iframe").length + jQuery(theImage_id + " object").length + jQuery(theImage_id + " embed").length) > 0) {
+
+        if (jQuery(theImage_id + " object").length > 0) {
           type_src = "object";
-        } else if (jQuery("#theImage" + " embed").length > 0) {
+        } else if (jQuery(theImage_id + " embed").length > 0) {
           type_src = "embed";
         } else {
           type_src = "iframe";
         }
-        iframes = jQuery("#theImage" + " " + type_src);
+        iframes = jQuery(theImage_id + " " + type_src);
         var st_frame = true;
         nbf = iframes.length;
-        jQuery("#theImage" + " " + type_src).each(function (i) {
+        jQuery(theImage_id + " " + type_src).each(function (i) {
           if (this.src.match(RegExp("http", "gi")) || this.src.match(RegExp("javascript", "gi"))) {
 
@@ -129,5 +154,5 @@
         }
         // 'fb - xfbml - like - button
-        objs = jQuery("#theImage" + " div").get(0);
+        objs = jQuery(theImage_id + " div").get(0);
         if (jQuery(objs).length > 0) {
           id_0 = jQuery(objs).attr("id");
@@ -147,7 +172,7 @@
 
 
-      } else if (jQuery("#theImage").find("img").length > 0) {
+      } else if (jQuery(theImage_id).find("img").length > 0) {
         Type_Img = "img";
-      } else if (jQuery("#theImage" + "Box").find("img").length > 0) {
+      } else if (jQuery(theImage_id + "Box").find("img").length > 0) {
         Type_Img = "img";
         Parent = Parent + "Box";
@@ -165,105 +190,105 @@
     // ====================================
     set_cl = function (Valid) {
-      if (typeof Valid == "undefined") Valid = options.pictureSelType.match(RegExp("Autosize", "gi")) || false;
-      if (typeof options.cl_visible == "undefined") return;
-      if (typeof src1 == "undefined") return;
-      if (options.cl_visible) src = src1;
-      else src = src2;
-      if (typeof options.pictureSelType != "undefined" && (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi")) {
-        if (options.pictureSelType == "SelMaxi") src = src6;
-      } else {
-        Valid = false;
-        src = src2;
-        jQuery("#bp_cla span").text("");
-      }
-      if (options.cl_visible) {
-        src_info = src3;
-        src_infos_1 = src3;
-      } else {
-        src_info = src4;
-        src_infos_1 = src5;
-      }
-      src_info = options.pictureDeriv;
-      if (!Valid) {
-        Zone_image.image.height = Zone_image.image_init.height;
-        Zone_image.image.width = Zone_image.image_init.width;
-
-      }
-
-      if ((typeof Zone_image != "undefined") && typeof Zone_image.image != "undefined") {
-        Zone_image.zoom = (Zone_image.image.height / Zone_image.image_init.height);
-        zoom_cl = parseInt(100 * Zone_image.zoom) + "%"; ;
-        if (!Valid) {
-          if (options.pictureSelType == "SelMaxi")
-            zoom_cl = options.pictureSelType + " [" + options.pictureDeriv + "]";
-          else {
-            zoom_cl = "";
-            src_info = options.pictureDeriv;
+      if (typeof Valid == "undefined")
+        Valid = options.pictureSelType.match(RegExp("Autosize", "gi")) || false;
+      if (typeof options.cl_visible != "undefined" && typeof src1 != "undefined") {
+        if (options.cl_visible) src = src1;
+        else src = src2;
+        if (typeof options.pictureSelType != "undefined" && (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi")) {
+          if (options.pictureSelType == "SelMaxi") src = src6;
+        } else {
+          Valid = false;
+          src = src2;
+          jQuery("#bp_cla span").text("");
+        }
+        if (options.cl_visible) {
+          src_info = src3;
+          src_infos_1 = src3;
+        } else {
+          src_info = src4;
+          src_infos_1 = src5;
+        }
+        src_info = options.pictureDeriv;
+
+
+        if ((typeof Zone_image != "undefined") && typeof Zone_image.image != "undefined") {
+          if (!Valid) {
+            Zone_image.image.height = Zone_image.image_init.height;
+            Zone_image.image.width = Zone_image.image_init.width;
+
           }
-        }
-        if (Type_Img == "pamoorama" || Type_Img == "iframe" || Type_Img == "charlie") {
-          zoom_cl = "";
-          src_info = "";
-          src = src2;
+          Zone_image.zoom = (Zone_image.image.height / Zone_image.image_init.height);
+          zoom_cl = parseInt(100 * Zone_image.zoom) + "%"; ;
+          if (!Valid) {
+            if (options.pictureSelType == "SelMaxi")
+              zoom_cl = options.pictureSelType + " [" + options.pictureDeriv + "]";
+            else {
+              zoom_cl = "";
+              src_info = options.pictureDeriv;
+            }
+          }
+          if (Type_Img == "pamoorama" || Type_Img == "iframe" || Type_Img == "charlie") {
+            // zoom_cl = "";
+            // src_info = "";
+            // src = src2;
+          };
+
+          jQuery('#bp_cla').attr('alt', src_info);
+          jQuery('#bp_cla').attr('title', src_info);
+          jQuery('#bp_cla').attr('Stitle', src_info);
+          jQuery('#bp_cla').attr('Stip', zoom_cl);
+          jQuery('#bp_cla span').text(zoom_cl);
+          color_back = jQuery('#imageToolBar').css("backgroundColor");
+          try {
+            if (color_back.match(new RegExp("rgb", "gi"))) {
+              color_back = color_back.split("(")[1].split(")")[0].split(",");
+              color_back = "rgb(" + Math.abs(255 - color_back[0]) + ","
+    					+ Math.abs(255 - color_back[1]) + ","
+    					+ Math.abs(255 - color_back[2]) + ")";
+            }
+            else if (color_back.match(new RegExp("#", "gi")))
+              color_back = Math.abs("#65536" - color_back);
+            else
+              color_back = jQuery('body').css("color");
+            jQuery('#bp_cla span').css({ color: color_back, aling: "center" });
+          } catch (e) {
+
+          }
+          jQuery("#derivativeSwitchBox span").removeClass("auto_details linkAutosize");
+          jQuery("#derivativeSwitchBox a").removeClass("auto_details linkAutosize");
+          if (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi") {
+            spans = jQuery("#derivativeChecked" + options.pictureSelType).next();
+            spans.addClass("linkAutosize");
+            spans.find("span").addClass("auto_details");
+            jQuery(".auto_details").text("");
+          }
+          if (options.pictureDeriv) {
+            jQuery(".switchCheck").css({ visibility: "hidden" });
+            if (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi") {
+              jQuery("#derivativeChecked" + options.pictureSelType).css("visibility", "visible");
+              jQuery("#derivativeChecked" + options.pictureDeriv + ".switchCheck").css({ visibility: "visible", color: "grey" });
+            } else
+              jQuery("#derivativeChecked" + options.pictureDeriv).css("visibility", "visible");
+            jQuery('.auto_details').text(" (" + Zone_image.image.width + " x " + Zone_image.image.height + ") " + options.pictureDeriv);
+          }
+          // ===============================================
+        } else {
+          src = src6;
+          jQuery('.auto_details').text("");
+
+        }
+        bp_scr = jQuery('#bp_img_cla');
+        if (bp_scr.length > 0) {
+          src_enc = bp_scr.attr("src");
+          if (!src_enc.match(src)) {
+            bp_scr.get(0).src = src;
+            jQuery('#bp_img_cla').attr('alt', src_info);
+            jQuery('#bp_img_cla').attr('title', src_info);
+          }
         };
-
-        jQuery('#bp_cla').attr('alt', src_info);
-        jQuery('#bp_cla').attr('title', src_info);
-        jQuery('#bp_cla').attr('Stitle', src_info);
-        jQuery('#bp_cla').attr('Stip', zoom_cl);
-        r = { width: jQuery("#theMainImage").width(), height: jQuery("#theMainImage").height(),
-          rap: jQuery("#theMainImage").width() / jQuery("#theMainImage").height(),
-          rap_init: Zone_image.image_init.rapport
-        };
-        jQuery('#bp_cla span').text(zoom_cl);
-        color_back = jQuery('#imageToolBar').css("backgroundColor");
-        try {
-          if (color_back.match(new RegExp("rgb", "gi"))) {
-            color_back = color_back.split("(")[1].split(")")[0].split(",");
-            color_back = "rgb(" + Math.abs(255 - color_back[0]) + ","
-                + Math.abs(255 - color_back[1]) + ","
-                + Math.abs(255 - color_back[2]) + ")";
-          }
-          else if (color_back.match(new RegExp("#", "gi")))
-            color_back = Math.abs("#65536" - color_back);
-          else
-            color_back = jQuery('body').css("color");
-          jQuery('#bp_cla span').css({ color: color_back, aling: "center" });
-        } catch (e) {
-
-        }
-        jQuery("#derivativeSwitchBox span").removeClass("auto_details linkAutosize");
-        jQuery("#derivativeSwitchBox a").removeClass("auto_details linkAutosize");
-        if (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi") {
-          spans = jQuery("#derivativeChecked" + options.pictureSelType).next();
-          spans.addClass("linkAutosize");
-          spans.find("span").addClass("auto_details");
-          jQuery(".auto_details").text("");
-        }
-        if (options.pictureDeriv) {
-          jQuery(".switchCheck").css({ visibility: "hidden" });
-          if (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi") {
-            jQuery("#derivativeChecked" + options.pictureSelType).css("visibility", "visible");
-            jQuery("#derivativeChecked" + options.pictureDeriv + ".switchCheck").css({ visibility: "visible", color: "grey" });
-          } else
-            jQuery("#derivativeChecked" + options.pictureDeriv).css("visibility", "visible");
-          jQuery('.auto_details').text(" (" + Zone_image.image.width + " x " + Zone_image.image.height + ") " + options.pictureDeriv);
-        }
-        // ===============================================
-      } else {
-        src = src6;
-        jQuery('.auto_details').text("");
-
-      }
-      bp_scr = jQuery('#bp_img_cla');
-      if (bp_scr.length > 0) {
-        src_enc = bp_scr.attr("src");
-        if (!src_enc.match(src)) {
-          bp_scr.get(0).src = src;
-          jQuery('#bp_img_cla').attr('alt', src_info);
-          jQuery('#bp_img_cla').attr('title', src_info);
-        }
-      };
-      Affiche_limite(pictureSelType_user);
+        if (typeof Affiche_limite != "function") return;
+        Affiche_limite(pictureSelType_user);
+      }
+      Save_cookies(options);
     };
     // ____________________ set_cl _____________________________
@@ -273,9 +298,5 @@
     **************************************************************************/
     Set_llbgo = function (Force) {
-
       if (options.marges_llgbo == 0) return;
-      if (Type_Img == "pamoorama") {
-
-      }
       if (Force)
         if (typeof LlgboFr_Resize == "function") {
@@ -319,159 +340,9 @@
     // __________ Set_llbgo _______________
     var wpng = 0;
-    /***************************************************************************
-    * window LOAD
-    **************************************************************************/
-    jQuery(window).load(function () {
-      location_href = location.href;
-      // =======================================================================
-      infos_theImage = jQuery(theImage_id).infos({ absolute: true });
-      infos_theMainImage = jQuery(theMainImage_id).infos({ absolute: true });
-      infos_theImageAndInfos = jQuery(theImageAndInfos_id).infos();  // Cadre
-      // general
-      the_mainImage_obj = "theMainImage_obj";
-      infos_theMainImage_obj = jQuery("#" + the_mainImage_obj).infos({ absolute: true });
-
-      infos_theMainImage_obj.rapport = infos_theMainImage_obj.width / infos_theMainImage_obj.height;
-      if (infos_theMainImage.width == 0) {
-        if (Type_Img == "pamoorama") {
-          infos_theMainImage = jQuery("#pamoorama").infos(true);
-          theMainImage_id = "#pamoorama";
-          options.valide = true;
-        } else if (Type_Img == "charlie") {
-          infos_theMainImage = jQuery("#charlie").infos(true);
-          theMainImage_id = "charlie";
-          options.valide = true;
-        } else if (Type_Img == "iframe") {
-          infos_theMainImage = jQuery("#iframe").infos(true);
-          options.valide = true;
-          infos_theMainImage.width = infos_theImage.general.width;
-          infos_theMainImage.height = infos_window.height - infos_theImage.top - options.marge_basse;
-          jQuery("#iframe").width(infos_theMainImage.width);
-          jQuery("#iframe").height(infos_theMainImage.height);
-        } else {
-          jQuery("img").each(function (i) {
-            imgSrc = options.imgSrc;
-          });
-          infos_theMainImage = jQuery("#theImage img").infos();
-        }
-        if (infos_theMainImage.id == "")
-          jQuery("#theImage img").attr("id", "theMainImage");
-        infos_theMainImage = jQuery(theMainImage_id).infos();
-      }
-
-      infos_theImage = jQuery(theImage_id).infos(true);                 // conteneur
-      if (options.pictureSelType != "Autosize" && options.pictureSelType != "SelMaxi") {
-        jQuery('#derivativeSwitchLink').show();
-      }
-      if (test_theme("simple")) {
-        jQuery(theMainImage_id).css({ maxWidth: "none" });
-        theImageAndInfos_id = "#content";
-        infos_theImageAndInfos = jQuery(theImageAndInfos_id).infos();  // Cadre
-        // general
-        infos_theImage.height = infos_window.height - infos_theImage.top;
-        // jQuery(theImage_id).height(infos_theImage.height);
-
-      } else {
-        infos_theImageAndInfos = jQuery(theImageAndInfos_id).infos();  // Cadre
-        // general
-        if (infos_theImageAndInfos.visible == false)
-          theImageAndInfos_id = "#imageContainer";
-      }
-
-
-      imageInfos_id = "#imageInfos";
-
-      content_id = "#content";
-      infos_content = jQuery(content_id).infos(true);                 // conteneur
-      infos_theImage = jQuery(theImage_id).infos(true);                 // conteneur
-      infos_imageInfos = jQuery(imageInfos_id).infos(true);             // information
-      infos_theMainImage = jQuery(theMainImage_id).infos(true);         // Image
-      infos_copyright = jQuery("#copyright").infos(true);
-
-
-      if (infos_theImage.top > infos_window.height) {
-        zheight = infos_window.height - infos_content.top;
-      } else {
-        zheight = infos_window.height - (infos_theImage.top);
-      }
-
-
-      if (options.check_desc_v) { }
-
-      infos_comments = jQuery("#comments").infos(true);
-      infos_Licence = jQuery(".licencetag").infos(true);
-      infos_imageComment = jQuery(imageComment_id).infos(true);
-
-
-
-      if (test_theme("simple")) {
-
-
-      } else {
-        if (test_theme("stripped")) {
-
-        } else
-
-          if (test_theme("blanc , pure, hr_ ")) {
-            options.marge_gauche += 10;
-            options.marge_droite += 10;
-          }
-      }
-      Zone_image = { image_init: {
-        width: infos_theMainImage.width,
-        height: infos_theMainImage.height,
-        rapport: infos_theMainImage.width / infos_theMainImage.height
-      },
-        image: {
-          width: infos_theImage.general.width,
-          height: infos_window.height - infos_theImage.top - options.marge_basse,
-          rapport: infos_theMainImage.width / infos_theMainImage.height
-        },
-        container: {
-          width: infos_theImage.general.width,
-          height: zheight,
-          margesWidth: infos_window.width - infos_theImage.width
-        }, marges: {
-          height: 0,
-          width: 0
-        }
-      };
-      Zone_image.zoom = (Zone_image.image.height / Zone_image.image_init.height);
-
-      /***********************************************************************
-      * RESIZE (une fois document chargé)
-      **********************************************************************/
-
-      jQuery(window).resize(function (event, ui) {
-        Autosize_resize(true, options);
-      });
-      // _____________ widow.resize _______________
-
-      type_src = "div";
-      old_window = { width: 0, height: 0 };
-      List_autosize = new Array();
-      nu_img = 0;
-      tempo = 0;
-
-
-      infos_llgbo = jQuery(llgbo_id).infos(true);
-      infos_llgboh2 = jQuery("#llgboh2").infos(true);
-      marges_llgbo = 0;
-      // ==========================================================================================
-      init_gen();
-    });
-    // __________________window.onload_________________
-
-    /***************************************************************************
-    * window unLOAD
-    **************************************************************************/
-    jQuery(window).unload(function () {
-   
-      // return;
-    });
-    // _________ unload ___________
+
 
     // ===================
     // VARIABLES
+    // ===================
 
 
@@ -482,4 +353,5 @@
       options = { imageAutosize: false };
     }
+    if (typeof Autosize_options == "undefined") return;
     options = jQuery.extend(Autosize_options, options);
 
@@ -511,4 +383,5 @@
     DEBUG_autosize = options.DEBUG_autosize;
     OptionsCookie = jQuery.extend({}, { path: options.COOKIE_PATH, expires: 1 });
+
     var cookies = Get_cookies();
     fade_in = options.fade_in || 0;
@@ -526,7 +399,7 @@
     var infos_window = jQuery(window).infos();
     var infos_theImageAndInfos = jQuery(theImageAndInfos_id).infos();  // Cadre
-    // general  
-    var infos_content = jQuery("#content").infos(true);
-    var infos_the_page = jQuery("#the_page").infos(true);
+    // general
+    var infos_content = jQuery("#content").infos({ absolute: true });
+    var infos_the_page = jQuery("#the_page").infos({ absolute: true });
     var nopano = false;
     var llgbo_id = "#llgbo0";
@@ -540,5 +413,7 @@
     var pictureSelType_user = eval("options." + user_status + "_type"); // limite
     // taille
-
+    var path_names = new Array();
+    var img_finale = null;
+    var mypanorama = null;
 
     if (pictureSelType_user != "Autosize" && pictureSelType_user != "SelMaxi") {
@@ -588,821 +463,10 @@
       }
     Get_type_img();
-    // auto_details
-    // ==== limite affichage selection = select_type ====
-    var path_names = new Array();
-
-    Affiche_limite = function (pictureSelType_Maxi) {
-      n = 0;
-      var pt = new Array();
-      path_names = new Array();
-      jQuery("#derivativeSwitchBox a").css('visibility', 'hidden');
-      // jQuery(".switchCheck").css('visibility', 'hidden');
-      var maxi_display = false;
-      jQuery("#derivativeSwitchBox a").each(function (i) {
-        href_path = jQuery(this).attr("href");
-        if (!href_path) {
-          href_path = jQuery(this).html();
-          return;
-        }
-        pt = href_path.replace(/(javascript|changeImgSrc)|[('):]/gi, "");
-
-        patname = href_path.replace("javascript\:", "");
-        if (typeof old_path == "undefined") old_path = patname;
-        pt = pt.split(",");
-        tsz = pt[pt.length - 1];
-        if (!maxi_display)
-          jQuery(this).css('visibility', 'visible');
-        else {
-          jQuery(this).next().next().remove();
-          jQuery(this).next().remove();
-          jQuery(this).remove();
-        }
-        // --- recherche limite ---
-
-        if (!options.valide && (tsz == "Autosize" || tsz == "SelMaxi")) {
-          jQuery(this).next().next().remove();
-          jQuery(this).next().remove();
-          jQuery(this).remove();
-        } else {
-          if (tsz == "Original" && (pictureSelType_Maxi != "Autosize" && pictureSelType_Maxi != "SelMaxi")) {
-            maxi_display = true;
-          } else if (tsz == pictureSelType_Maxi && (pictureSelType_Maxi != "Autosize" && pictureSelType_Maxi != "SelMaxi")) {
-            maxi_display = true;
-
-          } else if (tsz == "Autosize" || tsz == "SelMaxi") {
-            patname = old_path.replace("')", "','" + tsz + "')");
-          } else
-            old_path = patname;
-          path_names.push(patname);
-        }
-        // --- type en cours ---
-        if (tsz.match(RegExp("^" + options.pictureDeriv, "gi"))) {
-          us = n;
-        }
-        n++;
-      });
-    };
-    // =============================================================
-    // REPONSE ACTION
-    // =============================================================
-    theMainImage_st = false;
-    jQuery("#reset").click(function () {
-      location.reload();
-    });
-
-
-    // ===========================================================
-    // REPONSE TRIGGER
-    // ===========================================================
-    jQuery('#ret_autosize').live('ON', function (e) {
-      if (nu_img == "") nu_img = 8;
-      jQuery(jQuery('.debug').get(nu_img)).trigger('ON');
-
-    });
-
-    // ==========================================================
-    jQuery("map area").mouseover(function (e) {
-      try {
-        nok = theImg.useMap;
-        hok = this;
-      }
-      catch (r) {
-
-      }
-    });
-
-    // ==================================
-    // jQuery("#llgbo").trigger("ON");
-    // ==================================
-    jQuery(llgbo_id).live('ON', function (e) {
-      n_id = this;
-      infos_llgbo = jQuery(llgbo_id).infos();
-      if (infos_llgbo.visible == false) return;
-
-      marges_llgbo = 0;
-      if (infos_llgbo.height > 0) {
-        infos_llgboframe1 = jQuery(llgbo_id + " div:last").infos();
-        infos_llgboframe31 = jQuery(llgbo_id + "  div:first").infos();
-        // =============================================
-        ll2 = infos_llgboframe1.width; // llgboframe1 interieur
-        ll1 = infos_llgboframe31.exterieur.width; // llgboframe31 avec border
-        // width
-        options.marges_llgbo = (ll1 - ll2);
-        infos_llgboh2 = jQuery("#llgboh2").infos();
-      }
-    });
-    // ==============================
-    // jQuery("#mapPicture").trigger("ON");
-    // ==============================
-    jQuery("#mapPicture").live('ON', function (e) {
-      p2 = jQuery("#infoSwitcher").infos();
-    });
-    // ==============================
-    // jQuery("#map").trigger("ON");
-    // ==============================
-    jQuery("#map").live('ON', function (e) {
-      p2 = jQuery("#map").infos();
-    });
-    // ===================================
-    // jQuery("#theImage").trigger("ON");
-    // ===================================
-    jQuery("#imageInfos").live('on', function (e) {
-      target = e.target.id;
-    });
-
-    // ===================================
-    // jQuery("#theImage").trigger("ON");
-    // ===================================
-    jQuery("#theImage").live('ON', function (e) {
-      target = e.target.id;
-
-      id = this.id;
-      Select_Image(); // +calcul
-    });
-
-
-
-
-    // =================================================================
-    jQuery(document).live('gallyInterfaceReady', function (e) {
-      i = jQuery(this).text();
-      jQuery(this).trigger('ON');
-    }
-
-          );
-
 
     /***************************************************************************
     * 
     **************************************************************************/
-    jQuery("#theImage").resize(function (e) {
-      nu_img = 0;
-    });
-    jQuery("#menuSwitcher,#infoSwitcher").click(function (e) {
-      options.set_sw = this.id;
-      setTimeout(function () { div_resize(); }, 10);
-      nu_img = 0;
-    });
-
-    div_resize = function (i) {
-
-      jQuery("#theImage").trigger("resize");
-      /*
-      * if (jQuery("#theImage").width() != old_width) { setTimeout(function () {
-      * div_resize() }, 10); }
-      */
-    };
-    // ===========================================
-    // jQuery("#theImageAndInfos").trigger("ON");
-    // ===========================================
-    jQuery("#theImageAndInfos").live('ON', function (e) {
-      infos_theImageAndInfos = jQuery("#theImageAndInfos").infos();
-      // setTimeout(function () { Autosize_resize(true) }, 100);
-      nu_img = 0;
-    }); // fin click #theImageAndInfos ON
-
-
-    jQuery("#theImageAndInfos").resize(function (e) {
-
-    });
-
-
-    jQuery("#linkAutosize").click(function (e) {
-      nu_img = 0;
-    });
-    // ==================================
-    //
-    // ===================================
-    jQuery('#derivativeCheckedAutosize').click(function () {
-      try {
-        pathnames = jQuery(this).attr("href").split(":");
-
-        // eval(pathnames[1]);
-      } catch (e) {
-        n = false;
-      }
-    }); // fin click derivativeCheckedAutosize
-    // ====================================================
-    if (typeof decode_href != 'function') {
-      function decode_href(myObj) {
-        hrefPath = jQuery(myObj).attr("href");
-        if (hrefPath.indexOf("changeImgSrc") < 0) {
-          pt = hrefPath;
-        } else {
-          pt = hrefPath.replace(/(javascript|phpWGOpenWindow|javascript|changeImgSrc)|[('):]/gi, "");
-
-        }
-        pt = pt.split(",");
-        source = pt[0];
-        if (hrefPath.indexOf("phpWGOpenWindow") < 0) {
-          pictureDeriv = pt[1];
-          pictureMap = pt[2];
-          pictureSelType = pt[pt.length - 1];
-        } else {
-          pictureDeriv = options.pictureDeriv;
-          pictureMap = options.pictureMap;
-          pictureSelType = options.pictureSelType;
-        }
-        return { source: source,
-          pictureDeriv: pictureDeriv,
-          pictureMap: pictureMap,
-          pictureSelType: pictureSelType
-        };
-      }
-    }
-
-    jQuery("#derivativeSwitchBox a").click(function (e) {
-      Affiche_limite(pictureSelType_user);
-      retour = decode_href(this);
-      theImg = document.getElementById(theMainImage_id.replace("#", ""));
-      if (theImg) {
-        // options.pictureDeriv = retour.pictureDeriv;
-        if (this.name) {
-          options.pictureSelType = this.name;
-          spans = jQuery("#derivativeChecked" + this.name).next();
-          if (retour.pictureSelType != this.name)
-            spans.attr("href", "javascript:" +
-                        "ChangeImgSrc('" + retour.source + "," +
-                        retour.pictureDeriv + "," +
-                        retour.pictureMap + "," + options.COOKIE_PATH + "')");
-        }
-        options.pictureSelType = retour.pictureSelType;
-        options.pictureDeriv = retour.pictureDeriv;
-        options.pictureMap = retour.pictureDeriv;
-        Save_cookies(options);
-        setTimeout(function (i) {
-          Autosize_resize(false, options);
-        }, 2);
-
-      }
-    });
-    // __________ fin click #derivativeSwitchBox a ____________
-
-    jQuery("input").click(function () {
-      if (this.name.match(RegExp("_enabled", "gi"))) {
-        sel = "[name*=" + this.name + "]";
-        obj = jQuery("tr" + sel);
-
-        if (this.checked)
-          obj.css({ backgroundColor: "green", color: "white" });
-        else
-          obj.css({ backgroundColor: "red", color: "white" });
-        return;
-      }
-      return;
-    });
-
-
-    // ====================================
-    Autosize_init = function (name, value) {
-      img_defaut = { height: options.scaled_height, width: options.scaled_width };
-      img_reelle = { height: options.theImageHeight, width: options.theImageWidth };
-      img_init = { height: options.theImageHeight, width: options.theImageWidth };  // taille
-      // initiale
-
-      img_finale = img_init;
-
-      useMap = infos_theMainImage.useMap; // #mapmedium
-
-      useMap = options.pictureMap; // #mapxxx
-      pictureDeriv = options.pictureDeriv; // picturederiv xxx
-
-
-      old_img = options.imgSrc;
-      old_window_height = options.windowHeight || jQuery(window).height();
-      old_window_width = options.windowWidth || jQuery(window).width();
-      old_img_h = options.imgHeight;
-      old_img_w = options.imgWidth;
-      if (infos_theMainImage.visible == true) {
-        theImg = document.getElementById(theMainImage_id.replace("#", ""));
-        theImg.useMap = useMap;
-      }
-
-
-    };
-    // ____________________ Autosize_init _____________________
-
-    /***************************************************************************
-    * Autosize_resize
-    **************************************************************************/
-    Autosize_resize = function (force, parametres) {
-
-      if (!force) {
-        cookis = Get_cookies();
-        if (cookis.pictureSelType != options.pictureSelType) {
-          n = 0;
-        }
-      }
-      nauto = Get_dimensions(true, options);
-      if (nauto == "Wait") {
-        setTimeout(function (force, parametres) { Autosize_resize(force, parametres); }, 100);
-        return;
-      }
-      Save_cookies(options);
-      if (!options.valide || !nauto || (options.pictureSelType != "Autosize" && options.pictureSelType != "SelMaxi")) {
-        if (options.imageAutosize == true) {
-          options.pictureSelType = options.pictureDeriv;
-          Zone_image.image_init.width = jQuery(theImg).width();
-          Zone_image.image_init.height = jQuery(theImg).height();
-          set_cl("no");
-          Set_llbgo(true);
-          return;
-        }
-        // jQuery(theImg).width(Zone_image.image_init.width);
-        jQuery(theImg).height(Zone_image.image_init.height);
-        set_cl("no");
-        Set_llbgo(true);
-        return;
-
-      }
-      infos_theImage = jQuery(theImage_id).infos(true);
-
-      if (typeof img_finale == "undefined") img_finale = { width: Zone_image.image.width, height: Zone_image.image.height };
-      if (img_finale.width && (img_finale.width != Zone_image.image.width || img_finale.height != Zone_image.image.height)) {
-        img_finale = { width: Zone_image.image.width, height: Zone_image.image.height };
-      }
-
-      // ======================================================
-
-      affiche_debug({
-
-        Debug1: Debug_info(1, "Cont:" + infos_theImage.width
-    + " X " + infos_theImage.height
-    + " IMG: " + img_finale.width
-    + " X " + img_finale.height
-    + " mgw : " + Zone_image.marges.width
-    , "->")
-      });
-
-      if (Type_Img == "pamoorama") {// img_finale.width
-        jQuery("#pamoorama").width(img_finale.width);
-        jQuery("#pamoorama").height(img_finale.height);
-
-
-        infos_pamoorama = jQuery("#pamoorama").infos({ absolute: true });
-
-        Set_Pamoorama({ width: img_finale.width, height: img_finale.height });
-        if (nopano)
-          if (window.myPamoorama.options.autoscrollOnLoad) {
-            window.myPamoorama.startAnimRight();
-          }
-
-      } else if (Type_Img == "panorama") {
-        // jQuery("#pamoorama").width(img_finale.width);
-        // jQuery("#pamoorama").height(img_finale.height);
-
-
-
-        // jQuery("#theImage img.simple_panorama").panorama(asp_options);
-      } else {
-        if (options.imageAutosize == false)
-          if (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi") {
-            jQuery(theMainImage_id).height(Zone_image.image.height);
-            r1 = infos_theImage.width / infos_theImage.height;
-            jQuery(theMainImage_id).css("margin-top", options.marge_haute);
-          } else {
-            jQuery(theMainImage_id).width(Zone_image.image_init.width);
-            jQuery(theMainImage_id).height(Zone_image.image_init.height);
-          }
-        if (Type_Img == "charlie" || Type_Img == "iframe") {
-          init_w1 = Zone_image.image.width;
-          init_h1 = Zone_image.image.height;
-          if (pictureSelType_user != "Autosize" && pictureSelType_user != "SelMaxi") {
-            init_w1 = Autosize_options.ideal_size_width;
-            init_h1 = Autosize_options.ideal_size_height;
-          }
-          if (Type_Img == "charlie") {
-            dp1 = jQuery("#charlie").offset();
-            dp = jQuery("#" + the_mainImage_obj).offset();
-            if (dp) {
-              if (wpng == 0)
-                wpng = Math.abs(dp.left - dp1.left) * 2;
-            }
-            png_h = init_h1;
-            w01 = init_w1 - wpng;
-
-            jQuery("#" + "theImage").css({ padding: 0 });
-            if (!png_h) {
-              png_h = jQuery("#theMainImage").height();
-              h01 = png_h;
-            } else
-              h01 = Math.ceil(w01 / Zone_image.image.rapport);
-            // ==== Zone Affichage =====
-            if (h01 > png_h) {
-              h01 = png_h;
-              w01 = Math.ceil(h01 * Zone_image.image.rapport);
-            }
-            jQuery("#theMainImage").height(png_h);
-            jQuery("#theMainImage").width(w01 + wpng);
-            jQuery("#theMainImage").css({ verticalAlign: "middle", align: "center", textAlign: "center", margin: "auto" });
-
-            jQuery("#" + the_mainImage_obj).attr("width", w01);
-            jQuery("#" + the_mainImage_obj).attr("height", h01);
-
-            jQuery("#theMainImage_emb").attr("width", w01); // firefox opera
-            jQuery("#theMainImage_emb").attr("height", h01);
-
-            if (jQuery("#theMainImage_vid").length > 0) {
-              jQuery("#theMainImage_vid").attr("width", w01);
-              jQuery("#theMainImage_vid").attr("height", h01);
-            }
-            if (jQuery("video").length > 0) {
-              jQuery("video").attr("width", w01);
-              jQuery("video").attr("height", h01);
-            }
-            jQuery("#" + Type_Img).height(png_h);
-            jQuery("#" + Type_Img + " div").width(w01);
-            jQuery("#theImage").css({ height: "auto" });
-          } else {
-            jQuery("#theImage").css({ height: "auto" });
-            jQuery("#theMainImage").css({ width: "auto", height: "auto" });
-            jQuery("#" + Type_Img).attr("width", init_w1 - (infos_theMainImage.borderwidth.left + infos_theMainImage.borderwidth.right));
-            jQuery("#" + Type_Img).attr("height", init_h1 - (infos_theMainImage.borderwidth.top + infos_theMainImage.borderwidth.bottom));
-          }
-          jQuery("#" + Type_Img).show(fade_in);
-        }
-
-
-      }
-
-      set_cl();
-      Set_llbgo(true);
-      return true;
-    };
-    // _________________Autosize ____________________________________
-
-
-    /***************************************************************************
-    * pamoorama
-    **************************************************************************/
-    jQuery('#pamoorama').live('ON', function (e) {
-      jQuery(jQuery('.debug').get(1)).trigger('ON');
-      Autosize_resize(true, options);
-      jQuery("#pamoorama").fadeTo(fade_in + 20, 1);
-    });
-
-    // ===============================================
-    // jQuery("#theImage").trigger("Start_right");
-    // ===============================================
-    jQuery("#theImage").live('Start_right', function (e) {
-      if (typeof Zone_image == "undefined") return
-      test_w = window.myPamoorama.autoSlideFx.to;
-      test_w = window.myPamoorama.autoScrollFx.to;
-      nf = jQuery("#pamoorama_thumb").height();
-      jQuery("#pamoorama_thumb img").width(200);
-      jQuery("#pamoorama_thumb img").height(nf);
-      // 200=window.myPamoorama.imageWidth
-      // frame = Zone_image.container.width
-      nw = (200 * Zone_image.image.width) / window.myPamoorama.imageWidth;
-      jQuery("#pamoorama_frame").width(nw);
-    });
-    // ===============================================
-    // jQuery("#theImage").trigger("Start_left");
-    // ===============================================
-    jQuery("#theImage").live('Start_left', function (e) {
-      if (typeof Zone_image == "undefined") return
-      jQuery("#theImage").show(0);
-      window.myPamoorama.autoSlideFx.to = 0;
-      test_w = window.myPamoorama.autoSlideFx.to;
-      test_w = window.myPamoorama.autoScrollFx.to;
-      nf = jQuery("#pamoorama_thumb").height();
-      jQuery("#pamoorama_thumb img").width(200);
-      jQuery("#pamoorama_thumb img").height(nf);
-    });
-
-    /***************************************************************************
-    * Wait_pamoorama
-    **************************************************************************/
-    Wait_pamoorama = function () {
-      if (Type_Img != "pamoorama") return;
-      tempo = 0;
-      Wait_pamoorama_st = false;
-      while (Wait_pamoorama_st == false) {
-        Wait_pamoorama_st = Wait_pamoorama_time();
-        jQuery.noop();
-      }
-      tempo = 0;
-      if (nopano) {
-        if (window.myPamoorama.options.autoscrollOnLoad) {
-          window.myPamoorama.startAnimRight();
-          jQuery.delay(100);
-        }
-      }
-    };
-    // __________________ Wait_pamoorama ______________________
-    jQuery(".pwg-icon-clock-minus, .pwg-icon-clock-plus").click(function (i) {
-
-    }).mouseover(function (i) {
-
-    });
-
-    Wait_pamoorama_time = function () {
-      if (nopano == true) return true;
-      if (jQuery("#pamoorama").length) {
-        tempo = tempo + 1;
-        mypanorama = window.myPamoorama;
-        if (!mypanorama) {
-          if (tempo > 500) return true;
-          setTimeout("Wait_pamoorama_time()", 500);
-          return false;
-        }
-       /* if (mypanorama.skipInit == false) {
-          if (tempo > 500) return true;
-          setTimeout(function () {
-            Wait_pamoorama_time();
-          }, 500);
-          return false;
-        }*/
-       
-        // =============================================================
-        if(typeof mypanorama.imageHeight=="undefined"){
-          setTimeout(function () {
-            Wait_pamoorama_time();
-          }, 500);
-          return false;
-        }
-
-        if (jQuery(".infos").length > 0) {
-          jQuery(".infos").empty();
-          jQuery(".infos").hide();
-        }
-
-        nopano = true;
-
-        Zone_image = { image_init: { width: mypanorama.imageWidth,
-          height: mypanorama.imageHeight
-        }
-        };
-        jQuery("#pamoorama").trigger("ON");
-        return true;
-
-      }
-    };
-    // __________________ Wait_pamoorama time______________________
-
-    /***************************************************************************
-    * 
-    **************************************************************************/
-    Wait_Affichage = function () {
-      Wait_Affichage_st = false;
-      while (Wait_Affichage_st == false) {
-        jQuery.noop();
-        Wait_Affichage_st = Wait_Affichage_time();
-      }
-    };
-    // __________________ Wait_Affichage ______________________
-
-
-    Wait_Affichage_time = function () {
-      // if (nu_img > 1) return;
-      if (typeof stb != "undefined")
-        stb.stop().fadeTo(3500, 0);
-      if (typeof theMainImage_id == "undefined") return true;
-
-      if (theMainImage_id.selector) {
-        theMainImage_id = theMainImage_id.selector;
-      }
-      if (theMainImage_id == null) return;
-
-      if (jQuery(theMainImage_id).length == 0) {
-        if (jQuery("#pamoorama_inner").length > 0) {
-          return true;
-        }
-        // === attente Image chargée ===
-        if (tempo > 100) return true;
-        tempo++;
-        setTimeout("Wait_Affichage_time()", 500);
-        return false;
-
-      } else {
-
-        img_h = jQuery(theMainImage_id).height();
-        img_w = jQuery(theMainImage_id).width();
-
-        if (typeof infos_theImage == "undefined") return;
-        jQuery("#ret_autosize").trigger('ON', {
-          width: img_w,
-          height: img_h,
-          theImage: theMainImage_id,
-          img_src: infos_theMainImage.src,
-          window_height: infos_theImage.height,
-          window_width: infos_theImage.width
-        });
-      }
-      return true;
-    };
-    // ______________ Wait_affichage ______
-
-
-    /***************************************************************************
-    * 
-    **************************************************************************/
-    init_img = function (theImg) {
-      if (theImg.complete == false) {
-        return;
-      }
-      name_src = theImg.src;
-      stx = name_src.match(RegExp(Zone_image.src, "gi"));
-      if (stx == null) {
-        return false;
-      }
-      img_init = { width: jQuery(theImg).width(), height: jQuery(theImg).height() };
-
-      if (typeof theImg.naturalWidth != "undefined")
-        img_init.width = theImg.naturalWidth;
-      if (typeof theImg.naturalHeight != "undefined")
-        img_init.height = theImg.naturalHeight;
-      img_init.rapport = img_init.width / img_init.height;
-      if (typeof Zone_image == "undefined") Zone_image = { image: {} };
-      if (typeof Zone_image.image == "undefined") Zone_image.image = { height: Zone_image.image_init.height, width: Zone_image.image_init.width };
-      // theImg.height = img_init.height;
-      // theImg.width = img_init.width;
-
-      Zone_image.image_init = { height: img_init.height, width: img_init.width, rapport: img_init.rapport };
-      Zone_image.zoom = Zone_image.image_init.height / img_init.height;
-
-      if (typeof Zone_image.src == "undefined") {
-        Zone_image.src = name_src;
-        return false;
-      }
-      stx = name_src.match(RegExp(Zone_image.src, "gi"));
-      return stx;
-    };
-    // ___________ init_img _______
-
-
-
-    // ===========================================
-    //
-    // ===========================================
-    Set_Map = function (nds) {
-      p0 = jQuery("#map").offset();
-      if (!p0) return;
-      infos_mapPicture = jQuery("#mapPicture").infos({ absolute: true });
-      infos_theImage = jQuery("#theImage").infos({ absolute: true });
-      jQuery("#map").removeAttr("height");
-      jQuery("#map").removeAttr("width");
-      jQuery("#map").width(infos_theImage.width - (infos_mapPicture.width));
-      jQuery("#map").height(jQuery(window).height() - infos_theImage.top - infos_theImage.general.marges.height);
-      return true;
-    };
-
-    jQuery("map [name='#Autosize'] area").mouseover(function (e) {
-      return;
-    });
-    // ___ Set_Map ___
-
-    // =====================================
-    //
-    // =====================================
-    Get_Maxi = function (Maxi_image) {
-      var pt = options.liste_type;
-      if (pt.length > 0) {
-        tw = Maxi_image.width;  // valeur maxi
-        th = Maxi_image.height;  // valeur maxi
-        n = 0;
-        maxi_size = { w: Maxi_image.width, h: Maxi_image.height, idx: -1 };
-        mini_size = { w: tw, h: th, idx: 0 };
-        size_derive = { w: 0, h: 0 };
-        size_encours = { w: tw, h: th };
-        // =================================
-        jQuery(pt).each(function (i) {
-          vn = this;
-          v_pictureDeriv = vn[0]; v_imgSrc = vn[1]; v_width = parseInt(vn[2]); v_height = parseInt(vn[3]);
-          size_derive = { w: v_width, h: v_height };
-          if (v_pictureDeriv == options.pictureSelType) {
-            maxi_size = size_derive;
-            maxi_size.idx = n;
-            return false;
-          }
-
-          if (v_pictureDeriv != "square" && v_pictureDeriv != "thumb" && v_pictureDeriv != "SelMaxi" && v_pictureDeriv != "Autosize") {
-            if (size_derive.h > size_encours.h) {
-              if (maxi_size.idx < 0) {
-                maxi_size = size_derive;
-                maxi_size.idx = n;
-                if (options.pictureSelType == "SelMaxi" || options.pictureSelType == "Autosize")
-                  return false;
-              }
-            }
-            if (size_derive.h < size_encours.h && size_derive.h > 10) {
-              mini_size = size_derive;
-              mini_size.idx = n;
-            }
-          }
-          n++;
-        });
-
-
-
-
-        n = maxi_size.idx;
-        if (n < 0) {
-          n = mini_size.idx;
-        }
-        if (options.pictureSelType.match(RegExp("SelMaxi", "gi"))) {
-          n = mini_size.idx;
-
-        }
-        if (options.pictureSelType.match(RegExp("Autosize", "gi"))) {
-
-        }
-
-        pictureDeriv = pt[n][0];
-        last_id = pt[n][0];
-        jQuery(".switchCheck").each(function (i) {
-
-          if (!this.id.match(RegExp("Original", "gi"))) {
-            if (this.id.match(RegExp("SelMaxi", "gi"))) return false;
-            last_id = this.id.replace("derivativeChecked", "");
-          }
-          if (last_id == pictureDeriv)
-            return false;
-        });
-
-        options.pictureDeriv = last_id;
-
-        return { url: pt[n][1], pictureDeriv: last_id, pictureMap: last_id, width: pt[n][2], height: pt[n][3] };
-      }
-      return { imgSrc: "", pictureDeriv: "", width: "", height: "" };
-    };
-    // _______________ Get_Maxi ______
-
-    /***********************
-    * Selection de l'image 
-    ************************/
-    Select_Image = function () {
-      var pt = options.liste_type;
-      if (pt.length > 0) {
-        // ===== calcul Image ===
-        if (typeof imageInfos_id == "undefined") return;
-        if (Calcul_Image() == "Wait") {   // image en cours           
-          return "Wait";
-        }
-        //==================================================
-        options.theImageMargeZone = Zone_image.marges;
-        if (Type_Img != 'charlie') {
-          IMg = Get_Maxi(Zone_image.image);
-          imgSrc = IMg.url;
-          if (options.imgSrc.match(RegExp(imgSrc, "gi")))
-            options.imgSrc = imgSrc;
-          // dimension image
-          img_width = IMg.width;
-          img_height = IMg.height;
-          Zone_image.image_init = { height: IMg.height,
-            width: IMg.width,
-            rapport: IMg.width / IMg.height
-          };
-          if (typeof Zone_image.image == "undefined")
-            Zone_image.image = { height: IMg.height,
-              width: IMg.width,
-              rapport: IMg.width / IMg.height
-            };
-        } else {
-          return true;
-        }
-        Zone_image.zoom = Zone_image.image.height / Zone_image.image_init.height;
-        if (typeof Zone_image.src == "undefined")
-          Zone_image.src = imgSrc;
-        if (typeof Zone_image.name == "undefined")
-          Zone_image.name = " ";
-        if (typeof Zone_image.path == "undefined")
-          Zone_image.path = " ";
-
-        imgSrcS = imgSrc.split('/');
-        imgSrcS = imgSrcS[imgSrcS.length - 1];
-        if (!theImg.src) theImg.src = imgSrc;
-        identique = theImg.src.match(RegExp(imgSrc, "gi"));
-        if (identique)
-          identique = theImg.src.match(RegExp("loadajax", "gi"));
-        if (identique) return true;
-        href_path = get_href(IMg.pictureDeriv);
-        if (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi") {
-          spans = jQuery("#derivativeChecked" + options.pictureSelType).next();
-          spans.attr("href", "javascript:" + href_path);
-        }
-        theImg = document.getElementById(theMainImage_id.replace("#", ""));
-        if ((theImg == null) || theImg.tagName != "IMG") {
-          imgSrc_i = jQuery(theImg).css("backgroundImage");
-          imgSrc_j = jQuery(theImg).css("background-image");
-          return true;
-        } else {
-          eval(href_path);
-
-        }
-        theImg.useMap = "#map" + IMg.pictureMap;
-        return true;
-        theImg = document.getElementById(theMainImage_id.replace("#", ""));
-        if (init_img(theImg)) {
-          return true;
-        }
-        return false;
-      } else {
-        return false;
-      }
-
-    };  // _______________ Select_Image ______
-
     get_href = function (NewpictureDeriv) {
+      if (path_names.length == 0) Affiche_limite(pictureSelType_user);
       ref = path_names[0];
       for (i = 0; i < path_names.length; i++) {
@@ -1427,516 +491,8 @@
 
     /***************************************************************************
-    * correction pamoorama
+    * 
     **************************************************************************/
-    Set_Pamoorama = function (Format) {
-      myPamoorama = window.myPamoorama;
-      if (Type_Img == "pamoorama") {
-        if (!nopano) {
-          theMainImage_Id = "#pamoorama";
-          nopano = false;
-          Wait_pamoorama();
-          infos_theMainImage = jQuery(theMainImage_Id).infos();
-        }
-        if (typeof myPamoorama == "undefined") {
-          return;
-        }
-        // =========================================================
-        if (!nopano) {
-          nopano = false;
-          Wait_pamoorama();
-          infos_theMainImage = jQuery(theMainImage_Id).infos();
-        }
-
-
-        infos_pamoorama_outter = jQuery("#pamoorama_outter").infos({ absolute: true });
-        infos_pamoorama_inner = jQuery("#pamoorama_inner").infos({ absolute: true });
-        infos_pamoorama_frame = jQuery("#pamoorama_frame").infos({ absolute: true });
-        infos_frame = jQuery(myPamoorama.frame).infos({ absolute: true });
-
-
-        // ====================================================
-        marges_w = infos_pamoorama.general.marges.width;
-        marges_h = infos_pamoorama.general.marges.height;
-
-        jQuery("#pamoorama_footer").css({
-          width: Format.width + "px"
-        });
-        infos_pamoorama_footer = jQuery("#pamoorama_footer").infos();
-        marges_h += infos_pamoorama_footer.general.height;
-        outter_height = Format.height;
-
-        Zoom_pano = (Format.height - marges_h) / Zone_image.image_init.height;
-        new_image = { height: Math.ceil(Zone_image.image_init.height * Zoom_pano),
-          width: Math.ceil(Zone_image.image_init.width * Zoom_pano)
-        };
-
-        jQuery("#pamoorama_inner").css({
-          width: new_image.width + "px", height: new_image.height + "px", "background-size": "100%"
-        });
-        // ---------- test largeur image
-        new_width = Format.width; // -(options.marge_right + options.marge_left);
-
-        if (new_width > new_image.width) {
-          new_width = new_image.width;
-          jQuery("#pamoorama_outter").css({
-
-            align: "center",
-            margin: "0"
-          });
-        }
-        outter_width = new_width;
-
-        jQuery("#pamoorama_outter").css({
-          align: 'center',
-          margin: 'auto',
-          width: outter_width + "px",
-          height: Format.height - marges_h + "px"
-        });
-        // ============= Mise à l'echelle ==================
-        window.myPamoorama.options.width = Math.ceil(Format.width);
-        // ==================================================================
-        new_max_left = new_image.width - outter_width;
-        if (!window.myPamoorama.outter) return;
-        window.myPamoorama.outter.scrollTo(new_max_left, 0);
-
-        if (typeof window.myPamoorama.autoScrollFx != "undefined") window.myPamoorama.autoScrollFx.to = new Array(new_max_left, 0);
-        window.myPamoorama.ratio = Math.ceil(new_image.width / 200);
-        window.myPamoorama.imageWidth = new_image.width;
-        window.myPamoorama.imageHeight = new_image.height;
-        nf = jQuery("#pamoorama_thumb").height();
-        jQuery("#pamoorama_thumb img").width(200);
-        jQuery("#pamoorama_thumb img").height(nf);
-
-        jQuery("#pamoorama_thumb").css({
-          /* position: "absolute", */
-          left: (Format.width - 215) + "px"
-
-        });
-        jQuery("#pamoorama_thumb img").css({
-
-        });
-        // 200=window.myPamoorama.width
-        // frame = Zone_image.container.width
-
-        nw = (window.myPamoorama.image.width * Format.width) / window.myPamoorama.imageWidth;
-        jQuery("#pamoorama_frame").width(nw);
-
-
-      } //  
-    }; // Set_Pamoorama
-
-    /** ****************************************************** */
-
-    Toggle_bp = function () {
-      options.cl_visible = !options.cl_visible;
-      Autosize_resize();
-      Wait_Affichage();
-
-    };
-
-    // ====================================
-    // 
-    // ====================================
-    Calcul_Image = function () {
-
-      /** ************************************* */
-      if (typeof imageInfos_id == "undefined") return;
-      infos_imageInfos = jQuery(imageInfos_id).infos({ absolute: true });             // information
-      infos_theMainImage = jQuery(theMainImage_id).infos({ absolute: true });         // Image
-      // commentContent
-      // copyright
-
-      if (options.slideshow) {
-
-
-      } else {
-
-      }
-      if (typeof Zone_image.name == "undefined") {
-        var names = Array();
-        names = options.imgSrc.toString().split("/");
-        names = names[names.length - 1].split("-");
-        names = names[0].split(".");
-        Zone_image.name = names[0];
-      }
-
-      if (Type_Img == "img") {
-        Zone_image.src = jQuery(theMainImage_id).attr("src");
-        if (typeof Zone_image.src != "undefined") {
-          if (Zone_image.src.match(RegExp(Zone_image.name, "gi"))) {
-            Zone_image.path = infos_theMainImage.src;
-          } else
-            return "Wait";
-        } else {
-          Zone_image.src = "";
-          Zone_image.path = "";
-        }
-      } else {
-        Zone_image.src = jQuery(theMainImage_id).attr("src");
-        Zone_image.path = infos_theMainImage.src;
-      }
-      pos_top = options.pos_top;
-      // pos_top = infos_theImage.top;
-
-      pos = jQuery(theImage_id).offset();
-      infos_theImage = jQuery(theImage_id).infos(true);   // container
-      infos_window = jQuery(window).infos(true);   // window
-      w = infos_theImage.general.marges.width;
-
-      container = {
-        height: infos_window.height - options.theImageTop,
-        width: infos_window.width - options.theImageLeft - options.theImageRight
-      };
-      marge_left = options.marge_left | 0;
-      marge_right = options.marge_right | 0;
-      marge_top = options.marge_top | 0;
-
-
-      // ==========================================================
-      if (test_theme("stripped")) {
-        infos_the_page.margin.left = 20;  // taille fleche
-        infos_the_page.margin.right = 20;
-
-      } else if (test_theme("kardon")) {
-
-      } else if (test_theme("elegant")) {
-
-        if (infos_imageInfos.visible == true) {
-          // marge_right += infos_imageInfos.general.width; ;
-
-        } else {
-          marge_right += 0;
-
-        }
-        marge_right += 1;
-        marge_left += 1;
-
-      } else if (test_theme("stripped")) {
-
-      } else if (test_theme("simple")) {
-        infos_menubar = jQuery("#menubar").infos({ absolute: true });
-        infos_imageInfoBar = jQuery("#imageInfoBar").infos({ absolute: true });
-
-        if (infos_imageInfoBar.left - infos_theImage.left - 2 > 0) {
-          jQuery("#theImage").width(infos_imageInfoBar.left - infos_theImage.left - 2);
-        }
-        marge_left += 0;
-        marge_right += 0;
-
-      } else if (test_theme("OS")) {
-
-      } else if (test_theme("pur")) {
-        marge_right += 0;
-        // marge_right += 25;
-      } else if (test_theme("mont")) {
-        marge_right += 0;
-
-        // marge_right += 25;
-
-
-      } else {
-
-
-
-      }
-
-
-      retrait_img = {};
-      // ========== Format Image ==============
-      retrait_img.height = Math.ceil(options.marges_llgbo || 0)
-      + Math.ceil(infos_theMainImage.general.marges.height) +
-      +Math.ceil(options.marges_llgbo || 0);
-      retrait_img.height += 2;
-
-
-      // ===============================================================
-      retrait_img.width = Math.ceil(infos_theMainImage.general.marges.width); // borderwidth+padding
-      retrait_img.width = Math.ceil(infos_theImage.general.marges.width); // borderwidth+padding
-      retrait_img.width += Math.ceil(options.marges_llgbo || 0);
-      retrait_img.width += 2;
-      if (!options.check_desc_v)
-        options.marge_bottom_2 = 0;
-
-      marge_bottom = options.marge_bottom_2 + options.marge_bottom;
-      // ================== Limite Format Image =====================
-      container.height_interne = container.height - marge_top - marge_bottom;
-      container.width_interne = container.width - marge_left - marge_right;
-
-      container.height_interne = Math.max(
-    		  container.height_interne,
-    		  Math.ceil(options.mini_height) + retrait_img.height);
-      container.width_interne = Math.max(container.width_interne,
-    		  Math.ceil(options.mini_width) + retrait_img.width);
-      image_max = {
-        height: (container.height_interne - retrait_img.height),
-        width: (container.width_interne - retrait_img.width)
-      };
-      // =========================
-      // test débordement
-      // =========================
-      height_theMainImage = Math.ceil(image_max.height);
-      width_theMainImage = Math.ceil(image_max.width);
-
-      if (typeof Zone_image.image_init.rapport == "undefined") {
-        Zone_image.image_init.rapport = options.ratio;
-      }
-      if (Type_Img == "charlie") {
-        width_theMainImage = height_theMainImage * options.ratio;
-        Zone_image.image_init.rapport = options.ratio;
-
-      } else if (Type_Img == "pamoorama") {
-        if (height_theMainImage > container.height_interne) {
-          n = options.pictureSelType;
-        }
-      } else {
-
-        height_theMainImage = Math.ceil(width_theMainImage / options.ratio);
-
-
-
-        if (height_theMainImage > container.height_interne) {
-          image_max.height = container.height_interne;
-          image_max.width = image_max.height * Zone_image.image_init.rapport;
-          width_theMainImage = Math.ceil(image_max.width);
-          height_theMainImage = Math.ceil(image_max.height);
-        }
-        if (width_theMainImage > container.width_interne) {
-          image_max.width = container.width_interne;
-          image_max.height = image_max.width / Zone_image.image_init.rapport;
-          width_theMainImage = Math.ceil(image_max.width);
-          height_theMainImage = Math.ceil(image_max.height);
-
-        } else if (width_theMainImage > container.width) {
-
-        } else {
-
-        }
-      }
-      // ======== Initilisation Zone_image ===============
-      Zone_image.image = {
-        width: width_theMainImage,
-        height: height_theMainImage,
-        rapport: width_theMainImage / height_theMainImage
-      };
-      Zone_image.marges = { width: marge_left + marge_right + retrait_img.width,
-        height: marge_top + marge_bottom + retrait_img.height
-      };
-      return true;
-    };
-
-    /***************************************************************************
-    * Calcul les dimensions.
-    **************************************************************************/
-    Get_dimensions = function (force, parametres) {
-      new_img = jQuery(theMainImage_id).infos({ absolute: true });
-      new_dim = jQuery(theImage_id).infos({ absolute: true });
-      new_win = jQuery(window).infos({ absolute: true }); // avec ascenseur
-      options.theImageTop = new_dim.top;
-      options.theImageLeft = new_dim.left;
-      options.theImageRight = (new_win.width - new_dim.right);
-      options.marge_bottom_2 = Math.ceil(new_dim.out.bottom - new_img.out.bottom);
-      options.marge_top_2 = options.marge_top_2 | 0;
-      new_dim.out.bottom = new_win.height - options.marge_bottom_2;
-      options.theImageBottom = new_win.height - new_dim.out.bottom;
-      if (options.slideshow) {
-        options.marge_top = 0;
-      } else {
-        options.marge_top_2 = Math.ceil(new_img.top - new_dim.top) + options.marge_top;
-      }
-
-      if (options.theImageBottom_2 < 0) {
-        options.theImageBottom_2 = 0;
-      }
-
-      options.theImageWidth = new_win.width - options.theImageLeft - options.theImageRight;
-      options.theImageHeight = new_win.height - options.marge_top - options.theImageBottom - options.theImageTop;
-
-      if (Type_Img != "map" && Type_Img != "iframe")
-        if (Select_Image() == "Wait") {
-          return "Wait";
-        }
-      useMap = options.pictureSelType;
-      // =================================================================
-      switch (Type_Img) {
-        case "map":
-          if (Set_Map(true)) return false;
-          break;
-        case "panorama":
-          if (!theMainImage_id) {
-
-          }
-          infos_theImage = jQuery(theMainImage_id).infos();
-          infos_the_page = jQuery("#the_page").infos();
-          if (typeof img_finale == "undefined") img_finale = { width: Zone_image.image.width, height: Zone_image.image.height };
-
-          img_finale.height = infos_theImage.height;
-          break;
-        case "img":
-          break;
-        case "img_autre":
-          if (!theMainImage_id) {
-            if (DEBUG_autosize.match("true", "gi")) alert("The_MainImage=null");
-            return;
-
-          }
-
-          infos_the_page = jQuery("#the_page").infos();
-
-
-          break;
-        case "embed":
-          //
-          if (infos_theMainImage.width == 0)
-            infos_theMainImage = jQuery("#thePicturePage").infos();
-          if (infos_theMainImage.width == 0)
-            infos_theMainImage = jQuery("#the_page").infos();
-          iph1 = jQuery("#theImage div").infos();
-          break;
-        case "charlie":
-          Zone_image.zoom = 1;
-          Zone_image.image.width = options.theImageWidth;
-          Zone_image.image.height = options.theImageHeight;
-          break;
-        case "iframe":
-          wpng = 0;
-          Zone_image.image.width = options.theImageWidth;
-          Zone_image.image.height = options.theImageHeight;
-          Zone_image.zoom = 1;
-          break;
-        case "pamoorama":
-          Wait_pamoorama();
-          break;
-      }
-
-
-
-      // =================================================
-      if (Zone_image.image.height < options.mini_height2) {
-        Zone_image.image.height = parseInt(options.mini_height2);
-        Zone_image.image.width = Math.ceil(Zone_image.image.height * Zone_image.image_init.rapport);
-      }
-      if (Zone_image.image.width < options.mini_width2) {
-        Zone_image.image.width = parseInt(options.mini_width2);
-        Zone_image.image.height = Math.ceil(Zone_image.image.width / Zone_image.image_init.rapport);
-      }
-      // ==================================================
-      // ImageWidthidth largeur à atteindre
-      // Calcul du rapport d'agrandissement
-
-      echelle_max = parseFloat(options.echelle_max, '3');
-      if (Zone_image.zoom > echelle_max) {
-        Zone_image.zoom = echelle_max;
-        Zone_image.image.width = parseInt(Zone_image.image_init.width * Zone_image.zoom);
-        if (Zone_image.image_init.rapport > 0)
-          Zone_image.image.height = parseInt(Zone_image.image_init.width / Zone_image.image_init.rapport);
-      }
-      if (Type_Img != "pamoorama") {
-        mxi = Math.ceil(Zone_image.image.height + Zone_image.marges.height);
-        Zone_image.container.height = Math.max(Zone_image.container.height, mxi);
-      } else {
-
-
-      }
-      img_finale = { width: Zone_image.image.width, height: Zone_image.image.height };
-
-      return true;
-    };
-    // ________________ Get_dimensions ___________________
-
-
-    /***************************************************************************
-    * init_gen
-    **************************************************************************/
-    init_gen = function (e) {
-      theImg = document.getElementById(theMainImage_id.replace("#", ""));
-      // ==================================================
-      marges_llgbo = 0;
-      options.marges_llgbo = 0;
-      if (jQuery(llgbo_id).length > 0) {
-        infos_llgbo = jQuery(llgbo_id).infos(true);
-        if (infos_llgbo.visible == true) {
-          if (infos_llgbo.height > 0) {
-            infos_llgboframe1 = jQuery(llgbo_id + " div:last").infos();
-            infos_llgboframe31 = jQuery(llgbo_id + "  div:first").infos();
-            // =============================================
-            ll2 = infos_llgboframe1.width; // llgboframe1
-            ll1 = infos_llgboframe31.general.width; // llgboframe31
-            options.marges_llgbo = (ll1 - ll2);
-            infos_llgboh2 = jQuery("#llgboh2").infos();
-          }
-        }
-
-        marges_llgbo = options.marges_llgbo;
-      }
-
-      // ========= Récupération des informations =============
-
-      options.marge_top = 0;
-      pAll = jQuery(llgbo_id).absoluteAll({ absolute: true });
-      infos_llgbo.top = pAll.Top;
-      infos_llgbo.bottom = pAll.Bottom;
-      pAll = jQuery(theMainImage_id).absoluteAll({ absolute: true });
-      pos_top = pAll.Top; ;
-      pos_bottom = pAll.Bottom; ;
-      if (infos_llgbo.top > 0) {
-        pos_top = infos_llgbo.top;
-        options.marge_top = infos_theMainImage.top - infos_theImage.top;
-        options.marge_bottom = Math.ceil(options.marge_basse + options.marge_top);
-
-      } else {
-        pos_top = infos_theImageAndInfos.top;
-        options.marge_bottom = Math.ceil(options.marge_basse);
-      }
-
-      options.pos_top = pos_top;
-      new_img = jQuery(theMainImage_id).infos({ absolute: true });
-      new_dim = jQuery(theImage_id).infos({ absolute: true });
-      options.marge_top += Math.ceil(new_img.top - new_dim.top);
-
-
-      options.marge_left = infos_theImage.general.marges.left + Math.ceil(options.marge_gauche);
-      options.marge_right = infos_theImage.general.marges.right + Math.ceil(options.marge_droite);
-      options.marge_top += infos_theImage.general.marges.top +
-                           infos_content.general.marges.top +
-                           Math.ceil(options.marge_haute);
-
-
-      if (options.pictureDeriv == null)
-        options.first = true;
-      else
-        options.first = false;
-      // =================== Gestion liste photos size
-      us = 0;
-      if (!options.theMainImageWidth) options.theMainImageWidth = options.scaledWidth;
-      if (!options.theMainImageHeight) options.theMainImageHeight = options.scaledHeight;
-
-      if (options.first) {
-        if (options.pictureDeriv) {
-
-          pictureSelType = options.pictureSelType;
-          options.pictureMap = options.pictureDeriv;
-
-        } else {
-          IMg = Get_Maxi(Zone_image.image);
-          options.pictureDeriv = IMg.pictureDeriv;
-          imgSrc = IMg.url;
-          width = IMg.width;
-          height = IMg.height;
-          options.pictureDeriv = IMg.pictureDeriv;
-          options.pictureMap = IMg.pictureMap;
-        }
-      }
-      if (pictureSelType_user != options.pictureSelType) {
-        /*
-        * user_status = options.user_status; pictureSelType_user =
-        * eval("options." + user_status + "_type"); //limite taille
-        */
-        pictureDeriv_user = options.pictureDeriv;
-        options.pictureDeriv_user = pictureDeriv_user;
-        pictureSelType = options.pictureSelType;
-      }
-      Affiche_limite(pictureSelType_user);
-
-      // =================== 2==================================
+    Ajuste_Liens = function () {
+      // =================== 2 ============================
       sav_p = options.pictureSelType;
       options.pictureSelType = "SelMaxi";
@@ -1968,5 +524,1494 @@
         jQuery('#derivativeChecked' + options.pictureDeriv).css('visibility', 'visible');
       }
-      pictureDeriv = options.pictureDeriv;
+      return options.pictureDeriv;
+    };
+
+
+    /***************************************************************************
+    * 
+    **************************************************************************/
+    jQuery("#derivativeSwitchBox a").click(function (e) {
+      Affiche_limite(pictureSelType_user);
+      retour = decode_href(this);
+      theImg = document.getElementById(theMainImage_id.replace("#", ""));
+      if (theImg) {
+        // options.pictureDeriv = retour.pictureDeriv;
+        if (this.name) {
+          options.pictureSelType = this.name;
+          spans = jQuery("#derivativeChecked" + this.name).next();
+          if (retour.pictureSelType != this.name)
+            spans.attr("href", "javascript:" +
+  "ChangeImgSrc('" + retour.source + "," +
+  retour.pictureDeriv + "," +
+  retour.pictureMap + "," + options.COOKIE_PATH + "')");
+        }
+        options.pictureSelType = retour.pictureSelType;
+        options.pictureDeriv = retour.pictureDeriv;
+        options.pictureMap = retour.pictureDeriv;
+        Save_cookies(options);
+        if (typeof Autosize_resize == "function")
+          setTimeout(function (i) {
+            Autosize_resize(false, options);
+          }, 2);
+
+      }
+    });
+    // __________ fin click #derivativeSwitchBox a ____________
+    Affiche_limite = function (pictureSelType_Maxi) {
+      n = 0;
+      var pt = new Array();
+      path_names = new Array();
+      jQuery("#derivativeSwitchBox a").css('visibility', 'hidden');
+      // jQuery(".switchCheck").css('visibility', 'hidden');
+      var maxi_display = false;
+      jQuery("#derivativeSwitchBox a").each(function (i) {
+        href_path = jQuery(this).attr("href");
+        if (!href_path) {
+          href_path = jQuery(this).html();
+          return;
+        }
+        pt = href_path.replace(/(javascript|changeImgSrc)|[('):]/gi, "");
+
+        patname = href_path.replace("javascript\:", "");
+        if (typeof old_path == "undefined") old_path = patname;
+        pt = pt.split(",");
+        tsz = pt[pt.length - 1];
+        if (!maxi_display)
+          jQuery(this).css('visibility', 'visible');
+        else {
+          jQuery(this).next().next().remove();
+          jQuery(this).next().remove();
+          jQuery(this).remove();
+        }
+        // --- recherche limite ---
+
+        if (!options.valide && (tsz == "Autosize" || tsz == "SelMaxi")) {
+          jQuery(this).next().next().remove();
+          jQuery(this).next().remove();
+          jQuery(this).remove();
+        } else {
+          if (tsz == "Original" && (pictureSelType_Maxi != "Autosize" && pictureSelType_Maxi != "SelMaxi")) {
+            maxi_display = true;
+          } else if (tsz == pictureSelType_Maxi && (pictureSelType_Maxi != "Autosize" && pictureSelType_Maxi != "SelMaxi")) {
+            maxi_display = true;
+
+          } else if (tsz == "Autosize" || tsz == "SelMaxi") {
+            patname = old_path.replace("')", "','" + tsz + "')");
+          } else
+            old_path = patname;
+          path_names.push(patname);
+        }
+        // --- type en cours ---
+        if (tsz.match(RegExp("^" + options.pictureDeriv, "gi"))) {
+          us = n;
+        }
+        n++;
+      });
+    }; // _____ fin Affiche_limite ____
+    if (DEBUG_autosize.match(new RegExp("noresize", "gi"))) {
+      Ajuste_Liens();
+      Save_cookies();
+      return;
+
+    }
+    // auto_details
+    // ==== limite affichage selection = select_type ====
+
+
+
+
+    /***************************************************************************
+    * window LOAD
+    **************************************************************************/
+    jQuery(window).load(function () {
+      location_href = location.href;
+      // =======================================================================
+      infos_theMainImage = jQuery(theMainImage_id).infos({ absolute: true });        // Image
+      if (infos_theMainImage.src.match(RegExp("gif", "gi"))) {
+        setTimeout(function (i) {
+          jQuery(window).load();
+        }, 500);
+        return;
+      };
+      infos_theImageAndInfos = jQuery(theImageAndInfos_id).infos();         // Cadre
+      infos_theContainer = jQuery(theImage_id).infos({ absolute: true });   // conteneur
+
+      // general
+      if (infos_theMainImage.width == 0) {
+        if (Type_Img == "pamoorama") {
+          theMainImage_id = "#pamoorama";
+          infos_theMainImage = jQuery(theMainImage_id).infos({ absolute: true });
+          infos_theMainImage.width = options.scaled_width;
+          infos_theMainImage.height = options.scaled_height;
+          options.valide = true;
+        } else if (Type_Img == "charlie") {
+          theMainImage_id = "#charlie";
+          infos_theMainImage = jQuery(theMainImage_id).infos({ absolute: true });
+          options.valide = true;
+        } else if (Type_Img == "iframe") {
+
+          infos_theMainImage = jQuery("#iframe").infos({ absolute: true });
+          options.valide = true;
+          infos_theMainImage.width = infos_theContainer.general.width;
+          infos_theMainImage.height = infos_window.height - infos_theContainer.top - options.marge_basse;
+          jQuery("#iframe").width(infos_theMainImage.width);
+          jQuery("#iframe").height(infos_theMainImage.height);
+
+        } else {
+          jQuery("img").each(function (i) {
+            imgSrc = options.imgSrc;
+          });
+          infos_theMainImage = jQuery("#theImage img").infos({ absolute: true });
+        }
+        if (infos_theMainImage.id == "") {
+          jQuery("#theImage img").attr("id", "theMainImage");
+          infos_theMainImage = jQuery(theMainImage_id).infos({ absolute: true });
+        }
+
+      }
+      if (Type_Img == "charlie" || Type_Img == "iframe") {
+        options.scaled_width = options.theMainImageWidth;
+        options.scaled_height = options.theMainImageHeight;
+      }
+
+      if (options.pictureSelType != "Autosize" && options.pictureSelType != "SelMaxi") {
+        jQuery('#derivativeSwitchLink').show();
+      }
+      if (test_theme("simple")) {
+        jQuery(theMainImage_id).css({ maxWidth: "none" });
+        theImageAndInfos_id = "#content";
+        infos_theImageAndInfos = jQuery(theImageAndInfos_id).infos();  // Cadre
+        // general
+        infos_theContainer.height = infos_window.height - infos_theContainer.top;
+        // jQuery(theImage_id).height(infos_theContainer.height);
+
+      } else {
+        infos_theImageAndInfos = jQuery(theImageAndInfos_id).infos();  // Cadre
+        // general
+        if (infos_theImageAndInfos.visible == false)
+          theImageAndInfos_id = "#imageContainer";
+      }
+
+
+      imageInfos_id = "#imageInfos";
+      content_id = "#content";
+      infos_content = jQuery(content_id).infos({ absolute: true });                 // conteneur
+      infos_imageInfos = jQuery(imageInfos_id).infos({ absolute: true });            // information
+      infos_copyright = jQuery("#copyright").infos({ absolute: true });
+
+
+      if (infos_theContainer.top > infos_window.height) {
+        zheight = infos_window.height - infos_content.top;
+      } else {
+        zheight = infos_window.height - (infos_theContainer.top);
+      }
+
+
+      if (options.check_desc_v) { }
+
+      infos_comments = jQuery("#comments").infos({ absolute: true });
+      infos_Licence = jQuery(".licencetag").infos({ absolute: true });
+      infos_imageComment = jQuery(imageComment_id).infos({ absolute: true });
+
+      if (test_theme("simple")) {
+
+
+      } else {
+        if (test_theme("stripped")) {
+
+        } else
+
+          if (test_theme("blanc , pure, hr_ ")) {
+            options.marge_gauche += 10;
+            options.marge_droite += 10;
+          }
+      }
+      // ==============================================================================
+
+      infos_theMainImage.height = infos_theMainImage.height | zheight;
+
+      if (infos_theMainImage.height > 0) {
+        rapport_i = Math.ceil(infos_theMainImage.width / infos_theMainImage.height);
+
+        Zone_image = {
+          image_init: {
+            width: options.scaled_width, height: options.scaled_height,
+            rapport: options.ratio
+          },
+          image: {
+            width: infos_theContainer.width,
+            height: infos_window.height - infos_theContainer.top - options.marge_basse,
+            rapport: rapport_i
+          },
+          container: {
+            width: infos_theContainer.general.width,
+            height: zheight,
+            margesWidth: infos_window.width - infos_theContainer.width
+          }, marges: {
+            height: 0,
+            width: 0
+          },
+          zoom: Math.ceil(infos_theContainer.width / infos_theMainImage.width)
+        };
+
+      }
+      // ========================================================================
+
+      /***********************************************************************
+      * RESIZE (une fois document chargé)
+      **********************************************************************/
+
+      jQuery(window).resize(function (event, ui) {
+        Autosize_resize(true, options);
+      });
+      // _____________ widow.resize _______________
+
+      type_src = "div";
+      old_window = { width: 0, height: 0 };
+      List_autosize = new Array();
+      nu_img = 0;
+      tempo = 0;
+
+
+      infos_llgbo = jQuery(llgbo_id).infos({ absolute: true });
+      infos_llgboh2 = jQuery("#llgboh2").infos({ absolute: true });
+      marges_llgbo = 0;
+      // ==========================================================================================
+      init_gen();
+    });
+    // __________________window.onload_________________
+
+
+    // =============================================================
+    // REPONSE ACTION
+    // =============================================================
+    theMainImage_st = false;
+    jQuery("#reset").click(function () {
+      location.reload();
+    });
+
+
+    // ===========================================================
+    // REPONSE TRIGGER
+    // ===========================================================
+    jQuery('#ret_autosize').live('ON', function (e) {
+      if (nu_img == "") nu_img = 8;
+      jQuery(jQuery('.debug').get(nu_img)).trigger('ON');
+
+    });
+
+    // ==========================================================
+    jQuery("map area").mouseover(function (e) {
+      try {
+        nok = theImg.useMap;
+        hok = this;
+      }
+      catch (r) {
+
+      }
+    });
+
+    // ==================================
+    // jQuery("#llgbo").trigger("ON");
+    // ==================================
+    jQuery(llgbo_id).live('ON', function (e) {
+      n_id = this;
+      infos_llgbo = jQuery(llgbo_id).infos();
+      if (infos_llgbo.visible == false) return;
+
+      marges_llgbo = 0;
+      if (infos_llgbo.height > 0) {
+        infos_llgboframe1 = jQuery(llgbo_id + " div:last").infos();
+        infos_llgboframe31 = jQuery(llgbo_id + "  div:first").infos();
+        // =============================================
+        ll2 = infos_llgboframe1.width; // llgboframe1 interieur
+        ll1 = infos_llgboframe31.exterieur.width; // llgboframe31 avec border
+        // width
+        options.marges_llgbo = (ll1 - ll2);
+        infos_llgboh2 = jQuery("#llgboh2").infos();
+      }
+    });
+    // ==============================
+    // jQuery("#mapPicture").trigger("ON");
+    // ==============================
+    jQuery("#mapPicture").live('ON', function (e) {
+      p2 = jQuery("#infoSwitcher").infos();
+    });
+    // ==============================
+    // jQuery("#map").trigger("ON");
+    // ==============================
+    jQuery("#map").live('ON', function (e) {
+      p2 = jQuery("#map").infos();
+    });
+    // ===================================
+    // jQuery(theImage_id).trigger("ON");
+    // ===================================
+    jQuery("#imageInfos").live('on', function (e) {
+      target = e.target.id;
+    });
+
+    // ===================================
+    // jQuery(theImage_id).trigger("ON");
+    // ===================================
+    jQuery(theImage_id).live('ON', function (e) {
+      target = e.target.id;
+
+      id = this.id;
+      Select_Image(); // +calcul
+    });
+
+    jQuery("#theMainImage").load(function (e) {
+      if (!e.target.src) return;
+      if (e.target.src.match(RegExp("gif", "gi"))) {
+        target = theImg.src;
+      };
+
+    });
+    jQuery("#theMainImage").resize(function (e) {
+
+      if (!e.target.src) return;
+      //loaded ajax .gif
+      if (e.target.src.match(RegExp("\.gif", "gi"))) {
+        target = theImg.src;
+      };
+
+    });
+
+
+    // =================================================================
+    jQuery(document).live('gallyInterfaceReady', function (e) {
+      i = jQuery(this).text();
+      jQuery(this).trigger('ON');
+    }
+
+          );
+
+
+    /***************************************************************************
+    * 
+    **************************************************************************/
+    jQuery(theImage_id).resize(function (e) {
+      nu_img = 0;
+    });
+    jQuery("#menuSwitcher,#infoSwitcher").click(function (e) {
+      options.set_sw = this.id;
+      setTimeout(function () { div_resize(); }, 10);
+      nu_img = 0;
+    });
+
+    div_resize = function (i) {
+
+      jQuery(theImage_id).trigger("resize");
+      /*
+      * if (jQuery(theImage_id).width() != old_width) { setTimeout(function () {
+      * div_resize() }, 10); }
+      */
+    };
+    // ===========================================
+    // jQuery("#theImageAndInfos").trigger("ON");
+    // ===========================================
+    jQuery("#theImageAndInfos").live('ON', function (e) {
+      infos_theImageAndInfos = jQuery("#theImageAndInfos").infos();
+      // setTimeout(function () { Autosize_resize(true) }, 100);
+      nu_img = 0;
+    }); // fin click #theImageAndInfos ON
+
+
+    jQuery("#theImageAndInfos").resize(function (e) {
+      nu_img = 0;
+    });
+
+
+    jQuery("#linkAutosize").click(function (e) {
+      nu_img = 0;
+    });
+    // ==================================
+    //
+    // ===================================
+    jQuery('#derivativeCheckedAutosize').click(function () {
+      try {
+        pathnames = jQuery(this).attr("href").split(":");
+
+        // eval(pathnames[1]);
+      } catch (e) {
+        n = false;
+      }
+    }); // fin click derivativeCheckedAutosize
+    // ====================================================
+    if (typeof decode_href != 'function') {
+      function decode_href(myObj) {
+        retour = { source: null,
+          pictureDeriv: null,
+          pictureMap: null,
+          pictureSelType: null
+        };
+        hrefPath = jQuery(myObj).attr("href");
+        if (hrefPath.indexOf("changeImgSrc") < 0) {
+          pt = hrefPath;
+        } else {
+          pt = hrefPath.replace(/(javascript|phpWGOpenWindow|javascript|changeImgSrc)|[('):]/gi, "");
+
+        }
+        pt = pt.split(",");
+        retour.source = pt[0];
+        if (hrefPath.indexOf("phpWGOpenWindow") < 0) {
+          retour.pictureDeriv = pt[1];
+          retour.pictureMap = pt[2];
+          retour.pictureSelType = pt[pt.length - 1];
+        } else {
+          retour.pictureDeriv = options.pictureDeriv;
+          retour.pictureMap = options.pictureMap;
+          retour.pictureSelType = options.pictureSelType;
+        }
+
+        return retour;
+      }
+    }
+
+
+
+    jQuery("input").click(function () {
+      if (this.name.match(RegExp("_enabled", "gi"))) {
+        sel = "[name*=" + this.name + "]";
+        obj = jQuery("tr" + sel);
+
+        if (this.checked)
+          obj.css({ backgroundColor: "green", color: "white" });
+        else
+          obj.css({ backgroundColor: "red", color: "white" });
+        return;
+      }
+      return;
+    });
+
+
+    // ====================================
+    Autosize_init = function (name, value) {
+      img_defaut = { height: options.scaled_height, width: options.scaled_width };
+      img_reelle = { height: options.theMainImageHeight, width: options.MaintheImageWidth };
+      img_container = { height: options.theContainerHeight, width: options.theContainerWidth };  // taille
+      // initiale
+
+      img_finale = img_init;
+
+      useMap = infos_theMainImage.useMap; // #mapmedium
+
+      useMap = options.pictureMap; // #mapxxx
+      pictureDeriv = options.pictureDeriv; // picturederiv xxx
+
+
+      old_img = options.imgSrc;
+      old_window_height = options.windowHeight || jQuery(window).height();
+      old_window_width = options.windowWidth || jQuery(window).width();
+      old_img_h = options.imgHeight;
+      old_img_w = options.imgWidth;
+      if (infos_theMainImage.visible == true) {
+        theImg = document.getElementById(theMainImage_id.replace("#", ""));
+        theImg.useMap = useMap;
+      }
+
+
+    };
+    // ____________________ Autosize_init _____________________
+
+    /***************************************************************************
+    * Autosize_resize
+    **************************************************************************/
+    Autosize_resize = function (force, parametres) {
+      if (!force) {
+        cookis = Get_cookies();
+        if (cookis.pictureSelType != options.pictureSelType) {
+          n = 0;
+        }
+      }
+      nauto = Get_dimensions(true, parametres);
+      if (nauto == "Wait") {
+        setTimeout(function (force, parametres) { Autosize_resize(force, parametres); }, 100);
+        return;
+      }
+
+      if (!options.valide || !nauto || (options.pictureSelType != "Autosize" && options.pictureSelType != "SelMaxi")) {
+        if (options.imageAutosize == true) {
+          options.pictureSelType = options.pictureDeriv;
+          Zone_image.image_init.width = jQuery(theImg).width();
+          Zone_image.image_init.height = jQuery(theImg).height();
+          set_cl("no");
+          Set_llbgo(true);
+          return;
+        }
+        // jQuery(theImg).width(Zone_image.image_init.width);
+        for (n in options.liste_type) {
+          if (options.liste_type[n][0] == options.pictureSelType) {
+            Zone_image.image_init.height = options.liste_type[n][3];
+            Zone_image.image_init.width = options.liste_type[n][2];
+            break;
+          }
+        }
+
+
+        jQuery(theImg).height(Zone_image.image_init.height);
+        set_cl("no");
+        Set_llbgo(true);
+        return;
+      }
+      infos_theContainer = jQuery(theImage_id).infos({ absolute: true });
+      if (typeof img_finale.width == "undefined")
+        img_finale = { width: Zone_image.image.width, height: Zone_image.image.height };
+      if (img_finale.width && (img_finale.width != Zone_image.image.width ||
+          img_finale.height != Zone_image.image.height)) {
+        if (Type_Img == "pamoorama") {
+          img_finale.height = Zone_image.image.height;
+        } else
+          img_finale = { width: Zone_image.image.width, height: Zone_image.image.height };
+      }
+
+      // ======================================================
+
+      affiche_debug({
+        Debug1: Debug_info(1, "Cont:" + infos_theContainer.width
+    + " X " + infos_theContainer.height
+    + " IMG: " + img_finale.width
+    + " X " + img_finale.height
+    + " mgw : " + Zone_image.marges.width
+    , "->")
+      });
+      if (Type_Img == "pamoorama") {
+        // img_finale.width = Zone d'affichage :
+
+        if (nopano) {
+          jQuery(theMainImage_id).width(img_finale.width);
+          jQuery(theMainImage_id).height(img_finale.height);
+          infos_pamoorama = jQuery(theMainImage_id).infos({ absolute: true });
+          Set_Pamoorama({ width: img_finale.width, height: img_finale.height });
+        }
+
+      } else if (Type_Img == "panorama") {
+        // jQuery("#pamoorama").width(img_finale.width);
+        // jQuery("#pamoorama").height(img_finale.height);
+
+
+
+        // jQuery("#theImage img.simple_panorama").panorama(asp_options);
+      } else {
+        if (options.imageAutosize == false)
+          if (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi") {
+            jQuery(theMainImage_id).height(Zone_image.image.height);
+            r1 = infos_theContainer.width / infos_theContainer.height;
+            jQuery(theMainImage_id).css("margin-top", options.marge_haute);
+          } else {
+            jQuery(theMainImage_id).width(Zone_image.image_init.width);
+            jQuery(theMainImage_id).height(Zone_image.image_init.height);
+          }
+        if (Type_Img == "charlie" || Type_Img == "iframe") {
+          init_w1 = Zone_image.image.width;
+          init_h1 = Zone_image.image.height;
+          if (options.pictureSelType != "Autosize" && options.pictureSelType != "SelMaxi") {
+            init_w1 = Autosize_options.ideal_size_width;
+            init_h1 = Autosize_options.ideal_size_height;
+          }
+          if (Type_Img == "charlie") {
+            the_mainImage_html = jQuery(theMainImage_id).html();
+            img_objs = jQuery("#charlie object,#charlie embed");
+            if (img_objs.length > 0) {
+              jQuery(img_objs).each(function (e) {
+             //   init_h1 = jQuery(this).height();
+             //   init_w1 = jQuery(this).width();
+              });  
+            }
+            dp1 = jQuery("#charlie").offset();
+            dp = jQuery(img_objs).offset();
+            if (dp) { if (wpng == 0) wpng = Math.abs(dp.left - dp1.left) * 2; }
+            png_h = init_h1; w01 = init_w1 - wpng;
+            if (!png_h) {
+              png_h = jQuery("#theMainImage").height();
+              h01 = png_h;
+            }
+            else
+              h01 = Math.ceil(w01 / Zone_image.image.rapport);
+            // ==== Zone Affichage  ===== 
+            if (h01 > png_h) {
+              h01 = png_h;
+              w01 = Math.ceil(h01 * Zone_image.image.rapport);
+            }
+            jQuery("#theMainImage").height(png_h );
+            jQuery("#theMainImage").width(w01 + wpng);
+            jQuery("#theMainImage").css({ verticalAlign: "middle",
+              textAlign: "center", margin: "auto"
+            });
+
+            if (jQuery("#theMainImage_vid").length > 0) {
+              jQuery("#theMainImage_vid").attr("width", w01);
+              jQuery("#theMainImage_vid").attr("height", h01);
+            }
+            if (jQuery("video").length > 0) {
+              jQuery("video").attr("width", w01);
+              jQuery("video").attr("height", h01);
+            }
+            jQuery("#" + Type_Img).height(png_h);
+            jQuery("#" + Type_Img + "div").width(w01);
+            jQuery(theImage_id).css({ height: "auto" });
+
+
+       //     jQuery("#charlie object").attr("width", w01);
+            jQuery("#charlie	object").attr("height", h01);
+        //    jQuery("#charlie embed").attr("width", w01); // firefox opera
+            jQuery("#charlie embed").attr("height", h01);
+            jQuery("#charlie  embed").css("margin", "auto");
+
+          } else {
+            jQuery(theImage_id).css({ height: "auto" });
+            jQuery("#theMainImage").css({ width: "auto", height: "auto" });
+            jQuery("#" + Type_Img).attr("width", init_w1 - (infos_theMainImage.borderwidth.left + infos_theMainImage.borderwidth.right));
+            jQuery("#" + Type_Img).attr("height", init_h1 - (infos_theMainImage.borderwidth.top + infos_theMainImage.borderwidth.bottom));
+          }
+          // jQuery("#" + Type_Img).show(fade_in);
+        }
+
+
+      }
+
+      set_cl();
+      Set_llbgo(true);
+      return true;
+    };
+    // _________________Autosize ____________________________________
+
+
+    /***************************************************************************
+    * theMainImage_id=pamoorama
+    **************************************************************************/
+    /***************************************************************************
+    * Wait_pamoorama
+    **************************************************************************/
+
+    Wait_pamoorama = function () {
+      if (Type_Img != "pamoorama") return true;
+      if (nopano == true) return true;
+      mypanorama = window.myPamoorama;
+      if (mypanorama) {
+        jQuery(mypanorama).live('ON', function (e) {
+          jQuery(jQuery('.debug').get(1)).trigger('ON');
+          Autosize_resize(true, options);
+          jQuery("#pamoorama").fadeTo(fade_in + 20, 1);
+        });
+
+        // ===============================================
+        // jQuery(theImage_id).trigger("Start_right");
+        // ===============================================
+        jQuery(mypanorama).live('Start_right', function (e) {
+          if (typeof Zone_image == "undefined") return
+          test_w = window.myPamoorama.autoSlideFx.to;
+          test_w = window.myPamoorama.autoScrollFx.to;
+          nf = jQuery("#pamoorama_thumb").height();
+          jQuery("#pamoorama_thumb img").width(200);
+          jQuery("#pamoorama_thumb img").height(nf);
+          // 200=window.myPamoorama.imageWidth
+          // frame = Zone_image.container.width
+          nw = (200 * Zone_image.image.width) / window.myPamoorama.imageWidth;
+          jQuery("#pamoorama_frame").width(nw);
+        });
+        // ===============================================
+        // jQuery(theImage_id).trigger("Start_left");
+        // ===============================================
+        jQuery(mypanorama).live('Start_left', function (e) {
+          if (typeof Zone_image == "undefined") return
+          jQuery(theImage_id).show(0);
+          window.myPamoorama.autoSlideFx.to = 0;
+          test_w = window.myPamoorama.autoSlideFx.to;
+          test_w = window.myPamoorama.autoScrollFx.to;
+          nf = jQuery("#pamoorama_thumb").height();
+          jQuery("#pamoorama_thumb img").width(200);
+          jQuery("#pamoorama_thumb img").height(nf);
+        });
+      }
+      // =============================================================
+      if (mypanorama && typeof mypanorama.imageHeight != "undefined" && mypanorama.skipInit == true) {
+        nopano = true;
+        Zone_image.image_init = {
+          width: mypanorama.imageWidth,
+          height: mypanorama.imageHeight,
+          rapport: Math.ceil(mypanorama.imageWidth / mypanorama.imageHeight)
+        };
+        Autosize_resize();
+
+      } else {
+
+        setTimeout(function () {
+          Wait_pamoorama();
+        }, 500);
+      };
+
+      return true;
+
+    };
+    // __________________ Wait_pamoorama ______________________
+    jQuery(".pwg-icon-clock-minus, .pwg-icon-clock-plus").click(function (i) {
+
+    }).mouseover(function (i) {
+
+    });
+
+
+
+    /***************************************************************************
+    * 
+    **************************************************************************/
+    Wait_Affichage = function () {
+      Wait_Affichage_st = false;
+      while (Wait_Affichage_st == false) {
+        jQuery.noop();
+        Wait_Affichage_st = Wait_Affichage_time();
+      }
+    };
+    // __________________ Wait_Affichage ______________________
+
+
+    Wait_Affichage_time = function () {
+      // if (nu_img > 1) return;
+      if (typeof stb != "undefined")
+        stb.stop().fadeTo(3500, 0);
+      if (typeof theMainImage_id == "undefined") return true;
+
+      if (theMainImage_id.selector) {
+        theMainImage_id = theMainImage_id.selector;
+      }
+      if (theMainImage_id == null) return;
+
+      if (jQuery(theMainImage_id).length == 0) {
+        if (jQuery("#pamoorama_inner").length > 0) {
+          return true;
+        }
+        // === attente Image chargée ===
+        if (tempo > 100) return true;
+        tempo++;
+        setTimeout(function () { Wait_Affichage_time(); }, 500);
+        return false;
+
+      } else {
+
+        img_h = jQuery(theMainImage_id).height();
+        img_w = jQuery(theMainImage_id).width();
+
+        if (typeof infos_theContainer == "undefined") return;
+        jQuery("#ret_autosize").trigger('ON', {
+          width: img_w,
+          height: img_h,
+          theImage: theMainImage_id,
+          img_src: infos_theMainImage.src,
+          window_height: infos_theContainer.height,
+          window_width: infos_theContainer.width
+        });
+      }
+      return true;
+    };
+    // ______________ Wait_affichage ______
+
+
+    /***************************************************************************
+    * 
+    **************************************************************************/
+    init_img = function (theImg) {
+      if (theImg.complete == false) {
+        return;
+      }
+      name_src = theImg.src;
+      stx = name_src.match(RegExp(Zone_image.src, "gi"));
+      if (stx == null) {
+        return false;
+      }
+      img_init = { width: jQuery(theImg).width(), height: jQuery(theImg).height() };
+
+      if (typeof theImg.naturalWidth != "undefined")
+        img_init.width = theImg.naturalWidth;
+      if (typeof theImg.naturalHeight != "undefined")
+        img_init.height = theImg.naturalHeight;
+      img_init.rapport = img_init.width / img_init.height;
+      if (typeof Zone_image == "undefined") Zone_image = { image: {} };
+      if (typeof Zone_image.image == "undefined")
+        Zone_image.image = { height: Zone_image.image_init.height, width: Zone_image.image_init.width };
+      // theImg.height = img_init.height;
+      // theImg.width = img_init.width;
+
+      Zone_image.image_init = { height: img_init.height, width: img_init.width, rapport: img_init.rapport };
+      Zone_image.zoom = Zone_image.image_init.height / img_init.height;
+
+      if (typeof Zone_image.src == "undefined") {
+        Zone_image.src = name_src;
+        return false;
+      }
+      stx = name_src.match(RegExp(Zone_image.src, "gi"));
+      return stx;
+    };
+    // ___________ init_img _______
+
+
+
+    // ===========================================
+    //
+    // ===========================================
+    Set_Map = function (nds) {
+      p0 = jQuery("#map").offset();
+      if (!p0) return;
+      infos_mapPicture = jQuery("#mapPicture").infos({ absolute: true });
+      infos_theContainer = jQuery(theImage_id).infos({ absolute: true });
+      jQuery("#map").removeAttr("height");
+      jQuery("#map").removeAttr("width");
+      jQuery("#map").width(infos_theContainer.width - (infos_mapPicture.width));
+      jQuery("#map").height(jQuery(window).height() - infos_theContainer.top - infos_theContainer.general.marges.height);
+      return true;
+    };
+
+    jQuery("map [name='#Autosize'] area").mouseover(function (e) {
+      return;
+    });
+    // ___ Set_Map ___
+
+    // =====================================
+    //
+    // =====================================
+    Get_Maxi = function (Maxi_image) {
+      var pt = options.liste_type;
+      if (pt.length > 0) {
+        tw = Maxi_image.width;  // valeur maxi
+        th = Maxi_image.height;  // valeur maxi
+        n = 0;
+        maxi_size = { w: Maxi_image.width, h: Maxi_image.height, idx: -1 };
+        mini_size = { w: tw, h: th, idx: 0 };
+        size_derive = { w: 0, h: 0 };
+        size_encours = { w: tw, h: th };
+        // =================================
+        jQuery(pt).each(function (i) {
+          vn = this;
+          v_pictureDeriv = vn[0]; v_imgSrc = vn[1]; v_width = parseInt(vn[2]); v_height = parseInt(vn[3]);
+          size_derive = { w: v_width, h: v_height };
+          if (v_pictureDeriv == options.pictureSelType) {
+            maxi_size = size_derive;
+            maxi_size.idx = n;
+            return false;
+          }
+
+          if (v_pictureDeriv != "square" && v_pictureDeriv != "thumb" && v_pictureDeriv != "SelMaxi" && v_pictureDeriv != "Autosize") {
+            if (size_derive.h > size_encours.h || v_pictureDeriv == "Original") {
+              if (maxi_size.idx < 0) {
+                maxi_size = size_derive;
+                maxi_size.idx = n;
+                if (options.pictureSelType == "SelMaxi" || options.pictureSelType == "Autosize")
+                  return false;
+              }
+            }
+            if (size_derive.h < size_encours.h && size_derive.h > 10) {
+              mini_size = size_derive;
+              mini_size.idx = n;
+            }
+          }
+          n++;
+        });
+        n = maxi_size.idx;
+        if (n < 0) {
+          n = mini_size.idx;
+        }
+        if (options.pictureSelType.match(RegExp("SelMaxi", "gi"))) {
+          n = mini_size.idx;
+
+        }
+        if (options.pictureSelType.match(RegExp("Autosize", "gi"))) {
+
+        }
+
+        pictureDeriv = pt[n][0];
+        last_id = pt[n][0];
+        jQuery(".switchCheck").each(function (i) {
+          if (this.id.match(RegExp("derivative", "gi"))) {
+            if (!this.id.match(RegExp("Original", "gi"))) {
+              if (this.id.match(RegExp("SelMaxi", "gi"))) return false;
+              last_id = this.id.replace("derivativeChecked", "");
+            }
+            if (last_id == pictureDeriv)
+              return false;
+          }
+        });
+
+        options.pictureDeriv = last_id;
+
+        return { url: pt[n][1], pictureDeriv: last_id, pictureMap: last_id, width: pt[n][2], height: pt[n][3] };
+      }
+      return { imgSrc: "", pictureDeriv: "", width: "", height: "" };
+    };
+    // _______________ Get_Maxi ______
+
+    /***************************************************************************
+    * Selection de l'image
+    **************************************************************************/
+    Select_Image = function () {
+      memoire = options.imgSrc;
+      if (options.imgSrc.match(RegExp("gif", "gi")))
+        return;
+      var pt = options.liste_type;
+      if (pt.length > 0) {
+        // ===== calcul Image ===
+        if (typeof imageInfos_id == "undefined") return;
+        if (Calcul_Image() == "Wait") {   // image en cours
+          return "Wait";
+        }
+        // ==================================================
+        options.theContainerMargeZone = Zone_image.marges;
+        if (Type_Img != 'charlie' && Type_Img != "pamoorama") {
+          IMg = Get_Maxi(Zone_image.image);
+          imgSrc = IMg.url;
+          if (options.imgSrc.match(RegExp(imgSrc, "gi")))
+            options.imgSrc = imgSrc;
+          // dimension image
+          img_width = IMg.width;
+          img_height = IMg.height;
+          Zone_image.image_init = { height: IMg.height,
+            width: IMg.width,
+            rapport: IMg.width / IMg.height
+          };
+          if (typeof Zone_image.image == "undefined")
+            Zone_image.image = { height: IMg.height,
+              width: IMg.width,
+              rapport: IMg.width / IMg.height
+            };
+        } else {
+          return;
+        }
+        Zone_image.zoom = Math.ceil(Zone_image.image.height / Zone_image.image_init.height);
+        if (!theImg.src)
+          return true;
+        if (typeof Zone_image.src == "undefined")
+          Zone_image.src = imgSrc;
+        if (typeof Zone_image.name == "undefined")
+          Zone_image.name = " ";
+        if (typeof Zone_image.path == "undefined")
+          Zone_image.path = " ";
+
+        imgSrcS = imgSrc.split('/');
+        imgSrcS = imgSrcS[imgSrcS.length - 1];
+        if (!theImg.src)
+          return true;
+        identique = theImg.src.match(RegExp(imgSrc, "gi"));
+        if (identique) return true;
+        href_path = get_href(IMg.pictureDeriv);
+
+        if (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi") {
+          spans = jQuery("#derivativeChecked" + options.pictureSelType).next();
+          spans.attr("href", "javascript:" + href_path);
+        }
+        theImg = document.getElementById(theMainImage_id.replace("#", ""));
+        if ((theImg == null) || theImg.tagName != "IMG") {
+          imgSrc_i = jQuery(theImg).css("backgroundImage");
+          imgSrc_j = jQuery(theImg).css("background-image");
+          return true;
+        } else {
+          eval(href_path);
+
+        }
+        theImg.useMap = "#map" + IMg.pictureMap;
+        return true;
+
+      } else {
+        return false;
+      }
+
+    };  // _______________ Select_Image ______
+
+
+    /***************************************************************************
+    * correction pamoorama
+    **************************************************************************/
+    Set_Pamoorama = function (Format) {
+      if (Type_Img == "pamoorama") {
+        infos_pamoorama_outter = jQuery("#pamoorama_outter").infos({ absolute: true });
+        infos_pamoorama_inner = jQuery("#pamoorama_inner").infos({ absolute: true });
+        infos_pamoorama_frame = jQuery("#pamoorama_frame").infos({ absolute: true });
+        infos_frame = jQuery(myPamoorama.frame).infos({ absolute: true });
+        // ====================================================
+        marges_w = infos_pamoorama.general.marges.width;
+        marges_h = infos_pamoorama.general.marges.height;
+
+        jQuery("#pamoorama_footer").css({
+          width: Format.width + "px"
+        });
+        infos_pamoorama_footer = jQuery("#pamoorama_footer").infos();
+        marges_h += infos_pamoorama_footer.general.height;
+        outter_height = Format.height;
+
+        Zoom_pano = (Format.height - marges_h) / Zone_image.image_init.height;
+        new_image = { height: Math.ceil(Zone_image.image_init.height * Zoom_pano),
+          width: Math.ceil(Zone_image.image_init.width * Zoom_pano)
+        };
+
+        jQuery("#pamoorama_inner").css({
+          width: new_image.width + "px", height: new_image.height + "px", "background-size": "100%"
+        });
+        // ---------- test largeur image
+        new_width = Format.width; // -(options.marge_right +
+        // options.marge_left);
+
+        if (new_width > new_image.width) {
+          new_width = new_image.width;
+          jQuery("#pamoorama_outter").css({
+
+            align: "center",
+            margin: "0"
+          });
+        }
+        outter_width = new_width;
+
+        jQuery("#pamoorama_outter").css({
+          align: 'center',
+          margin: 'auto',
+          width: outter_width + "px",
+          height: Format.height - marges_h + "px"
+        });
+        // ============= Mise à l'echelle ==================
+        window.myPamoorama.options.width = Math.ceil(Format.width);
+        // ==================================================================
+        new_max_left = new_image.width - outter_width;
+        if (!window.myPamoorama.outter) return;
+        window.myPamoorama.outter.scrollTo(new_max_left, 0);
+
+        if (typeof window.myPamoorama.autoScrollFx != "undefined") window.myPamoorama.autoScrollFx.to = new Array(new_max_left, 0);
+        window.myPamoorama.ratio = Math.ceil(new_image.width / 200);
+        window.myPamoorama.imageWidth = new_image.width;
+        window.myPamoorama.imageHeight = new_image.height;
+        nf = jQuery("#pamoorama_thumb").height();
+        jQuery("#pamoorama_thumb img").width(200);
+        jQuery("#pamoorama_thumb img").height(nf);
+
+        jQuery("#pamoorama_thumb").css({
+          /* position: "absolute", */
+          left: (Format.width - 215) + "px"
+
+        });
+        jQuery("#pamoorama_thumb img").css({
+
+        });
+        // 200=window.myPamoorama.width
+        // frame = Zone_image.container.width
+
+        nw = (window.myPamoorama.image.width * Format.width) / window.myPamoorama.imageWidth;
+        jQuery("#pamoorama_frame").width(nw);
+
+
+        if (window.myPamoorama.options.autoscrollOnLoad && infos_frame) {
+          window.myPamoorama.startAnimRight();
+        }
+      } //  
+    }; // Set_Pamoorama
+
+    /** ****************************************************** */
+
+    Toggle_bp = function () {
+      options.cl_visible = !options.cl_visible;
+      Autosize_resize();
+      Wait_Affichage();
+
+    };
+
+    // ====================================
+    // 
+    // ====================================
+    Calcul_Image = function () {
+
+      /** ************************************* */
+      if (typeof imageInfos_id == "undefined") return;
+      infos_imageInfos = jQuery(imageInfos_id).infos({ absolute: true });             // information
+      infos_theMainImage = jQuery(theMainImage_id).infos({ absolute: true });         // Image
+      // commentContent
+      // copyright
+
+      if (options.slideshow) {
+
+
+      } else {
+
+      }
+      if (typeof Zone_image.name == "undefined") {
+        var names = Array();
+        names = options.imgSrc.toString().split("/");
+        names = names[names.length - 1].split("-");
+        names = names[0].split(".");
+        Zone_image.name = names[0];
+      }
+
+      if (Type_Img == "img") {
+        Zone_image.src = jQuery(theMainImage_id).attr("src");
+        if (typeof Zone_image.src != "undefined") {
+          if (Zone_image.src.match(RegExp(Zone_image.name, "gi"))) {
+            Zone_image.path = infos_theMainImage.src;
+          } else
+            return "Wait";
+        } else {
+          Zone_image.src = "";
+          Zone_image.path = "";
+        }
+      } else {
+        Zone_image.src = jQuery(theMainImage_id).attr("src");
+        Zone_image.path = infos_theMainImage.src;
+      }
+      pos_top = options.pos_top;
+      // pos_top = infos_theContainer.top;
+
+      pos = jQuery(theImage_id).offset();
+      infos_theContainer = jQuery(theImage_id).infos({ absolute: true });   // container
+      infos_window = jQuery(window).infos({ absolute: true });   // window
+      w = infos_theContainer.general.marges.width;
+
+      container = {
+        height: infos_window.height - options.theContainerTop,
+        width: infos_window.width - options.theContainerLeft - options.theContainerRight
+      };
+      marge_left = options.marge_left | 0;
+      marge_right = options.marge_right | 0;
+      marge_top = options.marge_top | 0;
+
+
+      // ==========================================================
+      if (test_theme("stripped")) {
+        infos_the_page.margin.left = 20;  // taille fleche
+        infos_the_page.margin.right = 20;
+
+      } else if (test_theme("kardon")) {
+
+      } else if (test_theme("elegant")) {
+
+        if (infos_imageInfos.visible == true) {
+          // marge_right += infos_imageInfos.general.width; ;
+
+        } else {
+          marge_right += 0;
+
+        }
+        marge_right += 1;
+        marge_left += 1;
+
+      } else if (test_theme("stripped")) {
+
+      } else if (test_theme("simple")) {
+        infos_menubar = jQuery("#menubar").infos({ absolute: true });
+        infos_imageInfoBar = jQuery("#imageInfoBar").infos({ absolute: true });
+
+        if (infos_imageInfoBar.left - infos_theContainer.left - 2 > 0) {
+          jQuery(theImage_id).width(infos_imageInfoBar.left - infos_theContainer.left - 2);
+        }
+        marge_left += 0;
+        marge_right += 0;
+
+      } else if (test_theme("OS")) {
+
+      } else if (test_theme("pur")) {
+        marge_right += 0;
+        // marge_right += 25;
+      } else if (test_theme("mont")) {
+        marge_right += 0;
+
+        // marge_right += 25;
+
+
+      } else {
+
+
+
+      }
+
+
+      retrait_img = {};
+      // ========== Format Image ==============
+      retrait_img.height = Math.ceil(options.marges_llgbo || 0)
+      + Math.ceil(infos_theMainImage.general.marges.height) +
+      +Math.ceil(options.marges_llgbo || 0);
+      retrait_img.height += 2;
+
+
+      // ===============================================================
+      retrait_img.width = Math.ceil(infos_theMainImage.general.marges.width); // borderwidth+padding
+      retrait_img.width = Math.ceil(infos_theContainer.general.marges.width); // borderwidth+padding
+      retrait_img.width += Math.ceil(options.marges_llgbo || 0);
+      retrait_img.width += 2;
+      if (!options.check_desc_v)
+        options.marge_bottom_2 = 0;
+
+      marge_bottom = options.marge_bottom_2 + options.marge_bottom;
+      // ================== Limite Format Image =====================
+      container.height_interne = container.height - marge_top - marge_bottom;
+      container.width_interne = container.width - marge_left - marge_right;
+
+      container.height_interne = Math.max(
+    		  container.height_interne,
+    		  Math.ceil(options.mini_height) + retrait_img.height);
+      container.width_interne = Math.max(container.width_interne,
+    		  Math.ceil(options.mini_width) + retrait_img.width);
+      image_max = {
+        height: (container.height_interne - retrait_img.height),
+        width: (container.width_interne - retrait_img.width)
+      };
+      // =========================
+      // test débordement
+      // =========================
+      height_theMainImage = Math.ceil(image_max.height);
+      width_theMainImage = Math.ceil(image_max.width);
+
+      if (Type_Img == "charlie") {
+        height_theMainImage = Math.ceil(width_theMainImage / options.ratio);
+
+        Zone_image.image_init = {
+          width: width_theMainImage, height: height_theMainImage,
+          rapport: options.ratio
+        };
+
+      } else if (Type_Img == "pamoorama") {
+        if (height_theMainImage > container.height_interne) {
+          n = options.pictureSelType;
+        }
+      } else {
+
+        height_theMainImage = Math.ceil(width_theMainImage / options.ratio);
+        // --- test si taille image inferieur au container
+        if (height_theMainImage > container.height_interne) {
+          image_max.height = container.height_interne;
+          image_max.width = image_max.height * Zone_image.image_init.rapport;
+          width_theMainImage = Math.ceil(image_max.width);
+          height_theMainImage = Math.ceil(image_max.height);
+        }
+        if (width_theMainImage > container.width_interne) {
+          image_max.width = container.width_interne;
+          image_max.height = image_max.width / Zone_image.image_init.rapport;
+          width_theMainImage = Math.ceil(image_max.width);
+          height_theMainImage = Math.ceil(image_max.height);
+
+        }
+      }
+      // ======== Initilisation Zone_image ===============
+      Zone_image.image = {
+        width: width_theMainImage,
+        height: height_theMainImage,
+        rapport: width_theMainImage / height_theMainImage
+      };
+      Zone_image.marges = { width: marge_left + marge_right + retrait_img.width,
+        height: marge_top + marge_bottom + retrait_img.height
+      };
+      return true;
+    };
+
+    /***************************************************************************
+    * Calcul les dimensions.
+    **************************************************************************/
+    Get_dimensions = function (force, parametres) {
+      new_img = jQuery(theMainImage_id).infos({ absolute: true });  // image
+      Container = jQuery(theImage_id).infos({ absolute: true });    // containeur
+      new_win = jQuery(window).infos({ absolute: true });           // avec
+      // ascenseur
+      options.theContainerTop = Container.top;
+      options.theContainerLeft = Container.left;
+      options.theContainerRight = (new_win.width - Container.right);
+      options.marge_bottom_2 = Math.ceil(Container.out.bottom - new_img.bottom); // marge
+      // avec
+      // infos
+      options.marge_top_2 = options.marge_top_2 | 0;
+      Container.out.bottom = new_win.height - options.marge_bottom_2;
+      options.theContainerBottom = new_win.height - Container.out.bottom;
+      if (options.slideshow) {
+        options.marge_top = 0;
+      } else {
+        options.marge_top_2 = Math.ceil(new_img.top - Container.top) + options.marge_top;
+      }
+
+      options.theContainerWidth = new_win.width - options.theContainerLeft - options.theContainerRight;
+      options.theContainerHeight = new_win.height - options.marge_top - options.theContainerBottom - options.theContainerTop;
+
+      if (Type_Img != "map" && Type_Img != "iframe")
+        if (Select_Image() == "Wait") {
+          return "Wait";
+        }
+      useMap = options.pictureSelType;
+      // =================================================================
+      switch (Type_Img) {
+        case "map":
+          if (Set_Map(true)) return false;
+          break;
+        case "panorama":
+          if (!theMainImage_id) {
+
+          }
+          infos_theContainer = jQuery(theMainImage_id).infos();
+          infos_the_page = jQuery("#the_page").infos();
+          if (typeof img_finale == "undefined")
+            img_finale = { width: Zone_image.image.width, height: Zone_image.image.height };
+          img_finale.height = infos_theContainer.height;
+          break;
+        case "img":
+          break;
+        case "img_autre":
+          if (!theMainImage_id) {
+            if (DEBUG_autosize.match("true", "gi")) alert("The_MainImage=null");
+            return;
+
+          }
+
+          infos_the_page = jQuery("#the_page").infos();
+
+
+          break;
+        case "embed":
+          //
+          if (infos_theMainImage.width == 0)
+            infos_theMainImage = jQuery("#thePicturePage").infos();
+          if (infos_theMainImage.width == 0)
+            infos_theMainImage = jQuery("#the_page").infos();
+          iph1 = jQuery("#theImage div").infos();
+          break;
+        case "charlie":
+          Zone_image.zoom = 1;
+          Zone_image.image.width = options.theContainerWidth;
+          Zone_image.image.height = options.theContainerHeight;
+          break;
+        case "iframe":
+          wpng = 0;
+          Zone_image.image.width = options.theContainerWidth;
+          Zone_image.image.height = options.theContainerHeight;
+          Zone_image.zoom = 1;
+          break;
+        case "pamoorama":
+          if (nopano == false) Wait_pamoorama();
+          break;
+      }
+      if (options.pictureSelType != "Autosize" && options.pictureSelType != "SelMaxi") return true;
+      if (Type_Img != "pamoorama") {
+        // =========== test Hauteur Mini ====================
+        if (Zone_image.image.height < options.mini_height2) {
+          Zone_image.image.height = parseInt(options.mini_height2);
+          Zone_image.image.width = Math.ceil(Zone_image.image.height * Zone_image.image_init.rapport);
+        }
+        // =========== test Largeur Mini ====================
+        if (Zone_image.image.width < options.mini_width2) {
+          Zone_image.image.width = parseInt(options.mini_width2);
+          Zone_image.image.height = Math.ceil(Zone_image.image.width / Zone_image.image_init.rapport);
+        }
+      }
+      // Calcul du rapport d'agrandissement
+      echelle_max = parseFloat(options.echelle_max, '3');
+      // =========== test Zoom Maxi ====================
+      Zone_image.zoom = Zone_image.image.height / Zone_image.image_init.height;
+      if (Zone_image.zoom > echelle_max) {
+        Zone_image.zoom = echelle_max;
+        if (Type_Img == "pamoorama") {
+          Zone_image.image.height = parseInt(Zone_image.image_init.height * Zone_image.zoom);
+        } else {
+          Zone_image.image.width = parseInt(Zone_image.image_init.width * Zone_image.zoom);
+
+          if (Zone_image.image_init.rapport > 0)
+            Zone_image.image.height = parseInt(Zone_image.image.width / Zone_image.image_init.rapport);
+        }
+      }
+      if (Type_Img != "pamoorama") {
+        mxi = Math.ceil(Zone_image.image.height + Zone_image.marges.height);
+        Zone_image.container.height = Math.max(Zone_image.container.height | mxi, mxi);
+        mxi = Math.ceil(Zone_image.image.width + Zone_image.marges.width);
+        Zone_image.container.width = Math.max(Zone_image.container.width | mxi, mxi);
+        img_finale = { width: Zone_image.image.width, height: Zone_image.image.height };
+      } else {
+        img_finale = { width: Zone_image.image.width, height: Zone_image.image.height };
+      }
+
+      return true;
+    };
+    // ________________ Get_dimensions ___________________
+
+
+    /***************************************************************************
+    * init_gen
+    **************************************************************************/
+    init_gen = function (e) {
+      theImg = document.getElementById(theMainImage_id.replace("#", ""));
+      // ==================================================
+      marges_llgbo = 0;
+      options.marges_llgbo = 0;
+      if (jQuery(llgbo_id).length > 0) {
+        infos_llgbo = jQuery(llgbo_id).infos({ absolute: true });
+        if (infos_llgbo.visible == true) {
+          if (infos_llgbo.height > 0) {
+            infos_llgboframe1 = jQuery(llgbo_id + " div:last").infos();
+            infos_llgboframe31 = jQuery(llgbo_id + "  div:first").infos();
+            // =============================================
+            ll2 = infos_llgboframe1.width; // llgboframe1
+            ll1 = infos_llgboframe31.general.width; // llgboframe31
+            options.marges_llgbo = (ll1 - ll2);
+            infos_llgboh2 = jQuery("#llgboh2").infos();
+          }
+        }
+
+        marges_llgbo = options.marges_llgbo;
+      }
+
+      // ========= Récupération des informations =============
+
+      options.marge_top = 0;
+      pAll = jQuery(llgbo_id).absoluteAll({ absolute: true });
+      infos_llgbo.top = pAll.Top;
+      infos_llgbo.bottom = pAll.Bottom;
+      pAll = jQuery(theMainImage_id).absoluteAll({ absolute: true });
+      pos_top = pAll.Top; ;
+      pos_bottom = pAll.Bottom; ;
+      if (infos_llgbo.top > 0) {
+        pos_top = infos_llgbo.top;
+        options.marge_top = infos_theMainImage.top - infos_theContainer.top;
+        options.marge_bottom = Math.ceil(options.marge_basse + options.marge_top);
+
+      } else {
+        pos_top = infos_theImageAndInfos.top;
+        options.marge_bottom = Math.ceil(options.marge_basse);
+      }
+
+      options.pos_top = pos_top;
+      new_img = jQuery(theMainImage_id).infos({ absolute: true });
+      Container = jQuery(theImage_id).infos({ absolute: true });
+      options.marge_top += Math.ceil(new_img.top - Container.top);
+
+
+      options.marge_left = infos_theContainer.general.marges.left + Math.ceil(options.marge_gauche);
+      options.marge_right = infos_theContainer.general.marges.right + Math.ceil(options.marge_droite);
+      options.marge_top += infos_theContainer.general.marges.top +
+                           infos_content.general.marges.top +
+                           Math.ceil(options.marge_haute);
+
+
+      if (options.pictureDeriv == null)
+        options.first = true;
+      else
+        options.first = false;
+      // =================== Gestion liste photos size
+      us = 0;
+      if (!options.theMainImageWidth) options.theMainImageWidth = options.scaledWidth;
+      if (!options.theMainImageHeight) options.theMainImageHeight = options.scaledHeight;
+
+      if (options.first) {
+        if (options.pictureDeriv) {
+
+          pictureSelType = options.pictureSelType;
+          options.pictureMap = options.pictureDeriv;
+
+        } else {
+          IMg = Get_Maxi(Zone_image.image);
+          options.pictureDeriv = IMg.pictureDeriv;
+          imgSrc = IMg.url;
+          width = IMg.width;
+          height = IMg.height;
+          options.pictureDeriv = IMg.pictureDeriv;
+          options.pictureMap = IMg.pictureMap;
+        }
+      }
+      if (pictureSelType_user != options.pictureSelType) {
+        /*
+        * user_status = options.user_status; pictureSelType_user =
+        * eval("options." + user_status + "_type"); //limite taille
+        */
+        pictureDeriv_user = options.pictureDeriv;
+        options.pictureDeriv_user = pictureDeriv_user;
+        pictureSelType = options.pictureSelType;
+      }
+      // Affiche_limite(pictureSelType_user);
+      pictureDeriv = Ajuste_Liens();
+
       Autosize_resize(true, options);
       Autosize_resize(true, options);
@@ -2047,5 +2092,5 @@
         Context = jQuery(this).context.nodeName;
         obj_id = "#" + this.id.toString();
-        infos_g = jQuery(obj_id).infos(true);
+        infos_g = jQuery(obj_id).infos({ absolute: true });
         infos_g.top = jQuery(obj_id).absoluteTop();
         wg = jQuery("body").width() - infos_g.right;
@@ -2165,9 +2210,10 @@
     } // Debug_pos
     // ==========================================================
-  });                                                                                                                                                                                                    // ready
+
+  });                                                 // ready
   jQuery("#derivativeSwitchBox a").click(function (e) {
     k1 = 0;
   });
-  //==========================================================
+  // ==========================================================
   if(typeof changeImgSrc=="undefined"){
   function changeImgSrc(url, typeSave, typeMap) {
Index: /extensions/Autosize/js/JScript.js
===================================================================
--- /extensions/Autosize/js/JScript.js	(revision 22359)
+++ /extensions/Autosize/js/JScript.js	(revision 22360)
@@ -22,20 +22,5 @@
 
 jQuery(document).ready(function (jQuery) {
-  
-
-  jQuery(window).unload(function () {
-    return;
-
-  }); // unload 
-
-
-
-
-
-
-  jQuery(window).load(function () {
-   
-
-
+  jQuery(window).load(function () {  
     if (jQuery("#scrolltotop").length == 0)
       jQuery('#scrolltobottom').before('<div id="scrolltotop" ><a title="Revenir en haut de la page" href="#"></a></div>');
Index: /extensions/Autosize/js/autosize.cookie.js
===================================================================
--- /extensions/Autosize/js/autosize.cookie.js	(revision 22359)
+++ /extensions/Autosize/js/autosize.cookie.js	(revision 22360)
@@ -1,3 +1,5 @@
 if (typeof jQuery.cookie != "function") {
+  var cookie_options = null;
+
   jQuery.cookie = function (name, value, options) {
     if (typeof value != 'undefined') { // name and value given, set cookie
@@ -21,4 +23,5 @@
       // in the following expressions, otherwise they evaluate to undefined
       // in the packed version for some reason...
+      cookie_options = options;
       var path = options.path ? '; path=' + (options.path) : '';
       var domain = options.domain ? '; domain=' + (options.domain) : '';
@@ -27,4 +30,5 @@
     } else { // only name given, get cookie
       var cookieValue = null;
+      if (name == "*") cookieValue = new Array();
       if (document.cookie && document.cookie != '') {
         var cookies = document.cookie.split(';');
@@ -35,4 +39,10 @@
             cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
             break;
+          } else if (name == "*") {
+
+            cookie_name = cookie.split("=")[0];
+            cookie_value = cookie.split("=")[1];
+            cookieValue[cookie_name] = decodeURIComponent(cookie_value);
+
           }
         }
Index: /extensions/Autosize/js/autosizeDetect.js
===================================================================
--- /extensions/Autosize/js/autosizeDetect.js	(revision 22359)
+++ /extensions/Autosize/js/autosizeDetect.js	(revision 22360)
@@ -1,70 +1,62 @@
-function on_load() {
-	var myWidth = 0, myHeight = 0;
-	if (typeof (window.innerWidth) == 'number') {
-		// Non-IE
-		myWidth = window.innerWidth;
-		myHeight = window.innerHeight;
-	} else if (document.documentElement
+jQuery(document).ready(function (jQuery) {
+  jQuery(window).load(function (e) {
+    var myWidth = 0, myHeight = 0;
+    if (typeof (window.innerWidth) == 'number') {
+      // Non-IE
+      myWidth = window.innerWidth;
+      myHeight = window.innerHeight;
+    } else if (document.documentElement
 			&& (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
-		// IE 6+ in 'standards compliant mode'
-		myWidth = document.documentElement.clientWidth;
-		myHeight = document.documentElement.clientHeight;
-	} else if (document.body
+      // IE 6+ in 'standards compliant mode'
+      myWidth = document.documentElement.clientWidth;
+      myHeight = document.documentElement.clientHeight;
+    } else if (document.body
 			&& (document.body.clientWidth || document.body.clientHeight)) {
-		// IE 4 compatible
-		myWidth = document.body.clientWidth;
-		myHeight = document.body.clientHeight;
-	}
-	windowWidth = parseInt(myWidth);
-	windowHeight = parseInt(myHeight);
-	theImageRight = 2;
-	theImageLeft = 261;
-	theImageMargeWidth = 0;
-	theImageTop = 73;
-	theImageBottom = 0;
-	theImageMargeHeight = 0;
-	jQuery.cookie('windowHeight', myHeight, {
-		path : COOKIE_PATH
-	});
-	jQuery.cookie('windowWidth', myWidth, {
-		path : COOKIE_PATH
-	});
-	jQuery.cookie('theImageRight', theImageRight, {
-		path : COOKIE_PATH
-	});
-	jQuery.cookie('theImageLeft', theImageLeft, {
-		path : COOKIE_PATH
-	});
-	jQuery.cookie('theImageMargeWidth', theImageMargeWidth, {
-		path : COOKIE_PATH
-	});
-	jQuery.cookie('theImageTop', theImageTop, {
-		path : COOKIE_PATH
-	});
-	jQuery.cookie('theImageBottom', theImageBottom, {
-		path : COOKIE_PATH
-	});
-	jQuery.cookie('theImageMargeHeight', theImageMargeHeight, {
-		path : COOKIE_PATH
-	});
-	retval = jQuery.cookie('autosize_reload');
-	retval2 = jQuery.cookie('picture_deriv');
+      // IE 4 compatible
+      myWidth = document.body.clientWidth;
+      myHeight = document.body.clientHeight;
+    }
 
-	if (!retval2)
-	  jQuery.cookie('picture_deriv','medium');
-	//
-	jQuery.cookie('autosize_reload', "ok", {path : COOKIE_PATH,expires:1});
+    windowWidth = jQuery(window).width();
+    windowHeight = jQuery(window).height();
+    if (windowWidth != myWidth) {
+      windowWidth = parseInt(myWidth);
+      windowHeight = parseInt(myHeight);
+    }
 
-	if (reload == "true") {
-		document.location = document.location;
+    jQuery.cookie('windowHeight', myHeight | 800, {
+      path: COOKIE_PATH
+    });
+    jQuery.cookie('windowWidth', myWidth | 600, {
+      path: COOKIE_PATH
+    });
 
-		return;
-		// document.location.reload(false); // from cache
-		try {
+    if (DEBUG_autosize.match(new RegExp("cookies", "gi"))) {
+      cookies = jQuery.cookie('*');
+      for (var i in cookies) {
+        jQuery("div").append("<br>" + i + " = " + cookies[i]);
+      };
+    }
+    jQuery.cookie('autosize_reload', "ok", { path: COOKIE_PATH, expires: 1 });
+    if (reload == "true") {
+      document.location = document.location;
+    }
+    return;
 
-			var retval = document.location.reload(true);
-		} catch (err) {
-			var retval = window.location.reload();
-		}
-	}
-}
+    jQuery.cookie('autosize_reload', "ok", { path: COOKIE_PATH, expires: 1 });
+    if (reload == "true") {
+      document.location = document.location;
+
+      return;
+      // document.location.reload(false); // from cache
+      try {
+
+        var retval = document.location.reload(true);
+      } catch (err) {
+        var retval = window.location.reload();
+      }
+    }
+  }
+
+);
+});
Index: /extensions/Autosize/js/conflit.js
===================================================================
--- /extensions/Autosize/js/conflit.js	(revision 22359)
+++ /extensions/Autosize/js/conflit.js	(revision 22360)
@@ -387,11 +387,10 @@
             var fname = fn.substring(fn.indexOf("function") + 8, fn.indexOf("(")) || " ";
             if (fname != " ") {
-
-                jQuery.noop;
+             
                 if (states.length > 0) break;
 
                 // if (fname != " $") callstack.push(fn);
             } if (fname != "") {
-                jQuery.noop;
+                 
                 // if (fname != " $") callstack.push(fn);
             }
Index: /extensions/Autosize/main.inc.php
===================================================================
--- /extensions/Autosize/main.inc.php	(revision 22359)
+++ /extensions/Autosize/main.inc.php	(revision 22360)
@@ -53,5 +53,5 @@
 				add_event_handler('render_element_content', array(&$autosize_ctrl, 'autosize_calcContent'),EVENT_HANDLER_PRIORITY_NEUTRAL-11,2);
 				add_event_handler('render_element_content', array(&$autosize_ctrl, 'init_1'),EVENT_HANDLER_PRIORITY_NEUTRAL-9,2);
-				add_event_handler('render_element_content', array(&$autosize_ctrl, 'init'),EVENT_HANDLER_PRIORITY_NEUTRAL-1,2  );
+				add_event_handler('render_element_content', array(&$autosize_ctrl, 'init'),EVENT_HANDLER_PRIORITY_NEUTRAL-10,2  );
 				add_event_handler('render_element_content', array(&$autosize_ctrl, 'init2'),EVENT_HANDLER_PRIORITY_NEUTRAL+1,2  );
 				add_event_handler('loc_after_page_header',  array(&$autosize_ctrl, 'cl_autosize_script_1') );
@@ -59,5 +59,5 @@
 				add_event_handler('loc_after_page_header',  array(&$autosize_ctrl, 'cl_autosize_script_3')  );
 				add_event_handler('loc_after_page_header',  array(&$autosize_ctrl, 'cl_autosize_affiche'), EVENT_HANDLER_PRIORITY_NEUTRAL +21    );
-			if(!isset($_GET['slideshow'])) add_event_handler('loc_begin_picture', array(&$autosize_ctrl, 'init_3'), EVENT_HANDLER_PRIORITY_NEUTRAL+6);
+			if(!isset($_GET['slideshow'])) add_event_handler('loc_begin_picture', array(&$autosize_ctrl, 'init_0'), EVENT_HANDLER_PRIORITY_NEUTRAL+6);
 	}
 } ;
