/**
 * RokIEWarn - An IE6 Warning to invite people upgrading to IE6
 * 
 * @version		1.2
 * 
 * @license		MIT-style license
 * @author		Djamil Legato <djamil@rockettheme.com>
 * @client		RocketTheme, LLC.
 * @copyright	Author
 */
 
 
var RokIEWarn = new Class({
	'site': 'sitename',
	'initialize': function() {
		var warning = "<h3></h3><h4>NOTE: TRES IMPORTANT.</h4><p>- Il se peut que la version du navigateur internet que vous utilisez ne vous permet pas d'afficher correctement notre site :Vous devez mettre &agrave; jour votre navigateur internet !</br></br>- La version arabe de notre site web peut &ecirc;tre affich&eacute;e correctement sur les navigateurs suivants: IE8, Firefox, opera </br></br>- Vous pouvez cliquer sur l'un de ces liens pour mettre &agrave; jour votre navigateur (<BLINK>c'est gratuit</BLINK>):</br></br></p> <br /><a class=\"external\"  href=\"http://download.microsoft.com/download/B/B/F/BBFCC870-E61D-4515-B81F-69D4D2F2B23B/IE8-WindowsXP-x86-FRA.exe\">Internet Explorer 8 </a>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a class=\"external\"  href=\"http://mozilla.bit.nl/firefox/releases/3.5.3/win32/fr/Firefox%20Setup%203.5.3.exe\">FireFox 3.5.3</a>";
		
		this.box = new Element('div', {'id': 'iewarn'}).inject(document.body, 'top');
		var div = new Element('div').inject(this.box).setHTML(warning);
		
		var click = this.toggle.bind(this);
		var button = new Element('a', {'id': 'iewarn_close'}).addEvents({
			'mouseover': function() {
				this.addClass('cHover');
			},
			'mouseout': function() {
				this.removeClass('cHover');
			},
			'click': function() {
				click();	
			}
		}).inject(div, 'top');
		
		this.height = $('iewarn').getSize().size.y;
		
		this.fx = new Fx.Styles(this.box, {duration: 1000}).set({'margin-top': $('iewarn').getStyle('margin-top').toInt(), 'opacity': 0});
		this.open = false;
		
		var cookie = Cookie.get('rokIEWarn'), height = this.height;
		//cookie = 'open'; // added for debug to not use the cookie value
		if (!cookie || cookie == "open") this.show();
		else this.fx.set({'margin-top': -height, 'opacity': 0});

		
		return ;
	},
	
	'show': function() {
		this.fx.start({
			'margin-top': 0,
			'opacity': 1
		});
		this.open = true;
		Cookie.set('rokIEWarn', 'open', {duration: 7});
	},	
	'close': function() {
		var margin = this.height;
		this.fx.start({
			'margin-top': -margin,
			'opacity': 0
		});
		this.open = false;
		Cookie.set('rokIEWarn', 'close', {duration: 7});
	},	
	'status': function() {
		return this.open;
	},
	'toggle': function() {
		if (this.open) this.close();
		else this.show();
	}
});

window.addEvent('domready', function() {
	if (window.ie6) { (function() {var iewarn = new RokIEWarn();}).delay(2000); }
});