// Put yo ur custom scripts here
<!------- Fonction génération du numéro aléatoire DART  ------> 
ord=Math.random()*10000000000000000;
<!------- Fin de la fonction  ------> 

// Sample code registering rule effect on Message Box
/*
	var rules1 = {
	  'DIV.mboxWarning' : function(element){
	    new Effect.Shake(element);
	  }
	}
	EventSelectors.register(rules1);
*/




/***** Custom for M6 *****/


//document.write("<script language=\"Javascript\" src=\"CMS/paris_premiere/js/fonctions.js\">");

function switchTab(tab) {
	        if ($(tab).style.display=="none") {
          $("onglet1").style.display = $("onglet1").style.display=="none" ? "block" : "none";
          $("onglet2").style.display = $("onglet2").style.display=="none" ? "block" : "none";
        	}
}


function imagette(nom,name){
  cesoir1 = new Image(61,20);
  cesoir1.src = "CMS/paris_premiere/skins/nav_horiz/cesoir_on.gif";
  cesoir2 = new Image(61,20);
  cesoir2.src = "CMS/paris_premiere/skins/nav_horiz/cesoir_off.gif";
  moment1 = new Image(110,20);
  moment1.src = "CMS/paris_premiere/skins/nav_horiz/encemoment_on.gif";
  moment2 = new Image(110,20);
  moment2.src = "CMS/paris_premiere/skins/nav_horiz/encemoment_off.gif";  
if (document.images) document.images[nom].src=eval(name+".src");
}

function Is() {
  var agent = navigator.userAgent.toLowerCase();
  this.major = parseInt(navigator.appVersion);
  this.minor = parseFloat(navigator.appVersion);
  this.ns = ((agent.indexOf('mozilla') != -1) &&
  (agent.indexOf('spoofer') == -1) &&
  (agent.indexOf('compatible') == -1) &&
  (agent.indexOf('opera') == -1) &&
  (agent.indexOf('webtv') == -1));
  this.ns2 = (this.ns && (this.major == 2));
  this.ns3 = (this.ns && (this.major == 3));
  this.ns4 = (this.ns && (this.major == 4));
  this.ns6 = (this.ns && (this.major >= 5));
  this.ie = (agent.indexOf("msie") != -1);
  this.ie3 = (this.ie && (this.major < 4));
  this.ie4 = (this.ie && (this.major >= 4) &&
  (agent.indexOf("msie 5.0") == -1));
  this.ie5 = (this.ie && (this.major == 4) &&
  (agent.indexOf("msie 5.0") != -1));
  this.ieX = (this.ie && !this.ie3 && !this.ie4);
 }

 function _nt(){ 
  var agt=navigator.userAgent.toLowerCase(); 
   if((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1))
    return true;
   else
    return false;
 }

