
  /*********/
 /* Layer */
/*********/	
/*
desactiver la selection du texte qd on drag & drop un layer
*/
function Layers()
{
  var _just_loaded = 1;
  var self = this;	  
  function is_layer(idValue)	
  {
    return idValue && idValue.lastIndexOf(LAYER_SUFFIX) != -1 && idValue.lastIndexOf(LAYER_SUFFIX) == (idValue.length - LAYER_SUFFIX.length);
  }
  function init_layers()
  {
    // ATTN aux doublons ds le tab ci-dessous
    var layernames = new Array('commentsDiv', 'photoStatusDiv', 'infoStatusDiv', 'statusBarreDiv', 'contentDiv', 'imageDiv', 'enteteDiv', 'modepaiementDiv', 'coverDiv', 'alerttitreDiv', 'alertcontentDiv', 'alerteDiv', 'passeDiv', 'fondDiv', 'descDiv', 'chronoDiv', 'navDiv', 'startDiv', 'photoDiv', 'optionsDiv', 'waitingDiv', 'bodyDiv', 'startDiv', 'loadingDiv', 'logoDiv', 'photoaccueilDiv', 'nbphotosDiv', 'totalhtDiv', 'totalttcDiv', 'photosDiv', 'urlsiteDiv', 'check1Div', 'check2Div', 'check3Div', 'check4Div', 'check5Div', 'check6Div', 'check7Div', 'check8Div', 'check9Div', 'check10Div', 'check11Div', 'check12Div', 'imagecontent1Div', 'imagecontent2Div', 'imagecontent3Div', 'imagecontent4Div', 'imagecontent5Div', 'imagecontent6Div', 'imagecontent7Div', 'imagecontent8Div', 'imagecontent9Div', 'imagecontent10Div', 'imagecontent11Div', 'imagecontent12Div', 'loading1Div', 'loading2Div', 'loading3Div', 'loading4Div', 'loading5Div', 'loading6Div', 'loading7Div', 'loading8Div', 'loading9Div', 'loading10Div', 'loading11Div', 'loading12Div', 'image1Div', 'image2Div', 'image3Div', 'image4Div', 'image5Div', 'image6Div', 'image7Div', 'image8Div', 'image9Div', 'image10Div', 'image11Div', 'image12Div', 'imageInfos1Div', 'imageInfos2Div', 'imageInfos3Div', 'imageInfos4Div', 'imageInfos5Div', 'imageInfos6Div', 'imageInfos7Div', 'imageInfos8Div', 'imageInfos9Div', 'imageInfos10Div', 'imageInfos11Div', 'imageInfos12Div', 'sexeDiv', 'dateDiv', 'profileDiv', 'infoDiv', 'classementDiv', 'voirthemeDiv', 'listescrollDiv', 'urlDiv', 'prixcdromDiv', 'vignDiv', 'indexDiv', 'interfaceDiv', 'linkIndexDiv', 'linkFormatDiv', 'linkDiapoDiv', 'linkNextDiv', 'linkPrevDiv', 'diapoDiv', 'yamDiv', 'navdiapoDiv');
	for(i in layernames){
	  if(document.getElementById(layernames[i])){
	    eval(layernames[i].split('Div')[0]+' = new Layer("'+layernames[i]+'");');	  
//	    eval(layernames[i]+' = new Layer("'+layernames[i]+'Div");');
	  }
	}
	/*
	if (document.all){
	  var d = document.all;
	}else if(document.getElementById){
	  var d = document.getElementById;
	}
	//poubelle = new Layer('poubelleDiv');
	for(idValue in d){
	  // Si le mot 'Div' se trouve a la fin du id de l'elt html
	  if(is_layer(idValue)){
		var layerName = idValue.split('Div')[0];
		eval('if(window.'+layerName+' && _just_loaded) alert("Mot '+layerName+' reserve!"); else '+layerName+' = new Layer("'+idValue+'");');
	  }
	}
	*/
    _just_loaded = 0;
  }
  this.init = function(){
    if(_just_loaded) {
	  init_layers();
	}
  }
  this.init();
}

