/* ======================================================================================
 * Filename: theme/javascript/functions.js
 * Author: Rebecca Skeers, rebecca@webmistress.com.au, www.webmistress.com.au
 * Copyright: Rebecca Skeers
 * Date: 1 Mar 2011
 * Description: JavaScript functions for the Designed Objects Tasmania website.
 * Visual design: Tracey Allen, tracey@traceyallen.com, www.traceyallen.com
 *
 * This file may not be used for any purpose other than for the Designed Objects Tasmania 
 * website and may not be copied or modified without written permission from the author.
 * ======================================================================================
 */

$(document).ready(function()
{	
	$("a[rel='external']").attr("target","_blank");
	
	$("#subnav a").each(
		function( intIndex )
		{
			var tooltip = $("<div class=\"tooltip\">"+$(this).attr("title")+"</div>");
			$(this).after(tooltip);
		}	
	);
	
	$("#subnav li a").hover(
		function () { $(this).closest("li").addClass("hover"); },
		function() { $(this).closest("li").removeClass("hover"); }
	);
	
	if($("#section-artists").length)
		$("#section-artists #content p").last().addClass("last");
	
	if($("#scrollbar").length)
		$('#content').tinyscrollbar();
		
	if($("#section-home").length)
	{
		$("#homeimages li a").each(
			function( intIndex )
			{
				var overlay = $("<span></span>");
				$(this).append(overlay);
			}	
		);
		
		$("#homeimages li span").hover(
			function () { $(this).addClass("hover"); },
			function() { $(this).removeClass("hover"); }
		);
	}	
	
	if($("#image-pagination").length)
	{
		$('#image1').click(function() 
		{
			$('#image-pagination li').removeClass('active');
			$(this).closest('li').addClass('active');
			$('#page').css('background-position','0 0');
		});
	
		$('#image2').click(function() 
		{
			$('#image-pagination li').removeClass('active');
			$(this).closest('li').addClass('active');
			$('#page').css('background-position','0 -1000px');
		});
	}
});

