// JavaScript Document

var relatedUL 	= new Array;

var showing 	= new Array;

var changing 	= new Array;

var arrow	 	= new Array;



function getChildULid(parent){

		var HDid 		= $(parent).id;

		var lastdash 	= HDid.lastIndexOf('_');

		var ULid 		= HDid.substring(0,lastdash);

		return ULid; 

}
function initCategories(){

		/*if (location.hash == "#shottreatments")
		{
			setTimeout("shottreatment()",500);	
		}*/

		relatedUL = $$('a.section_info_header');

		relatedUL.each(

				function(e,index){



						var ULid = getChildULid(e);

						//arrows = e.select('img');

						//arrow[index] = arrows[0];

						

						/*if(index == 0){

								showing[index] = true;

								$(ULid).setStyle({ display:'block' });

								arrow[index].src = '/img/message_arrow_showing.gif';

						} else {*/

								showing[index] = false;

								$(ULid).setStyle({ display:'none' });

								//arrow[index].src = '/img/message_arrow_hidden.gif';
								$(ULid+'_hd').setStyle({ backgroundImage : 'url(/img/message_arrow_hidden.gif)' });

						//}



						Event.observe(e, 'click', function(e){ e.stop(); toggleCategory(index); }, false);

						changing[index] = false;

				}

		)
		
		if ($('culture_nav_1') != null){Event.observe('culture_nav_1', 'click', showSimple, false)};
		if ($('culture_nav_2') != null){Event.observe('culture_nav_2', 'click', showInventive, false)};
		if ($('culture_nav_3') != null){Event.observe('culture_nav_3', 'click', showReliable, false)};
		if ($('culture_nav_4') != null){Event.observe('culture_nav_4', 'click', showEveryone, false)};
		
		if ($('stock_nav_1') != null){Event.observe('stock_nav_1', 'click', showPrice, false)};
		if ($('stock_nav_2') != null){Event.observe('stock_nav_2', 'click', showQuote, false)};
		if ($('stock_nav_3') != null){Event.observe('stock_nav_3', 'click', showCalculator, false)};
		if ($('stock_nav_4') != null){Event.observe('stock_nav_4', 'click', showHistoric, false)};
		
		if ($('activities_nav_1') != null){Event.observe('activities_nav_1', 'click', showStationary, false)};
		if ($('activities_nav_2') != null){Event.observe('activities_nav_2', 'click', showLighters, false)};
		if ($('activities_nav_3') != null){Event.observe('activities_nav_3', 'click', showShavers, false)};
		if ($('activities_nav_4') != null){Event.observe('activities_nav_4', 'click', showPromo, false)};
		if ($('activities_nav_5') != null){Event.observe('activities_nav_5', 'click', showOther, false)};

}



function toggleCategory(HDkey){

		if(!changing[HDkey]){



				changing[HDkey] = true;

				
				
				var ULid = getChildULid(relatedUL[HDkey]);
				

				if(showing[HDkey]){

					/*	if(Prototype.Browser.IE){ //sick of writing hacks for internet explorer... just do a show / hide

								$(ULid).hide(); showing[HDkey] = false; changing[HDkey] = false;

						} else {*/

								Effect.BlindUp($(ULid), { duration: 0.7, afterFinish: function() { showing[HDkey] = false; changing[HDkey] = false; } });

								
						//}

						//arrow[HDkey].src = '/img/message_arrow_hidden.gif';
						$(ULid+'_hd').setStyle({ backgroundImage : 'url(/img/message_arrow_hidden.gif)' });

				} else {

					/*	if(Prototype.Browser.IE){

								$(ULid).show(); showing[HDkey] = true; changing[HDkey] = false;

						} else {*/

								Effect.BlindDown($(ULid), { duration: 0.7, afterFinish: function() { showing[HDkey] = true; changing[HDkey] = false; } });
						//}

						//arrow[HDkey].src = '/img/message_arrow_showing.gif';
						$(ULid+'_hd').setStyle({ backgroundImage : 'url(/img/message_arrow_showing.gif)' });

						relatedUL.each(function(e, index) {
						if(index != HDkey){
							if(showing[index])
							{
							var ULid = getChildULid(relatedUL[index]);
						  	/*if(Prototype.Browser.IE){ 

									$(ULid).hide();

							} else {*/

									Effect.BlindUp($(ULid), { duration: 0.7, afterFinish: function() { showing[index] = false; changing[index] = false; } });


							//}

							//arrow[index].src = '/img/message_arrow_hidden.gif';
							$(ULid+'_hd').setStyle({ backgroundImage : 'url(/img/message_arrow_hidden.gif)' });
						}
						}
						});


				}



		}

}
function hideCultureTabs(){
	for (i=1;i<5;i++){
		$('culture_'+i+'_detail').hide();
		$('culture_nav_'+i).removeClassName('sel');
	}
	$('culture_nav_1').removeClassName('sel_first');
	$('bottom').setStyle({ backgroundImage: 'url(/img/ie6/rg_2.gif)' });
}
function showSimple(e){
	Event.stop(e);
	pageTracker._trackPageview(window.location.pathname+"simple");
	hideCultureTabs();
	$('culture_1_detail').show();
	$('culture_nav_1').addClassName('sel_first');
}
function showInventive(e){
	Event.stop(e);
	pageTracker._trackPageview(window.location.pathname+"inventive");
	hideCultureTabs();
	$('culture_2_detail').show();
	$('culture_nav_2').addClassName('sel');
	$('bottom').setStyle({ backgroundImage: 'url(/img/rg_inventive.gif)' });
}
function showReliable(e){
	Event.stop(e);
	pageTracker._trackPageview(window.location.pathname+"reliable");
	hideCultureTabs();
	$('culture_3_detail').show();
	$('culture_nav_3').addClassName('sel');
}
function showEveryone(e){
	Event.stop(e);
	pageTracker._trackPageview(window.location.pathname+"everyone-everywhere");
	hideCultureTabs();
	$('culture_4_detail').show();
	$('culture_nav_4').addClassName('sel');
	$('bottom').setStyle({ backgroundImage: 'url(/img/rg_everyone.gif)' });
}

