//Conteneur de valeur de parametre
var parameterList = new Array();

// variable to handle expansion, so we can't skip steps!!
var isReady = 1;
var getPrice = 0;

function stepItemParameter( lmname, lmvalue )
{
this.paramName  = lmname;
this.paramValue = lmvalue;
}

/**
*
* Permet de gerer la liste des etapes. ( parametres collectes + depli / repli des etapes )
* 
**/
function StepList()
{
this.parameterList = new Array();
this.steps         = new Array();
this.steps[0]      = 'TpStepChoixFormat';
this.steps[1]      = 'TpStepNbreFace';
this.steps[2]      = 'TpStepUploadImageTableauPerso';
this.steps[3]      = 'TpStepCreatePelemele';
this.steps[4]      = 'TpStepChoixOptions';
this.steps[5]      = 'TpStepTableauPersoFin';
this.currentStep   = this.steps[0];

	//Ajoute un parametre lparamName avec pour valeur lparamValue a la liste 
	this.addParameter = function( lparamName, lparamValue ){
	
		var currentP    = new stepItemParameter( lparamName, lparamValue );
		var paramnumber = this.getParameterNumber( lparamName );
		
		if( paramnumber != -1 )
		{
		window['parameterList'][ paramnumber ] = currentP;
		}
		else
		{
		window['parameterList'].push( currentP );
		}
	}

	//Retourne vrai si la liste contient lpname
	this.hasParameter = function( lpname ){
	
		for( var i=0; i< window['parameterList'].length; i++ )
		{
			if( window['parameterList'][i].paramName == lpname )
			{
			return true;
			}
		}
		
		return false;
	}
	
	//Retourne la valeur d'un parametre lpname ou false si le parametre nexiste pas
	this.getParameter = function( lpname ){
		
		for( var i=0; i< window['parameterList'].length; i++ )
		{
			if( window['parameterList'][i].paramName == lpname )
			{
			return window['parameterList'][i].paramValue;
			}
		}
		
		return false;
	}
	
	//Retourne le numero d'un parametre paramname
	this.getParameterNumber = function( paramname ){
		
		for( var i=0; i< window['parameterList'].length; i++ )
		{
			if( window['parameterList'][i].paramName == paramname )
			{
			return i;
			}
		}
	
	return -1;
	}
	
	//Retourne la valeur d'un parametre pour le numero lNUMP
	this.getParameterValueForNo = function( lNUMP ){
		if( lNUMP < this.getNbParameter() )
		{
		return window['parameterList'][lNUMP].paramValue ;
		}
		else
		{
		return false;
		}
	}
	
	//Retourne le nombre de parametre de la liste
	this.getNbParameter= function()	{
	return window['parameterList'].length;
	}
	
	//Transforme la liste en URL
	this.makeAsUrl = function(){
	
	var lcurrentStr ="";
	
		for( var i=0; i< window['parameterList'].length; i++ )
		{
		var separator = ( i < ( window['parameterList'].length - 1 ) ) ? '&' : '';
		lcurrentStr += window['parameterList'][i].paramName+"="+escape( window['parameterList'][i].paramValue )+separator;
		
		}
		
	return lcurrentStr;
	}
	
	this.getCurrentStepNum = function()	{
	
		for( var d =0; d < this.steps.length; d++ )
		{
			if( this.currentStep == this.steps[d] )
			{
			return d;
			}
		}
		
		return -1;
	}
	
	this.gotoNextStep = function(){
  	if(isReady == 1) {
  	  isReady = 0;
  	  var nextStepName = this.getNextStepName();
  		if( nextStepName != false )
  		{
  		cl($(this.currentStep+'-content'));
  		cc($(this.currentStep+'-header'),'');
  	
  		ex($(nextStepName+'-content'));
  		n=$(nextStepName+'-header');
  		cc(n,'__');
  		n.className=n.className+' '+n.tc;
  		$(this.currentStep+"-statusIcon").className = "stepStatusIconOk";
  
  		// invalider ici si impacte sur la suite
      if( this.currentStep != "TpStepStyle") {
        this.invalidateNextSteps( this.currentStep );
      }
      		
  		this.currentStep = nextStepName;
      dspRightPanText(nextStepName);
  		  		

  		// adding status "in progress"
      if( $( this.currentStep+"-statusIcon").className != "stepStatusIconOk" ) {
        $( this.currentStep+"-statusIcon").className = "stepStatusIconEnCours";
  		}
  		
  		}
  	}
  	
    // Recharge le bouton sur la requete ajax de l'étape final pour l'aperçut du prix du
    // produit en cour de création 
    // recharge que quand arriv� � la fin  
		if( this.getCurrentStepNum() == (this.steps.length - 1) || getPrice == 1 ) {
      getCurrentProductPriceValue();
      getPrice = 1;
    }
    	ActualiseBuildedProduct();

  	}
	
	
	this.gotoPrevStep = function(){
	/*
	var prevStepName = this.currentStep;
	
		if( nextStepName != false )
		{
		cl($(this.currentStep+'-content'));
		cc($(this.currentStep+'-header'),'');
		
		ex($(prevStepName+'-content'));
		n=$(prevStepName+'-header');
		cc(n,'__');
		n.className=n.className+' '+n.tc;
		$(this.currentStep+"-statusIcon").className = "stepStatusIconOk";
		this.currentStep = nextStepName;
		}*/
	}
	
	this.getNextStepName = function(){
	
	var sNum = this.getCurrentStepNum();
		
		if( ( sNum + 1 ) < this.steps.length )
		{
		return this.steps[sNum + 1];
		}
		
	return false;
	}
	
	this.setCurrentStep  = function( lstepname ){
	this.currentStep = lstepname;
	}
	
	this.expandFirstStep = function(){
	
	var nextStepName = this.steps[0];
	
	cl($(this.currentStep+'-content'));
	cc($(this.currentStep+'-header'),'');
	
	ex($(nextStepName+'-content'));
	n=$(nextStepName+'-header');
	cc(n,'__');
	n.className=n.className+' '+n.tc;
	
	this.currentStep = nextStepName;
	dspRightPanText(nextStepName);
	
	$( this.currentStep+"-statusIcon").className = "stepStatusIconEnCours";
	}
	
	this.getStepPos = function( stepName ){
	
		for( var d =0; d < this.steps.length; d++ )
		{
			if( this.steps[d] == stepName )
			{
			return d;
			}
			//getStepPos
		}
		
	return false;
	}
	
  this.invalidateNextSteps = function( stepname ){

  var posOfStep = this.getStepPos( stepname );
  var nbOfParams = this.getNbParameter();
  var tempArray = new Array();
  var j = 0;

  if( nbOfParams > (posOfStep + 1) ) {
    for( var i= 0; i<= posOfStep; i++ )
    {
      tempArray[j] = window['parameterList'][i];
            j++;
    }
    window['parameterList'] = tempArray;
  }
  
    for( var de = (posOfStep + 1); de <= this.steps.length ; de++ )
    {
      if($( this.steps[de]+"-statusIcon")) $( this.steps[de]+"-statusIcon").className = "stepStatusIconNoOk";
    }
  }
  
	this.getCurrentStepName = function(){
	
	return this.currentStep;
	
	}
}


