// 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 shottreatment()
{
	Effect.ScrollTo('shottreatment', { duration: 0, offset: 0 });
}

function showSohoVideo(e)
{
	Event.stop(e);
	$('soho_smooth_video').show();
}

function hideSohoVideo(e)
{
	Event.stop(e);
	$('soho_smooth_video').hide();
}

function initCategories(){
	
	if ($('soho_smooth_video_close') != null){Event.observe('soho_smooth_video_close', 'click', hideSohoVideo, false)};
	if ($('soho_smooth_video_open') != null){Event.observe('soho_smooth_video_open', 'click', showSohoVideo, false)};

		if (location.hash == "#shottreatments")
		{
			setTimeout("shottreatment()",500);	
		}

		relatedUL = $$('a.related_content_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/products/chem/arrow_showing.gif';

						} else {*/

								showing[index] = false;

								$(ULid).setStyle({ display:'none' });

								arrow[index].src = '/img/products/chem/arrow_hidden.gif';

						//}



						Event.observe(e, 'click', function(e){ e.stop(); toggleCategory(index); }, false);

						changing[index] = 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/products/chem/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/products/chem/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 });


							//}

							arrow[index].src = '/img/products/chem/arrow_hidden.gif';
						}
						}
						});


				}



		}

}


Event.observe(window, 'load', initCategories, false);


