var IE5=(document.getElementById && document.all)? true : false;
var W3C=(document.getElementById)? true: false;
var currIDb=null, currIDs=null, xoff=0, yoff=0; zctr=0; totz=0;
var hideonclick=true;


function Show(i)
{
	url="artotheque/fiche.php?technique=all&CodeOeuvre="+i ;
	showPopup( '_popup', 'FICHE &OElig;uvre', '' ) ;
	document.getElementById('fiche').src=url;
}
function ShowT(i)
{
	url="artotheque/fiche.php?artiste=all&CodeOeuvre="+i ;
	showPopup( '_popup', 'FICHE &OElig;uvre', '' ) ;
	document.getElementById('fiche').src=url;
}

function trackmouse(evt)
{
   if((currIDb!=null) && (currIDs!=null))
   {
      var x=(IE5)? event.clientX+document.body.scrollLeft : evt.pageX;
      var y=(IE5)? event.clientY+document.body.scrollTop : evt.pageY;
      currIDb.style.left=x+xoff+'px';
      currIDs.style.left=x+xoff+10+'px';
      currIDb.style.top=y+yoff+'px';
      currIDs.style.top=y+yoff+10+'px';
      return false;
   }
}

function stopdrag()
{
   currIDb=null;
   currIDs=null;
   NS6bugfix();
}

function grab_id(evt)
{
   xoff=parseInt(this.IDb.style.left)-((IE5)? event.clientX+document.body.scrollLeft : evt.pageX);
   yoff=parseInt(this.IDb.style.top)-((IE5)? event.clientY+document.body.scrollTop : evt.pageY);
   currIDb=this.IDb;
   currIDs=this.IDs;
}

function NS6bugfix()
{
   if(!IE5)
   {
      self.resizeBy(0,1);
      self.resizeBy(0,-1);
   }
}

function incrzindex()
{
   zctr=zctr+2;
   this.subb.style.zIndex=zctr;
   this.subs.style.zIndex=zctr-1;
}

function createPopup(id, title, width, height, x , y , isdraggable, boxcolor, bordercolor, borderwidth, barcolor, shadowcolor, text, textcolor, textptsize, textfamily, titlecolor )
{
   if(W3C)
   {
      zctr+=2;
      totz=zctr;
      var txt='';
      txt+='<div id="'+id+'_s" style="position:absolute; left:'+(x+5)+'px; top:'+(y+5)+'px; width:'+width+'px; height:'+height+'px; background-color:'+shadowcolor+'; filter:alpha(opacity=20); z-index:2; visibility:hidden"></div>';
      txt+='<div id="'+id+'_b" style="border:solid '+bordercolor+' '+borderwidth+'px;  position:absolute; left:'+x+'px; top:'+y+'px; width:'+width+'px; overflow:hidden; height:'+height+'px; background-color:'+boxcolor+'; z-index:2; visibility:hidden">';
	  txt += '<a href="#null" id="popupclose" onmousedown="hideonclick=true;hidePopup(\''+id+'\');return false">Fermer</a>' ;
 //     txt+='<table cellpadding="0" cellspacing="0" border="0" width="'+(IE5? width-4 : width)+'" style="width:'+width+'px; height:15px; background-color:'+barcolor+'; color: #FFFFFF;"><tr class="smenu"><td width="100%"><div id="'+id+'_h" >'+title+'</div></td><td><b><a href="#null" id="'+id+'_close" style="color: #FFFFFF; font-size: 10px; text-decoration: none;" onmousedown="hideonclick=true;hidePopup(\''+id+'\');return false">Fermer</a>&nbsp;&nbsp;</b></td></tr></table>';
      txt+='<div id="'+id+'_ov" style=" width:'+(width-12)+'px; height:'+(height-20)+'px; margin-left:5px; margin-top:5px; color:'+textcolor+'; font:'+textptsize+'pt '+textfamily+';"><iframe frameborder="0" height="440" id="fiche" name="fiche" scrolling="no" width="640" src="artotheque/chargement.php"></iframe></div></div>';

      if ( document.getElementById(id+'_s') )  
      	showPopup( id, title, text ) ;
      else 
      	document.write(txt);
		
      IDs=document.getElementById(id+'_s');
      if(!IE5)
         IDs.style.MozOpacity=.5;
   }
}

function showPopup( id, title, text ) 
{
      if ( document.getElementById(id+'_s') )  
      {
			//document.getElementById(id+'_h').innerHTML = title;
//			document.getElementById(id+'_ov').innerHTML = text;
//      currIDb.style.top= H +'px';
//      currIDs.style.top=H+10+'px';
		var sc = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
		var sl = Math.max(document.body.scrollLeft,document.documentElement.scrollLeft) ;		
	
		var hh = parseInt(document.getElementById(id+'_s').style.height );
		var H= Math.round((document.body.clientHeight - hh )/2) + sc;

		var ww = parseInt(document.getElementById(id+'_s').style.width );
		var W= Math.round((document.body.clientWidth - ww )/2) + sl;

		document.getElementById(id+'_s').style.top= H +'px' ;
		document.getElementById(id+'_b').style.top= H - 5 +'px' ;

		document.getElementById(id+'_s').style.left= W +'px' ;
		document.getElementById(id+'_b').style.left= W - 5 +'px' ;

		document.getElementById(id+'_s').style.visibility='visible' ;
		document.getElementById(id+'_b').style.visibility='visible' ;
      }
	
}
function showPopupEncoded( id, title, text, hiding ) 
{
      if ( document.getElementById(id+'_s') )  
      {
			document.getElementById(id+'_h').innerHTML = unescape(title);
			document.getElementById(id+'_ov').innerHTML = unescape(text);
      	document.getElementById(id+'_s').style.visibility='visible' ;
      	document.getElementById(id+'_b').style.visibility='visible' ;
			hideonclick=hiding ;
      }
	
}

function hidePopup( id ) 
{
      if ( (hideonclick) && ( document.getElementById(id+'_s') )  )
      {
		url="artotheque/chargement.php" ;
		document.getElementById('fiche').src=url;
      	document.getElementById(id+'_s').style.visibility='hidden' ;
      	document.getElementById(id+'_b').style.visibility='hidden' ;
	  }
}

function News_Resize( id, w, h, x, y )
{
   if ( document.getElementById(id+'_s') )  
   {
		document.getElementById(id+'_s').style.width = w+'px' ;
		document.getElementById(id+'_s').style.height = h+'px' ;
		document.getElementById(id+'_s').style.left = (x+5)+'px' ;
		document.getElementById(id+'_s').style.top  = (y+5)+'px' ;
		
		document.getElementById(id+'_b').style.width = w+'px' ;
		document.getElementById(id+'_b').style.height = h+'px' ;
		document.getElementById(id+'_b').style.left = x+'px' ;
		document.getElementById(id+'_b').style.top  = y+'px' ;
		
		document.getElementById(id+'_ov').style.width = (w-12)+'px' ;
		document.getElementById(id+'_ov').style.height = (h-20)+'px' ;
	}
}

if(W3C)document.onmousemove=trackmouse;

