jQuery(document).ready(function($) {
	
var $content = $('#content-wraper'),
$girl = $('#girl'),
$allNavLinksLi = $('#menu-main-navigation li'),
URL = '',
title = '';
//navigation animation
	$('.menu-main-navigation-container ul li a').attr('style','background-position:0 -36px');
	$('.menu-main-navigation-container ul li.current-menu-item a').attr('style','background-position:0 0');
	$('.menu-main-navigation-container ul li a').hover(function(){
			if(!$(this).parent().hasClass('current-menu-item')){
				$(this).stop().animate({backgroundPosition:"0 0"},{duration:300});
			}
		},function(){
			if(!$(this).parent().hasClass('current-menu-item')){
				$(this).stop().animate({backgroundPosition:"0 -36px"},{duration:300});
			}
	});
//home fader
if($('#home-fader').length!=0 && navigator.appName != "Microsoft Internet Explorer"){
	var counter = $('#home-fader img').length-1;
	setInterval (function homeFaderChange(){
		$("#home-fader img:eq("+counter+")").fadeOut(1500, function(){
			$('#home-fader').prepend($(this));		
			$('#home-fader img:eq(0)').fadeIn(0);	
		});}
	,6000 );
}
//end of home fader shit
//about page pics
if($('.about-pics').length!=0 && navigator.appName != "Microsoft Internet Explorer"){
	$('.about-pics img:first-child').addClass('first');
	$('.about-pics img:nth-child(2)').addClass('second').rotate('-10deg');
	$('.about-pics img:nth-child(3)').addClass('third').rotate('20deg');

	setInterval (function aboutPicsChange(){
		$('#about-pics-slide-show-1 .second').animate({rotate: '0deg'},1000);
		$('#about-pics-slide-show-1 .third').animate({rotate: '-10deg'},1000);
		$('#about-pics-slide-show-1 .first').fadeOut(1000, function(){
			$('#about-pics-slide-show-1').append($(this));
			$('#about-pics-slide-show-1 .first').animate({rotate: '20deg'},0).fadeIn(1000);
			$('#about-pics-slide-show-1 img').removeClass('first').removeClass('second').removeClass('third');
			$('#about-pics-slide-show-1 img:first-child').addClass('first');
			$('#about-pics-slide-show-1 img:nth-child(2)').addClass('second');
			$('#about-pics-slide-show-1 img:nth-child(3)').addClass('third');
		});}
	, 5000 );

	setInterval (function aboutPicsChange(){
		$('#about-pics-slide-show-2 .second').animate({rotate: '0deg'},1000);
		$('#about-pics-slide-show-2 .third').animate({rotate: '-10deg'},1000);
		$('#about-pics-slide-show-2 .first').fadeOut(1000, function(){
			$('#about-pics-slide-show-2').append($(this));
			$('#about-pics-slide-show-2 .first').animate({rotate: '20deg'},0).fadeIn(1000);
			$('#about-pics-slide-show-2 img').removeClass('first').removeClass('second').removeClass('third');
			$('#about-pics-slide-show-2 img:first-child').addClass('first');
			$('#about-pics-slide-show-2 img:nth-child(2)').addClass('second');
			$('#about-pics-slide-show-2 img:nth-child(3)').addClass('third');
		});}
	, 5000 );
}
//end of about page stuff
//portfolio page stuff
$('#portfolio-categories a').live('click', function(){
	
	href = $(this).attr('href');
	$('#portfolio-thumbs').load(href+"?size=thumb&file="+href , function(){
		$('#portfolio-display').load(href+"?size=full&file="+href , function(){
			changePortImg($('#portfolio-thumbs img:first-child'));
		});
	});
	$('#portfolio-categories a').removeClass('active');
	$(this).addClass('active');
	return false;

})
function changePortImg(image){
	src = $(image).attr('src').split('/');
	srcLen = src.length - 1 ;
	$('#portfolio-display img').parent().fadeOut(1000);
	$('#portfolio-display img[src $= "'+src[srcLen]+'"]').parent().fadeIn(1000);
}
$('#portfolio-thumbs img').live('click', function(){
	changePortImg($(this));
})
$('#portfolio-categories a:first-child').click();

//prettyphoto for members gallery

if($("a[rel^='prettyPhoto']").length!=0){
	$("a[rel^='prettyPhoto']").prettyPhoto({theme: 'facebook' /* light_rounded / dark_rounded / light_square / dark_square / facebook */});
}

});

$("section h1").append("<span class='arrow'></span>");
$("h1 .arrow").hide();
$(".members #content-inner h1").hover(function(){
	$(this).children('.arrow').stop().fadeIn(600);
},function(){
	$(this).children('.arrow').stop().fadeOut(600);
});
$("section h1").toggle(function(){$(this).siblings().slideUp();}, function(){$(this).siblings().slideDown();});


//end of my js stuff



/**
 * @author Alexander Farkas
 * v. 1.21
 * background position plugin
 */


(function($) {
	if(!document.defaultView || !document.defaultView.getComputedStyle){ // IE6-IE8
		var oldCurCSS = jQuery.curCSS;
		jQuery.curCSS = function(elem, name, force){
			if(name === 'background-position'){
				name = 'backgroundPosition';
			}
			if(name !== 'backgroundPosition' || !elem.currentStyle || elem.currentStyle[ name ]){
				return oldCurCSS.apply(this, arguments);
			}
			var style = elem.style;
			if ( !force && style && style[ name ] ){
				return style[ name ];
			}
			return oldCurCSS(elem, 'backgroundPositionX', force) +' '+ oldCurCSS(elem, 'backgroundPositionY', force);
		};
	}
	
	var oldAnim = $.fn.animate;
	$.fn.animate = function(prop){
		if('background-position' in prop){
			prop.backgroundPosition = prop['background-position'];
			delete prop['background-position'];
		}
		if('backgroundPosition' in prop){
			prop.backgroundPosition = '('+ prop.backgroundPosition;
		}
		return oldAnim.apply(this, arguments);
	};
	
	function toArray(strg){
		strg = strg.replace(/left|top/g,'0px');
		strg = strg.replace(/right|bottom/g,'100%');
		strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
		var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
		return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
	}
	
	$.fx.step. backgroundPosition = function(fx) {
		if (!fx.bgPosReady) {
			var start = $.curCSS(fx.elem,'backgroundPosition');
			
			if(!start){//FF2 no inline-style fallback
				start = '0px 0px';
			}
			
			start = toArray(start);
			
			fx.start = [start[0],start[2]];
			
			var end = toArray(fx.options.curAnim.backgroundPosition);
			fx.end = [end[0],end[2]];
			
			fx.unit = [end[1],end[3]];
			fx.bgPosReady = true;
		}
		//return;
		var nowPosX = [];
		nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
		nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];           
		fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];

	};
})(jQuery);

