/********************* Single div Show Hide ********************************/


//This js is used in the QuarterlyResults page

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}



$(document).ready(

function() {

//we need to parse the URL to see if we are on the quarterly results page - ajh 4.14.09
	var string=(location.href); 
//alert("eagh");
if (string.indexOf('uarterly')>0){
	$('div.thelanguage:first').show();
	$('img.toggleImage:first').attr({src: "images/arrow-down.gif"});
}
	
	
//Below i've added logic so that the toggle will work together with the expand all and collapse all. This logic tests the src attribute of the arrow image to determine if it needs to open or close - ajh 4.14.09	
	$('div.technology').toggle(
	function() {

		var imgSrc = $(this).find(".toggleImage").attr("src");
		
		if (imgSrc.indexOf("arrow-rt.gif")>0){
			imgSrc = $(this).find(".toggleImage").attr("src").replace( /\-rt.gif$/, '-down.gif');
		$(this).next(".thelanguage").slideDown();
		$(this).find(".toggleImage").attr("src", imgSrc);
		}
		else if (imgSrc.indexOf("arrow-down.gif")>0){
			imgSrc = $(this).find(".toggleImage").attr("src").replace( /\-down.gif$/, '-rt.gif');
		$(this).next(".thelanguage").slideUp();
		$(this).find(".toggleImage").attr("src", imgSrc);
		}
		
	},
	
	function() {
		//this function is identical to the above, so that the logic happens on either toggle state. - ajh 4.14.09
		var imgSrc2 = $(this).find(".toggleImage").attr("src");
		

		if (imgSrc2.indexOf("arrow-rt.gif")>0){
			imgSrc2 = $(this).find(".toggleImage").attr("src").replace( /\-rt.gif$/, '-down.gif');
		$(this).next(".thelanguage").slideDown();
		$(this).find(".toggleImage").attr("src", imgSrc2);
		}
		else if (imgSrc2.indexOf("arrow-down.gif")>0){
			imgSrc2 = $(this).find(".toggleImage").attr("src").replace( /\-down.gif$/, '-rt.gif');
		$(this).next(".thelanguage").slideUp();
		$(this).find(".toggleImage").attr("src", imgSrc2);
		}
	});
});

/********************* All divs Show Hide ********************************/
$(document).ready(function() 
{
	// hides the slickbox as soon as the DOM is ready
	// (a little sooner than page load)
	
	//this fixed IE6 bug where triangle gifs disappear on collapse - ajh 4.23.09
	MM_preloadImages('images/arrow-rt.gif','images/arrow-down.gif')
	
	
	
	
	// shows the slickbox on clicking the noted link
	
	$('a.ResultsExpandAll').click(	
		function() {
			var imgSrc = $(".toggleImage").attr("src").replace( /\-rt.gif$/, '-down.gif');
			$('div.thelanguage').slideDown();
			$(".toggleImage").attr("src", imgSrc);
			$('.thelanguage:visible').trigger('click');
			}
		);

	// hides the slickbox on clicking the noted link
	
	$('a.ResultsCollapseAll').click(
		function() {
			var imgSrc = $(".toggleImage").attr("src").replace( /\-down.gif$/, '-rt.gif');
			$('div.thelanguage').slideUp();
			$(".toggleImage").attr("src", imgSrc);
			//alert("eagh");
			//$('.thelanguage:hidden').trigger('click');
			}
		);
	}
);

