// JavaScript Document

<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x;
  if(!x.oSrc) {
   if(x.realSrc) x.oSrc=x.realSrc;
   else x.oSrc=x.src;
  }
  x.src=a[i+2];}
}

// swap image
// definir la valeur de l'image alternative dans l'attribut rel
function swap_image() {
    tmp = jQuery(this).attr('src');
    jQuery(this).attr('src', jQuery(this).attr('rel'));
    jQuery(this).attr('rel', tmp);
};


// gestion des menu gauches, attribut display
function voir() {
	var i, obj, args = voir.arguments;

	if(document.getElementById) {
		for (i=0; i<args.length; i++) {
			obj = document.getElementById(args[i]);
	 		obj.style.display = "block";
	 		obj.style.visibility = "visible";
	 	}
	}
}
var thumbon = false;
function showThumb(id, src){
  if (thumbon)
    return;
  thumbon = true;
  var div = document.getElementById(id);
  var img = document.getElementById(id+'img');
  img.src = src;
  div.style.display = "block";	
  div.style.visibility = "visible";
}
function cache() {
  thumbon = false;
  var i, obj, args = cache.arguments;
  
  if(document.getElementById) {
    for (i=0; i<args.length; i++) {
      obj = document.getElementById(args[i]);
      obj.style.display = "none";
      obj.style.visibility = "hidden";
    }
  }
}
function scrollbarWidth() {
  var div = jQuery('<div style="width:50px;height:50px;overflow:hidden;position:absolute;top:-200px;left:-200px;"><div style="height:100px;"></div>');
  // Append our div, do our calculation and then remove it
  jQuery('#contenu').append(div);
  var w1 = jQuery('div', div).innerWidth();
  div.css('overflow-y', 'scroll');
  var w2 = jQuery('div', div).innerWidth();
  jQuery(div).remove();
  return (w1 - w2);
}
var hottipdiv = null;
var hottipimg = null;
TZR.myApplyHottip=function(obj,param){
  hottipdiv = jQuery('#aide1');
  hottipimg = jQuery('#aide1img');
  obj.hover(function(){
    $this = jQuery(this);
    var $src = $this.attr('data-image');
    var $poid = $this.attr('data-oid');
    var $url = TZR._self+"&geometry="+escape("200x350%3E")+"&template=empty.txt&_raw=1&function=getItemListImage&oid="+$poid;
    var r = jQuery.ajax({type:'GET', async:false,cache:true,dataType:'text', url:$url});
    var $src2 = jQuery.trim(r.responseText);
    if ($src2 != 'empty'){
      $src = $src2;
    } else {
      if ($src != '')
      $src = $src+"&geometry=200x350%3E";
    }
    var $p = $this.offset();
    $top = $p.top - 20; 
    $right = jQuery('body').innerWidth() - $p.left ;
    if ($src == ''){
      hottipimg.attr('alt','not available');
      hottipimg.attr('src','/images/bas_load_puce.gif');
    }else{
      hottipimg.attr('alt','loading');
      hottipimg.attr('src',$src);
    }
     hottipdiv.css('top',$top+'px').css('right',$right+'px').show();
  },function(){
    hottipimg.attr('alt','photo');
    hottipimg.attr('src','/images/bas_load_puce.gif');
    hottipdiv.hide();

  }); 
  return obj;
}
/* fonctions de la fenetre de download */
/* fonction de la fenetre de selection : coche/decoche un choix de media */
function togglemediacateg(mcateg, ele){
  jQuery(ele).parent().toggleClass('select');
  var field = 'msegs['+mcateg+']';
  var e = document.forms['downloadSelectedProducts'].elements[field];
  if (typeof(e) != 'undefined'){
    var v = e.value;
    if (v == 1)
      document.forms['downloadSelectedProducts'].elements[field].value = 0;
    else
      document.forms['downloadSelectedProducts'].elements[field].value = 1;
  }
}
/* fonction de la fenetre de selection des media : download des medias cochés*/
function downloadselectedmedias(){
  // si au moins 1, sousmission
  var mcategs = jQuery("input.mcategselect");
  var one = false;
  jQuery.each(mcategs, function(){
    if (this.value == 1)
      one = true;
  });
  if (one){
    if (document.forms['downloadSelectedProducts'].elements['usageagreement'].checked){
      try {
	pageTracker._trackPageview('/downloads/'+currentsection+'.html');
      } catch(err) {}
      document.forms['downloadSelectedProducts'].submit();
    }else alert(downloadmess.agreement);
  } else {
    alert(downloadmess.emptyselection);
  }
}
/* fonction de la fenetre de selection des media : download de tous les media, cochés ou pas*/
function downloadallmedias(){
  // selectionner tout les medias
  var mcategs = jQuery("input.mcategselect");
  jQuery.each(mcategs, function(){
    this.value = 1;
  });
  downloadselectedmedias();
}
/* appel de la fenetre de selection des medias pour les produits selectionnes */
function genericDownloadSelectedItems(param){
  var checks = jQuery("input.productSelection");
  var oids = [];
  jQuery.each(checks, function(){
    if (this.checked)
      oids.push(this.value);
  });
  if (oids.length>0){
    var _selected = {_selected:oids};
    var url = TZR._self+"&amp;function=preDownloadSelectedItems&amp;template=items-download.html&ori="+currentsection;
    var r = jQuery.ajax({type:'POST', async:false,cache:false,dataType:'html', url:url, data:_selected});
    jQuery.nyroModalManual({content:r.responseText,
    width:740,
    closeButton:'', 
    closeSelector:'a.closeDownloadSelectedProducts',
    cssOpt:{wrapper:{border:'none'}},  
    wrap:{ manual: '<div class=""></div>'}
    });
  } else {
    // ...
  }
}
//-->

