//IGNORE
/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 5/25/2009
 * @author Ariel Flesler
 * @version 1.4.2
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
/*ColorBox v1.3.6 - a full featured, light-weight, customizable lightbox based on jQuery 1.3 */
(function(c){function r(b,d){d=d==="x"?m.width():m.height();return typeof b==="string"?Math.round(b.match(/%/)?d/100*parseInt(b,10):parseInt(b,10)):b}function M(b){b=c.isFunction(b)?b.call(i):b;return a.photo||b.match(/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i)}function Y(){for(var b in a)if(c.isFunction(a[b])&&b.substring(0,2)!=="on")a[b]=a[b].call(i);a.rel=a.rel||i.rel;a.href=a.href||i.href;a.title=a.title||i.title}function Z(b){i=b;a=c.extend({},c(i).data(q));Y();if(a.rel&&a.rel!=="nofollow"){g= c(".cboxElement").filter(function(){return(c(this).data(q).rel||this.rel)===a.rel});j=g.index(i);if(j<0){g=g.add(i);j=g.length-1}}else{g=c(i);j=0}if(!B){C=B=n;N=i;N.blur();c(document).bind("keydown.cbox_close",function(d){if(d.keyCode===27){d.preventDefault();e.close()}}).bind("keydown.cbox_arrows",function(d){if(g.length>1)if(d.keyCode===37){d.preventDefault();D.click()}else if(d.keyCode===39){d.preventDefault();E.click()}});a.overlayClose&&s.css({cursor:"pointer"}).one("click",e.close);c.event.trigger(aa); a.onOpen&&a.onOpen.call(i);s.css({opacity:a.opacity}).show();a.w=r(a.initialWidth,"x");a.h=r(a.initialHeight,"y");e.position(0);O&&m.bind("resize.cboxie6 scroll.cboxie6",function(){s.css({width:m.width(),height:m.height(),top:m.scrollTop(),left:m.scrollLeft()})}).trigger("scroll.cboxie6")}P.add(D).add(E).add(t).add(Q).hide();R.html(a.close).show();e.slideshow();e.load()}var q="colorbox",F="hover",n=true,e,x=c.browser.msie&&!c.support.opacity,O=x&&c.browser.version<7,aa="cbox_open",H="cbox_load",S= "cbox_complete",T="resize.cbox_resize",s,k,u,p,U,V,W,X,g,m,l,I,J,K,Q,P,t,E,D,R,y,z,v,w,i,N,j,a,B,C,$={transition:"elastic",speed:350,width:false,height:false,innerWidth:false,innerHeight:false,initialWidth:"400",initialHeight:"400",maxWidth:false,maxHeight:false,scalePhotos:n,scrolling:n,inline:false,html:false,iframe:false,photo:false,href:false,title:false,rel:false,opacity:0.9,preloading:n,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:false,overlayClose:n, slideshow:false,slideshowAuto:n,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",onOpen:false,onLoad:false,onComplete:false,onCleanup:false,onClosed:false};e=c.fn.colorbox=function(b,d){var h=this;if(!h.length)if(h.selector===""){h=c("<a/>");b.open=n}else return this;h.each(function(){var f=c.extend({},c(this).data(q)?c(this).data(q):$,b);c(this).data(q,f).addClass("cboxElement");if(d)c(this).data(q).onComplete=d});b&&b.open&&Z(h);return this};e.init=function(){function b(d){return c('<div id="cbox'+ d+'"/>')}m=c(window);k=c('<div id="colorbox"/>');s=b("Overlay").hide();u=b("Wrapper");p=b("Content").append(l=b("LoadedContent").css({width:0,height:0}),J=b("LoadingOverlay"),K=b("LoadingGraphic"),Q=b("Title"),P=b("Current"),t=b("Slideshow"),E=b("Next"),D=b("Previous"),R=b("Close"));u.append(c("<div/>").append(b("TopLeft"),U=b("TopCenter"),b("TopRight")),c("<div/>").append(V=b("MiddleLeft"),p,W=b("MiddleRight")),c("<div/>").append(b("BottomLeft"),X=b("BottomCenter"),b("BottomRight"))).children().children().css({"float":"left"}); I=c("<div style='position:absolute; top:0; left:0; width:9999px; height:0;'/>");c("body").prepend(s,k.append(u,I));if(x){k.addClass("cboxIE");O&&s.css("position","absolute")}p.children().bind("mouseover mouseout",function(){c(this).toggleClass(F)}).addClass(F);y=U.height()+X.height()+p.outerHeight(n)-p.height();z=V.width()+W.width()+p.outerWidth(n)-p.width();v=l.outerHeight(n);w=l.outerWidth(n);k.css({"padding-bottom":y,"padding-right":z}).hide();E.click(e.next);D.click(e.prev);R.click(e.close);p.children().removeClass(F); c(".cboxElement").live("click",function(d){if(d.button!==0&&typeof d.button!=="undefined")return n;else{Z(this);return false}})};e.position=function(b,d){function h(A){U[0].style.width=X[0].style.width=p[0].style.width=A.style.width;K[0].style.height=J[0].style.height=p[0].style.height=V[0].style.height=W[0].style.height=A.style.height}var f=m.height();f=Math.max(f-a.h-v-y,0)/2+m.scrollTop();var o=Math.max(document.documentElement.clientWidth-a.w-w-z,0)/2+m.scrollLeft();b=k.width()===a.w+w&&k.height()=== a.h+v?0:b;u[0].style.width=u[0].style.height="9999px";k.dequeue().animate({width:a.w+w,height:a.h+v,top:f,left:o},{duration:b,complete:function(){h(this);C=false;u[0].style.width=a.w+w+z+"px";u[0].style.height=a.h+v+y+"px";d&&d()},step:function(){h(this)}})};e.resize=function(b){function d(){a.w=a.w||l.width();a.w=a.mw&&a.mw<a.w?a.mw:a.w;return a.w}function h(){a.h=a.h||l.height();a.h=a.mh&&a.mh<a.h?a.mh:a.h;return a.h}function f(G){e.position(G,function(){if(B){if(x){A&&l.fadeIn(100);k[0].style.removeAttribute("filter")}if(a.iframe)l.append("<iframe id='cboxIframe'"+ (a.scrolling?" ":"scrolling='no'")+" name='iframe_"+(new Date).getTime()+"' frameborder=0 src='"+a.href+"' "+(x?"allowtransparency='true'":"")+" />");l.show();Q.show().html(a.title);if(g.length>1){P.html(a.current.replace(/\{current\}/,j+1).replace(/\{total\}/,g.length)).show();E.html(a.next).show();D.html(a.previous).show();a.slideshow&&t.show()}J.hide();K.hide();c.event.trigger(S);a.onComplete&&a.onComplete.call(i);a.transition==="fade"&&k.fadeTo(L,1,function(){x&&k[0].style.removeAttribute("filter")}); m.bind(T,function(){e.position(0)})}})}if(B){var o,A,L=a.transition==="none"?0:a.speed;m.unbind(T);if(b){l.remove();l=c('<div id="cboxLoadedContent"/>').html(b);l.hide().appendTo(I).css({width:d(),overflow:a.scrolling?"auto":"hidden"}).css({height:h()}).prependTo(p);c("#cboxPhoto").css({cssFloat:"none"});O&&c("select:not(#colorbox select)").filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one("cbox_cleanup",function(){this.style.visibility="inherit"});a.transition=== "fade"&&k.fadeTo(L,0,function(){f(0)})||f(L);if(a.preloading&&g.length>1){b=j>0?g[j-1]:g[g.length-1];o=j<g.length-1?g[j+1]:g[0];o=c(o).data(q).href||o.href;b=c(b).data(q).href||b.href;M(o)&&c("<img />").attr("src",o);M(b)&&c("<img />").attr("src",b)}}else setTimeout(function(){var G=l.wrapInner("<div style='overflow:auto'></div>").children();a.h=G.height();l.css({height:a.h});G.replaceWith(G.children());e.position(L)},1)}};e.load=function(){var b,d,h,f=e.resize;C=n;i=g[j];a=c.extend({},c(i).data(q)); Y();c.event.trigger(H);a.onLoad&&a.onLoad.call(i);a.h=a.height?r(a.height,"y")-v-y:a.innerHeight?r(a.innerHeight,"y"):false;a.w=a.width?r(a.width,"x")-w-z:a.innerWidth?r(a.innerWidth,"x"):false;a.mw=a.w;a.mh=a.h;if(a.maxWidth){a.mw=r(a.maxWidth,"x")-w-z;a.mw=a.w&&a.w<a.mw?a.w:a.mw}if(a.maxHeight){a.mh=r(a.maxHeight,"y")-v-y;a.mh=a.h&&a.h<a.mh?a.h:a.mh}b=a.href;J.show();K.show();if(a.inline){c('<div id="cboxInlineTemp" />').hide().insertBefore(c(b)[0]).bind(H+" cbox_cleanup",function(){c(this).replaceWith(l.children())}); f(c(b))}else if(a.iframe)f(" ");else if(a.html)f(a.html);else if(M(b)){d=new Image;d.onload=function(){var o;d.onload=null;d.id="cboxPhoto";c(d).css({margin:"auto",border:"none",display:"block",cssFloat:"left"});if(a.scalePhotos){h=function(){d.height-=d.height*o;d.width-=d.width*o};if(a.mw&&d.width>a.mw){o=(d.width-a.mw)/d.width;h()}if(a.mh&&d.height>a.mh){o=(d.height-a.mh)/d.height;h()}}if(a.h)d.style.marginTop=Math.max(a.h-d.height,0)/2+"px";f(d);g.length>1&&c(d).css({cursor:"pointer"}).click(e.next); if(x)d.style.msInterpolationMode="bicubic"};d.src=b}else c("<div />").appendTo(I).load(b,function(o,A){A==="success"?f(this):f(c("<p>Request unsuccessful.</p>"))})};e.next=function(){if(!C){j=j<g.length-1?j+1:0;e.load()}};e.prev=function(){if(!C){j=j>0?j-1:g.length-1;e.load()}};e.slideshow=function(){function b(){t.text(a.slideshowStop).bind(S,function(){h=setTimeout(e.next,a.slideshowSpeed)}).bind(H,function(){clearTimeout(h)}).one("click",function(){d();c(this).removeClass(F)});k.removeClass(f+ "off").addClass(f+"on")}var d,h,f="cboxSlideshow_";t.bind("cbox_closed",function(){t.unbind();clearTimeout(h);k.removeClass(f+"off "+f+"on")});d=function(){clearTimeout(h);t.text(a.slideshowStart).unbind(S+" "+H).one("click",function(){b();h=setTimeout(e.next,a.slideshowSpeed);c(this).removeClass(F)});k.removeClass(f+"on").addClass(f+"off")};if(a.slideshow&&g.length>1)a.slideshowAuto?b():d()};e.close=function(){c.event.trigger("cbox_cleanup");a.onCleanup&&a.onCleanup.call(i);B=false;c(document).unbind("keydown.cbox_close keydown.cbox_arrows"); m.unbind(T+" resize.cboxie6 scroll.cboxie6");s.css({cursor:"auto"}).fadeOut("fast");k.stop(n,false).fadeOut("fast",function(){c("#colorbox iframe").attr("src","about:blank");l.remove();k.css({opacity:1});try{N.focus()}catch(b){}c.event.trigger("cbox_closed");a.onClosed&&a.onClosed.call(i)})};e.element=function(){return c(i)};e.settings=$;c(e.init)})(jQuery);

/*
 * jQuery BBQ: Back Button & Query Library - v1.2.1 - 2/17/2010
 * http://benalman.com/projects/jquery-bbq-plugin/
 * 
 * Copyright (c) 2010 "Cowboy" Ben Alman
 * Dual licensed under the MIT and GPL licenses.
 * http://benalman.com/about/license/
 */
(function($,p){var i,m=Array.prototype.slice,r=decodeURIComponent,a=$.param,c,l,v,b=$.bbq=$.bbq||{},q,u,j,e=$.event.special,d="hashchange",A="querystring",D="fragment",y="elemUrlAttr",g="location",k="href",t="src",x=/^.*\?|#.*$/g,w=/^.*\#/,h,C={};function E(F){return typeof F==="string"}function B(G){var F=m.call(arguments,1);return function(){return G.apply(this,F.concat(m.call(arguments)))}}function n(F){return F.replace(/^[^#]*#?(.*)$/,"$1")}function o(F){return F.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")}function f(H,M,F,I,G){var O,L,K,N,J;if(I!==i){K=F.match(H?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);J=K[3]||"";if(G===2&&E(I)){L=I.replace(H?w:x,"")}else{N=l(K[2]);I=E(I)?l[H?D:A](I):I;L=G===2?I:G===1?$.extend({},I,N):$.extend({},N,I);L=a(L);if(H){L=L.replace(h,r)}}O=K[1]+(H?"#":L||!K[1]?"?":"")+L+J}else{O=M(F!==i?F:p[g][k])}return O}a[A]=B(f,0,o);a[D]=c=B(f,1,n);c.noEscape=function(G){G=G||"";var F=$.map(G.split(""),encodeURIComponent);h=new RegExp(F.join("|"),"g")};c.noEscape(",/");$.deparam=l=function(I,F){var H={},G={"true":!0,"false":!1,"null":null};$.each(I.replace(/\+/g," ").split("&"),function(L,Q){var K=Q.split("="),P=r(K[0]),J,O=H,M=0,R=P.split("]["),N=R.length-1;if(/\[/.test(R[0])&&/\]$/.test(R[N])){R[N]=R[N].replace(/\]$/,"");R=R.shift().split("[").concat(R);N=R.length-1}else{N=0}if(K.length===2){J=r(K[1]);if(F){J=J&&!isNaN(J)?+J:J==="undefined"?i:G[J]!==i?G[J]:J}if(N){for(;M<=N;M++){P=R[M]===""?O.length:R[M];O=O[P]=M<N?O[P]||(R[M+1]&&isNaN(R[M+1])?{}:[]):J}}else{if($.isArray(H[P])){H[P].push(J)}else{if(H[P]!==i){H[P]=[H[P],J]}else{H[P]=J}}}}else{if(P){H[P]=F?i:""}}});return H};function z(H,F,G){if(F===i||typeof F==="boolean"){G=F;F=a[H?D:A]()}else{F=E(F)?F.replace(H?w:x,""):F}return l(F,G)}l[A]=B(z,0);l[D]=v=B(z,1);$[y]||($[y]=function(F){return $.extend(C,F)})({a:k,base:k,iframe:t,img:t,input:t,form:"action",link:k,script:t});j=$[y];function s(I,G,H,F){if(!E(H)&&typeof H!=="object"){F=H;H=G;G=i}return this.each(function(){var L=$(this),J=G||j()[(this.nodeName||"").toLowerCase()]||"",K=J&&L.attr(J)||"";L.attr(J,a[I](K,H,F))})}$.fn[A]=B(s,A);$.fn[D]=B(s,D);b.pushState=q=function(I,F){if(E(I)&&/^#/.test(I)&&F===i){F=2}var H=I!==i,G=c(p[g][k],H?I:{},H?F:2);p[g][k]=G+(/#/.test(G)?"":"#")};b.getState=u=function(F,G){return F===i||typeof F==="boolean"?v(F):v(G)[F]};b.removeState=function(F){var G={};if(F!==i){G=u();$.each($.isArray(F)?F:arguments,function(I,H){delete G[H]})}q(G,2)};e[d]=$.extend(e[d],{add:function(F){var H;function G(J){var I=J[D]=c();J.getState=function(K,L){return K===i||typeof K==="boolean"?l(I,K):l(I,L)[K]};H.apply(this,arguments)}if($.isFunction(F)){H=F;return G}else{H=F.handler;F.handler=G}}})})(jQuery,this);
/*
 * jQuery hashchange event - v1.2 - 2/11/2010
 * http://benalman.com/projects/jquery-hashchange-plugin/
 * 
 * Copyright (c) 2010 "Cowboy" Ben Alman
 * Dual licensed under the MIT and GPL licenses.
 * http://benalman.com/about/license/
 */
(function($,i,b){var j,k=$.event.special,c="location",d="hashchange",l="href",f=$.browser,g=document.documentMode,h=f.msie&&(g===b||g<8),e="on"+d in i&&!h;function a(m){m=m||i[c][l];return m.replace(/^[^#]*#?(.*)$/,"$1")}$[d+"Delay"]=100;k[d]=$.extend(k[d],{setup:function(){if(e){return false}$(j.start)},teardown:function(){if(e){return false}$(j.stop)}});j=(function(){var m={},r,n,o,q;function p(){o=q=function(s){return s};if(h){n=$('<iframe src="javascript:0"/>').hide().insertAfter("body")[0].contentWindow;q=function(){return a(n.document[c][l])};o=function(u,s){if(u!==s){var t=n.document;t.open().close();t[c].hash="#"+u}};o(a())}}m.start=function(){if(r){return}var t=a();o||p();(function s(){var v=a(),u=q(t);if(v!==t){o(t=v,u);$(i).trigger(d)}else{if(u!==t){i[c][l]=i[c][l].replace(/#.*/,"")+"#"+u}}r=setTimeout(s,$[d+"Delay"])})()};m.stop=function(){if(!n){r&&clearTimeout(r);r=0}};return m})()})(jQuery,this);

/* prevent console message errors when firebug isn't active or available */

if (!window.console || !console.firebug)
{
	var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
	"group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];

	window.console = {};
	for (var i = 0; i < names.length; ++i)
		window.console[names[i]] = function() {}
}
//END IGNORE
//custom jq fn's
jQuery.fn.center = function () {  
	this.css('position','absolute');  
	this.css('left', ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + 'px');
	this.css('display','block');
	$("body").css("background-color", "#000000");
	return this;
}

//global constant vars init
var sir_heading_height, home_heading_height, pov_heading_height, suits_heading_height, suits_jason_heading_height, about_heading_height, allies_heading_height, talk_heading_height, produced_heading_height,
	sir_content_height, home_content_height, pov_content_height, suits_content_height, suits_jason_content_height, about_content_height, allies_content_height, talk_content_height, produced_content_height,
	suits_justin_heading_height, suits_ted_heading_height, suits_darin_heading_height, suits_michael_heading_height, suits_rene_heading_height, suits_rebecca_heading_height, suits_assistants_heading_height, suits_barrick_heading_height, suits_naia_heading_height, 
	suits_justin_content_height, suits_ted_content_height, suits_darin_content_height, suits_michael_content_height, suits_barrick_content_height, suits_naia_content_height,suits_rene_content_height, suits_rebecca_content_height, suits_assistants_content_height,
	production_links_height, produced_immortals_heading_height, produced_immortals_content_height, produced_mgp_heading_height, produced_mpg_content_height, produced_limitless_heading_height, produced_limitless_content_height = 0;

function init_content_states(){
	(function() {
		var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
		ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
		var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
	})();
	
	//remember heights
	//console.log("init_ content_ states");

	$("#nav_watch_this").hide();
	home_heading_height = $("#home .heading").height();
	home_content_height = $("#home div.wrap div.content").height();

	pov_heading_height = $("#pov .heading").height();
	pov_content_height = $("#pov div.wrap div.content").height();
	
	sir_heading_height = $("#sir .heading").height();
	sir_content_height = $("#sir div.wrap div.content").height();
	
	suits_heading_height = $("#suits .heading").height();
	suits_content_height = $("#suits div.wrap div.content").height();
	
	suits_jason_heading_height = $("#suits_jason .heading").height();
	suits_jason_content_height = $("#suits_jason div.wrap div.content").height();
	
	suits_justin_heading_height = $("#suits_justin .heading").height();
	suits_justin_content_height = $("#suits_justin div.wrap div.content").height();
	
	suits_ted_heading_height = $("#suits_ted .heading").height();
	suits_ted_content_height = $("#suits_ted div.wrap div.content").height();
	
	suits_darin_heading_height = $("#suits_darin .heading").height();
	suits_darin_content_height = $("#suits_darin div.wrap div.content").height();
	
	suits_michael_heading_height = $("#suits_michael .heading").height();
	suits_michael_content_height = $("#suits_michael div.wrap div.content").height();
	
	suits_rene_heading_height = $("#suits_rene .heading").height();
	suits_rene_content_height = $("#suits_rene div.wrap div.content").height();
	
	suits_barrick_heading_height = $("#suits_barrick .heading").height();
	suits_barrick_content_height = $("#suits_barrick div.wrap div.content").height();
	
	suits_naia_heading_height = $("#suits_naia .heading").height();
	suits_naia_content_height = $("#suits_naia div.wrap div.content").height();
	
	suits_rebecca_heading_height = $("#suits_rebecca .heading").height();
	suits_rebecca_content_height = $("#suits_rebecca div.wrap div.content").height();
	
	suits_assistants_heading_height = $("#suits_assistants .heading").height();
	suits_assistants_content_height = $("#suits_assistants div.wrap div.content").height();
	
	about_heading_height = $("#about .heading").height();
	about_content_height = $("#about div.wrap div.content").height();
	
	allies_heading_height = $("#allies .heading").height();
	allies_content_height = $("#allies div.wrap div.content").height();
	
	talk_heading_height = $("#talk .heading").height();
	talk_content_height = 10;
	
	produced_heading_height = $('#produced .heading').height();
	produced_content_height = $('#produced div.wrap div.content').height();
	
	produced_immortals_heading_height = $('#produced_immortals .heading').height();
	produced_immortals_content_height = $('#produced_immortals div.wrap div.content').height();
	
	produced_mgp_heading_height = $('#produced_mgp .heading').height();
	produced_mgp_content_height = $('#produced_mgp div.wrap div.content').height();
	
	produced_limitless_heading_height = $('#produced_limitless .heading').height();
	produced_limitless_content_height = $('#produced_limitless div.wrap div.content').height();
	
	production_links = $('.production_links tr').length;
	production_links_height = production_links * 62;
	
	if (production_links_height > 190) {
		production_links_height = 190;
	}
	
	production_links_height += 10;
	
	$('.production_links').css('height', production_links_height+'px');
	
	tv_links = $('.tv_links tr').length;
	tv_links_height = tv_links * 62;
	
	if (tv_links_height > 190) {
		tv_links_height = 190;
	}
	
	tv_links_height += 10;
	
	$('.tv_links').css('height', tv_links_height+'px');
	
	//reset_content_states();
	
}
function reset_content_states(a_id, t_h_top, t_c_top){
	//init to thin black line
	//console.log("reset_ content_ states");
	//console.log(pov_heading_height+ " -content:"+pov_content_height);
	

	$("article div.wrap div.content p").css({visibility:"hidden"});
	$("article div.wrap div.content table").css({visibility:"hidden"});
	$("article div.wrap div.next").css({display:"none"});
	$("article div.wrap div.talklinks").css({display:"none"});
	$("article .heading").css({height:"0px",top:t_h_top+"px"});
	$("article div.wrap div.content").css({height:"0px",padding:"0px",top:(t_h_top+5)+"px"});
	
}
function pinch_content(article_id){
	//console.log("in pinch content id:"+article_id);
	//reset_content_states();
	var the_heading_top = 0;
	var the_content_top = 0;
	var plus_padding = 20;
	
	switch (article_id){
		case "#home":
			the_heading_top = home_heading_height; the_content_top = home_content_height;
			break;
		case "#pov":
			the_heading_top = pov_heading_height; the_content_top = pov_content_height;
			break;
		case "#about":
			the_heading_top = about_heading_height; the_content_top = about_content_height;
			break;
		case "#sir":
			the_heading_top = sir_heading_height; the_content_top = sir_content_height;
			break;
		case "#suits":
			the_heading_top = suits_heading_height; the_content_top = suits_content_height;
			break;
		case "#suits_jason":
			the_heading_top = suits_jason_heading_height; the_content_top = suits_jason_content_height;
			break;
		case "#suits_justin":
			the_heading_top = suits_justin_heading_height; the_content_top = suits_justin_content_height;
			break;
		case "#suits_ted":
			the_heading_top = suits_ted_heading_height; the_content_top = suits_ted_content_height;
			break;	
		case "#suits_darin":
			the_heading_top = suits_darin_heading_height; the_content_top = suits_darin_content_height;
			break;
		case "#suits_michael":
			the_heading_top = suits_michael_heading_height; the_content_top = suits_michael_content_height;
			break;
		case "#suits_rene":
			the_heading_top = suits_rene_heading_height; the_content_top = suits_rene_content_height;
			break;
		case "#suits_barrick":
			the_heading_top = suits_barrick_heading_height; the_content_top = suits_barrick_content_height;
			break;
		case "#suits_naia":
			the_heading_top = suits_naia_heading_height; the_content_top = suits_naia_content_height;
			break;
			
		case "#suits_rebecca":
			the_heading_top = suits_rebecca_heading_height; the_content_top = suits_rebecca_content_height;
			break;
		case "#suits_assistants":
			the_heading_top = suits_assistants_heading_height; the_content_top = suits_assistants_content_height;
			break;
		case "#allies":
			the_heading_top = allies_heading_height; the_content_top = allies_content_height;
			break;
		case "#talk":
			the_heading_top = talk_heading_height; the_content_top = talk_content_height;
			break;
		case "#produced":
			the_heading_top = produced_heading_height; the_content_top = produced_content_height;
			break;
		case "#produced_immortals":
			the_heading_top = produced_immortals_heading_height; the_content_top = produced_immortals_content_height;
			break;
		case "#produced_mgp":
			the_heading_top = produced_mgp_heading_height; the_content_top = produced_mgp_content_height;
			break;
		case "#produced_limitless":
			the_heading_top = produced_limitless_heading_height; the_content_top = produced_limitless_content_height;
			break;
		default : return;
	}
	reset_content_states(article_id, the_heading_top, the_content_top);
	//console.log(the_heading_top+ " -content:"+the_content_top);

	//animate heading
	$(article_id+" div.wrap div.content, "+article_id+" .heading").css("display","block");
	$(article_id+" .heading").animate({top:"0px",height:the_heading_top+"px"},{queue:"false",duration:"slow", complete:function(){
		 if(article_id !="#suits" && article_id !="#talk" && article_id !="#allies"){//suits and talk pages has no content, so don't animate it

			$(article_id+" div.wrap div.content").animate({height:the_content_top+"px",padding:"10px"},{queue:"false",duration:"slow", complete:function(){
				$(article_id+" div.wrap div.content p").css({visibility:"visible"});
				$(article_id+" div.wrap div.content table").css({visibility:"visible"});
				$(article_id+" div#jason div.content").jScrollPane({showArrows: true});
				$(article_id+" div.wrap div.next").css({top:(the_heading_top+the_content_top + plus_padding) +"px"}).fadeIn("slow");
				$(article_id+" div.wrap div.talklinks").css({top:(the_heading_top+the_content_top + plus_padding) +"px"}).fadeIn("slow");
				$(article_id+' div.wrap .tv_links').jScrollPane({showArrows: true});
			}});

		}else{
			plus_padding = 0;
			$(article_id+" div.wrap div.next").css({top:(the_heading_top+the_content_top + plus_padding) +"px"}).fadeIn("slow");	
			$(article_id+" div.wrap div.talklinks").css({top:(the_heading_top+the_content_top + plus_padding) +"px"}).fadeIn("slow").jScrollPane({showArrows: true});	
		}
	}});
	
	
	
}


function goto_loc(the_hash){
	//console.log("gotoloc: "+window.location.hash+" passedin: "+the_hash);
	$("#home.heading").css({display:"none"});
	if(the_hash != ''){
		var steps = "";
		var pg = "";
		
		pg = the_hash;
		console.log(pg +" -"+the_hash);
		
		if(pg =="#home"){
			$("#nav_watch_this_trailer_30s").fadeIn("slow");
			$("#nav_watch_this_trailer_60s").fadeIn("slow");
		}else{
			$("#nav_watch_this_trailer_30s").fadeOut("slow");
			$("#nav_watch_this_trailer_60s").fadeOut("slow");
			
		}
		
		if(pg =="#pov" || pg == "#home"){
			$("#nav_watch_this").fadeIn("slow");
			$(".watch_nav").fadeIn("slow");
			
		}else{
			
			$("#nav_watch_this").fadeOut("slow");
			$(".watch_nav").fadeOut("slow");
		}
		
		//make sure proper nav is selected.
		$('#navigation a').removeClass("selectednav");
		if(pg.indexOf("suits")>0){//suits page
			$('#nav_suits').addClass("selectednav");
		}else if(pg =="#about" || pg =="#sir" || pg =="#pov"){
			$('#nav_pov').addClass("selectednav");
		}else if(pg =="#allies"){
			$('#nav_allies').addClass("selectednav");
		}else if(pg =="#talk"){
			$('#nav_talk').addClass("selectednav");
		}else if(pg.indexOf('produced')>0) {
			$('#nav_produced').addClass("selectednav");
		}
		/*if(pg =="#about" || pg =="#sir" || (pg.indexOf("suits")>0 || pg == "#talk" || pg == "#allies")){
			$("#nav_watch_this").fadeOut("slow");
		}*/
		
		if(pg != ""){
			$("#content_wrapper").scrollTo( pg || 0, 1500, { 
						onAfter:function(){
							pinch_content(pg);
						}
			});
			
		}
		var name_of_page = pg.replace("#","");
		if(window.location.hash.indexOf(name_of_page)<0){//if window does not already have hash, push it
			$.bbq.pushState({p: name_of_page});
		}
		
		//dynamic tracking
		_gaq.push(['_trackPageview', name_of_page]);
		
	}
}
$(document).ready(function(){
	
	
	
	/* This code is executed after the DOM has been completely loaded */
	
	
	$(".footerLinks").hover(
	  function () {
	    $(this).find('span').css('display', 'inline');
	    $(this).css('font-weight', 800);
	    $(this).css('color', '#E0173C');
	  }, 
	  function () {
	    $(this).find('span').css('display', 'none');
	    $(this).css('font-weight',400);
	    $(this).css('color', '#ffffff');
	  }
	);
	
	
	//center content
	
	
	
	$("#nav_wrapper, #content_wrapper").center();
	
	//initial page reveal animation
	//wait 1 sec then show home, wait one sec, then load other pages
	$("#logo").delay(1000).fadeIn(2000);
	$("#home").delay(1000).fadeIn(2000, function(){
		$(".article:hidden").delay(1000).css("display","block");//show other pages
		init_content_states();
		
		
		$("#nav_pov").animate({left:"-89px"},"fast", function(){
			$("#nav_suits").animate({left:"-70px"},"fast", function(){
				$('#nav_produced').animate({left:"-37px"},"fast", function(){
					$("#nav_allies").animate({left:"-45px"},"fast", function(){
						$("#nav_talk").animate({left:"-23px"},"fast", function(){
								
								$("#nav_watch_this").delay(500).fadeIn("slow", function(){
								if(!(navigator.userAgent.match(/iPhone/i)) && !(navigator.userAgent.match(/iPod/i)) && !(navigator.userAgent.match(/iPad/i))) {			
								
									$(".talklinks a.box").colorbox({iframe:true, innerWidth:560, innerHeight:660, scrolling:true});
									$(".contact").colorbox({iframe:true, innerWidth:305, innerHeight:215, scrolling:true});
									$(".legal").colorbox({iframe:true, innerWidth:560, innerHeight:660, scrolling:true});
									$(this).colorbox({iframe:true, innerWidth:550, innerHeight:380});
									$('.productions a.watchthisclass').colorbox({iframe:true, innerWidth:650, innerHeight:400});
									
									//init colorbox litebox for #nav_watch_this	
								}else{
									$("#nav_watch_this").attr("href", "video.html#lnk" ); 
									
									
									
								
									}
									
								
								
								if(window.location.hash != ""){
									goto_loc("#" + $.deparam.fragment(window.location.hash).p);
								}else{
									$.bbq.pushState({p: "home"});
								}
							});
						});
					});
				});
			});
		});
	});
	
	$("#nav_watch_this_trailer_30s").delay(1000).fadeIn("slow", function(){
							if(!(navigator.userAgent.match(/iPhone/i)) && !(navigator.userAgent.match(/iPod/i)) && !(navigator.userAgent.match(/iPad/i))) {
								$(this).colorbox({iframe:true, innerWidth:650, innerHeight:400});//init colorbox litebox for #nav_watch_this
							}else{
								$("#nav_watch_this_trailer").attr("href", "trailer.html#lnk" );
							}
	});


	
	$("#nav_watch_this_trailer_60s").delay(1000).fadeIn("slow", function(){
							if(!(navigator.userAgent.match(/iPhone/i)) && !(navigator.userAgent.match(/iPod/i)) && !(navigator.userAgent.match(/iPad/i))) {
								$(this).colorbox({iframe:true, innerWidth:650, innerHeight:400});//init colorbox litebox for #nav_watch_this
							}else{
								$("#nav_watch_this_trailer").attr("href", "trailer.html#lnk" );
							}
	});
	
	//if someone resizes the page, recenter the content
	$(window).resize(function() {
	  $("#nav_wrapper, #content_wrapper").center();
	});
	//back button
	$(window).bind('hashchange', function(){
		//console.log("hashchange");
		//console.log("hashchange: "+window.location.hash);
		
		goto_loc("#" + $.deparam.fragment(window.location.hash).p);
		
	});
	
	//bind click event
	$('.header a, div.next a').click(function(e){
	// If a link has been clicked, scroll the page to the link's hash target:
		if(this.hash != ''){
			//goto_loc(this.hash);
			var name_of_page = this.hash.replace("#","");
			
			if(!$(this).hasClass("watchthisclass")){
				$.bbq.pushState({p: name_of_page});

				e.preventDefault();
			}
			
		}
	});
	$("#navigation a").click(function(e){
		$('#navigation a').removeClass("selectednav");
		$(this).addClass("selectednav");
		
		if(!$(this).hasClass("watchthisclass")){
			console.log("hasclass not");
			e.preventDefault();
		}
	});

	$("#logo a").click(function(e){
		$('#navigation a').removeClass("selectednav");
		e.preventDefault();
	});

	$("#foot .home").click(function(e){
				//alert("home");
		$('#navigation a').removeClass("selectednav");
		goto_loc("#home");
		e.preventDefault();
	});
	
	$('.accordion').accordion({collapsible: true, active: false,
		changestart: function(e, ui){
			if (ui.newHeader != false && ui.newHeader.length != 0) {
				ui.newHeader.children('a').html(ui.newHeader.children('a').html().replace('+', '-'));
				ui.newHeader.children('a').css('color', '#e0173c');
			}
			if (ui.oldHeader != false && ui.oldHeader.length != 0) {
				ui.oldHeader.children('a').html(ui.oldHeader.children('a').html().replace('-', '+'));
				ui.oldHeader.children('a').css('color', '#fff');
			}
		},
		change: function(e, ui) {
			var pane = ui.newContent;
			if (pane.data('jsp') != null) {
				var api = pane.data('jsp');
				api.reinitialise();
			}
		}
	});

	$('div.wrap .production_links').jScrollPane({showArrows: true});
	
});



