
$(window).load(function() {
	
		//$("#fullReference").html('<img src="images/fancybox/fancy_progress.png" alt="" border="0" class="referenceLoader" style="padding: 40px 0 0 100px;" />');
		var first_id = $(".reference_title:first").attr("id");
		//alert(first_id);
		$(".reference_title:first").parents("tr").addClass("active");
		get_reference(first_id);
		
		$("#table_references").jTPS( {perPages:[10,'Kaikki']} );
		
		
		$(".reference_title").click(function () {
			//$(this).addClass("active");	
			$(".reference_title").parents("tr").removeClass("active");
			$(this).parents("tr").addClass("active");

			$("#fullReference").fadeOut("fast");
			
			var id = $(this).attr('id');
			get_reference(id);	
		});
		
		function get_reference(id)
		{
			var t = new Date();
			var timestamp = t.getTime();
			//alert(timestamp);
			$.get("www/xbrand/index.php/reference/show_ajax/" + id + "/" + timestamp,
		 	 	function(data) {
					//alert(data);
		 	 		$("#fullReference").html(data).fadeIn("fast");
		 	 		
		 	 		/*
		 	 		$('a.fancybox').live('click', function() {
		  				$('.fancybox').fancybox();
						//alert('_');
					});
		 	 		*/
		 	 		
		 	 		//$("a.fancybox").fancybox();
		 	 		//$('a.fancybox').click(function () {
					//	alert('.');
					//});
 			   });
			
		}
		
});
