// Librairie de fonctions d'affichage

function aff_iframe( nom, url, w, h, l, t )
{
	if( ! w ) w = 300; if( ! h ) h = 400;
	if( ! l ) l = 20; if( ! t ) t = 20;
	var f = aff_findObj( nom );
	f.src = url;
	var s = ( f.style ) ? f.style : f;
	s.width = w; s.height = h; s.top = 1000; s.left = 1000;
	aff_showHideLayers( nom, 'show' );
	s.top = t; s.left = l;	
}

function aff_cache_iframe( nom )
{
	var f = aff_findObj( nom );
	f.src = "";
	aff_showHideLayers( nom, 'hide' );
}		
		
function aff_charge_iframe( nom, url )
{
	var f = aff_findObj( nom );
	f.src = "";
	f.src = url;
}
		
// Gestion POP-UP
var nom_pop_souris = 'framepop';

function pop_souris( u ) { aff_pop_gris( nom_pop_souris, u ); }
function pop_cache() { cache_pop_gris(); }
function pop_affiche( u, w, h, l, t ) { aff_pop_gris( nom_pop_souris, u, w, h ); }

function pop_resize( w, h )
{
	id_div = nom_pop_souris;
	xResizeTo( id_div , w, h );
	xMoveTo( id_div , xScrollLeft() + ( xClientWidth() - xWidth( id_div ) ) / 2, xScrollTop() + ( xClientHeight() - ( xHeight( id_div ) ) ) / 2 );
}

// POPUP SUR FOND GRIS	

var global_pg = null;
function page_grise_aff()
{
	if( ! global_pg )
	{
		global_pg  = new xPageGrey( 'clsPageGreyDiv' );
		global_pg.ele.onclick = function() { cache_pop_gris();  };
	}
	global_pg.show();
}
function page_grise_ferme() { global_pg.hide(); }
function xPageGrey( sDivClass )
{
	this.ele = document.createElement( 'div' ); 
	this.ele.className = sDivClass; 
	document.body.appendChild( this.ele );
	this.show = function() { if( this.ele ) { var ds=xDocSize(); xMoveTo( this.ele, 0, 0 ); xResizeTo( this.ele, ds.w, ds.h ); } }
	this.hide = function() { if( this.ele ) { xResizeTo( this.ele, 10, 10); xMoveTo( this.ele, -10, -10 ); } }
}
function aff_centre( id_div )
{
	xMoveTo( id_div, xScrollLeft + ( xClientWidth() - xWidth( id_div ) ) / 2, xScrollTop() + ( xClientHeight() - ( xHeight( id_div ) ) ) / 2 );
	aff_showHideLayers( id_div, 'show' );
}
var global_pop_gris = null;
function aff_pop_gris( nom, u )
{
	var f = aff_findObj( nom );
	f.src = u;
	page_grise_aff();
	aff_centre( nom );
	global_pop_gris = nom;
}
function cache_pop_gris()
{	
	var f = aff_findObj( global_pop_gris );
	if( f ) { f.src = ''; xResizeTo( f, 1, 1 ); }
	page_grise_ferme();
	aff_showHideLayers( global_pop_gris, 'hide' );
	global_pop_gris = null;
}

// LES ROLLOVERS

var g_num_image = 0;

function aff_roll( lien, a_off, a_on, option )
{
	g_num_image += 1;
	s = '<a href="' + lien + '"';
	if( option ) s+= ' ' + option;
	s+= ' onMouseOut="aff_swapImgRestore()"'; 
	s+= ' onMouseOver="aff_swapImage(\'I' + g_num_image + '\',\'\',\'' + a_on + '\',1)"><img'; 
	s+= ' name="I' + g_num_image + '" border="0" src="' + a_off + '"></a>';

	document.write( s );
}


function aff_swapImgRestore() 
{
	var i,x,a=document.aff_sr; 
  for( i = 0; a && i < a.length && ( x = a[i] ) && x.oSrc; i++ ) x.src = x.oSrc;
}

function aff_preloadImages() 
{
	var d = document; 
	if( d.images )
	{ 
		if( ! d.aff_p ) d.aff_p = new Array();
    	var i, j = d.aff_p.length, a = aff_preloadImages.arguments; 
    	for( i = 0; i < a.length; i++ )
		{
    		if( a[i].indexOf( "#" ) != 0 )
    		{ 
    			d.aff_p[j] = new Image; 
    			d.aff_p[j++].src = a[i];
    		}
		}
   }
}

function aff_findObj( n, d )
{
 	var p, i, x;  
 	if( ! d ) d = document;
 	if( ! n ) x = false;
 	else {
	 	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 = aff_findObj( n, d.layers[i].document);
	  if( !x && d.getElementById ) x = d.getElementById( n ); 
	}
  return x;
}

function aff_swapImage() 
{
 	var i, j = 0, x , a = aff_swapImage.arguments;
 	document.aff_sr = new Array; 
 	for( i = 0; i < ( a.length - 2 ); i += 3 )
 	{
 		if( ( x = aff_findObj( a[i] ) ) != null )
 		{ 
 			document.aff_sr[j++] = x;
 			if( ! x.oSrc ) x.oSrc = x.src;
 			x.src = a[i+2];
 		}
 	}
}

function aff_showHideLayers() 
{
  var i, p, v, obj, args = aff_showHideLayers.arguments;

	for( i = 0; i < ( args.length - 1 ); i += 2 )
  	{
  		if( ( obj = aff_findObj( args[ i ] ) ) != null ) 
  		{ 
  			v = args[ i + 1 ];
    		if( obj.style ) 
    		{ 
    			obj = obj.style; 
    			v = ( v == 'show' ) ? 'visible' : ( v = 'hide' ) ? 'hidden' : v; 
    		}
    		obj.visibility = v;
    	}
	}
}

	var lastScrollY = 0;

	NS = ( document.layers ) ? 1 : 0;
	IE = ( document.all ) ? 1: 0;
	NS7 = ( navigator.userAgent.indexOf( "Gecko" ) != -1 );

	function Colle( quoi ) 
	{
		if( IE ) diffY = document.body.scrollTop;
		if( NS || NS7 ) diffY = self.pageYOffset;
		if( diffY < 30 ) 
		{
			aff_showHideLayers( quoi, 'hide' );
		} else if( diffY != lastScrollY ) {
			aff_showHideLayers( quoi, 'show' );
  		if( NS7 && ( obj = aff_findObj( quoi ) ) != null ) { obj.style.top = diffY + 25; }
  		else 
  		{
				if( IE ) eval( 'document.all.' + quoi + '.style.pixelTop = diffY + 25;' );
				if( NS ) eval( 'document.' + quoi + '.top = diffY + 25;' );
			}
			lastScrollY = diffY;
		}
	}

	function jet_colle( lay_a_coller ) 
	{
		if( NS || IE || NS7 ) action = window.setInterval( "Colle( '" + lay_a_coller + "' )" , 100 );
	}
	
	function ajout_favoris( lien, texte )
	{
		window.external.AddFavorite( lien, texte);
	}