var stepListObject = new StepList();

//consthtml : HtmlTpStepChoixFormat
//consthtml : HtmlTpStepChoixFace

callbackFunctionAfterLogin = function(){			
	
	//if( stepListObject)
	$('divConnectionUploadImage').innerHTML = '<a href="/MySpace/MyPics" class="my_galerie" onclick="userIsLoggedAndDontWantToUploadPic();return false;">Je souhaite utiliser des images issues uniquement de ma galerie</a>';

	
}
			
function userHasPaperImage()
{
	parameterChoosed( 'images_format_papier', '1' );
	
	new Ajax.Request(
	'http://www.tableauphoto.com/TpStepManagement/AjaxFormatPapierChoosed',
		{
			method: 'get',
			parameters: {guide_id:stepListObject.getParameter( 'guide_id' )},
			onSuccess: function(){
				parameterChoosed( 'images_uploaded', '1' );
				stepListObject.gotoNextStep();
			}
		}
	);
}

function startUploadPhotos()
{
	//$('infos').innerHTML += '<br />start upload photos<br />';
}

function stopUploadPhotos()
{
	parameterChoosed( 'images_uploaded', '1' );
	stepListObject.gotoNextStep();
}

function createGuidePlaceDropBox()
{
	var urlreq = 'http://www.tableauphoto.com/TpStepManagement/AjaxGetDropBoxForGuide';
	
	new Ajax.Updater(
	'fileUploadDiv',
	urlreq,
		{
			method: 'get',
			parameters: {guide_id:stepListObject.getParameter( 'guide_id' )},
			onSuccess: function(){
			
			personalSpaceLinkFollow( '/MySpace/PicUpPics' );	
			
			setTimeout( "makePicturesDraggable();", 1000 );
			setTimeout( "makeDropBoxDropable();", 1000 );
			
			
			}
		}
	);
}

function makeDropBoxDropable()
{
	
	var ldropboxGroup = document.getElementsByClassName('DropBoxPhoto');
	
	alert( $('testici').innerHTML );
	
	//new Draggable( 'putaindemerde', { revert:true, zindex:1000 } );
	
			Droppables.add( 'testici' , {
			accept: 'vignette',
			hoverclass: 'hoverDropBox',
				onDrop: function(element,autre) {
					alert( element.toString() );
					//ImgHasBeenDroppedInBox( element.id, ldropboxGroup[i].id );
					return true;
				},
				onHover: function(ldg, ldpbl, lpercent){
					alert('ICI hover test');
					return true;
				}
			} 
		);
	
	for( var i = 0; i < ldropboxGroup.length; i++ )
	{
		//alert(' '+ldropboxGroup[i].id+' droppable ');
			Droppables.add( ldropboxGroup[i] , {
			accept: 'vign_option',
			hoverclass: 'hoverDropBox',
				onDrop: function(element,autre) {
					alert( element.id.toString() );
					ImgHasBeenDroppedInBox( element.id, ldropboxGroup[i].id );
					return true;
				},
				onHover: function(ldg, ldpbl, lpercent){
					alert('ICI hover');
				}
			} 
		);
	}

}

function makePicturesDraggable()
{
	var limgGroup    = document.getElementsByClassName('vignette');
	
	for( var i = 0; i < limgGroup.length; i++ )
	{
		new Draggable( limgGroup[i].id, { revert:false, zindex:99 } );
	}
	
	alert('Cliquez sur une de vos image, et glissez la dans la zone bleu ');
}

function ImgHasBeenDroppedInBox( imgid, boxid )
{
	alert(imgid+' ImgHasBeenDroppedInBox '+boxid);
}


function userDroppedAllPics()
{
	parameterChoosed( 'images_uploaded', '1' );
}//consthtml : HtmlTpStepUploadPhotoTP

var lSelectedArea = false;
var regnumeric	  = new RegExp("[^0-9]", "g");
var zoomLevel     = 4;
var moveLevel     = 4;
//Zoom, etc...
var timerOperationOnPic = false;

var regfloat	= new RegExp("[^0-9\.]", "g");

function dbg( vvinfos )
{

$('infos').innerHTML += vvinfos+'<br /> ';

}

