// (C) 2000 www.CodeLifter.com // http://www.codelifter.com // Free for all users, but leave in this  header
// NS4-6,IE4-6 // Fade effect only in IE; degrades gracefully

// =======================================
// set the following variables
// =======================================

// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 4000

// Duration of crossfade (seconds)
var crossFadeDuration = 3

// Specify the image files
var Pic = new Array() // don't touch this
// to add more images, just continue
// the pattern, adding to the array below

Pic[0] = 'i/slide0.jpg'
Pic[1] = 'i/slide1.jpg'
Pic[2] = 'i/slide2.jpg'
Pic[3] = 'i/slide3.jpg'
Pic[4] = 'i/slide4.jpg'
Pic[5] = 'i/slide5.jpg'
Pic[6] = 'i/slide6.jpg'
Pic[7] = 'i/slide7.jpg'
Pic[8] = 'i/slide8.jpg'
Pic[9] = 'i/slide9.jpg'
Pic[10] = 'i/slide10.jpg'
Pic[11] = 'i/slide11.jpg'


// =======================================
// do not edit anything below this line
// =======================================

var t
var j = 0
var p = Pic.length

var preLoad = new Array()
for (i = 0; i < p; i++){
   preLoad[i] = new Image()
   preLoad[i].src = Pic[i]
}

function runSlideShow(){
   if (document.all){
      document.images.SlideShow.style.filter="blendTrans(duration=2)"
      document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
      document.images.SlideShow.filters.blendTrans.Apply()      
   }
   document.images.SlideShow.src = preLoad[j].src
   if (document.all){
      document.images.SlideShow.filters.blendTrans.Play()
   }
   j = j + 1
   if (j > (p-1)) j=0
   t = setTimeout('runSlideShow()', slideShowSpeed)
}

function hover(obj){ 
 if(document.all){  
   UL = obj.getElementsByTagName('ul'); 
      if(UL.length > 0){   
	     sousMenu = UL[0].style;  
		     if(sousMenu .display == 'none' || sousMenu.display == ''){  
			       sousMenu.display = 'block';      }
				   else{        sousMenu.display = 'none';      }  
				     } 
					  }
					  }

function setHover(){ 
 LI = document.getElementsByTagName('li');
   nLI = LI.length;  
   for(i=0; i < nLI; i++){  
     LI[i].onmouseover = function(){ 
	      hover(this);   
		   }    
		   LI[i].onmouseout = function(){  
		       hover(this);    
			   }  
			   }
			   }

function reloadpage () {
	window.location.reload();
}
			   
			   
window.onresize= function(evt) {
	
	timer=setTimeout(reloadpage,100);
	
	
}

function findPos(obj) {
	// Kudos : http://www.quirksmode.org/js/findpos.html
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		//curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}



function tribun(id, nom, ev) {
	
        obj = (document.all) ?  event.srcElement : ev.target ;
	    coords = findPos(obj);
	    x = coords[0];
	    y = coords[1] - 160;
        
        var tribdiv = document.createElement("div");
        var closetribdiv = document.createElement("div");
        var crossdiv = document.createElement("div");
        var closecrossdiv = document.createElement("div");

        var newstyle = "position: absolute; border: 0px solid; right:0; top:0; width: 20px; cursor: pointer" ;
        var styleimg = "cursor: pointer" ;
       
        if (document.all) { closetribdiv.style.setAttribute("cssText", newstyle); } 
        	else closetribdiv.setAttribute("style", newstyle);

        if (document.all) { closecrossdiv.style.setAttribute("cssText", newstyle); } 
        	else closecrossdiv.setAttribute("style", newstyle);

        closecrossdiv.appendChild(document.createTextNode('[X]'));
        crossdiv.appendChild(closecrossdiv);	

        tribdiv.appendChild(crossdiv);	
        
        var newstyle = "position: absolute; z-index:10 ;border: 1px solid;top:" + y + "px; left:" + x + "px; width: 120px;  padding: 15px; background-color: #FFFFFF" ;
       
        if (document.all) { tribdiv.style.setAttribute("cssText", newstyle); } 
        	else tribdiv.setAttribute("style", newstyle);
        var linkdoc = document.createElement("a");
		linkdoc.setAttribute('href', '/13/tribun/fiches_id/' + id + '.asp');
		linkdoc.setAttribute('target', '_blank');
        var imgdoc = document.createElement("img");
        imgdoc.setAttribute('src', '/13/tribun/photos_100/' + id + '.gif');
        imgdoc.setAttribute('width', '100');
        imgdoc.setAttribute('height', '128');
        imgdoc.setAttribute('style', styleimg);
		linkdoc.appendChild(imgdoc);
        tribdiv.appendChild(linkdoc);
        closecrossdiv.onclick = function() {
       		var spanelem = document.getElementById('spanordre');
	        spanelem.innerHTML = "";
        }
        tribdiv.onclick = function() {
       		var spanelem = document.getElementById('spanordre');
	        spanelem.innerHTML = "";
       		open('/13/tribun/fiches_id/' + id + '.asp');
        }

        var txtbr = document.createElement("br");
        var txtdoc = document.createElement("p");
        txtdoc.appendChild(document.createTextNode(nom));
        txtdoc.setAttribute('style', styleimg);
        tribdiv.appendChild(txtdoc);
        var spanelem = document.getElementById('spanordre');
        spanelem.innerHTML = "";
        spanelem.appendChild(tribdiv);
        //alert(spanelem.innerHTML)
                
}
function encodeMyHtml(htmlToEncode,cible,myform) {
	encodedHtml = document.getElementById(htmlToEncode).value;
	encodedHtml = encodedHtml.replace(/é/g,'&eacute;');
	encodedHtml = encodedHtml.replace(/è/g,'&egrave;');
	encodedHtml = encodedHtml.replace(/à/g,'&agrave;');
	encodedHtml = encodedHtml.replace(/ê/g,'&ecirc;');
	encodedHtml = encodedHtml.replace(/î/g,'&icirc;');
	encodedHtml = encodedHtml.replace(/û/g,'&ucirc;');
	encodedHtml = encodedHtml.replace(/ü/g,'u');
	encodedHtml = encodedHtml.replace(/ï/g,'i');
	encodedHtml = encodedHtml.replace(/ô/g,'&ocirc;');
	encodedHtml = encodedHtml.replace(/É/g,'&Eacute;');
	encodedHtml = encodedHtml.replace(/È/g,'&Egrave;');
	encodedHtml = encodedHtml.replace(/À/g,'&Agrave;');
	encodedHtml = encodedHtml.replace(/Ê/g,'&Ecirc;');
	encodedHtml = encodedHtml.replace(/Î/g,'&Icirc;');
	encodedHtml = encodedHtml.replace(/Û/g,'&Ucirc;');

	document.getElementById(cible).value=encodedHtml;
	document.getElementById(myform).submit();
  
}

function testsearchquery() {
	if (document.getElementById('recherchechampssaisie').value=="" || document.getElementById('recherchechampssaisie').value=="*") {
		alert("Veuillez saisir un ou plusieurs mots clés et relancez la recherche");
	}
	else {
		encodeMyHtml("recherchechampssaisie","recherchechamps","rechercheid");
	}
}	

function fenetreCent(url,nom,largeur,hauteur,options) {
var haut=(screen.height-hauteur)/2;
var Gauche=(screen.width-largeur)/2;
fencent=window.open(url,nom,"top="+haut+",left="+Gauche+",width="+largeur+",height="+hauteur+","+options);
}
