/**
 * @author Nazzanuk
 */

$(document).ready( function() {

	$('.menuitem').jrumble();
	$('.y1').jrumble();
	
	$(".y1").each( function() {
		logoFade (this);
	})
	
	function logoFade (block) {
		$(block).fadeIn(Math.floor(Math.random()*6000), function () {
			$(block).fadeOut(Math.floor(Math.random()*6000), function () {
				logoFade (block);
			});
		});
	}
	
	$(".singlenav").hover( function() {
		$(this).stop(true,true).fadeTo(200, 0.6)
	}, function() {
		$(this).stop(true,true).fadeTo(200, 1)
	})

	$(".showcase").hover( function() {
		$(this).find('.logoimage').stop(true,true).fadeTo(300, 0)
	}, function() {
		$(this).find('.logoimage').stop(true,true).fadeTo(1200, 1)
	})

	$(".portfolio-image").hover( function() {
		$(this).find('.portfolio-desc').stop(true,true).fadeTo(200, 0.8)
	}, function() {
		$(this).find('.portfolio-desc').stop(true,true).fadeTo(200, 0)
	})
	
	$(".showcase, .singlenav").click( function() {
		$(".singlenav").each(function(){ $(this).css("background","#fff") })
		if ($(this).attr('class') == "singlenav") { $(this).css("background","#743399") }
		dd = $(this).attr('data-distance')
		$("#insidefocus").stop().animate({
			marginLeft: dd
		}, 1000, "easeInOutExpo", function() {
			// Animation complete.
		});
	})
	
	$(".singlenav").each(function(){
		$(this).attr('data-clicked','0')
	})
	
	$(".singlenav").first().click();
	$(".singlenav").first().attr('data-clicked','1');
	
	function nextNav() { 
		oflag = true;
		$(".singlenav").each(function(){
			if ($(this).attr('data-clicked') == '1') { 
				
				$(this).attr('data-clicked','0')
				$(this).next().attr('data-clicked','1')
				$(this).next().click();
				oflag = false;
				return false;
			}
		});
		
		if (oflag){
			$(".singlenav").first().click();
			$(".singlenav").first().attr('data-clicked','1');
		}
		
		setTimeout(nextNav,3000);
	}
	
	setTimeout(nextNav,2000);
	
});