function imageHasBeenRotated( lAngle ){
	
  var lZone      = $('place'+lSelectedArea);
	// var lZoneH     = parseInt( lZone.style.height );
	var lZoneH     = parseFloat( lZone.style.height );
	// var lZoneW     = parseInt( lZone.style.width );
	var lZoneW     = parseFloat( lZone.style.width );
	var imgRatio   = $('place'+lSelectedArea+'_ratio_img_value').value;
  var img        = getWorkingPicForZone( lSelectedArea );
  var id_photo   = document.getElementById('place'+lSelectedArea+'_id_img').value
	
	var lOriWidth  = $('place'+lSelectedArea+'_img_width').value;
	var lOriHeight = $('place'+lSelectedArea+'_img_height').value;
	
	var lZone      = $('place'+lSelectedArea);
	// var lZoneH     = parseInt( lZone.style.height );
	var lZoneH     = parseFloat( lZone.style.height );
	// var lZoneW     = parseInt( lZone.style.width );
	var lZoneW     = parseFloat( lZone.style.width );
	
    switch( lAngle )
    {
    	case 90:
    	
	    	img_height 		   = lOriWidth;
	   		img_width 		   = lOriHeight;
   		
    	break;
    	
    	case 180:
    	
	    	img_height 		   = lOriHeight;
	   		img_width 		   = lOriWidth;
    	
    	break;
    	
    	case 270:
    	
	    	img_height 		   = lOriWidth;
	   		img_width 		   = lOriHeight;
    	
    	break;
    	
    	default:
    	
	    	img_height 		   = lOriHeight;
	   		img_width 		   = lOriWidth;
	   		
    	break;
    }
    //dbg( ' angle '+lAngle+' taille '+img_width+'X'+img_height );
    lnewImage = img;
    
	var ratiow     = lZoneW / img_width;
	var ratioh     = lZoneH / img_height;
	var ratioimg   = lOriWidth / img_height;
    //Ratio image / zone w
	var ratiow     = lZoneW / img_width;
	var ratioh     = lZoneH / img_height;
	
	var ratioimg   = img_width / img_height;
	
	//$('place'+lSelectedArea+'_ratio_img_value').value = ratioimg;
	
	if ( ratioh > ratiow  ) 
	{
        resize_factor   	   = lZoneH / img_height;
		
		imgNewW				   = resize_factor *  img_width;
		imgNewH 			   = lZoneH;
		
        lnewImage.style.height = lZoneH +'px';
        lnewImage.style.width  = imgNewW+ 'px';
        lnewImage.style.top    = '0px';
        // lnewImage.style.left   = ( lZoneW - parseInt(imgNewW)) / 2 + 'px';
        lnewImage.style.left   = ( lZoneW - parseFloat(imgNewW)) / 2 + 'px';
		
		//dbg( 'centrage horizontal' +lnewImage.style.left );
    } 
	else 
	{
        resize_factor   	   = lZoneW / img_width ;
		
		imgNewW 			   = lZoneW;
		imgNewH 			   = resize_factor *  img_height;
		
        lnewImage.style.width  =  lZoneW  + 'px';
        lnewImage.style.height = resize_factor *  img_height + 'px';
        //centrage de l'image verticalement
        lnewImage.style.left   ='0px';
        // lnewImage.style.top    = ( lZoneH - parseInt( imgNewH )) / 2 + 'px';
        lnewImage.style.top    = ( lZoneH - parseFloat( imgNewH )) / 2 + 'px';
		
		//dbg( 'centrage vertical' + lnewImage.style.top  );
    }
    //handleZoom( 1 );
   $('place'+lSelectedArea+'_ratio_img_value').value = imgNewW / imgNewH;
}

function rotate_img(angle) 
{
    if (angle < 0) {
       angle = 360 + angle;
    }
    old_angle =  document.getElementById('place'+lSelectedArea+'_photo_angle').value;
    //$('infos').innerHTML += '<br />Infos angle : '+old_angle;
    new_angle = (parseFloat(old_angle) + parseFloat(angle)) % 360 ;
  
    var img      = getWorkingPicForZone( lSelectedArea );
    
    var id_photo = document.getElementById('place'+lSelectedArea+'_id_img').value
    
    var lZone      	  = $('place'+lSelectedArea);
		var lZoneH        = parseFloat( lZone.style.height );
		var lZoneW        = parseFloat( lZone.style.width );
		var imgRatio      = $('place'+lSelectedArea+'_ratio_img_value').value;
	
    img.src= '/FileManagement/RotateMyPic/image/'+id_photo+'/angle/'+new_angle+'/forpelemele/true';
    document.getElementById('place'+lSelectedArea+'_photo_angle').value = new_angle;
    
    img.onload = function(){imageHasBeenRotated( new_angle );}
}


function handleMove( lDirection )
{

var lZone 	      = $('place'+lSelectedArea);
var lImage 	      = $('working_img'+lSelectedArea);

// var lImgWidth     = parseInt( lImage.style.width );
var lImgWidth     = parseFloat( lImage.style.width );
// var lImgHeight    = parseInt( lImage.style.height );
var lImgHeight    = parseFloat( lImage.style.height );

// var lImgPosTop    = parseInt( lImage.style.top );
var lImgPosTop    = parseFloat( lImage.style.top );
// var lImgPosLeft   = parseInt( lImage.style.left );
var lImgPosLeft   = parseFloat( lImage.style.left );

var lZone      	  = $('place'+lSelectedArea);
// var lZoneH        = parseInt( lZone.style.height );
var lZoneH        = parseFloat( lZone.style.height );
// var lZoneW        = parseInt( lZone.style.width );
var lZoneW        = parseFloat( lZone.style.width );	

	switch( lDirection )
	{
		case 'left' :
		
		if( ( lImgPosLeft - moveLevel ) > ( lZoneW - lImgWidth )) 
		{
			lImage.style.left = (lImgPosLeft - moveLevel) + "px" ;
			//dbg('moving photo_offx_'+lSelectedArea+' : '+lImage.style.left );
        }
		else
		{
			//dbg('ne peux deplacer a gauche photo car '+lImgPosLeft+' - '+ moveLevel+' > '+lZoneW+' - '+lImgWidth);
		}
		
		break;
		
		case 'right' :
		
		if( ( lImgPosLeft + moveLevel ) < 0 )   
		{
			lImage.style.left = (lImgPosLeft + moveLevel) + "px";
			//dbg(' moving photo_offx_'+lSelectedArea+' : '+(moveLevel)+'<br />');
		}
		else
		{
			//dbg('ne peux deplacer a gauche photo car '+lImgPosLeft+' + '+ moveLevel+' < 0');
		}
			
		break;
		
		case 'top' :
		
		if( ( lImgPosTop - moveLevel ) > (lZoneH - lImgHeight ) ) 
		{
			lImage.style.top     = (lImgPosTop - moveLevel) + "px" ;
			//dbg(' moving photo_offy_'+lSelectedArea+' : '+(-moveLevel ) );
		}
		
		break;
		
		case 'bottom':
		
        if( ( lImgPosTop + moveLevel ) < 0 )
		{
			lImage.style.top     = (lImgPosTop + moveLevel) + "px";
	        //dbg('moving photo_offy_'+lSelectedArea+' : '+moveLevel );
        }
		
		break;
	}
}



    //// creation du timer de deplacement
/*
    if(!timerOperationOnPic)
	{
       timerOperationOnPic = window.setTimeout("zoom("+speed+")", timer_delai) ;
    }*/
