/***************************************************************
 * common.js    11/23/2010
 *
 * Author: John Norton - jukebox42@gmail.com
 * Copyright 2010 Amplify Studios
 *
 * Compress with: http://closure-compiler.appspot.com/home
 ***************************************************************/
var nCW=80,nEW=730,nMT=1500,nC=["green","orange","purple","red","blue"],cc="navState-green navState-orange navState-purple navState-red navState-blue",_Site={currentUrl:document.location.hash,whipeNav:false,forceLoad:true,init:function(){$(document).bind("pagechange",_Site.Util.loadPage);$.each($(".mainNav li"),function(){var b=$(this),c=b.width();b.width(c);b.hover(function(){var d=$(this),e=nC[d.index()];d.addClass("navState-"+e);$(".navLine .last").addClass("navState-"+e)},function(){var d=$(this), e=nC[d.index()];if(!d.hasClass("expanded")){d.removeClass("navState-"+e);$(".navLine .last").removeClass("navState-"+e)}}).click(function(){return _Site.Util.topNavClick(this)})});$('.subNav:not(".subNav-purple-special") li.minor, .subSubNavLive li.minor').live("click",_Site.Util.linkSubNav);$('.subNav:not(".subNav-purple-special") li.major, .subSubNavLive li.major').live("click",_Site.Util.linkSubNavMajor);$(".siteLogo").click(function(){_Site.whipeNav=true;_Site.Util.loc("#/index");$(".navLine .navState-blue").removeClass(cc); $(".mainNav li.expanded").animate({width:nCW},nMT,"easeOutBounce").removeClass(cc+" expanded");return false});$(".toolbar a").tinyTips("title");var a=undefined;$.each($(".mainNav li"),function(){var b=$(this);if(document.location.hash.indexOf($("a",b).attr("href"))!=-1)a=b});a!=undefined?_Site.Util.topNavClick(a,document.location.hash):_Site.Util.loc("#/index",nMT);setInterval(function(){if(window.location.hash&&window.currentHash!=window.location.hash){window.currentHash="#/"+window.location.hash.split("#/")[1]; _Site.Util.loc(window.currentHash)}},300);$(".tbi-email").colorbox({inline:true,href:".form-subscribe",onCleanup:function(){$(".form-subscribe input[name=email]").val("")}});$(".form-subscribe").nextVal({useSummary:true,useInline:false,useErrorText:false,formCallback:function(b){if(!b)return b;var c=$(".form-subscribe");b=c.find("input[name=email]").val();var d=c.attr("action");c.attr("action","javascript:;");$.ajax({type:"POST",dataType:"json",url:d,data:{email:b},success:function(e){if(e.status== "OK")$(".form-subscribe").html('<h2>Subscribe to our newsletter!</h2><p>Thank you for subscribing to our newsletter!</p><p style="text-align:right;margin:50px 40px -50px 0;"><img src="app_images/return-to-site.gif" alt="Return to our site." /></p>');else{$('<ul class="validation-summary" id="'+c.attr("nextval")+'"><li>'+e.message+"</li></ul>").prependTo(c);c.attr("action",d)}}});return false}})},Util:{topNavClick:function(a,b){var c=$(a);if(!c.hasClass("expanded")){_Site.Util.loc(b!=undefined?b:$("a", c).attr("href"),nMT);var d=nC[c.index()];c.queue(function(){$(".navLine .navState-blue").removeClass(cc);$(".mainNav li.expanded").animate({width:nCW},nMT,"easeOutBounce").removeClass("expanded "+cc);$(this).dequeue()}).queue(function(){$(this).addClass("expanded navState-"+d);$(this).dequeue()}).animate({width:nEW},nMT,"easeOutBounce");$(".navLine .last").addClass("navState-"+d)}return false},linkSubNav:function(){var a=$(this);$(".subNav li.active").removeClass("active");a.addClass("active");_Site.Util.loc($("a", a).attr("href"));return false},linkSubNavMajor:function(){var a=$(this),b=a.parent();if($("li.active",b).size()==0){$(".subNav li.active").removeClass("active");a.addClass("active");b=$("a",a);_Site.Util.loc(b.attr("href"),nMT);a=parseInt($("a",a).text());b=nC[a-1];$(".mainNav li:nth-child("+a+")").queue(function(){$(".navLine .navState-blue").removeClass(cc);$(".mainNav li.expanded").animate({width:nCW},nMT,"easeOutBounce").removeClass("expanded "+cc);$(this).dequeue()}).addClass("expanded navState-"+ b).animate({width:nEW},nMT,"easeOutBounce");$(".navLine .last").addClass("navState-"+b)}else{$(".subNav li.active").removeClass("active");a.addClass("active");_Site.Util.loc($("a",a).attr("href"))}return false},loc:function(a,b){$(".loading").stop().fadeTo(500,"0.6").delay(b||500).queue(function(){a="#/"+a.split("#/")[1];window.currentHash=a;document.location=a;$(document).trigger("pagechange");$(this).dequeue()})},loadPage:function(){var a="#/"+document.location.hash.toString().split("#/")[1],b= _Site.currentUrl,c=a.split("/");if(_Site.forceLoad){_Site.forceLoad=false;_Site.currentUrl=""}else _Site.currentUrl=document.location.hash;if(c.length>2)a=c[0]+"/"+c[1]+"/"+c[2];c=b.split("/");if(c.length>2)b=c[0]+"/"+c[1]+"/"+c[2];if(b==""&&(a=="#/index"||a==""||a=="#")||b==a){$(".loading").stop().fadeOut();return false}else $(".decorated").removeClass("decorated").css("background-image","");$(".loading").queue(function(){$.ajax({type:"POST",dataType:"json",url:"includes/load.php",data:{url:a,currurl:b, type:"page"},success:function(d){if(d.subnav!=""||_Site.whipeNav){_Site.whipeNav=false;$(".case .subNav").fadeOut("n",function(){$(this).remove()})}d.subsubnav==""&&$(".case .subSubNav").fadeOut("n",function(){$(this).remove()});$(".pages .page").fadeOut("n",function(){$(this).remove().parent().html("");document.title="GY&K: "+d.title;$(".pages").append(d.content);if(d.subnav!=""){var e=$(d.subnav);e.find('a[href*="'+a.replace(/\/+$/,"")+'"]:first').parent().addClass("active");e.appendTo(".case")}if(d.subsubnav!= ""&&$(".subSubNav").size()==0){e=$(d.subsubnav);e.find('a[href*="'+a.replace(/\/+$/,"")+'"]:first').parent().addClass("active");e.appendTo(".case")}$(".loading").stop().delay(300).fadeOut()})},error:function(){$(".loading").stop().delay(300).fadeOut();alert("oops")}});$(this).dequeue()});return true}},Page:{Green:{AboutUs:function(){$(".peopleroll li:not(.playvideo) a").mouseenter(function(){$(".peoplehover").remove();var a=$(this),b=$(this).clone(),c=a.position();a.parent().addClass("hover");b.data("owner", a.parent().index());b.addClass("peoplehover").css({left:c.left-3+"px",top:c.top-3+"px"}).appendTo(".peopleroll").mouseleave(function(){$(".peopleroll a.peoplehover:last").remove();$(".peopleroll li.hover").removeClass("hover")}).click(function(){$(".peopleroll a.peopleactive:last").remove();var d=$(this);if(d.hasClass("peoplehover")){$(".peopleroll a.peopleactive:last").remove();$(".peopleroll li.active").removeClass("active");$(".peoplepopup").fadeOut("n",function(){$(this).remove()});d.removeClass("peoplehover").addClass("peopleactive"); var e=d.position();$(".peopleroll li.hover").addClass("active");$c=$(".peopleroll li.active");$('<div class="peoplepopup"><a class="peoplepopupclose" href="#"><img src="app_images/green-biobox-close.jpg" alt="close" /></a><h3>'+$("a",$c).html()+'</h3><div class="peoplepopupcont">'+$(".personbio",$c).html()+"</div></div>").queue(function(){$(this).css({left:e.left+82+"px",top:e.top+"px","z-index":1001});$(this).dequeue()}).appendTo(".peopleroll").fadeIn()}else{$(".peopleroll a.peopleactive:last").remove(); $(".peopleroll li.active").removeClass("active");$(".peoplepopup").fadeOut("n",function(){$(this).remove()})}return false})});$(".peoplepopup .peoplepopupclose").live("click",function(){$(".peopleroll a.peopleactive:last").remove();$(".peopleroll li.active").removeClass("active");$(".peoplepopup").fadeOut("n",function(){$(this).remove()});return false})},Carrers:function(){$("form.form").nextVal({useSummary:true,useInline:false,useErrorText:false,formCallback:function(a){if(!a)return a;$(".loading").stop().fadeTo(500, "0.6");$("#upload_target").load(function(){$(".loading").stop().delay(300).fadeOut();$(this).contents().find("body").html()=="OK"?$("form.form").fadeOut(500,function(){$('<p class="validation-passed">Thanks for submitting! We\'ll be contacting you shortly.</p>').appendTo(".page-green")}):$('<p class="validation-failed">Oh no! Something went wrong... Please try again will ya?</p>').insertBefore("form.form")});return true}});$(".fileBox").live("change",function(){$(this).css("top","-5000px").next().attr("disabled", "disabled").parent().parent().addClass("disabled")})},TheDigs:function(){$("#slider").scrollable({vertical:true,speed:300}).navigator({navi:"#slidercontrols",naviItem:"li",indexed:true})},FindUs:function(){}},Orange:{Services:function(){$("#slider").scrollable({speed:300});$(".subSubNav li").live("click",function(){$("#slider").data("scrollable").seekTo($("a",$(this)).attr("rel"),300);$(".subSubNav li.active").removeClass("active");$(this).addClass("active");return false});$("#nextBtn").live("click", function(){if($(".subSubNav li.active").is(":last-child"))return false;var a=$("#slider").data("scrollable"),b=$(".subSubNav li.active").removeClass("active").next().addClass("active").find("a").attr("rel");a.seekTo(b,300);return false});$("#prevBtn").live("click",function(){if($(".subSubNav li.active").is(":first-child"))return false;var a=$("#slider").data("scrollable"),b=$(".subSubNav li.active").removeClass("active").prev().addClass("active").find("a").attr("rel");a.seekTo(b,300);return false})}}, Purple:{ThePartnership:function(){$("#slider > ul.items").simplyScroll({autoMode:"loop",pauseOnHover:true,pauseOnClick:false,frameRate:20,speed:2}).parent().after('<div class="edge-left"></div>').after('<div class="edge-right"></div>')}},Red:{FiveDs:function(){$("#slider").scrollable({vertical:true,speed:300}).navigator({navi:"#slidercontrols",naviItem:"li",indexed:true}).delay(5).queue(function(){var a=document.location.hash.toString().split("/");if(a.length>3){$(".subNav-red li.active").removeClass("active"); a=$('.subNav-red li.minor a[href$="/'+a[3]+'"]');if(a.size()>0){$("#slider ul.items li.active").removeClass("active");$("#slider ul.items li.red-box-d"+a.attr("rel")).addClass("active");a.parent().addClass("active");$("#slider").data("scrollable").seekTo(a.attr("rel")-1,300)}else $(".subNav-red li.minor:first").addClass("active")}else $(".subNav-red li.minor:first").addClass("active");$(".subNav-red li.minor").click(function(){$(".subNav-red li.active").removeClass("active");var b=$(this).addClass("active"), c=b.find("a").attr("rel");$("#slider ul.items li.active").removeClass("active");$("#slider ul.items li.red-box-d"+c).addClass("active");$("#slider").data("scrollable").seekTo(c-1,300);b.delay(500).queue(function(){document.location=b.find("a").attr("href")});return false});$(this).dequeue()});$(".nextBtn").live("click",function(){var a=$(this);a.parent().removeClass("active").next().addClass("active");var b=$("#slider").data("scrollable"),c=a.attr("rel");b.seekTo(c,300);a.delay(500).queue(function(){document.location= $(".subNav-red .minor.active").removeClass("active").next().addClass("active").find("a").attr("href")});return false});$("#slider ul.items li").live("click",function(){var a=$(this);if(a.hasClass("active"))return false;a.addClass("active").next().removeClass("active");var b=$("#slider").data("scrollable"),c=a.attr("class").substring(9,10);b.seekTo(c-1,300);a.delay(500).queue(function(){document.location=$(".subNav-red .minor.active").removeClass("active").prev().addClass("active").find("a").attr("href")}); return false})}},Blue:{Showreel:function(){$(".siteCase").css("background-image","url(app_images/blue-showreel-box.png)").addClass("decorated");flowplayer("player",{src:"assets/flash/flowplayer-3.2.5.swf",wmode:"opaque"})},CaseStudies:function(){$(".btnCaseStudy").colorbox({onClose:function(){$.colorbox.remove()}});$(".viewDetails").live("click",function(){$t=$(this);$("#popDetails").empty();if($t.is('a[href$=".flv"]')){$("#popDetails").width(850).height(478);flashembed("popDetails","assets/flash/videoPlayer.swf", {videoPath:$t.attr("href")});$.colorbox({inline:true,href:"#popDetails",onCleanup:function(){$("#popDetails").width("auto").height("auto").empty()},onClose:function(){$.colorbox.remove()}})}return false})}}}};$(function(){_Site.init()});
