	/*
		Simple AJAX Albums System
		------------------------------------
		
		by Daniel Schmitz, bashgeek.net
		- 10th February 2009
	*/

		var alb_cur = 0;
		var team_cur = 0;
	
		function loadAlbum (team, album, atitle, image, type, width, height, title)
		{
			alb_cur = album;
			team_cur = team;
			
			// atitle switch
				document.getElementById('album_atitle').innerHTML = atitle;
			// imagelist
				Lokris.AjaxCall('/libraries/ajax/?type=teams_albums&sub=list&albumid='+album, _loadAlbum_List);
			// load first image
				switchImage(image, type, width, height, title);
		}
		
		function _loadAlbum_List (ret)
		{
			document.getElementById('album_images').scrollTop = 0;
			document.getElementById('album_images').innerHTML = ret;
		}
		
		function switchImage (image, type, width, height, title)
		{
			// switchbar
				Lokris.AjaxCall('/libraries/ajax/?type=teams_albums&sub=switch&albumid='+alb_cur+'&imageid='+image, _switchImage_RC);
			
			var static_url = "http://static1.reprogrammed.net/cmstorm/teams/"+team_cur+"/"+alb_cur+"/";

			document.getElementById('album_cur_img').src = "";
			
			document.getElementById('album_cur_link').href = static_url + image + "." + type;
			document.getElementById('album_cur_link').title = title;

			var max_width = 400;
			var max_height = 300;
			if (width >= height && width > max_width)
			{
				document.getElementById('album_cur_img').width = max_width;
				document.getElementById('album_cur_img').height = Math.floor(max_width * height / width);
			}
			else if (width < height && height > max_height)
			{
				document.getElementById('album_cur_img').width = Math.floor(max_height * width / height);
				document.getElementById('album_cur_img').height = max_height;
			}
			else
			{
				document.getElementById('album_cur_img').width = width;
				document.getElementById('album_cur_img').height = height;
			}
			
			document.getElementById('album_cur_img').alt = title;
			document.getElementById('album_cur_img').title = title;
			document.getElementById('album_cur_img').src = static_url + image + "." + type;
		}
		
		function _switchImage_RC (ret)
		{
			document.getElementById('album_image_switch').innerHTML = ret;
		}