function handleZoom( lZoomLevel )
{
	var lZone 	      = $('place'+lSelectedArea);
	var lImage 	      = $('working_img'+lSelectedArea);
	
	var lImgWidth     = parseFloat( lImage.style.width );
	var lImgHeight    = parseFloat( lImage.style.height );
	
	var lImgPosTop    = parseFloat( lImage.style.top );
	var lImgPosLeft   = parseFloat( lImage.style.left );
	
	var lZone      	  = $('place'+lSelectedArea);
	var lZoneH        = parseFloat( lZone.style.height );
	var lZoneW        = parseFloat( lZone.style.width ); 	

	var imgRatio      = $('place'+lSelectedArea+'_ratio_img_value').value;
	// dbg('ratio image ='+imgRatio);
	
	$('place'+lSelectedArea+'_img_final_height').value = lImage.style.height.replace( regfloat, '' );
  $('place'+lSelectedArea+'_img_final_width').value

	// test if zoom is too big
	var targetedWidth = $('place'+lSelectedArea+'_img_final_width').value;
  var initialWidth = $('width_zone'+lSelectedArea).value;
  
  var targetedHeight = $('place'+lSelectedArea+'_img_final_height').value;
  var initialHeight = $('height_zone'+lSelectedArea).value;
  
  var original_id       = $('place'+lSelectedArea+'_id_img').value;
  /*
  var original_width    = $('pic_'+original_id+'_width').value;
  var original_height   = $('pic_'+original_id+'_height').value;
  */
  var original_width    = $('place'+lSelectedArea+'_img_width').value;
  var original_height   = $('place'+lSelectedArea+'_img_height').value;  
  
  if( (targetedWidth / original_width) > 1.5 || (targetedHeight / original_height) > 1.5 ) {
    $("zoom_danger_2").show();
  }
  else $("zoom_danger_2").hide();
  
	//Si mode dezoom, verifie si on peux dezoomer
	if( lZoomLevel < 0 )
	{
		if( (lImgWidth + lZoomLevel + lImgPosLeft ) < document.getElementById('width_zone'+lSelectedArea).value )
		{
			return false; 
		}
	
		if( Math.round( ((lImgWidth + lZoomLevel) / imgRatio)+lImgPosTop  )  < document.getElementById('height_zone'+lSelectedArea).value )
		{
			return false; 
		}
	}
	else //verifie la qualite de l'image par rapport au zoom, et affiche une alerte si besoin
	{
		//TODO
	}
	
	lImgWidth   += lZoomLevel;
	lImgHeight  = lImgWidth / imgRatio;

	
	lImage.style.width  = lImgWidth+'px';
	lImage.style.height = lImgHeight+'px';
	
	// $('place'+lSelectedArea+'_zoom_value').value       = parseInt( $('place'+lSelectedArea+'_zoom_value').value ) + lZoomLevel;
	$('place'+lSelectedArea+'_zoom_value').value       = parseFloat( $('place'+lSelectedArea+'_zoom_value').value ) + lZoomLevel;
	$('place'+lSelectedArea+'_img_final_height').value = lImage.style.height.replace( regfloat, '' );
	$('place'+lSelectedArea+'_img_final_width').value  = lImage.style.width.replace( regfloat, '' );;
}

/*

*/

function reinitZoneValues( lzoneId, alsoImage )
{

	var valueToReset = new Array( 
		'place'+lzoneId+'_id_img',
		'place'+lzoneId+'_zoom_value'
	);
	
	if( alsoImage == true )
	{
		if( getWorkingPicForZone( lzoneId ) != false )
		{
			getWorkingPicForZone( lzoneId ).parentNode.removeChild( getWorkingPicForZone( lzoneId ) );
		}
	}
}




function getWorkingPicForZone( lzoneid )
{
	var lppics = $('place'+lzoneid).getElementsByTagName('img');
	
	if( lppics.length <= 0 )
	{
		return false;
	}
	else
	{
		return lppics[0];
	}
}
// Calcule la meilleure taille image et la centre dans la zone
function assignImageToZone( limgid, lzoneid )
{
reinitZoneValues( lzoneid, true );
	
	var lOriImage     = $('pic'+limgid);
	var lImageForArea = $('pic_grand_'+limgid);
	// var lOriWidth     = parseInt( lOriImage.width );
	var lOriWidth     = parseFloat( lOriImage.width );
	// var lOriHeight    = parseInt( lOriImage.height );
	var lOriHeight    = parseFloat( lOriImage.height );
	
	$('place'+lzoneid+'_img_height').value = lOriHeight;
	$('place'+lzoneid+'_img_width').value  = lOriWidth;
	
	var lZone      	  = $('place'+lzoneid);
	// var lZoneH        = parseInt( lZone.style.height );
	var lZoneH        = parseFloat( lZone.style.height );
	// var lZoneW        = parseInt( lZone.style.width );
	var lZoneW        = parseFloat( lZone.style.width );
	
	var lnewImage     = document.createElement('img');
	
	//assigne image a zone
	lnewImage.setAttribute( 'id', 'working_img'+lzoneid );
	lnewImage.setAttribute( 'class', 'working_img' );
	lnewImage.setAttribute( 'src', lImageForArea.src );
	with( lnewImage.style ){
		position = 'relative';
		top 	 = 0;
		left 	 = 0;
	}
	
	lZone.appendChild( lnewImage );
	
	//Ratio image / zone w
	var ratiow     = lZoneW / lOriWidth;
	var ratioh     = lZoneH / lOriHeight;
	
	var ratioimg   = lOriWidth / lOriHeight;
	$('place'+lzoneid+'_ratio_img_value').value = ratioimg;
	//dbg( ' le ratio est '+ratioimg);
	//Detecte comment centrer l'image ( vertical si image portrait / horizontal si paysage )
	if ( ratioh > ratiow ) 
	{
        resize_factor   	   = lZoneH / lOriHeight;
		
		imgNewW				   = resize_factor *  lOriWidth;
		imgNewH 			   = lZoneH;
		
        // lnewImage.style.height = lZoneH +'px';
        lnewImage.style.height = Math.ceil( parseFloat(lZoneH) )+'px';
        // alert( parseFloat(lZoneH )+'px' );
        lnewImage.style.width  = resize_factor * lOriWidth + 'px';
        // lnewImage.style.left   = ( lZoneW - parseInt(imgNewW)) / 2 + 'px';
        lnewImage.style.left   = ( lZoneW - parseFloat(imgNewW)) / 2 + 'px';
		
		//dbg( 'centrage horizontal' +lnewImage.style.left );
    } 
	else 
	{
        resize_factor   	   = lZoneW / lOriWidth ;
		
		imgNewW 			   = lZoneW;
		imgNewH 			   = resize_factor *  lOriHeight;
		
        // lnewImage.style.width  =  lZoneW  + 'px';
        lnewImage.style.width  = Math.ceil( parseFloat(lZoneW) ) + 'px';
        // alert( Math.ceil( parseFloat(lZoneW) )+'px' );
        lnewImage.style.height = resize_factor *  lOriHeight + 'px';
        //centrage de l'image verticalement
        // lnewImage.style.top    = ( lZoneH - parseInt( imgNewH )) / 2 + 'px';
        lnewImage.style.top    = ( lZoneH - parseFloat( imgNewH )) / 2 + 'px';
		
		//dbg( 'centrage vertical' + lnewImage.style.top  );
    }
	
	//dbg( ' image nouvelle tailles '+imgNewW+'x'+imgNewH );
	
	$('place'+lzoneid+'_id_img').value 			= limgid ;
	$('place'+lzoneid+'_ratio_img_value').value = ratioimg ;
	
	// add 2 inputs for original sizes !!
	// on hold ...
	/*
	$('place'+lzoneid+'_original_height').value   = limgid ;
  $('place'+lzoneid+'_original_height').value   = ratioimg ;
	*/
	
	//simule un click sur la zone pour la selectionner
	clickOnZone( lzoneid );
}


