function getNumericLeft(element){return parseInt($(element).css("left").replace("px",""));}
SP.homeCarousel=function()
{var that;var prevButton;var nextButton;var indexButtons;var animationSpeed=5;var opacitySpeed=.1;var timer=15000;var buttonOpacity=60;var itemWidth;var itemWrapper;var carousel;var carouselNav;var items;var currIndex;var hold=false;var autoTimer;var videoPlayerHandler;var flashvars;var params;var attributes;var videoButtons;var videoPlaying=false;return{init:function(){that=SP.homeCarousel;that.carousel=$(".carousel:first");that.itemWrapper=that.carousel.find(".carouselItems:first");that.carouselNav=that.carousel.find(".carouselNavigation:first");that.prevButton=that.carouselNav.find(".prevButton:first");that.nextButton=that.carouselNav.find(".nextButton:first");that.indexButtons=that.carouselNav.find(".indexButton");that.items=that.itemWrapper.find(".carouselItem");that.itemWidth=parseInt(that.items.eq(0).css("width").replace("px",""));that.currIndex=0;that.buttonOpacity=60;that.animationSpeed=1;that.timer=10000;that.attributes={name:"mtvnPlayer2",id:"mtvnPlayer2",type:"application/x-shockwave-flash"};that.params={quality:"high",bgcolor:"#000000",align:"middle",allowFullScreen:"true",allowScriptAccess:"always",enablejavascript:"true",type:"application/x-shockwave-flash",pluginspage:"http://www.macromedia.com/go/getflashplayer",wmode:"opaque"};that.flashvars={nid:"82125",sid:"South_Park_Homepage",autoPlay:"true"};that.videoButtons=that.itemWrapper.find(".videoButton");that.videoButtons.bind("click",that.playButtonClick);that.arrangeItems();that.indexButtonsOpacity();that.videoButtons2=that.itemWrapper.find(".videoButtonSide");that.videoButtons2.bind("click",that.playButtonSideClick);that.nextButton.bind("click",that.nextButtonClick);that.nextButton.bind("mouseover",that.directionButtonMouseOver);that.nextButton.bind("mouseout",that.directionButtonMouseOut);that.buttonOpacityChange(that.buttonOpacity,that.nextButton);that.prevButton.bind("click",that.prevButtonClick);that.prevButton.bind("mouseover",that.directionButtonMouseOver);that.prevButton.bind("mouseout",that.directionButtonMouseOut);that.buttonOpacityChange(that.buttonOpacity,that.prevButton);that.indexButtons.bind("click",that.indexButtonClick);that.indexButtons.bind("mouseover",that.indexButtonMouseOver);that.indexButtons.bind("mouseout",that.indexButtonMouseOut);if(!sticky)
{that.carousel.bind("mouseover",that.carouselMouseOver);that.carousel.bind("mouseout",that.carouselMouseOut);that.startTimer();}},animateNext:function()
{that.animateIndex(that.currIndex+1);},animatePrev:function()
{that.animateIndex(that.currIndex-1);},animateDefault:function()
{that.animateNext();},animateIndex:function(index)
{if(!that.hold){var wrappedIndex=that.wrapIndex(that.items,index)
that.preAnimation();var changeLeft=getNumericLeft(that.items.get(wrappedIndex))*-1;that.items.each(function(index,element){$(element).animate({left:getNumericLeft(element)+changeLeft},that.animationSpeed*1000,"swing",function(){that.postAnimationEvent(this);});});that.currIndex=wrappedIndex;}},postAnimationEvent:function(event)
{that.arrangeItems();that.indexButtonsOpacity();},preAnimation:function()
{that.clearVideo();},indexButtonsOpacity:function()
{that.indexButtons.each(function(index,element){var button=$(element);var buttonIndex=parseInt(button.attr("data-index"));var opacity=that.buttonOpacity;if(buttonIndex==that.currIndex)
{opacity=100;}
that.buttonOpacityChange(opacity,button);});},arrangeItems:function()
{that.hold=true;for(var i=-1;i<(that.items.length-1);i++)
{var wrappedIndex=that.wrapIndex(that.items,i+that.currIndex);that.items.eq(wrappedIndex).css("left",(i*that.itemWidth)+"px");}
that.hold=false;},startTimer:function()
{if(!sticky){clearInterval(that.autoTimer);that.autoTimer=setInterval(that.animateDefault,that.timer);}},stopTimer:function(){clearInterval(that.autoTimer);},itemMouseOver:function(event)
{},itemMouseOut:function(event)
{},carouselMouseOver:function(event)
{that.stopTimer();},carouselMouseOut:function(event)
{if(!that.videoPlaying)
that.startTimer();},nextButtonClick:function(event)
{event.preventDefault();that.animateNext();},prevButtonClick:function(event)
{event.preventDefault();that.animatePrev();},indexButtonClick:function(event)
{event.preventDefault();var index=parseInt($(that.getTarget(event.target)).attr("data-index"));if(!isNaN(index))
that.animateIndex(index);},indexButtonMouseOver:function(event)
{var button=that.getTarget(event.target);var buttonIndex=parseInt($(button).attr("data-index"));that.buttonOpacityChange(100,button);},indexButtonMouseOut:function(event)
{var button=that.getTarget(event.target);var buttonIndex=parseInt($(button).attr("data-index"));var newValue=that.buttonOpacity;if(buttonIndex==that.currIndex)
newValue=100;that.buttonOpacityChange(newValue,button);},directionButtonMouseOver:function(event)
{var button=that.getTarget(event.target);var newValue=100;that.buttonOpacityChange(newValue,button);},directionButtonMouseOut:function(event)
{var button=that.getTarget(event.target);var newValue=that.buttonOpacity;that.buttonOpacityChange(newValue,button);},buttonOpacityChange:function(newValue,element)
{$(element).animate({opacity:newValue/100.0},opacitySpeed*1000);},clearVideos:function()
{that.videoButtons.forEach(function(button){that.clearVideo(button);});},playButtonClick:function(event)
{if(!event)
event=window.event;var playerWrap=$(event.target);var videoId=playerWrap.attr("data-videoId");that.stopTimer();that.videoPlaying=true;that.playVideo(videoId);event.preventDefault();},playButtonSideClick:function(event)
{if(!event)
event=window.event;var playerWrap=$(event.target).parent().parent().find("[data-videoId]");var videoId=playerWrap.attr("data-videoId");that.stopTimer();that.videoPlaying=true;that.playVideo(videoId);event.preventDefault();},playVideo:function(videoId)
{$(".carouselVideoPlayer:first").removeClass("hide");swfobject.embedSWF("http://media.mtvnservices.com/mgid:cms:item:southparkstudios.com:"+videoId,"video_player_swf","100%","100%","10.0.32","/clips/expressInstall.swf",that.flashvars,that.params,that.attributes);},clearVideo:function()
{$(".carouselVideoPlayer:first").html("<span id=\"video_player_swf\"></span>").addClass("hide");},wrapIndex:function(obj,index)
{if(index>=0)
return index%obj.length;else
return(index%obj.length)+obj.length;},getTarget:function(possibleTarget)
{while(possibleTarget.nodeName.toLowerCase()!=="a"){possibleTarget=possibleTarget.parentNode;}
return possibleTarget;}};}();$(document).ready(SP.homeCarousel.init);SP.activity=function(){var that;var target;var refreshInterval=60*1000;return{init:function(){that=SP.activity;target=$(".twitter-feed:first");if(target.length<=0)
return;$(".facebook_tab_button").bind("mouseover",function(e){that.switchTabs('facebook');});$(".twitter_tab_button").bind("mouseover",function(e){that.switchTabs('twitter');e.preventDefault();});$(".facebook_tab_button").bind("click",function(e){e.preventDefault();});$(".twitter_tab_button").bind("click",function(e){e.preventDefault();});that.loadFacebook();that.loadTweets();},loadFacebook:function()
{$("#facebook_tab_content").html("<iframe src=\"http://www.facebook.com/plugins/activity.php?site=southparkstudios.se&amp;width=300&amp;height=270&amp;header=false&amp;colorscheme=dark&amp;font=arial&amp;border_color=%23000000&amp;recommendations=false\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\"></iframe>");},loadTweets:function()
{var tweetUrl="http://www.southparkstudios.se//feeds/twitter_search/query/cart.mn/";target.html("");$.ajax(tweetUrl,{dataType:"text",success:function(data,textStatus,jqXHR){that.processTweets(data);}});},processTweets:function(responseText)
{var data=that.sanitize(responseText);for(var i in data.results)try{var tweet=data.results[i];var tweetPic=tweet.profile_image_url;var twitterUserName=tweet.from_user;var text=tweet.text.replace(/(http:\/\/\S+)/g,'<a target="_blank" href="$1">$1</a>').replace(/\B#([_a-z0-9]+)/ig,function(hashtag){return'<a target="_blank" href="http://twitter.com/search?q=%23'+hashtag.substring(1)+'">'+hashtag+'</a>';}).replace(/\B@([_a-z0-9]+)/ig,function(reply){return'<a target="_blank" href="http://twitter.com/'+reply.substring(1)+'">'+reply.charAt(0)+reply.substring(1)+'</a>';});target.append('<li class="tweet"><img class="tweetPic" src="'+tweetPic+'" width="28" height="28"/> <div class="tweetText"><span class="twitterUserName">'+twitterUserName+'</span> '+text+'<br/>'+that.relative_time(tweet.created_at)+'</div></li>');}catch(e){}},relative_time:function(time_value)
{var b=new Date();var c=new Date(time_value);var d=b-c;var e=1000;var minute=e*60;var hour=minute*60;var day=hour*24;var week=day*7;if(isNaN(d)||d<0){return""}
if(d<e*7){return'<span class="tweetDate">right now</span>';}
if(d<minute){return'<span class="tweetDate">'+Math.floor(d/e)+" seconds ago</span>";}
if(d<minute*2){return'<span class="tweetDate">about 1 minute ago</span>';}
if(d<hour){return'<span class="tweetDate">'+Math.floor(d/minute)+' minutes ago</span>';}
if(d<hour*2){return'<span class="tweetDate"> about 1 hour ago</span>';}
if(d<day){return'<span class="tweetDate">'+Math.floor(d/hour)+' hours ago</span>';}
if(d>day&&d<day*2){return"yesterday"}
if(d<day*365){return'<span class="tweetDate">'+Math.floor(d/day)+' days ago</span>';}else{return'<span class="tweetDate">over a year ago</span>';}},switchTabs:function(activeTab)
{$(".tab_content").hide();$(".tabs > div").removeClass("selected");$(".tabs > div."+activeTab+"_tab").addClass("selected");$("#"+activeTab+"_tab_content").show();},sanitize:function(json)
{json=eval("("+unescape(json)+")");return json;}};}();$(document).ready(SP.activity.init);SP.linkTrack=function(){var that;return{init:function()
{that=SP.linkTrack;$("a").bind("click",function(e)
{var link_name=that.findAttributeUpTree($(this),"data-reportingName");if(link_name==null||link_name=="")
return;var dest_url=that.findAttributeUpTree($(this),"href");if(dest_url==null||dest_url==""||dest_url=="#")
return;if(dest_url.charAt(0)=='/')
dest_url="http://www.southparkstudios.se/"+dest_url.substring(1);sendClickTrackEvent(link_name,dest_url);});$("#searchbttn").bind("click",function(e){var link_name="search";var dest_url="http://www.southparkstudios.se/search/";sendClickTrackEvent(link_name,dest_url);});},findAttributeUpTree:function(obj,attr)
{var test=obj.attr(attr);if(typeof(test)!="undefined")
return test;var list=obj.parents("["+attr+"]");if(list.length>0)
return list.eq(0).attr(attr);return null;}};}();$(document).ready(SP.linkTrack.init);
/* 2012-02-23 02:17:21 - cached for 11534 seconds */
