// JavaScript Document

var agt=navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );

var isOldIE = (is_ie5 || is_ie5_5 || is_ie6);


function hover(obj,boolLinked)
{
	var useHover = true;
	if(boolLinked)
	{
		if(obj.getElementsByTagName("a").length == 0)
			useHover = false;
	}
	
	if (isOldIE && useHover)
	{				
		if (obj.className.indexOf("hover") == -1)
		{
			obj.className += " hover";
		}
		else
		{
			obj.className = obj.className.substring(0,obj.className.length - 6);
		}
	}
}

function linkContainer_click(pushItem, pageTrackerView)
{
	if(pageTrackerView != null && pageTrackerView != "")
	{	
		// alert(pageTrackerView);
		pageTracker._trackPageview(pageTrackerView);
	}
			
	var links = pushItem.getElementsByTagName("a");
	
	if(links.length > 0)
	{
		this.window.location.href = links[0].href;
	}
}

var visibleShortCutId = 0;

function showShortcut(id) 
{	
	if(id != "")
	{
		$("#quick_selector").attr("disabled", "true");
		$("#shortcut").css("cursor", "progress");

		if(visibleShortCutId > 0)
		{
			height = $("#shortcut_info_" + visibleShortCutId).height();
			
			$("#shortcut_info_" + visibleShortCutId).animate(
				{ height: "0px" },
				350,
				function()
				{
					$("#shortcut").height("148px");
					
					$("#shortcut_info_" + visibleShortCutId).hide();
					$("#shortcut_info_" + visibleShortCutId).height(height + "px");
																					
					visibleShortCutId = 0;
				});
		}
				
		$("#shortcut").animate(
			{ width: "323px" },
			350,
			function()
			{
				$("div#shortcut_start img.ajaxLoading").show();
				
//				Post slutade funka helt plöstligt, kan inte hitta varför... /bang				
//				$("#shortcut_info_" + id + " #projectList").load(document.location + " .shortcut_projects", { AreaPageLinkId : id }, function()
				$("#shortcut_info_" + id + " #projectList").load(document.location + "?AreaPageLinkId=" + id + " .shortcut_projects", null, function()
				{
					$("#shortcut_images").show();
					
					var height = $("#shortcut_info_" + id).height();
					
					$("#shortcut").height("auto");
					$("#shortcut_info_" + id).height("0px").show();
					
					$("#shortcut_info_" + id).animate({ height: height + "px" }, 350, function()
					{
						$("#shortcut").addClass("expanded");
					});

					$("#quick_selector").attr("disabled", "");
					$("#shortcut").css("cursor", "");
					
					$("div#shortcut_start img.ajaxLoading").hide();
					
					visibleShortCutId = id;					
				});
			});
	}
}

function hideShortcut() 
{
	if(visibleShortCutId > 0)
	{
		height = $("#shortcut_info_" + visibleShortCutId).height();
		
		$("#shortcut_info_" + visibleShortCutId).animate(
			{ height: "0px" },
			350,
			function()
			{
				$("#shortcut").height("148px");
				
				$("#shortcut_info_" + visibleShortCutId).hide();
				$("#shortcut_info_" + visibleShortCutId).height(height + "px");
																
				$("#shortcut").animate({ width: "148px" }, 350, function()
				{
					$("#shortcut_images").hide();
					$("#shortcut").removeClass("expanded");
					document.getElementById("quick_selector").selectedIndex = 0;
				});
				
				visibleShortCutId = 0;
			});
	}	
}