function getObjPhpId( ltxttoconv )
{
	return ltxttoconv.replace( regnumeric, '' );
}

function openPopupScalePictures()
{
  // workaround for IE so it handles dropable generated by AJAX:
  if (document.all) { Droppables.drops = [] }
  
	var popupManager = new TpGenericPopupManager();
	popupManager.startPlacingPopup( 1020, 670 );
	
	var item1 = $('createScalePartPreview');
	var item2 = $('createScalePartItems');
	
	popupManager.addPopupItemHorizontal( item1, 686, 670 );
	popupManager.insertHorizontalBlank( 10 );
	popupManager.addPopupItemHorizontal( item2, 170, 670 );
	popupManager.endPlacingPopup();
	popupManager.setCloseBehavior( false );
	
	popupManager.onCloseAction = function(){setTimeout( "removeAllDroppablePictures()", 500 ) };

	new Ajax.Updater(
	'createScalePartPreview',
	'/Configurators/GetCreateScalePartPreview',
		{
			method: 'get',
			parameters: {guide_id:stepListObject.getParameter( 'guide_id' ), starty:currentGenericPopup.placingPopupStartY, startx:currentGenericPopup.placingPopupStartX },
			onSuccess: function(){
      
      popupManager.showItems();
      
			setTimeout( "makeScaleItemsDraggable();", 1000 );
			setTimeout( "makeScaleDropZones();", 1000 );
			
			}
		}
	);
}

function makeScaleDropZones()
{
	var dppables   = document.getElementsByClassName( 'onecase' );
	//dbg( dppables.length+' zone droppable trouve' ); 
	// alert( dppables.length+' zone droppable trouve' );
	
	for( var i=0; i< dppables.length; i++ )
	{
		var tempidOfZone = dppables[ i ].id;
		//dbg( tempidOfZone+' devenu droppable ' );
		
		// get this as height (without the "px")
		// alert( "hauteur: "+dppables[ i ].style.height );
		
			Droppables.add( tempidOfZone,{ 
				
				accept: 'userpicture',
				hoverclass: 'pelemele_case_img_over',
				onDrop: function(lelement,autre ){
				
				var zoneid = getObjPhpId( autre.id );
				var imgid  = getObjPhpId( lelement.id );
				
				imageHasBeenDroppedOnZone( imgid , zoneid );
				}
			} 
		);
	}
}

function makeScaleItemsDraggable()
{
	var lcontainer = document.getElementsByClassName('userpicture');
	//dbg( lcontainer.length+' images draggable trouve' ); 
	
	var maximagepages = parseInt( $('maxPicturesPages').firstChild.data );
	var currentPage   = parseInt( document.getElementById('userPicturesCurrentPage').firstChild.data );
	$('pm_page_max').innerHTML = maximagepages;
	$('pm_page_current').innerHTML = currentPage;
	
	for( var i=0; i< lcontainer.length; i++ )
	{
		if( lcontainer[i].id!= '' )
		{
		new Draggable( lcontainer[i].id, { revert:true, zindex:400 } );
		}
	}
}


function switchDropableImages()
{
	// alert("switchDropableImages()");
	var maximagepages = parseInt( $('maxPicturesPages').firstChild.data );
	var currentPage   = parseInt( document.getElementById('userPicturesCurrentPage').firstChild.data );
	
	// alert("Il y a "+maximagepages+" pages, et vous etes sur la numero: "+currentPage);
	
	if( maximagepages <= currentPage )
	{
	  // corrected so we can now go back to page one AND see last page
		document.getElementById('userPicturesCurrentPage').firstChild.data = 0;
		currentPage = 0;
		// return false;
	}
	
	
	new Ajax.Request(
	'/Configurators/GetCreateScalePartPreviewUserPics',
		{
			method: 'get',
			parameters: {page: parseInt( document.getElementById('userPicturesCurrentPage').firstChild.data)+1},
			onComplete: function(xhr){
				
			resetDroppableImageSrcWithXml( xhr.responseXML );
			// alert( xhr.responseText );
			
			removeAllDroppablePictures( false );
			
			$('pm_page_max').innerHTML = maximagepages;
			$('pm_page_current').innerHTML = currentPage +1;
			
			setTimeout( "allDroppablePicturesReappear();", 500 );
			
			document.getElementById('userPicturesCurrentPage').firstChild.data = parseInt( document.getElementById('userPicturesCurrentPage').firstChild.data ) + 1;
			}
		}
	);
}

function clickOnZone( lzoneId )
{
	//dbg( 'clickOnZone' );
	
	//Deselectionne la zone precedente
	if( lSelectedArea != false )
	{
		$('place'+lSelectedArea).className = 'onecase';
		$('place'+lSelectedArea).setAttribute( 'class', 'onecase');
	}
	
	lSelectedArea = lzoneId;
	$('place'+lzoneId).className = 'onecase_selected';
	$('place'+lzoneId).setAttribute( 'class', 'onecase_selected');
}


function resetDroppableImageSrcWithXml( xmls )
{
	var newsrcs    = xmls.getElementsByTagName('onepic');
	var oldpics    = document.getElementsByClassName('userpicture');
	var preloadpic = document.getElementsByClassName('userpicture_preload');
	var page_status = document.getElementsByClassName('page_status');
	
	for( var i=0; i< newsrcs.length; i++ )
	{
		var intid = newsrcs[i].getAttribute('id').replace( regnumeric, '' );
		oldpics[i].setAttribute('src', newsrcs[i].getAttribute('src') );
		oldpics[i].setAttribute('id', newsrcs[i].getAttribute('id') );
		//alert( newsrcs[i].getAttribute('id') );
		preloadpic[i].setAttribute('src', newsrcs[i].getAttribute('src') );
		preloadpic[i].setAttribute('id', "pic_grand_"+intid );
		
	}
}

