$(document).ready(function() {
	$("header#masthead nav ul:last-child").css({width: "96px"})
	$("header#masthead nav ul:last-child li").css({width: "96px"})
	$("header#masthead nav ul:last-child li a").css({width: "82px"})
	
	$('#content header').css({'width': '+=14', 'left': '-14px' });
	
	$('[title]').removeAttr('title');
	
	//hiding and showing .hidden
	$('.hidden').hide();
	$("h3.info").css({cursor: "pointer"})
	$("h3.info").hover(
		function () {
			$(this).addClass("hover");
		},
		function () {
			$(this).removeClass("hover");
		}
	);
	

if ($("#divisional-wheel").length > 0){

	//var $tip = $('<img src="/wp-content/themes/SLATTERY/images/tip.png"/>');
	//$("#divisional-wheel section div").append($tip);	
	$("#divisional-wheel section div").hide();
	$("#divisional-wheel section h2").hover(
		function () {
			$(this).parents("section").children("div").show(200);
			//$(this).parents("section").children("div").css({'top': '70px', 'left': '50%', 'opacity': '0.3'});
			//$(this).parents("section").children("div").animate( { top:"50px", opacity:"1"}, 200 );
		},
		function () {
			$(this).parents("section").children("div").hide(200);
			//$(this).parents("section").children("div").animate( { top:"70px", opacity:"0"}, 100).animate( { top:"-9999px", left:"-9999px", opacity:"1"}, 0);
			//$(this).parents("section").children("div").children("img").animate( { opacity:"0"}, 100).animate( {opacity:"1"}, 0);
		}
	);

	
}

if ($("body.page-template-homepage-php").length > 0){
	$('.green').parents("body").addClass("green");
	$('.pink').parents("body").addClass("pink");
	$('.yellow').parents("body").addClass("yellow");
	$('.orange').parents("body").addClass("orange");
	$('.blue').parents("body").addClass("blue");
	$('.red').parents("body").addClass("red");

}

if ($("#latestwork").length > 0){
	$('#content section:first-child').append($("#latestwork"));
}


if ($("#people").length > 0){

	//move the image in pixel
	var move = -10;
	
	//zoom percentage, 1.2 =120%
	var zoom = 1.2;

	//On mouse over those thumbnail
	$('.person').hover(function() {
		
		//Set the width and height according to the zoom percentage
		width = $('.person').width() * zoom;
		height = $('.person').height() * zoom;
		
		//Move and zoom the image
		$(this).find('img').stop(false,true).animate({'width':width, 'height':height, 'top':move, 'left':move}, {duration:200});
		
		//Display the caption
		$(this).find('div.caption').stop(false,true).fadeIn(200);
	},
	function() {
		//Reset the image
		$(this).find('img').stop(false,true).animate({'width':$('.person').width(), 'height':$('.person').height(), 'top':'0', 'left':'0'}, {duration:100});	

		//Hide the caption
		$(this).find('div.caption').stop(false,true).fadeOut(200);
	});
	
	

/*	$('div.caption').css("cursor","pointer").click(function () {
		var addr = $(this).children('h2').children('a').attr("href");
		window.location = addr;
      });*/

}


/*if ($("#mainimage").length > 0){
	$(function(){
		$('#mainimage img').captify({});
	});
}*/

if ($("body.home #mainimage").length > 0){

	$("#captionbox").animate( { bottom:"-200px"}, 0 );
	
	$('#mainimage div#cycle').cycle({ 
		fx:      'scrollLeft', 
		speed:    500, 
		timeout:  6000,
		random:  1,
		after:     function() {
            $('body.home #mainimage #captionbox p').html(this.alt);
        }
	});

	$("#mainimage #cycle img").hover(
		function () {
			$("#captionbox").animate( { bottom:"0"}, 300 );
		},
		function () {
			$("#captionbox").animate( { bottom:"-200px"}, 300 );
		}
	);
	
}




if ($("body.page-template-division-php #mainimage").length > 0){

	$("#captionbox").animate( { bottom:"-200px"}, 0 );
	
	var texty= $('#mainimage img:first-child').attr('alt');
	
	$('#mainimage #captionbox p').html(texty);
	
	$('#mainimage div#cycle').cycle({ 
		fx:      'scrollLeft', 
		speed:    500, 
		timeout:  6000,
		random:  1,
		after:     function() {
            $('#mainimage #captionbox p').html(this.alt);
        }
	});

	$("#mainimage #cycle img").hover(
		function () {
			$("#captionbox").animate( { bottom:"0"}, 300 );
		},
		function () {
			$("#captionbox").animate( { bottom:"-200px"}, 300 );
		}
	); 
	
}





});

	
	




