$(document).ready(function() {
	
	//dropDownMenu();
	
	noteSlider(4000);
	
	portfolio();
	
});

function dropDownMenu() {
	
	$("#menu ul li ul").css({display: "none"});
	  
	$("#menu ul li").hover(function() {
		$(this).find('ul:first').stop().css({ display: 'inline', opacity: 0 }).animate({ opacity: 1 }, 300); //Slides down when hover the UL
		$(this).children('a').addClass("hovered"); //Adds a hovered class, so you can see the menu path you are following
	}
	,function() {
		$(this).find('ul:first').stop().animate({ opacity: 0 }, 300); //Slides up on mouseleave
		$(this).children('a').removeClass("hovered"); //removes the hovered class.
	});
	
}

function noteSlider($time) {
	
	//adds the current class to the first slide
	$('#slider_note ul li:first').addClass('current');
	
	//hovering effect
	$('#slider_note ul li').hover(function() {
		
		$(this).children('div').css({ opacity: 0, display: 'block' }).stop().animate({ opacity: 1 }, 300);
		
	}, function() {
		
		$(this).children('img').stop().animate({ opacity: 1 }, 200);
		$(this).children('div').stop().animate({ opacity: 0 }, 200);
		
	});
	
	if(typeof(isHovered) == 'undefined') { var isHovered = 0; }
	//If no item has been hovered yet, the variable isHovered doesn't exist, so we create it. 
		
	$("#slider_note").hover(function() { // Whenever an item is hovered
		isHovered = 1; //Setting isHovered 1, we stop the autsliding from going on
	}, function() {
		isHovered = 0;//Setting isHovered 1, we make the autsliding go on
	});
	
	setInterval(function() { if(isHovered == 0) { nextNoteSlide(); } }, $time);
	
	$('#slider_note_left').click(function(){ prevNoteSlide(); });
	$('#slider_note_right').click(function(){ nextNoteSlide(); });
	
}

function nextNoteSlide() {
	
	$currentNote = $('#slider_note ul li.current');
	$nextNote = $('#slider_note ul li.current').next();
	
	//alert($nextNote.length);
	
	if($nextNote.length == 00) {
		
		$nextNote = $("#slider_note ul li:first"); 
		
	}
	
	$nextNote.addClass('next');
	$nextNote.stop().css({ left: '-171px' }).animate({ left: 0 }, {duration: 800, easing: 'easeOutBounce', complete: function() {
		
		$currentNote.removeClass('current').css({ left: '171px' });
		$nextNote.removeClass('next').addClass('current');
		
	}});
	
	
}

function prevNoteSlide() {
	
	$currentNote = $('#slider_note ul li.current');
	$nextNote = $('#slider_note ul li.current').prev();
	
	//alert($nextNote.length);
	
	if($nextNote.length == 00) {
		
		$nextNote = $("#slider_note ul li:last"); 
		
	}
	
	$nextNote.addClass('next');
	$nextNote.stop().animate({ left: 0 }, {duration: 800, easing: 'easeOutBounce', complete: function() {
		
		$currentNote.removeClass('current').css({ left: '171px' });
		$nextNote.removeClass('next').addClass('current');
		
	}});
	
	
}

function portfolio() {
	
	$('.portfolio_image ul li').hover(function() {
		
		$(this).children('img').stop().animate({ opacity: .7 }, 400);
		$(this).children('div').stop().css({ display: 'block', opacity: 0 }).animate({ opacity: 1 }, 400);
		
	}, function() {
		
		$(this).children('img').stop().animate({ opacity: 1 }, 250);
		$(this).children('div').stop().animate({ opacity: 0 }, 250);
		
	});
	
		// Sign in panel toggle
	$("#signin_show").click(function(){
		$("#signin_panel").slideToggle({duration: 800, easing: 'easeOutSine'});
	},
	function(){
		$(this).find("span").stop().animate({right:'-70px'},{ queue: false, duration: 150, easing: 'easeInBack'});
	});
	// Video thumbnails Watch Now effect
	$('.video_thumbnail').hover(function(){
		$(this).find("span").stop().animate({right:'0px'},{ queue: false, duration: 300, easing: 'easeOutSine'});
	},
	function(){
		$(this).find("span").stop().animate({right:'-70px'},{ queue: false, duration: 150, easing: 'easeInBack'});
	});
	// Thumbnail pictures in Browse album pages
	$('.pictures_entry a').hover(function(){
		$(this).find("img").stop().animate({opacity:'0.25'},{ queue: false, duration: 600, easing: 'easeOutSine'});
	},
	function(){
		$(this).find("img").stop().animate({opacity:'1'},{ queue: false, duration: 400, easing: 'easeOutSine'});
	});
}
