window.scroll(0,0);
	
$(document).ready(function() {
	$("#information > li").hide();
	$("#information > li:eq(0)").show();
	$("#section-menu li:eq(0)").addClass("selected");
	
	$("#section-menu a").click(function(){
		$("#section-menu li").removeClass("selected");
		$(this).parent().addClass("selected");
		var index = 0;
		for( i = 0; i < $("#section-menu li").length; i++){
			if($("#section-menu li:eq("+i+")").hasClass("selected")){
				index = i;
			}
		}
		$("#information > li.selected").fadeOut("fast");
		$("#information > li").removeClass("selected");
		$("#information > li:eq("+index+")").addClass("selected");
		$("#information > li.selected").fadeIn("fast", function(){
			$(this).blur();
			if($("#information > li.selected .start").length > 0){
				$("#information > li.selected .start").focus();
			}
			if(toSubMenu){
				window.scroll(0,findPosY(document.getElementById(url[1])));
				toSubMenu = false;
			}
		});
		window.scroll(0,0);
		return false;
	});
	
	$("div.quick-links li a, #information a[href*='#']").click(function(){
		var element = $(this).attr("href").split("#")[1];
		if($("a[href='#"+ element +"']").length){
			if($("#section-menu a[href='#"+ element +"']").length){
				$("a[href='#"+ element +"']").click();
			} else {		 
				$("a[href='#"+ $("#" + element).siblings("h2").attr("id") +"']").click().chain(function(){
					$("a[href='#"+ element +"']").click();
				});
			}
			return false;
		}
	});

	//veryfi if the url has an anchor to navitate 
	var url = document.URL.split("#");
	var toSubMenu = false; 
	if(url.length > 1){
		//test to see if it's a main section
		if($("#" + url[1]).length){
			if($("h2#"+url[1]).length){	
				$('a[href="#'+url[1]+'"]').click();
			}else{ 	//it is a sub-section
				$("a[href='#"+ $("#" + url[1]).siblings("h2").attr("id") +"']").click();
				toSubMenu = true;
			}	
		} 		
	}
	
	
	
	//To control maxwidth, create object only on pages without submenus
	if (! $("#section-menu").length ){	
		var myElementMax = new ElementMaxHeight;
	}

function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }


});
