/**
	To make your life easier, all the scripts that are loaded once the DOM has fully loaded have been written here.
	These scripts are linked to the Practica Theme @ ThemeForest.net by Christopher 'crozer' Honninger
**/

$(document).ready(function() { /* ///// start DOM ready ///// */
						   
	/** Style Switcher **/
	$('.styleSwitcherClose').toggle(function() {
		$('.styleSwitcher').fadeOut();
	}, function() {
		$('.styleSwitcher').fadeIn();
	}); 
	$('ul.styleSwitcher li').find(":contains('bg')").click(function() {
		var anchorClass = $(this).attr('class');
		$('body')[0].className = $('body')[0].className.replace(/\bbg.*?\b/g, '');
		$('body').addClass(anchorClass);
		}, function() {
			/**/ 
	});
	$('a.onoffSwitchDim').click(function() {
		$('.dimWrap_navi, .dimWrap_content, .dimWrap_portfolio, .dimWrap_bottom, .dimWrap_title').toggle();
		
		$('.dimWrap_title:visible').toggleClass('dimWrap_title_blue');
		$('.dimWrap_title:visible').toggleClass('dimWrap_title_liblue');
		$('.dimWrap_title:visible').toggleClass('dimWrap_title_img');
		$('.dimWrap_title:visible').toggleClass('dimWrap_title_brown');
		$('.dimWrap_title:visible').toggleClass('dimWrap_title_red');
		$('.dimWrap_title:visible').toggleClass('dimWrap_title_purple');
		$('.dimWrap_title:visible').toggleClass('dimWrap_title_pink');
		$('.dimWrap_title:visible').toggleClass('dimWrap_title_orange');
		$('.dimWrap_title:visible').toggleClass('dimWrap_title_white');
		$('.dimWrap_title:visible').toggleClass('dimWrap_title_green');
		$('.dimWrap_title:visible').toggleClass('dimWrap_title_lime');
		
		if( $('.dimWrap_title').is(':hidden') == true) {
			$('.dimWrap_title_blue, .dimWrap_title_liblue, .dimWrap_title_img, .dimWrap_title_brown, .dimWrap_title_red, .dimWrap_title_purple, .dimWrap_title_pink, .dimWrap_title_orange, .dimWrap_title_white, .dimWrap_title_green, .dimWrap_title_lime').css('display', 'none');
		} else {
			// Do nothing for now
		}
	});
	
	/** Improved Hover Effect **/
	if (($.browser.webkit) || ($.browser.mozilla && $.browser.version > '2.0')) { 
		$('.effectStack').addClass('modernEffectStack');
	} else {
		$('.effectStack img.grayscale').hover(function() {
			$(this).stop().animate({'opacity':'0'}, 600);
			$('img.color').stop().animate({'opacity':'1'}, 0);
		}, function() {
			$(this).stop().animate({'opacity':'1'}, 600);
			$('img.color').stop().animate({'opacity':'0'}, 600);
		});
	}
	
	/** Portfolio Categories Slide **/
	$('.trigger').click(function() {
		var $marginLefty = $(this).next();
			$marginLefty.animate({
				marginLeft: parseInt($marginLefty.css('marginLeft'),10) === 0 ?
			-$marginLefty.outerWidth() :
			0
		});
	});
	
	/** Portfolio Description Hide/show **/
	$('.descr').hover(function() {
		$(this).hide();
	}, function() {
		$(this).show();
	});
	
	/** jTruncator **/
    $('.descrText').jTruncate({
        length: 100,
        minTrail: 0,
        moreText: '&#91;..&#93;'
	});
    $('.descrTitle').jTruncate({
        length: 20,
        minTrail: 0,
        moreText: '..'
	});
	
	/** About Social Info (Rotating Plus Hover effect) **/
	$(".idOne").hover(function() {
		$(".aboutMoreContentDone1").delay(400).fadeIn("fast");
		$(".triggerAbout1").animate({ 
			rotate: '-=90deg',
			opacity:1 }, 400);
		}, function() {
			$(".triggerAbout1").delay(400).animate({ opacity: 0 }, "fast");
			$(".aboutMoreContentDone1").fadeOut("fast");
	});
	$(".triggerAbout1").click(function() {
			var $marginLefty = $(this).next();
				$marginLefty.animate({
					marginLeft: parseInt($marginLefty.css('marginLeft'),10) === 0 ?
				-$marginLefty.outerWidth() : 0
			}, function() {
				$(this).addClass("aboutMoreContentDone1");
				$(this).mouseleave(function() { /**/ });
		});
	});
	$(".idTwo").hover(function() {
		$(".aboutMoreContentDone2").delay(400).fadeIn("fast");
		$(".triggerAbout2").animate({ 
			rotate: '-=90deg',
			opacity:1 }, 400);
		}, function() {
			$(".triggerAbout2").delay(400).animate({ opacity: 0 }, "fast");
			$(".aboutMoreContentDone2").fadeOut("fast");
	});
	$(".triggerAbout2").click(function() {
			var $marginLefty = $(this).next();
				$marginLefty.animate({
					marginLeft: parseInt($marginLefty.css('marginLeft'),10) === 0 ?
				-$marginLefty.outerWidth() : 0
			}, function() {
				$(this).addClass("aboutMoreContentDone2");
				$(this).mouseleave(function() { /**/ });
		});
	});
	$(".idThree").hover(function() {
		$(".aboutMoreContentDone3").delay(400).fadeIn("fast");
		$(".triggerAbout3").animate({ 
			rotate: '-=90deg',
			opacity:1 }, 400);
		}, function() {
			$(".triggerAbout3").delay(400).animate({ opacity: 0 }, "fast");
			$(".aboutMoreContentDone3").fadeOut("fast");
	});
	$(".triggerAbout3").click(function() {
			var $marginLefty = $(this).next();
				$marginLefty.animate({
					marginLeft: parseInt($marginLefty.css('marginLeft'),10) === 0 ?
				-$marginLefty.outerWidth() : 0
			}, function() {
				$(this).addClass("aboutMoreContentDone3");
				$(this).mouseleave(function() { /**/ });
		});
	});
		
	/** Pretty Photo **/
	$("a[rel^='prettyPhoto']").prettyPhoto({
		allow_resize: true,
		theme: 'facebook' /* light_rounded / dark_rounded / light_square / dark_square / facebook */
	});
	
	/** jQZoom **/
	$('.zoomedImage').jqzoom({
	});
	
	/** .info Scroll Pane **/
	$('li.info').jScrollPane({
		scrollbarOnLeft : true,
		dragMinHeight : 10
	});
	
}); /* ///// end DOM ready ///// */
	
/** Nivo slider start-up and settings **/
$(window).load(function() {
	$('#slider').nivoSlider({
		effect:'random', //Specify sets like: 'fold,fade,sliceDown'
		slices:15,
		animSpeed:500, //Slide transition speed
		pauseTime:3000,
		startSlide:0, //Set starting Slide (0 index)
		directionNav:false, //Next and Prev
		directionNavHide:false, //Only show on hover
		controlNav:true, //1,2,3...
		controlNavThumbs: false, //Use thumbnails for Control Nav
		controlNavThumbsFromRel:false, //Use image rel for thumbs
		controlNavThumbsSearch: '.jpg', //Replace this with...
		controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
		keyboardNav:true, //Use left and right arrows
		pauseOnHover:true, //Stop animation while hovering
		manualAdvance:false, //Force manual transitions
		captionOpacity:0.8, //Universal caption opacity
		beforeChange: function(){},
		afterChange: function(){},
		slideshowEnd: function(){} //Triggers after all slides have been shown
	});
});
