// Menu hover
//______________________________________________________________________________________________

	function mainmenu(){
	$("#menu ul ul, #sub-menu ul ul").css({display: "none"}); // Opera Fix
	$("#menu ul li, #sub-menu ul li").hover(function(){
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).show(220);
		},function(){
		$(this).find('ul:first').css({visibility: "hidden"});
		});
	}
	$(document).ready(function(){		
		mainmenu();
	});

	$(function() {
		$('#menu ul a, #sub-menu ul a').each(function() {
		if ( $(this).parent('li').children('ul').size() > 0 ) {
		$(this).append('<span class="menu-right-arrow">&ensp;&#43;</span>');
        }           
	});
	});

// Link hover
//______________________________________________________________________________________________

	$(document).ready(function(){

		$(".social a, .info-social a, .button, .fade, .search-wrap").css("opacity","0.65");


		$(".social a, .info-social a, .button, .fade, .search-wrap").hover(function() {
			$(this).stop().animate({opacity:1},'fast');
			
		}, function() {
		$(".social a, .info-social a, .button, .fade, .search-wrap").stop().animate({opacity:0.65},'fast');
		});
	});
	
	
	
	$(document).ready(function(){

		$(".info").hover(function() {
        		$(this).animate({ width: "310px", height: "130px"}, 250);
			
		}, function() {
       			 $(this).animate({ width: "20px", height: "110px"}, 250);
		});
	});
	
	
	$(document).ready(function(){
	

		$(".social").hover(function() {
        		$(this).animate({ height: "35px"}, 250);
			
		}, function() {
       			 $(this).animate({ height: "15px"}, 250);
		});
	});
	
// Back to top link
//______________________________________________________________________________________________


	
$(document).ready(function() {
$('.scrollPage').click(function() {
   var elementClicked = $(this).attr("href");
   var destination = $(elementClicked).offset().top;
   $("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination-0}, 500 );
   return false;
});
});

	
// Tooltip
//______________________________________________________________________________________________
	
	function tooltip(target_items, name){
 	$(target_items).each(function(i){
		$("body").append("<div class='"+name+"' id='"+name+i+"'><p>"+$(this).attr('title')+"</p></div>");
		var my_tooltip = $("#"+name+i);

		if($(this).attr("title") != ""){ // checks if there is a title

		$(this).removeAttr("title").mouseover(function(){
				my_tooltip.css({display:"none"}).fadeIn(100);
		}).mousemove(function(kmouse){
				my_tooltip.css({left:kmouse.pageX+10, top:kmouse.pageY+21});
		}).mouseout(function(){
				my_tooltip.fadeOut(100);
		});

		}
	});
	}

	$(document).ready(function(){
		tooltip(".social a, #wp-calendar *,.addtooltip *, .addtooltip","tooltip");
	});
	
// Slider
//______________________________________________________________________________________________
	
$(document).ready(function() {

	//Set Default State of each portfolio piece
	$(".paging").show();
	$(".paging a:first").addClass("active");
		
	//Get size of images, how many there are, then determin the size of the image reel.
	var imageWidth = $(".window").width();
	var imageSum = $(".image_reel img").size();
	var imageReelWidth = imageWidth * imageSum;
	
	//Adjust the image reel to its new size
	$(".image_reel").css({'width' : imageReelWidth});
	
	//Paging + Slider Function
	rotate = function(){	
		var triggerID = $active.attr("rel") - 1; //Get number of times to slide
		var image_reelPosition = triggerID * imageWidth; //Determines the distance the image reel needs to slide

		$(".paging a").removeClass('active'); //Remove all active class
		$active.addClass('active'); //Add active class (the $active is declared in the rotateSwitch function)
		
		//Slider Animation
		$(".image_reel").animate({ 
			left: -image_reelPosition
		}, 500 );
		
	}; 
	
	//Rotation + Timing Event
	rotateSwitch = function(){		
		play = setInterval(function(){ //Set timer - this will repeat itself every 3 seconds
			$active = $('.paging a.active').next();
			if ( $active.length === 0) { //If paging reaches the end...
				$active = $('.paging a:first'); //go back to first
			}
			rotate(); //Trigger the paging and slider function
		}, 7000); //Timer speed in milliseconds (3 seconds)
	};
	
	rotateSwitch(); //Run function on launch
	
	//On Hover
	$(".image_reel a").hover(function() {
		clearInterval(play); //Stop the rotation
	}, function() {
		rotateSwitch(); //Resume rotation
	});	
	
	//On Click
	$(".paging a").click(function() {	
		$active = $(this); //Activate the clicked paging
		//Reset Timer
		clearInterval(play); //Stop the rotation
		rotate(); //Trigger rotation immediately
		rotateSwitch(); // Resume rotation
		return false; //Prevent browser jump to link anchor
	});	
	
});

// Toggles
//______________________________________________________________________________________________


$(document).ready(function(){

	$(".toggle_container").hide(); 

	$("h3.trigger").click(function(){
		$(this).toggleClass("active").next().slideToggle("fast");
		return false;
	});

});