function Layer(id)
{
  this.display = function(what){
    //for (i = 0; i<this.display.arguments.length; i++) {
    this.layer.style.display = what;
  }
  this.undisplay = function(){
    this.layer.style.display = 'none';
  }
  this.set_class = function(what){
    this.layer.className = what;
  }
  // this = document.all[id].style; (ex: l_photo
  this.type		= 'layer';
  if(document.all){
    this.name = id.split('Div')[0];
    this.layer  = document.all[id];
    this.style 	= this.layer.style;		
    this.width  = this.layer.offsetWidth;
    this.height = this.layer.offsetHeight;	
  }else if (document.getElementById) {
    this.name = id.split('Div')[0];  
    this.layer = document.getElementById(id);
	this.style 	= this.layer.style;
    // Rq: si pas defini ds css vaut Nan => if isNan alors...
    //this.width  = parseInt(this.layer.style.width);
    //this.height = parseInt(this.layer.style.height);			
    this.width  = this.layer.offsetWidth;
    this.height = this.layer.offsetHeight;	
  }
  this.get_pos();
//  alert(id);
//  alert(this.layer.style.height);
}

// Coordonnees du layer en valeurs absolues dans le repere cartesien ayant pour origine la position du parent si position = absolute
// actual positions within the document area
Layer.prototype.get_pos = function(x, y){ 
  if(document.all){
    this.x  = this.layer.offsetLeft;
    this.y  = this.layer.offsetTop;
  }else if (document.getElementById) {
    // Rq: si pas defini ds css vaut Nan => if isNan alors...
    this.x  = parseInt(this.layer.style.left);
	if(this.layer.style.top){
	  this.y  = parseInt(this.layer.style.top);	  
	}else if(this.layer.style.bottom){
	  this.y  = parseInt(this.layer.style.bottom);	  
	}else{
	  this.y  = 0;	  
	}
  }
}	

Layer.prototype.get_dims = function(){ 
  if(document.all){
    this.width  = this.layer.offsetWidth;
    this.height  = this.layer.offsetHeight;
  }else if (document.getElementById) {
    this.width  = parseInt(this.layer.style.width);
    this.height  = parseInt(this.layer.style.height);	  
  }
}	
// Positionne/Deplace le layer aux coord x et y (unite = pixel)
Layer.prototype.move = function(x, y){ //, repos
  if(document.all){
    this.style.pixelLeft = x; 
    this.style.pixelTop  = y; 
  }else if (document.getElementById) {
    this.style.left = x + 'px'; 
    this.style.top  = y + 'px'; 	  
  }
  this.get_pos();
  //if(repos) this.get_pos();
}	


Layer.prototype.move2 = function(pos){
  var parent = this.move2.arguments.length > 1?this.move2.arguments[1]:screen;
  this.get_dims();
  switch(pos){
    case 'center':
	  // tenir compte du scroll (nottament pour le body)
	  this.style.left = (parent.width - this.width) / 2;
	  this.style.top  = (parent.height - this.height) / 2; // Important: definir la height dans le layer sinon NaN	
	break;
	case 'bottom_left':
      this.style.left = 0;
	  this.style.top  = screen.height - this.height;	
	  break;
	case 'middle_left':
      this.style.left = 0;
	  this.style.top  = (parent.height - this.height) / 2;
	  break;
	case 'top_right':
      this.style.left = screen.width - this.width;
	  this.style.top  = 0;	
	  break;    	  
	case 'top_left':
      this.style.left = 0;
	  this.style.top  = 0;	
	  break;
  }
}

// Changement dynamique du contenu du layer
Layer.prototype.write = function(content){
  this.layer.innerHTML = unescape(content);
}

Layer.prototype.show = function(){
  this.style.visibility = 'visible';
} 

Layer.prototype.hide = function()  {  
  this.style.visibility = 'hidden'; 
  }

Layer.prototype.center = function(){
  this.style.left = (screen.width - this.width) / 2;
  this.style.top  = (screen.height - this.height) / 2; // Important: definir la height dans le layer sinon NaN  
}
Layer.prototype.top_left = function(){
  this.style.left = 0;
  this.style.top  = 0;
}  
