var isIE6=false;

$(document).ready(function() 
{
	runOnDOMready()
});

	function runOnDOMready()
	{
		
		function a(c)
		{
			var e=navigator.userAgent;
			var b=e.indexOf(c);
			if(b==-1)
			{
				return
			}
			var d=parseFloat(e.substring(b+c.length+1));
			return d.toString().split(".")[0]
		}
		
	
		
		if(!isIE6)
		{
			paddingBottom();
			slideFunctions();
			$.scrollTo("showreel",600)
		}

	}
	
	function paddingBottom()
	{
		if(!isIE6){var a=$(window).height();var c=$("#nav").height();var b=$("#nav").css("top");var d=$("div.section").height();b=b.replace(/px/g,"");b=b*1;
		if(a>=(c+b)){$("#content").css("padding-bottom",(a-(c+b)+(b-d)))
	}
}
}

window.onresize=paddingBottom;
function slideFunctions()
{
	$("div#tools").hide();
	var e=false;var l=
	{
		toolsVisible:true,currentBlock:"#"+$("div.section:first-child").attr("id"),people:0,weddings:0,performers:0
	};
	var j={next:$("div#tools ul li.next"),previous:$("div#tools ul li.previous")
};

j.previous.addClass("inactive");
$("div#content ul.gallery li img").after('<div class="wrapper"><span class="left"></span><span class="right"></span></div>');
$("div#lightbox ul li img").after('<div class="wrapper"></div>');

var m=new Array();
$("div#people ul.gallery li img").each(function(n,o)
{
	m[n]=$(o).width();$(o).next().attr("index",n)
});

var a=new Array();
$("div#weddings ul.gallery li img").each(function(n,o)
{
	a[n]=$(o).width();$(o).next().attr("index",n)
});

var z=new Array();
$("div#performers ul.gallery li img").each(function(n,o)
{
	z[n]=$(o).width();$(o).next().attr("index",n)
});

$("div#people-thumbs ul li img").each(function(n,o)
	{
		$(o).next().attr("index",n)
	});

$("div#weddings-thumbs ul li img").each(function(n,o)
	{
		$(o).next().attr("index",n)
	});

$("div#performers-thumbs ul li img").each(function(n,o)
	{
		$(o).next().attr("index",n)
	});

$("div#nav ul a[href^=#]").click(function(n)
	{
		if($(this).attr("href").length>1)
		{
			n.preventDefault();l.currentBlock=$(this).attr("href");
			$.scrollTo(l.currentBlock,600);
			$("div#nav").find("li").removeClass("current");
			$(this).parent().addClass("current");
			if(l.currentBlock=="#contact"||l.currentBlock=="#about"||l.currentBlock=="#showreel")
			{
				h()
			}
			else if(l.currentBlock=="#weddings"||l.currentBlock=="#people"||l.currentBlock=="#performers")
			{
				b()
			}
		}
	});


$("div#tools ul li.next a[href^=#]").click(function(n)
	{
		n.preventDefault();
		if(!$(this).parent().hasClass("inactive")&&!e)
		{
			e=true;
			if(l.currentBlock=="#people")
			{
				l.people++
			}
			else if(l.currentBlock=="#weddings")
			{
				l.weddings++
			}
			else if(l.currentBlock=="#performers")
			{
				l.performers++
			}
			g("next")
		}
	});

$("div#tools ul li.previous a[href^=#]").click(function(n)
{
	n.preventDefault();
	if(!$(this).parent().hasClass("inactive")&&!e)
	{
		e=true;
		if(l.currentBlock=="#people")
		{
			l.people--
		}
		else if(l.currentBlock=="#weddings")
		{
			l.weddings--
		}
		else if(l.currentBlock=="#performers")
		{
			l.performers--
		}
		g("previous")
	}
});

$("div#tools p a[href^=#]").click(function(n)
	{
		n.preventDefault()
	});

$("div#content ul.gallery li div.wrapper").click(function(n)
{
	d("#"+$(this).parent().parent().parent().attr("id"),$(this).attr("index"))
});

$("div#content ul.gallery li.back a[href^=#]").click(function(n)
{
	n.preventDefault();
	d("#"+$(this).parent().parent().parent().attr("id"),0)
});

$("div#tools p a[href^=#]").click(function(n)
{
	n.preventDefault();f()
});

$("div#lightbox div.thumbs p a[href^=#]").click(function(n)
{
	n.preventDefault();k()
});

$("div#lightbox div.thumbs ul li div.wrapper").click(function(n)
{
	n.preventDefault();k(true,l.currentBlock,$(this).attr("index"))
});

function h()
{
	if(l.toolsVisible)
	{
		l.toolsVisible=false;
		$("div#tools").animate({top:"-130px"},600)
	}
}

function b()
{
	$("div#tools").show();
	c();
	if(!l.toolsVisible)
	{
		l.toolsVisible=true;$("div#tools").animate({top:"597px"},600)
	}
}

function c()
{
	if(l.currentBlock=="#people")
	{
		l.people==0?j.previous.addClass("inactive"):j.previous.removeClass("inactive");l.people==(m.length-1)?j.next.addClass("inactive"):j.next.removeClass("inactive")
	}
	else if(l.currentBlock=="#weddings")
	{
		l.weddings==0?j.previous.addClass("inactive"):j.previous.removeClass("inactive");l.weddings==(a.length-1)?j.next.addClass("inactive"):j.next.removeClass("inactive")
	}
	else if(l.currentBlock=="#performers")
	{
		l.performers==0?j.previous.addClass("inactive"):j.previous.removeClass("inactive");l.performers==(z.length-1)?j.next.addClass("inactive"):j.next.removeClass("inactive")
	}
}
	
function g(r)
{
	c();
	var q,o,p,n,s;
	if(l.currentBlock=="#people")
	{
		q=$("div#people ul.gallery").css("left").replace(/px/g,"");o=m;s=l.people*1
	}
	else if(l.currentBlock=="#weddings")
	{
		q=$("div#weddings ul.gallery").css("left").replace(/px/g,"");o=a;s=l.weddings*1
	}
	else if(l.currentBlock=="#performers")
	{
		q=$("div#performers ul.gallery").css("left").replace(/px/g,"");o=z;s=l.performers*1
	}
	q=q*1;p=$("ul.gallery li").css("margin-right").replace(/px/g,"");p=p*1;
	if(r=="next"){n=q-o[s-1]-p
}
else
{
	n=q+o[s]+p}$(l.currentBlock+" ul.gallery").animate({left:n+"px"},600,function()
	{
		e=false
	})
}

function d(p,n)
{
	if(!e)
	{
	e=true;
	if(l.currentBlock!=p)
	{
		l.currentBlock=p;$.scrollTo(l.currentBlock,600);setTimeout(o,600);$("div#nav").find("li").removeClass("current");$("div#nav li a[href^="+l.currentBlock+"]").parent().addClass("current");b()
	}
	else
	{
		o()
	}
}
	
function o()
{
	var u,s,t,r,v,q;v=n*1;
	if(l.currentBlock=="#people")
	{
		u=$("div#people ul.gallery").css("left").replace(/px/g,"");s=m;q=l.people;l.people=v
	}
	else if(l.currentBlock=="#weddings")
	{
		u=$("div#weddings ul.gallery").css("left").replace(/px/g,"");s=a;q=l.weddings;l.weddings=v
	}
	else if(l.currentBlock=="#performers")
	{
		u=$("div#performers ul.gallery").css("left").replace(/px/g,"");s=z;q=l.performers;l.performers=v
	}
	c();u=u*1;t=$("ul.gallery li").css("margin-right").replace(/px/g,"");t=t*1;r=u;
	if(q<v)
	{
		for(i=q;i<v;i++){r=r-s[i]-t}
	}
	else
	{
		if(q>v)
		{
			for(i=q;i>v;i--){r=r+s[i-1]+t
		}
	}
}

$(l.currentBlock+" ul.gallery").animate(
	{
		left:r+"px"
	}
	,600
	,function()
	{
		e=false
	})
}}

function f()
{

}

function k(o,p,n,z)
{

}

};