/**********************************************************
***	TIMELINE
**********************************************************/

	var iToggle = 1;
	var iBuoyid = 0;
	
	var iWidth = 386;
	var iWidth2 = 350;
	iWidthBoth = iWidth + iWidth2;
	

	
	function jsNextVideo(e)
	{

		$(".VideoContainer").hide();
		$("#"+e).show();

	}
	
	
	function jsToggle(e) // show tooltip
	{
		$("#"+e).toggle();
	}
	
	function jsToggleInfo(id, category) // if infofield is hidden
	{
		if(iToggle == 0)
		{
			jsLoadPage(id, category);
			jsExpand();
			iBuoyid = id;	
		}
		else if(iToggle > 0 && iBuoyid == id) //if infofield is showing, and a the same buoy is clicked again
		{
			jsHide();
			iBuoyid = id;
		}
		else //if infofield is showing, and a different buoy is clicke
		{
			iBuoyid = id;
			jsLoadPage(id, category);
		}
	}
	
	function jsHide()
	{
	
		if(iToggle == 1)
		{
			$("#InfoField").animate({"right": "-="+iWidth+"px"}, "fast");
		} else if (iToggle == 2)
		{
			$("#InfoField").animate({"right": "-="+ iWidthBoth +"px"}, "fast");
		}
		iToggle = 0;
	}
	
	function jsExpand()
	{
		if(iToggle == 0)
		{
			$("#InfoField").animate({"right": "+="+iWidth+"px"}, "fast");
			iToggle++;
		}
		else if(iToggle == 1)
		{
			$("#InfoField").animate({"right": "+="+iWidth2+"px"}, "fast");
			iToggle++;
		}
	}
	
	function jsLoadPage(id, category)
	{
		jsShowLoader()
		setTimeout(function()
		{
			$("#Info").load("../../load_timeline_info.asp", "I="+id+"&C="+category, function() {
				jsGetImages();
				$("#RelatedImages").show();
			});
		}
		, 0);
	}
	
	function jsToggleVideo()
	{
		$("#RelatedImages").hide();
		$("#RelatedVideo").show();
		jsExpand()
	}
	
	function jsToggleImages()
	{	
		$("#RelatedVideo").hide();
		$("#RelatedImages").show();
		jsExpand();
	}
	
	function jsShowLoader()
	{
		document.getElementById("Info").innerHTML = '<div id="InfoText"><img id="Loader" src="../../images/gfx/ajax-loader.gif" alt="Loader" /></div>';
	}
	
	function jsGetImages()
	{		
	
			$("#RelatedImages").find("a[href*='image_listgroup.asp']").each(function() {
				
				var url = $(this).attr('href');
				var catId = 0;
				var arrRequestVars = url.split("?");
				
				arrRequestVars = arrRequestVars[1].split("&");
				
				for(i=0; i<arrRequestVars.length; i++){
					var arrRequestVar = arrRequestVars[i].split("=");
					if(arrRequestVar[0] == "iGroupId"){
						catId = arrRequestVar[1];
					}
				}
				
				$.get("../../load_images.asp", { id: catId },
				function(result){
					$("#RelatedImages").append(result);
				});
				
				$(this).remove();
			});

	}
	
	function jsShowVideo(e)
	{
		$("#"+e).show();
	}