function allDroppablePicturesReappear()
{
	//$('infos').innerHTML +='<br />allDroppablePicturesReappear<br />';
	var lcontainer = document.getElementsByClassName('userpicture');
	var temptimer  = 20;
	
	for( var i=0; i< lcontainer.length; i++ )
	{
		if( lcontainer[i].id!= '' )
		{
		setTimeout( "Effect.Grow( '"+lcontainer[i].id+"' );", temptimer );
		temptimer += 50;
		}
	}
	
	//setTimeout( "makeScaleItemsDraggable();", temptimer );
}

function imageHasBeenDroppedOnZone( limgid, lzoneid )
{
	//dbg(' image '+limgid+' drop dans '+lzoneid );
	
	var limgh = $('pic'+limgid);
	var lzone = $('place'+lzoneid);
	
	//dbg( ' taille image '+limgh.width+'x'+limgh.height);
	assignImageToZone( limgid, lzoneid );
	
	var targetedWidth  = $('width_zone'+lzoneid).value;
	var targetedHeight = $('height_zone'+lzoneid).value;
	
	var original_id       = $('place'+lzoneid+'_id_img').value;
  var original_width    = $('pic_'+original_id+'_width').value;
  var original_height   = $('pic_'+original_id+'_height').value;
  
  
  if( (targetedWidth / original_width) > 1.5 || (targetedHeight / original_height) > 1.5 ) {
    $("zoom_danger_2").show();
  }
  else {
    $("zoom_danger_2").hide();
  }
}


function removeAllDroppablePictures( removehard )
{
	//$('infos').innerHTML +='<br />Removing pics<br />';
	var lcontainer = document.getElementsByClassName('userpicture');
	var temptimer  = 20;
	
	for( var i=0; i< lcontainer.length; i++ )
	{
		if( lcontainer[i].id!= '' )
		{
		//setTimeout( "Effect.Squish( '"+lcontainer[i].id+"' );", temptimer );
		$( lcontainer[i].id ).style.display='none';
		
		//setTimeout( "deleteOneDroppablePic( '"+lcontainer[i].id+"' );", temptimer );
		//deleteOneDroppablePic( lcontainer[i].id )
		temptimer += 100;
		
			if( removehard )
			{
			setTimeout( "deleteOneDroppablePic( '"+lcontainer[i].id+"' )", temptimer*1.5 );
			}
		}
	}
}


function deleteOneDroppablePic( lpicid )
{
	document.getElementById( lpicid ).parentNode.removeChild( document.getElementById( lpicid ) );	
}


function doSavePelemele()
{
  var lpinutTags  = $('form_pelemele_cases').getElementsByClassName('init');
	// lpinutTags.length
	// check that they are all assigned
	// alert(lpinutTags.length);
	
	for( var i=0; i< lpinutTags.length; i++ )
	{
		var lzoneid = lpinutTags[ i ].id.replace( /[^0-9]/g, '' );
		
		if( lzoneid != '' )
		{
		//alert('l full name'+lpinutTags[ i ].name+'l full id = '+lpinutTags[ i ].id+'lid ='+lzoneid );
		var litem   = lpinutTags[ i ].id.replace( /[^a-zA-Z_]/g, '' );
		
		var limg    = $('place'+lzoneid).getElementsByTagName( 'img' )[0];
		
		if ( !limg ) {
		 alert("veuillez remplir tous les emplacements!");
		 $('mytesteur').style.display='block';
		 return false;
		}
		
		//place
		$('place'+lzoneid+'_img_final_width').value  = limg.style.width.replace(regfloat,'');
		$('place'+lzoneid+'_img_final_height').value = limg.style.height.replace(regfloat,'');
		$('place'+lzoneid+'_img_final_pos_x').value  = limg.style.left.replace(regfloat,'');
		$('place'+lzoneid+'_img_final_pos_y').value  = limg.style.top.replace(regfloat,'');
		$('place'+lzoneid+'_cssText').value  = limg.style.cssText;
		}
	}
	
	var serialDatas = Form.serialize( 'form_pelemele_cases' );
	//serialDatas = serialDatas.replace( "&", "<br />" );
	//document.write( serialDatas );
	
	new Ajax.Request(
		'/Configurators/SavePelemeleInfos',
		{
			method: 'post',
			parameters: {pelemele_datas: serialDatas},
			onComplete: function( response ){

			var reptxt = response.responseText;
				//pelemele_configuration
				if( reptxt == 'SUCCESS' )
				{	
					currentGenericPopup.hideAllItems();
					parameterChoosed('pelemele_configuration', 1);
					stepListObject.gotoNextStep();
				}
				else
				{
					alert('Une erreur est survenue, voici une description :'+reptxt );
					$('mytesteur').style.display='block';
				}			
			}
		}
	);
}//consthtml : HtmlTpStepCreatePelemele
function optVueChezVousClick(status)
{
//vueChezVousDetail
//lOptVueChezVous
	if( status == 'yes' )
	{
	window.open( '/TpStepManagement/ShowPopupOptVueChezVous',"nom_popup","menubar=no, status=no, scrollbars=no, menubar=no, width=400, height=400");
	}
	else
	{
		parameterChoosed( 'opt_vue_chez_vous_checked', 0 );
	}
}


function optRetirageClick(status)
{
	if( status == "yes" )
	{
		parameterChoosed( 'opt_retirage_choosed', 1 );
	}
	else
	{
		parameterChoosed( 'opt_retirage_choosed', 0 );
	}
}


function optNumeriqueClick(status)
{
  if( status == 'yes' )
	{
		parameterChoosed( 'opt_numerique_choosed', 1 );
		alert('numerique choisit ');
	}
	else
	{
		parameterChoosed( 'opt_numerique_choosed', 0 );
	}
}

