
/**
* Class Toolbar
* @author : Bob Gaudaen
* @date : 18/07/2007
*/

// Ajoute un evenement onload :
function addOnLoadEvent( func )
{
	if( typeof window.onload != 'function' )
	{
		window.onload = func;
	}
	else
	{
		var oldOnload = window.onload;
		window.onload = function()
		{
			oldOnload();
			func();
		}
	}
}

function ToolBar ()
{
	this.transitionTime = 0.5; // Temps de transition en secondes
	this.fps = 30; // Images par seconde
	this.nb_boucles;
	this.iter = 0;
	this.timeout;
	this.move;
	this.Body;
	this.Container;
	this.BodyMargin;
	this.BodyMrgnHrz;
	this.ContainerHeight = 25;
	
	// Initialisation :
	this.init = function ()
	{
		this.Body = document.getElementsByTagName( 'body' )[0];
		this.Container = document.getElementById( 'ezPTB' );
		this.Container.style.top = '-' + this.ContainerHeight + 'px';
		if( document.all )
		{
			this.BodyMargin = this.Body.currentStyle.marginTop;
			this.BodyMrgnHrz = (parseInt(this.Body.currentStyle.marginLeft.replace( /([0-9]+)(.+)/, "$1" )) + parseInt(this.Body.currentStyle.marginRight.replace( /([0-9]+)(.+)/, "$1" )));
		}
		else
		{
			this.BodyMargin = document.defaultView.getComputedStyle( this.Body, null ).getPropertyValue( 'margin-top' );
		}
		this.BodyMargin = Number( this.BodyMargin.replace( /([0-9]+)(.+)/, "$1" ) );
			
		this.nb_boucles = this.transitionTime * this.fps;
		this.timeout = (this.transitionTime*1000)/this.nb_boucles;
		this.move = this.ContainerHeight/this.nb_boucles;
		this.resize();
		this.Container.style.display = 'block';
		this.show();
	}
	
	this.appear = function()
	{
		var px = ( this.iter * this.move );
		this.Container.style.top = '-' + ( this.ContainerHeight - px ) + 'px';
		this.Body.style.marginTop = ( this.BodyMargin + px ) + 'px';
		
		this.iter++;
	}
	
	this.disappear = function()
	{
		this.iter--;
		
		var px = ( this.iter * this.move );
		this.Container.style.top = '-' + ( this.ContainerHeight - px ) + 'px';
		this.Body.style.marginTop = ( this.BodyMargin + px ) + 'px';
	}
	
	this.show = function()
	{
		this.iter = 0;
		for( var i=0; i<this.nb_boucles; i++ )
		{
			setTimeout( "Toolbar.appear()", i*this.timeout );
		}
	}
	
	this.hide = function()
	{
		for( var i=0; i<this.nb_boucles; i++ )
		{
			setTimeout( "Toolbar.disappear()", i*this.timeout );
		}
	}
	this.resize = function()
	{
		if (parseInt(navigator.appVersion)>3)
		{
			if (navigator.appName=="Netscape")
			{
				var winW = window.innerWidth;
			}
			if (navigator.appName.indexOf("Microsoft")!=-1)
			{
				var winW = document.body.offsetWidth;
			}
			this.Container.style.width = (winW+this.BodyMrgnHrz);
		}
	}
}
document.write("<style type=\"text/css\">#ezPTB{width:100%;position:absolute;top:-23;left:0;margin:0;display:none;height:23px;line-height:24px;text-align:center;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px;background-color:#FFFFCC;border-bottom:1px solid #b4b4b4;background-repeat: no-repeat;background-position: 4px 4px;cursor:pointer;}#ezPTB a.close{position:absolute;right:0;display:block;float:right;width:23px;height:23px;background-repeat: no-repeat;background-position: center center;}</style><div id=\"ezPTB\" style=\"background-image:url(http://www.amourmaghreb.biz/images/logo_mini.png)\" onmouseover=\"this.style.backgroundColor=\'#bebebe\'\" onmouseout=\"this.style.backgroundColor=\'\'\"><a href=\"#\" onclick=\"Toolbar.hide();return false;\" class=\"close\" style=\"background-image:url(http://www.amourmaghreb.biz/images/close.gif)\"></a><div style=\"width:100%;height:24px\" onclick=\"window.open(\'http://www.amourmaghreb.biz/?ban=infobar&r=samy8350\')\">Site de Rencontres Musulman : Laissez le destin d&eacute;cider ! Rejoignez la communaut&eacute; : <strong><u>cliquez ici</u></strong></div></div>");

var Toolbar = new ToolBar();
addOnLoadEvent( function () { Toolbar.init() } );
document.body.onresize = function (){
	Toolbar.resize();
}
