
	$(document).ready( function () {
							 
	/* DIAGRAMS FUNCTIONS */
	$("#diagram #content_diagram .accordion").css("display","none");
	$("#diagram #content_diagram .fullDisplay").css("display","block");
	
	$("#diagram #content_diagram #loadingFrame").css("display","block");
	$("#diagram #content_diagram").addClass("javascript");
	$("#html_bottom").addClass("javascript");
	
	
	
	$(window).load( function () {
		$("#diagram #content_diagram #loadingFrame").css("display","none");
	
				
		
		$("#diagram #content_diagram .accordion").fadeIn(1800, function () {
			initDiagram();		
			preFlashyDiagram(0);
			preFlashy = setInterval(function(){preFlashyDiagram(0);},7000);
		});
	});
								 
});
	
	function initDiagram () {
		
	
		$("#diagram #content_diagram .item  .resized").click(
			function () {
				if ($(this).height() != $("img",this).height()) {
					
					
					$("#html_bottom").animate({ 
						opacity: "0.04"
					},  { queue:false, duration:1200 } );
					
					
					$("#content_diagram .item .resized").animate({ 
						height: "24px"
					},  { queue:false, duration:1200 } );
					
					$(this).animate({ 
						height: $("img",this).height()
					},  { queue:false, duration:1200 } );
				} else {
					
					
					$(this).animate({ 
						height: "24px"
					},  { queue:false, duration:1200 } );
					
					$("#html_bottom").animate({ 
						opacity: "1"
					},  { queue:false, duration:1200 } );
				}

			}				
		);
		
		
		
		$("#diagram #content_diagram .item  .resized").mouseover(
			function () {
				clearInterval(preFlashy);
				$("#content_diagram .item .resized").dequeue();
				if ($(this).height() != $("img",this).height()) {
					$(this).animate({ 
						opacity: "0.6"
					},  { queue:true, duration:150 } ).animate({ 
						opacity: "1"
					},  { queue:true, duration:150 } );
				}
			}
		);
		
		
		$("#diagram img.fullDisplay").bind("click",function () {$(this).fullDisplay();});
		
		$("#content_for_print").html($("#content_diagram .accordion").html());
		$("#html_bottom_for_print").html($("#html_bottom").html());
		
	}


	/* Pre animation for flashy diagram */
	function preFlashyDiagram (i) {
		
		if ("#content_diagram .accordion .item:nth(" + i + ") .resized") {
			$("#content_diagram .accordion .item:nth(" + i + ") .resized").animate({ 
						opacity: "0.6"
					},  { queue:true, duration:150 } ).animate({ 
						opacity: "1"
					},150 , function (){preFlashyDiagram (i + 1)} );
		}
	}

	$.fn.fullDisplay = function () {
		clearInterval(preFlashy);
		
		$("#diagram img.fullDisplay").unbind();
		
		$("#diagram img.fullDisplay").animate({ 
			opacity: 0
		},600, function () { 
			$(this).attr("src","/diagrams/images/diagramarrow_up.gif");
			$(this).attr("alt","Collapse all"); 
			$(this).attr("title","Collapse all"); 
		}).animate({ 
			opacity: 1
		},  {queue:true,  duration: 600 } );
		
		
		
		$("#html_bottom").animate({ 
			opacity: "0.04"
		},  { queue:false, duration:1200 } );
		
		
		$("#content_diagram .item .resized").each(
			function () {
				$(this).animate({ 
					height: $("img",this).height()
				},  { queue:false, duration:1200 } );
			}
		);
		$("#diagram img.fullDisplay").bind("click",function () {$(this).smallDisplay();});
	}						
	
	$.fn.smallDisplay = function () {
		clearInterval(preFlashy);
		
		$("#diagram img.fullDisplay").unbind();
		
		$("#diagram img.fullDisplay").animate({ 
			opacity: 0
		},600, function () { 
			$(this).attr("src","/diagrams/images/diagramarrow_down.gif");
			$(this).attr("alt","Expand all"); 
			$(this).attr("title","Expand all"); 
		}).animate({ 
			opacity: 1
		},  {queue:true,  duration: 600 } );
		
		
		$("#content_diagram .item .resized").each(
			function () {
				$(this).animate({ 
					height: "24px"
				},  { queue:false, duration:1200 } );
			}
		);
		$("#html_bottom").animate({ 
			opacity: "1"
		},  { queue:false, duration:1200 } );
		
		$("#diagram img.fullDisplay").bind("click",function () {$(this).fullDisplay();});
	}							
	