//Fonction appele lorsque la popup vue chez vous se ferme
function confirmVueChezVousImageReception()
{
	parameterChoosed( 'opt_vue_chez_vous_checked', 1 );
	//alert('confirmVueChezVousImageReception');
}//consthtml : HtmlTpStepChoixOptions
function getCurrentProductPriceValue()
{
	new Ajax.Updater(
	'lproduct_price',
	'/TpStepManagement/GetProductPriceValue',
	 {
	 	method: 'get',
	 	onComplete: function(xhr){
	 		$('montableau').style.display='none';
	 		$('resultatPrice').style.display='block';
	 		$('resultatPrice').innerHTML= xhr.responseText;
	 	}
	 }
	
	);

}//consthtml : HtmlTpStepTableauPersoFin
//Fin code aditionel

	function choixFormatParameterChanged()
	{
	alert('open choix format');
	}
	function choixNbFaceParameterChanged()
	{
	
new Ajax.Updater(
	'ChoixFaceDiv',
	'/TpStepManagement/AjaxGetHtmlChoixFace',
	{
		method: 'get',
		parameters: {support_format_id:stepListObject.getParameter( 'support_format_id' )}
		//insertion: Insertion.Bottom
	}
);

	}
	function stepUploadImageParameterChanged()
	{
	
$('frameFileUpload').src='/FileManagement/FileUploadForGuide?guide_id='+stepListObject.getParameter( 'guide_id' );

$('frameFilePaper').src='/FileManagement/FilePaperByMail?guide_id='+stepListObject.getParameter( 'guide_id' );

//$('TpStepUploadImageTableauPerso-content').maxh=220;


/*
new Ajax.Updater(
	'fileUploadDiv',
	'/TpStepManagement/AjaxGetHtmlUploadFile',
	{
		method: 'get',
		parameters: {guide_id:stepListObject.getParameter( 'guide_id' )},
		onComplete: function(){
		
			var lheight = 0;
			
			lheight = Try.these(
			function() {return $('frameFileUpload').document.body.clientHeight;},
			function() {return $('frameFileUpload').innerHeight;}
			);
			
			//alert( lheight );
			//$('TpStepUploadImageTableauPerso-content').maxh=lheight;
			$('TpStepUploadImageTableauPerso-content').maxh=220;
			
			
		}
	}
);
*/


	}
	function choixPelemeleParameterChanged()
	{
	alert('open scale');
	}
	function nofunction()
	{
	stepListObject.addParameter( 'options_choosed', '1' );
parameterChoosed( 'options_choosed', '1' );
	}
	function choixOptionParameterChanged()
	{
	
new Ajax.Updater(
	'ChoixFaceDiv',
	'/TpStepManagement/AjaxGetHtmlChoixFace',
	{
		method: 'get',
		parameters: {support_format_id:stepListObject.getParameter( 'support_format_id' )}
		//insertion: Insertion.Bottom
	}
);

	}

function liveUpdateParameter( pname, pv )
{
new Ajax.Request(
	'/TpStepManagement/UpdateParameterValue',
	{
		method: 'post',
		parameters: {pname: pname, pvalue: pv}
	}
);

}

function parameterChoosed( lparamName, lparamValue )
{
	//Pour eviter de prevenir les etapes d'un "non changement de valeur"
	if( !stepListObject.hasParameter( lparamName ) || ( lparamValue != stepListObject.getParameter( lparamName ) ))
	{
	stepListObject.addParameter( lparamName, lparamValue );
	parameterHasBeenModified( lparamName, lparamValue );
		liveUpdateParameter( lparamName, lparamValue );
		}
}

function parameterHasBeenModified( lparamName, lparamValue )
{

			if( lparamName == 'support_format_id' ){
				//step : Sélection du format is not interested by support_format_id 
				choixNbFaceParameterChanged();
				//step : Sélection des Photos is not interested by support_format_id 
				//step : Création du pêle-mêle is not interested by support_format_id 
				//step : Options avec creation pele mele is not interested by support_format_id 
				//step : Finalisation avec option is not interested by support_format_id 
				}
				if( lparamName == 'guide_id' ){
				//step : Sélection du format is not interested by guide_id 
				//step : Nombre de faces is not interested by guide_id 
				stepUploadImageParameterChanged();
				//step : Création du pêle-mêle is not interested by guide_id 
				//step : Options avec creation pele mele is not interested by guide_id 
				//step : Finalisation avec option is not interested by guide_id 
				}
				if( lparamName == 'style_id' ){
				//step : Sélection du format is not interested by style_id 
				//step : Nombre de faces is not interested by style_id 
				//step : Sélection des Photos is not interested by style_id 
				//step : Création du pêle-mêle is not interested by style_id 
				//step : Options avec creation pele mele is not interested by style_id 
				//step : Finalisation avec option is not interested by style_id 
				}
				if( lparamName == 'images_uploaded' ){
				//step : Sélection du format is not interested by images_uploaded 
				//step : Nombre de faces is not interested by images_uploaded 
				//step : Sélection des Photos is not interested by images_uploaded 
				//step : Création du pêle-mêle is not interested by images_uploaded 
				//step : Options avec creation pele mele is not interested by images_uploaded 
				//step : Finalisation avec option is not interested by images_uploaded 
				}
				if( lparamName == 'images_format_papier' ){
				//step : Sélection du format is not interested by images_format_papier 
				//step : Nombre de faces is not interested by images_format_papier 
				//step : Sélection des Photos is not interested by images_format_papier 
				//step : Création du pêle-mêle is not interested by images_format_papier 
				//step : Options avec creation pele mele is not interested by images_format_papier 
				//step : Finalisation avec option is not interested by images_format_papier 
				}
				if( lparamName == 'pelemele_configuration' ){
				//step : Sélection du format is not interested by pelemele_configuration 
				//step : Nombre de faces is not interested by pelemele_configuration 
				//step : Sélection des Photos is not interested by pelemele_configuration 
				//step : Création du pêle-mêle is not interested by pelemele_configuration 
				//step : Options avec creation pele mele is not interested by pelemele_configuration 
				//step : Finalisation avec option is not interested by pelemele_configuration 
				}
				if( lparamName == 'product_bat' ){
				//step : Sélection du format is not interested by product_bat 
				//step : Nombre de faces is not interested by product_bat 
				//step : Sélection des Photos is not interested by product_bat 
				//step : Création du pêle-mêle is not interested by product_bat 
				//step : Options avec creation pele mele is not interested by product_bat 
				//step : Finalisation avec option is not interested by product_bat 
				}
				if( lparamName == 'options_choosed' ){
				//step : Sélection du format is not interested by options_choosed 
				//step : Nombre de faces is not interested by options_choosed 
				//step : Sélection des Photos is not interested by options_choosed 
				//step : Création du pêle-mêle is not interested by options_choosed 
				//step : Options avec creation pele mele is not interested by options_choosed 
				//step : Finalisation avec option is not interested by options_choosed 
				}
				if( lparamName == 'vue_chez_vous_f1' ){
				//step : Sélection du format is not interested by vue_chez_vous_f1 
				//step : Nombre de faces is not interested by vue_chez_vous_f1 
				//step : Sélection des Photos is not interested by vue_chez_vous_f1 
				//step : Création du pêle-mêle is not interested by vue_chez_vous_f1 
				//step : Options avec creation pele mele is not interested by vue_chez_vous_f1 
				//step : Finalisation avec option is not interested by vue_chez_vous_f1 
				}
				if( lparamName == 'vue_chez_vous_f2' ){
				//step : Sélection du format is not interested by vue_chez_vous_f2 
				//step : Nombre de faces is not interested by vue_chez_vous_f2 
				//step : Sélection des Photos is not interested by vue_chez_vous_f2 
				//step : Création du pêle-mêle is not interested by vue_chez_vous_f2 
				//step : Options avec creation pele mele is not interested by vue_chez_vous_f2 
				//step : Finalisation avec option is not interested by vue_chez_vous_f2 
				}
				if( lparamName == 'opt_vue_chez_vous_checked' ){
				//step : Sélection du format is not interested by opt_vue_chez_vous_checked 
				//step : Nombre de faces is not interested by opt_vue_chez_vous_checked 
				//step : Sélection des Photos is not interested by opt_vue_chez_vous_checked 
				//step : Création du pêle-mêle is not interested by opt_vue_chez_vous_checked 
				//step : Options avec creation pele mele is not interested by opt_vue_chez_vous_checked 
				//step : Finalisation avec option is not interested by opt_vue_chez_vous_checked 
				}
				if( lparamName == 'opt_numerique_choosed' ){
				//step : Sélection du format is not interested by opt_numerique_choosed 
				//step : Nombre de faces is not interested by opt_numerique_choosed 
				//step : Sélection des Photos is not interested by opt_numerique_choosed 
				//step : Création du pêle-mêle is not interested by opt_numerique_choosed 
				//step : Options avec creation pele mele is not interested by opt_numerique_choosed 
				//step : Finalisation avec option is not interested by opt_numerique_choosed 
				}
		}