function hideStockTabs(){	
	for (i=1;i<5;i++){
		$('stock_'+i+'_detail').hide();
		$('stock_nav_'+i).removeClassName('sel');
	}
	$('stock_nav_1').removeClassName('sel_first');
	$('stock_nav_4').removeClassName('sel_last');
	//$('bottom').setStyle({ backgroundImage: 'url(/img/ie6/rg_2.gif)' });
}
function showPrice(e){
	Event.stop(e);
	pageTracker._trackPageview(window.location.pathname+"share-price");
	hideStockTabs();
	$('stock_1_detail').show();
	$('stock_nav_1').addClassName('sel_first');
}
function showQuote(e){
	Event.stop(e);
	pageTracker._trackPageview(window.location.pathname+"stock-quote");
	hideStockTabs();
	$('stock_2_detail').show();
	$('stock_nav_2').addClassName('sel');
	$('if_quote').src = "http://qfx.quartalflife.com/clients/fr/bic/sm6/Default.aspx?culture=fr-FR";
	//$('bottom').setStyle({ backgroundImage: 'url(/img/rg_inventive.gif)' });
}
function showCalculator(e){
	Event.stop(e);
	pageTracker._trackPageview(window.location.pathname+"calculator");
	hideStockTabs();
	$('stock_3_detail').show();
	$('stock_nav_3').addClassName('sel');
	$('if_calc').src = "http://ir.quartalflife.com/ic/controller?client=bic&lang=fr";
}
function showHistoric(e){
	Event.stop(e);
	pageTracker._trackPageview(window.location.pathname+"historic");
	hideStockTabs();
	$('stock_4_detail').show();
	$('stock_nav_4').addClassName('sel_last');
	$('if_hist').src = "http://ir3.quartalflife.com/data/bic/download_f.php";
	//$('bottom').setStyle({ backgroundImage: 'url(/img/rg_everyone.gif)' });
}






function hideActivitiesTabs(){
	for (i=1;i<6;i++){
		$('activities_'+i+'_detail').hide();
		$('activities_nav_'+i).removeClassName('sel');
	}
	if($('activities_nav_1')!=null){$('activities_nav_1').removeClassName('sel_first');}
	if($('activities_nav_5')!=null){$('activities_nav_5').removeClassName('sel_last');}
	$('bottom').setStyle({ backgroundImage: 'url(/img/ie6/rg_2.gif)' });
}
function showStationary(e){
	Event.stop(e);
	pageTracker._trackPageview(window.location.pathname+"stationery");
	hideActivitiesTabs();
	$('activities_1_detail').show();
	$('activities_nav_1').addClassName('sel_first');
}
function showLighters(e){
	Event.stop(e);
	pageTracker._trackPageview(window.location.pathname+"lighters");
	hideActivitiesTabs();
	$('activities_2_detail').show();
	$('activities_nav_2').addClassName('sel');
	$('bottom').setStyle({ backgroundImage: 'url(/img/rg_lighters.gif)' });
}
function showShavers(e){
	Event.stop(e);
	pageTracker._trackPageview(window.location.pathname+"shavers");
	hideActivitiesTabs();
	$('activities_3_detail').show();
	$('activities_nav_3').addClassName('sel');
	$('bottom').setStyle({ backgroundImage: 'url(/img/rg_shavers.gif)' });
}
function showPromo(e){
	Event.stop(e);
	pageTracker._trackPageview(window.location.pathname+"promotional-products");
	hideActivitiesTabs();
	$('activities_4_detail').show();
	$('activities_nav_4').addClassName('sel');
	$('bottom').setStyle({ backgroundImage: 'url(/img/ie6/rg_2.gif)' });
}
function showOther(e){
	Event.stop(e);
	pageTracker._trackPageview(window.location.pathname+"other-products");
	hideActivitiesTabs();
	$('activities_5_detail').show();
	$('activities_nav_5').addClassName('sel_last');
	$('bottom').setStyle({ backgroundImage: 'url(/img/rg_otherproducts.gif)' });
}
Event.observe(window, 'load', initCategories, false);