function effacer(nom) {
  
  if(is.ie)
    document.all[nom].style.visibility="hidden";
  else if(is.ns6)
    document.getElementById(nom).style.visibility="hidden";
  else if(is.ns4)
    document.layers[nom].visibility="hide";
 }

 function show_cont(i,e){
 for(j=0;j<tabmenu.length && e==1;j++){
  if(('r_'+i)!=('r_'+j));
  effacer('r_'+j+'');
 } 
  clearTimeout(tid);
  alerte('toto   ');
  if (old_hr!=i){
   if(old_hr>-1){
    eval("_sh_"+t3+"(_obj_"+t1+"('r_"+old_hr+"'), 0, 'z"+old_hr+"')");
   }
   eval("_sh_"+t3+"(_obj_"+t1+"('r_"+i+"'), 1,'z"+i+"')");
  }
  old_hr = i;
  }

 function hide_cont(i){
  if(old_hr>-1){
   eval("tid = setTimeout(\"_sh_"+t3+"(_obj_"+t1+"('r_"+old_hr+"'), 0, 'r_"+old_hr+"')\", 1)");
//   eval("_sh_"+t3+"(_obj_"+t1+"('r_"+old_hr+"'), 0)");
  }
  old_hr = -1;
  }

 function _locate_0(_objn){
  var _lobj = document.getElementById(_objn);
  var _lx = _lobj.offsetLeft, _ly = _lobj.offsetTop;
  while(_lobj.offsetParent){
   _lx += _lobj.offsetParent.offsetLeft;
   _ly += _lobj.offsetParent.offsetTop;
   _lobj = _lobj.offsetParent;
  }
  return new Array(_lx+0, _ly+17);
 }

 function _locate_1(_objn){
  var _lobj = document.all[_objn];
  var _lx = _lobj.offsetLeft, _ly = _lobj.offsetTop;
  while(_lobj.offsetParent){
   _lx += _lobj.offsetParent.offsetLeft;
   _ly += _lobj.offsetParent.offsetTop;
   _lobj = _lobj.offsetParent
  }
  return new Array(_lx+0, _ly+17);
 }

 function _locate_3(_objn){
  _p = document.layers[_objn];
  return new Array(_p.pageX+0, _p.pageY+17);
 }

 function _build_0(xy, le){
  res = "";
  for(i=0;i<_rcontent.length;i++){
   l = xy[i][0];
   u = l+157-le;
   if(u>0)
    l -= u;
   res += "<div align=left id=r_"+i+" style='position:absolute;top:"+xy[i][1]+"px;left:"+l+"px;z-index:1;visibility:hidden;width:155px;' onmouseover='show_cont("+i+",0)' onmouseout='hide_cont("+i+")'>"+_rcontent[i]+"</div>";
  }
  return res;
 }

 function _build_1(xy, le){
  res = "";
  for(i=0;i<_rcontent.length;i++){
   l = xy[i][0];
   u = l+157-le;
   if(u>0)
    l -= u;
   res += "<layer name=r_"+i+" top="+xy[i][1]+" left="+l+" zindex=1 visibility='hide' onmouseover='show_cont("+i+",0)' onmouseout='hide_cont("+i+")'>"+_rcontent[i]+"</layer>";
  }
  return res;
 }

 function _do_resize_0(){
  onresize = function() { window.location.reload(); }
 }

 function _do_resize_1(){
   onresize = function() { if(innerWidth != origWidth || innerHeight != origHeight) location.reload(); }
 }

 function _obj_0(id){
  return document.getElementById(id).style;
 }

 function _obj_1(id){
  return document.all[id].style;
 }

 function _obj_3(id){
  return document.layers[id];
 }

 function _sh_0(obj, v, name){
  obj.visibility = (v==1)?'visible':'hidden';
  if(v==1)
  	hideElement(name);
  else
  	showElement();
 }

 function _sh_1(obj, v, name){
  obj.visibility = (v==1)?'show':'hide';
  if(v==1)
  	hideElement(name);
  else
  	showElement();
 }

 function init(){
  var coord = new Array();
  for(i=0;i<_rcontent.length;i++){
   coord[i]=eval("_locate_"+t1+"('z"+i+"')");
  }
  ledg = eval("_locate_"+t1+"('ledge')");
  document.write(eval("_build_"+t3+"(coord, ledg[0]+770)"));
  eval("_do_resize_"+t3+"()");
 /* for(i=0;i<_rcontent.length;i++){
  if(is.ns6) document.getElementById("r_"+i).style.MozOpacity = 85 + '%';
  if(is.ie){
   if(!((is.ie5)&&(_nt())))
    document.all("r_"+i).style.filter="alpha(opacity=85)";
  }
  }*/
 }
 function hideElement(nameOfImg)
{
	//if (bw.ie5 ||  bw.ie55 || bw.ie6 || bw.ie4 ||  bw.ie){
	if(nameOfImg.indexOf('z5')>-1 || nameOfImg.indexOf('z6')>-1) {
		var elmID = 'select';
		for (i = 0; i < document.all.tags(elmID).length; i++)
		{
			obj = document.all.tags(elmID)[i];
			if (! obj || ! obj.offsetParent)
				continue;
	
			// Find the element's offsetTop and offsetLeft relative to the BODY tag.
			objLeft   = obj.offsetLeft;
			objTop    = obj.offsetTop;
			objParent = obj.offsetParent;
			while (objParent.tagName.toUpperCase() != 'BODY')
			{
				objLeft  += objParent.offsetLeft;
				objTop   += objParent.offsetTop;
				objParent = objParent.offsetParent;
			}
				obj.style.visibility = 'hidden';
		}
	}
	if(nameOfImg.indexOf('z5')>-1 || nameOfImg.indexOf('z6')>-1) {
		var elmID = 'input';
		for (i = 0; i < document.all.tags(elmID).length; i++)
		{
			obj = document.all.tags(elmID)[i];
			if (! obj || ! obj.offsetParent)
				continue;
	
			// Find the element's offsetTop and offsetLeft relative to the BODY tag.
			objLeft   = obj.offsetLeft;
			objTop    = obj.offsetTop;
			objParent = obj.offsetParent;
			while (objParent.tagName.toUpperCase() != 'BODY')
			{
				objLeft  += objParent.offsetLeft;
				objTop   += objParent.offsetTop;
				objParent = objParent.offsetParent;
			}
			if (obj.name == 'strSearch') obj.style.visibility = 'hidden';
		}
	}
	//}
}