//TODO pour chaque etape, tester si collecte lpname, etendre etape et afficher message
function expandParameterStepForP( lpname )
{

$('infos').innerHTML += " <br /> detetection de letape qui possede : "+lpname;


$('infos').innerHTML += " <br /> aucune etape collecte : "+lpname;

}


//Retourne vrai si litem peut etre etendu
function AccordionItemExpandHandler( litem )
{
var lstepExpandId = litem.id;
var lstepName 	  = lstepExpandId.substring( 0, lstepExpandId.indexOf( "-", 0 ) );
// dspRightPanText(lstepName);
//$('infos').innerHTML += "<br />Expansion de "+litem.id;
//$('infos').innerHTML += " <br /> Step expanded = "+lstepName;

		if( lstepName == 'TpStepChoixFormat' )
		{
					}
		if( lstepName == 'TpStepNbreFace' )
		{
						
			//$param
			if( stepListObject.getParameter( 'support_format_id' ) === false )
			{
			//$('infos').innerHTML += " <br /> Step non expanded : support_format_id";
			
			alert('Parametre Format non rempli' );
			/*
			alert(stepListObject.getNbParameter());
			alert( stepListObject.getParameter( 'encadrement_id' )
             );
      alert( stepListObject.makeAsUrl()
             );
      */
			
			//expandParameterStepForP( 'support_format_id' );
			return false;
			}
			else {
			  dspRightPanText(lstepName);
			}
					}
		if( lstepName == 'TpStepUploadImageTableauPerso' )
		{
						
			//$param
			if( stepListObject.getParameter( 'guide_id' ) === false )
			{
			//$('infos').innerHTML += " <br /> Step non expanded : guide_id";
			
			alert('Parametre Faces non rempli' );
			/*
			alert(stepListObject.getNbParameter());
			alert( stepListObject.getParameter( 'encadrement_id' )
             );
      alert( stepListObject.makeAsUrl()
             );
      */
			
			//expandParameterStepForP( 'guide_id' );
			return false;
			}
			else {
			  dspRightPanText(lstepName);
			}
					}
		if( lstepName == 'TpStepCreatePelemele' )
		{
						
			//$param
			if( stepListObject.getParameter( 'pelemele_configuration' ) === false )
			{
			//$('infos').innerHTML += " <br /> Step non expanded : pelemele_configuration";
			
			alert('Parametre Image pelemele non rempli' );
			/*
			alert(stepListObject.getNbParameter());
			alert( stepListObject.getParameter( 'encadrement_id' )
             );
      alert( stepListObject.makeAsUrl()
             );
      */
			
			//expandParameterStepForP( 'pelemele_configuration' );
			return false;
			}
			else {
			  dspRightPanText(lstepName);
			}
					}
		if( lstepName == 'TpStepChoixOptions' )
		{
						
			//$param
			if( stepListObject.getParameter( 'pelemele_configuration' ) === false )
			{
			//$('infos').innerHTML += " <br /> Step non expanded : pelemele_configuration";
			
			alert('Parametre Image pelemele non rempli' );
			/*
			alert(stepListObject.getNbParameter());
			alert( stepListObject.getParameter( 'encadrement_id' )
             );
      alert( stepListObject.makeAsUrl()
             );
      */
			
			//expandParameterStepForP( 'pelemele_configuration' );
			return false;
			}
			else {
			  dspRightPanText(lstepName);
			}
					}
		if( lstepName == 'TpStepTableauPersoFin' )
		{
						
			//$param
			if( stepListObject.getParameter( 'options_choosed' ) === false )
			{
			//$('infos').innerHTML += " <br /> Step non expanded : options_choosed";
			
			alert('Parametre Options non rempli' );
			/*
			alert(stepListObject.getNbParameter());
			alert( stepListObject.getParameter( 'encadrement_id' )
             );
      alert( stepListObject.makeAsUrl()
             );
      */
			
			//expandParameterStepForP( 'options_choosed' );
			return false;
			}
			else {
			  dspRightPanText(lstepName);
			}
					}
// appel ici de la fonction qui invalide les �tapes suivante (obsol�te?)
// stepListObject.invalidateStepUntil( lstepName );

return true;
}

function makeStepListAsUrlTest(){
alert( stepListObject.makeAsUrl() );
}

function returnConceptId(){
return (12);	
}


function ActualiseBuildedProduct(){
		new Ajax.Request(
			'/TpStepManagement/AjaxActualiseBuildedProduct',
			{
				method: 'post',
				parameters: {BuildId: $('buildInConstruct').value}
			}
		);
}