combo_active="";
combo_active_link="";
combo_chosen=false;

window.addEvent('domready', function(){
	/**
	This javascript was added for IE6 for simulating the min-width and max-width css properties
	 */
//	if(Browser.Engine.trident4)
//	{
//		resize();
//
//		window.addEvent('resize',
//				resize
//		);
//	}

//	function resize()
//	{
//		var size = window.getSize();
//
//		margin_left=$('body').getStyle('margin-left').replace("px","");
//		margin_right=$('body').getStyle('margin-right').replace("px","");
//		size_width= size.x-margin_right-margin_left; /* minus 50px for the left and right padding between body and the width*/
//
//		if(size_width<736)
//		{
//			$('body').setStyle('width',"736px");
//		}
//
//
//		if(size_width>735 && size_width<1021)
//		{
//			$('body').setStyle('width',size_width+"px");
//		}
//
//		if(size_width>1222)
//		{
//			$('body').setStyle('width',"1021px");
//		}
//
//	}

	/*
   if (Browser.Engine.trident)
	{
			$('choices-languages').setStyle('margin-left','-43px');
	}
	 */
	$$('.comboBoo-label').each(function(el){
		el.addEvent('click',
				function(){
			id=el.get('id');

			
			$$('.comboBoo-list').each(function(el){
				el.removeClass('comboBoo-list-active');
			});

			$$('.comboBoo-label').each(function(el){
				el.removeClass('comboBoo-label-active');
			});
						
						
			if(id!=combo_active_link && combo_chosen==false)
			{
				$('choices-'+id).addClass('comboBoo-list-active');
				$(id).addClass('comboBoo-label-active');
				combo_active_link=id;
				combo_active='choices-'+id;
				combo_linked_input=combo_active_link+'-value';
				combo_chosen=true;
			}
			else
			{
				combo_active_link="";
				combo_chosen=false;
			}
			
		});
	});

	$$('.comboBoo-list li').each(function(el){

		el.addEvent('mouseenter',
				function(){
			el.addClass('choice-selected');
		});

		el.addEvent('mouseleave',
				function(){
			el.removeClass('choice-selected');
		});

		el.addEvent('click',
				function(){
			
			var target = el.get('target');
			
			// If target=blank => window.open
			if(target != null && target == "blank") {
				$(combo_active).removeClass('comboBoo-list-active');
				$(combo_active_link).removeClass('comboBoo-label-active');
				combo_active="";
				combo_active_link="";
				
				window.open(el.get('id'));
			}
			// else => window.location.href
			else {
				el.getParent().removeClass('comboBoo-list-active');
				$(combo_active_link).removeClass('comboBoo-label-active');
				$(combo_active_link).set('text',el.get('text'));
				$(combo_linked_input).set('value',el.get('value'));
			
				window.location.href = el.get('id');
			}
		});

	});

});



/***
 * Add by Laurent Doreille 18/08/2008
 */

function hasClass(ele,cls)
{
	return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}

function addClass(ele,cls)
{
	if (!this.hasClass(ele,cls)) ele.className += " "+cls;
}

function removeClass(ele,cls)
{
	if (hasClass(ele,cls))
	{
		var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
		ele.className=ele.className.replace(reg,' ');
	}
}

function sleep(milliseconds) {


	var start = new Date().getTime();
	for (var i = 0; i < 1e7; i++) {
		if ((new Date().getTime() - start) > milliseconds){
			break;
		}
	}
}

/*
to create dynamic tabs
 */

/**
 * cette fonction ne fonctionne pas lorsque l'on sort du contenaire
 * et que l'on clique.
 * 
 * 
$('body').addEvent('click',
		function (){
	if(combo_active!="")
	{
		if (combo_chosen==false)
		{
			$(combo_active).removeClass('comboBoo-list-active');
			$(combo_active_link).removeClass('comboBoo-label-active');
		}
		else
		{
			combo_chosen=false;
		}
	}
}
);

*/
function clicBody(){
	if(combo_active!="")
	{
		if (combo_chosen==false)
		{
			$(combo_active).removeClass('comboBoo-list-active');
			$(combo_active_link).removeClass('comboBoo-label-active');
		}
		else
		{
			combo_chosen=false;
		}
	}

}

// used for the rollover on news / market news pages
function activateBackground(el) {
	el.style.backgroundColor = '#F1EEEA';
}
function deactivateBackground(el) {
	el.style.backgroundColor = '';
}