function showElement()
{
	//if (bw.ie5 ||  bw.ie55 || bw.ie6 || bw.ie4 ||  bw.ie){
		var elmID = 'select';
		for (i = 0; i < document.all.tags(elmID).length; i++)
		{
			obj = document.all.tags(elmID)[i];
			if (! obj || ! obj.offsetParent)
				continue;
			obj.style.visibility = "";
		}
		
		var elmID = 'input';
		for (i = 0; i < document.all.tags(elmID).length; i++)
		{
			obj = document.all.tags(elmID)[i];
			if (! obj || ! obj.offsetParent)
				continue;
			obj.style.visibility = "";
		}
	//}
}





function editItem(col, row, usr, idt, cur, url)
{
	window.open('phpPortal/edit.php?col=' + col + '&row=' + row + '&usr=' + usr + '&idt=' + idt + '&cur=' + cur + '&u_portal_home=' + escape(url), 'Edit', 'width=460,height=420,scrollbars=yes, resizable=yes');
}

function openParam(url)
{
	window.open('phpPortal/param.php?u_portal_home=' + escape(url), 'Param', 'width=600,height=420,scrollbars=yes, resizable=yes');
}




function getObj(name){
  if (document.getElementById){
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all){
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
}

function getAbsoluteLeft(objectId){
	var x = (new getObj(objectId)).obj;
	xLeft = x.offsetLeft;
	while(x.offsetParent!=null){
		xParent = x.offsetParent;
		xLeft += xParent.offsetLeft;
		x = xParent;
	}
	return xLeft;
}

function getAbsoluteTop(objectId){
	var x = (new getObj(objectId)).obj;
	xTop = x.offsetTop;
	while(x.offsetParent!=null) {
		xParent = x.offsetParent;
		xTop += xParent.offsetTop;
		x = xParent;
	}
	return xTop;
}

function getHeight(objectId){
	return (new getObj(objectId)).obj.offsetHeight;
}

function show_prog (repere,grille) {
        new getObj(grille).style.left = getAbsoluteLeft(repere);
        new getObj(grille).style.top = getAbsoluteTop(repere) + getHeight(repere);
        document.getElementById(grille).className = 'fenetre_volante_on';
}

function hide_prog (grille) {
        document.getElementById(grille).className = 'fenetre_volante_off';
}

// Ajout AWL pour galerie des legislatives

var ordBis = Math.random()*10000000000000000;

next = function(){
  
  if(pos < nom.length - 1){
    pos = pos + 1;
    new Effect.Opacity("imgLoad", {duration:1,from:1,to:0});
    setTimeout(function(){ document.images.cible.src=nom[pos];new Effect.Opacity("imgLoad", {duration:1,from:0,to:1});}, 1000);
    setTimeout("refreshPub()", 2000);
    $('prev').style.display = "inline";
  }
  
  if(pos == nom.length - 1){
    $('nexte').style.display = "none";
  }  
}

previous = function(){
  
  if(pos > 0){
    pos = pos - 1;
    new Effect.Opacity("imgLoad", {duration:1,from:1,to:0});
    setTimeout(function(){ document.images.cible.src=nom[pos];new Effect.Opacity("imgLoad", {duration:1,from:0,to:1});}, 1000);
    setTimeout("refreshPub()", 2000);
    $('nexte').style.display = "inline";
  }
  
  if(pos == 0){
    $('prev').style.display = "none";
  }
  
}

refreshPub = function(){

  top.frames["mega"].location = "custom/legislatives2007/pub/megabanniere.jsp?ord="+ordBis;
	top.frames["rect"].location = "custom/legislatives2007/pub/rectangle.jsp?ord="+ordBis;

}



