
/*------------------------START HOVER INTEDENT PLUGIN -----------------------------------------*/
/**
* hoverIntent r6 // 2011.02.26 // jQuery 1.5.1+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne brian(at)cherne(dot)net
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:5,interval:20,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev])}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev])};var handleHover=function(e){var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t)}if(e.type=="mouseenter"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob)},cfg.timeout)}}};return this.bind('mouseenter',handleHover).bind('mouseleave',handleHover)}})(jQuery);

/*------------------------END HOVER INTEDENT PLUGIN -------------------------------------------*/






/* jRumble v1.3 - http://jackrugile.com/jrumble - MIT License */
(function(f){f.fn.jrumble=function(g){var a=f.extend({x:4,y:4,rotation:2,speed:105,opacity:false,opacityMin:0.5},g);return this.each(function(){var b=f(this),h=a.x*2,i=a.y*2,k=a.rotation*2,g=a.speed===0?1:a.speed,m=a.opacity,n=a.opacityMin,l,j,o=function(){var e=Math.floor(Math.random()*(h+1))-h/2,a=Math.floor(Math.random()*(i+1))-i/2,c=Math.floor(Math.random()*(k+1))-k/2,d=m?Math.random()+n:1,e=e===0&&h!==0?Math.random()<0.5?1:-1:e,a=a===0&&i!==0?Math.random()<0.5?1:-1:a;b.css("display")==="inline"&&(l=true,b.css("display","inline-block"));b.css({position:"absolute","-ms-filter":"progid:DXImageTransform.Microsoft.Alpha(Opacity="+d*100+")",filter:"alpha(opacity="+d*100+")","-moz-opacity":d,"-khtml-opacity":d,opacity:d,"-webkit-transform":"rotate("+c+"deg)","-moz-transform":"rotate("+c+"deg)","-ms-transform":"rotate("+c+"deg)","-o-transform":"rotate("+c+"deg)",transform:"rotate("+c+"deg)"})},p={"-ms-filter":"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)",filter:"alpha(opacity=100)","-moz-opacity":1,"-khtml-opacity":1,opacity:1,"-webkit-transform":"rotate(0deg)","-moz-transform":"rotate(0deg)","-ms-transform":"rotate(0deg)","-o-transform":"rotate(0deg)",transform:"rotate(0deg)"};b.bind({startRumble:function(a){a.stopPropagation();clearInterval(j);j=setInterval(o,g)},stopRumble:function(a){a.stopPropagation();clearInterval(j);l&&b.css("display","inline");b.css(p)}})})}})(jQuery);





 /*
 * TipTip
 * Copyright 2010 Drew Wilson
 * www.drewwilson.com
 * code.drewwilson.com/entry/tiptip-jquery-plugin
 *
 * Version 1.3   -   Updated: Mar. 23, 2010
 *
 * This Plug-In will create a custom tooltip to replace the default
 * browser tooltip. It is extremely lightweight and very smart in
 * that it detects the edges of the browser window and will make sure
 * the tooltip stays within the current window size. As a result the
 * tooltip will adjust itself to be displayed above, below, to the left 
 * or to the right depending on what is necessary to stay within the
 * browser window. It is completely customizable as well via CSS.
 *
 * This TipTip jQuery plug-in is dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */
(function($){$.fn.tipTip=function(options){var defaults={activation:"hover",keepAlive:false,maxWidth:"200px",edgeOffset:3,defaultPosition:"bottom",delay:400,fadeIn:200,fadeOut:200,attribute:"title",content:false,enter:function(){},exit:function(){}};var opts=$.extend(defaults,options);if($("#tiptip_holder").length<=0){var tiptip_holder=$('<div id="tiptip_holder" style="max-width:'+opts.maxWidth+';"></div>');var tiptip_content=$('<div id="tiptip_content"></div>');var tiptip_arrow=$('<div id="tiptip_arrow"></div>');$("body").append(tiptip_holder.html(tiptip_content).prepend(tiptip_arrow.html('<div id="tiptip_arrow_inner"></div>')))}else{var tiptip_holder=$("#tiptip_holder");var tiptip_content=$("#tiptip_content");var tiptip_arrow=$("#tiptip_arrow")}return this.each(function(){var org_elem=$(this);if(opts.content){var org_title=opts.content}else{var org_title=org_elem.attr(opts.attribute)}if(org_title!=""){if(!opts.content){org_elem.removeAttr(opts.attribute)}var timeout=false;if(opts.activation=="hover"){org_elem.hover(function(){active_tiptip()},function(){if(!opts.keepAlive){deactive_tiptip()}});if(opts.keepAlive){tiptip_holder.hover(function(){},function(){deactive_tiptip()})}}else if(opts.activation=="focus"){org_elem.focus(function(){active_tiptip()}).blur(function(){deactive_tiptip()})}else if(opts.activation=="click"){org_elem.click(function(){active_tiptip();return false}).hover(function(){},function(){if(!opts.keepAlive){deactive_tiptip()}});if(opts.keepAlive){tiptip_holder.hover(function(){},function(){deactive_tiptip()})}}function active_tiptip(){opts.enter.call(this);tiptip_content.html(org_title);tiptip_holder.hide().removeAttr("class").css("margin","0");tiptip_arrow.removeAttr("style");var top=parseInt(org_elem.offset()['top']);var left=parseInt(org_elem.offset()['left']);var org_width=parseInt(org_elem.outerWidth());var org_height=parseInt(org_elem.outerHeight());var tip_w=tiptip_holder.outerWidth();var tip_h=tiptip_holder.outerHeight();var w_compare=Math.round((org_width-tip_w)/2);var h_compare=Math.round((org_height-tip_h)/2);var marg_left=Math.round(left+w_compare);var marg_top=Math.round(top+org_height+opts.edgeOffset);var t_class="";var arrow_top="";var arrow_left=Math.round(tip_w-12)/2;if(opts.defaultPosition=="bottom"){t_class="_bottom"}else if(opts.defaultPosition=="top"){t_class="_top"}else if(opts.defaultPosition=="left"){t_class="_left"}else if(opts.defaultPosition=="right"){t_class="_right"}var right_compare=(w_compare+left)<parseInt($(window).scrollLeft());var left_compare=(tip_w+left)>parseInt($(window).width());if((right_compare&&w_compare<0)||(t_class=="_right"&&!left_compare)||(t_class=="_left"&&left<(tip_w+opts.edgeOffset+5))){t_class="_right";arrow_top=Math.round(tip_h-13)/2;arrow_left=-12;marg_left=Math.round(left+org_width+opts.edgeOffset);marg_top=Math.round(top+h_compare)}else if((left_compare&&w_compare<0)||(t_class=="_left"&&!right_compare)){t_class="_left";arrow_top=Math.round(tip_h-13)/2;arrow_left=Math.round(tip_w);marg_left=Math.round(left-(tip_w+opts.edgeOffset+5));marg_top=Math.round(top+h_compare)}var top_compare=(top+org_height+opts.edgeOffset+tip_h+8)>parseInt($(window).height()+$(window).scrollTop());var bottom_compare=((top+org_height)-(opts.edgeOffset+tip_h+8))<0;if(top_compare||(t_class=="_bottom"&&top_compare)||(t_class=="_top"&&!bottom_compare)){if(t_class=="_top"||t_class=="_bottom"){t_class="_top"}else{t_class=t_class+"_top"}arrow_top=tip_h;marg_top=Math.round(top-(tip_h+5+opts.edgeOffset))}else if(bottom_compare|(t_class=="_top"&&bottom_compare)||(t_class=="_bottom"&&!top_compare)){if(t_class=="_top"||t_class=="_bottom"){t_class="_bottom"}else{t_class=t_class+"_bottom"}arrow_top=-12;marg_top=Math.round(top+org_height+opts.edgeOffset)}if(t_class=="_right_top"||t_class=="_left_top"){marg_top=marg_top+5}else if(t_class=="_right_bottom"||t_class=="_left_bottom"){marg_top=marg_top-5}if(t_class=="_left_top"||t_class=="_left_bottom"){marg_left=marg_left+5}tiptip_arrow.css({"margin-left":arrow_left+"px","margin-top":arrow_top+"px"});tiptip_holder.css({"margin-left":marg_left+"px","margin-top":marg_top+"px"}).attr("class","tip"+t_class);if(timeout){clearTimeout(timeout)}timeout=setTimeout(function(){tiptip_holder.stop(true,true).fadeIn(opts.fadeIn)},opts.delay)}function deactive_tiptip(){opts.exit.call(this);if(timeout){clearTimeout(timeout)}tiptip_holder.fadeOut(opts.fadeOut)}}})}})(jQuery);



 
 

 
/*------------------------START OPEN BLOCK SCRIPT----------------------------------------------*/
 var timerSteps;
 (function (elements) {
		var i = -1;
		var className = 'highlighted';
	
		if (!elements.length) {
			return false;
		}
	
		jQuery.step = function() {
			elements.eq(i).removeClass(className);
			elements.eq(i).animate({'top': "+=52px"}, 900).delay(400);
			if (++i >= elements.length) {
				i = 0;
			};
			elements.eq(i).addClass(className);
			elements.eq(i).animate({'top': "-=52px"}, 900, function(){
				elements.eq(i).animate({'top': "+=8px"} , 300, function(){
						elements.eq(i).animate({'top': "-=8px"} , 300, function(){
								elements.eq(i).animate({'top': "+=8px"} , 300, function(){
									elements.eq(i).animate({'top': "-=8px"} , 300);
								});
							});
					});
				}).delay(600);
			timerSteps = setTimeout(jQuery.step, 5000);
		}
	}($('#step1').children()));
/*------------------------END OPEN BLOCK SCRIPT----------------------------------------------*/ 
 
 
  
 
 
/*------------------------START OUT OF BOUNDS TIMER SCRIPT----------------------------------------------*/ 
 function initOutOfBoundsTimer() {
	return setTimeout(function(){ 
		 $('.steps').fadeOut();
		  $('#puzzleHolder').css("background-image", "url(/images/homeSlides/firstPart_Bg.png)"); 
		 $('.answerHolder').fadeOut();
		 $('#puzzleHolder').removeClass();
		 $('#firstPart').removeClass();
		 $("#firstPart a").removeClass('onState');
		 $('.steps a.showAnswer').show();
		 $(".static").fadeIn();
		 
	}, 17000);
}

var oobTimeout = false;
/*------------------------END OUT OF BOUNDS TIMER SCRIPT----------------------------------------------*/ 
 
 
 
var className = 'highlighted'; 
 

 
/*------------------------START UP LEFT ANIMATION SCRIPT----------------------------------------------*/ 
var numberCount = 0;
jQuery.callUpUp = function() {
 
	(jQuery.firstPartFunction = function(jq){
		jq.eq(0).addClass(className);
		jq.eq(0).animate({'top': "-=52px"}, 200, function(){
			jq.eq(0).animate({'top': "-=52px"}, 200, function(){
				jq.eq(0).removeClass(className);
				(jq=jq.slice(1)).length && jQuery.firstPartFunction(jq);
				
				 numberCount++;
			  	 if (numberCount == 1){
					 	jQuery.callDown();
						jQuery.callUpRight();
						jQuery.callDownLeft();
						jQuery.callUpLeft();					 
					}
				
				
				})
		}).delay(100);
	})($('#firstPart .upUp'));
}
/*------------------------END UP LEFT ANIMATION SCRIPT----------------------------------------------*/  
 
 
/*------------------------START UP RIGHT ANIMATION SCRIPT----------------------------------------------*/ 
var numberCountUpRight = 0;
jQuery.callUpRight = function() {
 	
	(jQuery.UpRight = function(jq){
		jq.eq(0).addClass(className);
		jq.eq(0).animate({'top': "-=52px"}, 200, function(){
			jq.eq(0).animate({'left': "+=52px"}, 200, function(){
				jq.eq(0).removeClass(className);
				(jq=jq.slice(1)).length && jQuery.UpRight(jq);		
				 
				
				})
		}).delay(150);
	})($('#firstPart .upRight'));
} 
/*------------------------END UP RIGHT ANIMATION SCRIPT----------------------------------------------*/ 
 
 
/*------------------------START UP RIGHT ANIMATION SCRIPT----------------------------------------------*/ 
var numberCountDown = 0;
jQuery.callDown = function() {
 	
	(jQuery.Down = function(jq){
		jq.eq(0).addClass(className);
		jq.eq(0).animate({'top': "+=52px"}, 200, function(){
				jq.eq(0).removeClass(className);
				(jq=jq.slice(1)).length && jQuery.Down(jq);		
		}).delay(150);
	})($('#firstPart .down'));
}  



/*------------------------START DOWN LEFT ANIMATION SCRIPT----------------------------------------------*/ 
var numberCountDownLeft = 0;
jQuery.callDownLeft = function() {
	(jQuery.DownLeft = function(jq){
		jq.eq(0).addClass(className);
		jq.eq(0).animate({'top': "+=52px"}, 200, function(){
			jq.eq(0).animate({'left': "-=52px"}, 200, function(){
				
				jq.eq(0).removeClass(className);
				(jq=jq.slice(1)).length && jQuery.DownLeft(jq);		
				 numberCountDownLeft++;
			  	 if (numberCountDownLeft == 1){
						jQuery.callLeftDown();
						//jQuery.callDownLeft();
					}
				
				})
		}).delay(100);
	})($('#firstPart .downLeft'));
} 
/*------------------------END DOWN LEFT ANIMATION SCRIPT----------------------------------------------*/ 


/*------------------------START UP RIGHT ANIMATION SCRIPT----------------------------------------------*/ 
var numberCountUpLeft = 0;
jQuery.callUpLeft = function() {
 	
	(jQuery.UpLeft = function(jq){
		jq.eq(0).addClass(className);
		jq.eq(0).animate({'top': "-=52px"}, 200, function(){
			
			
			jq.eq(0).animate({'left': "-=52px"}, 200, function(){
				jq.eq(0).removeClass(className);
				(jq=jq.slice(1)).length && jQuery.UpLeft(jq);		
				 
				
				})
		}).delay(150);
	})($('#firstPart .upLeft'));
} 
/*------------------------END UP RIGHT ANIMATION SCRIPT----------------------------------------------*/ 


/*------------------------START DOWN DOWN ANIMATION SCRIPT----------------------------------------------*/ 
var numberCountDownDown = 0;
jQuery.callDownDown = function() {
 	//$('#firstPart .downDown').addClass(className);
	(jQuery.DownDown = function(jq){
		jq.eq(0).addClass(className);
		jq.eq(0).animate({'top': "+=52px"}, 200, function(){
			jq.eq(0).animate({'top': "+=52px"}, 200, function(){
				jq.eq(0).removeClass(className);
				(jq=jq.slice(1)).length && jQuery.DownDown(jq);		
				 
				
				 if (numberCountDownDown == 0){
						 jQuery.startSecondStep();
					}	
				
				
				})
		}).delay(100);
	})($('#firstPart .downDown'));
} 
/*------------------------END DOWN LEFT ANIMATION SCRIPT----------------------------------------------*/ 


/*------------------------START LEFT DOWN ANIMATION SCRIPT----------------------------------------------*/ 
var numberCountLeftDown = 0;
jQuery.callLeftDown = function() {
 
	(jQuery.LeftDown = function(jq){
		jq.eq(0).animate({'left': "-=52px"}, 200, function(){
			jq.eq(0).animate({'top': "+=52px"}, 200, function(){
				(jq=jq.slice(1)).length && jQuery.LeftDown(jq);		
				 
				  numberCountLeftDown++;
			  	 if (numberCountLeftDown == 1){
					jQuery.callDownDown();
					}
				
					
				 
				 
				
				})
		}).delay(100);
	})($('#firstPart .leftDown'));
} 
/*------------------------END LEFT DOWN ANIMATION SCRIPT----------------------------------------------*/ 





 
 
 
 
 
 
/*------------------------START DOCUMENT READY----------------------------------------------*/	
$(document).ready(function() {



 
	/*---We Start Everything Here---*/
	setTimeout(jQuery.callUpUp, 1200);
	$(".steps").fadeOut();



	/*---Second Part Starts here---*/ 	
	jQuery.startSecondStep = function() {
	  $('#firstPart a').jrumble();
	   $('#firstPart a').trigger('startRumble');
	  $('#firstPart a').addClass(className);
	  $('#firstPart a').css("background-image", "url(/images/homeSlides/question_Mark.png)");
	  $('#firstPart a').css("background-position", "center");

	  
	  $("#tiptip_holder").delay(1500).fadeIn(function(){ $(this).delay(4000).fadeOut(); });	
	  
	};

 
 

	$("#firstPart a").hoverIntent(function() {  
		$(this).trigger('stopRumble');
		$(this).animate({ width: '62px',height: '62px', 'left':'-=5px', 'top':'-=5px'}, 200);
		$(this).css({'z-index': '999'});
		$("#tiptip_holder").stop().fadeOut();

	}, 
	  function () {
		$(this).trigger('startRumble');	
		$(this).animate({ width: '52px',height: '52px','left':'+=5px', 'top':'+=5px' }, 200);
		$(this).css({'z-index': '10'});
					 
	  }
	);
	
	
	
	
	
	
	
	
	 
	
	/*------------------------START LINK HOVERS----------------------------------------------*/	
		$("#firstPart a").click(function(e) {    
				var activeTab = $(this).attr("href"); 
				
				/*---We Start Timer Here 17 secs---*/
				clearTimeout(oobTimeout); 	
				oobTimeout = initOutOfBoundsTimer();

				//$(this).trigger('stopRumble');
				$("#firstPart a").removeClass('onState');
				
				$('#firstPart').css("background-image", "none"); 
				$(".steps").hide();
				$(".static").hide();
				
				$('#puzzleHolder').removeClass();
				$('.steps a.showAnswer').show();
				$('#puzzleHolder').css("background-image", "url(/images/fpo/interaction.png)"); 
				
						
				$(activeTab).fadeIn();
								   
				if(activeTab == '#step1A') {
						
					$('#puzzleHolder').removeClass();
					$('#puzzleHolder').addClass('step1Links');
					$(this).addClass('onState'); 
				}else if(activeTab == '#step2A'){
					$('#puzzleHolder').removeClass();
					$('#puzzleHolder').addClass('step2Links');
					$(this).addClass('onState');
				}else if(activeTab == '#step3A'){
					$('#puzzleHolder').removeClass();
					$('#puzzleHolder').addClass('step3Links');
					$(this).addClass('onState');
				}else if(activeTab == '#step4A'){
					$('#puzzleHolder').removeClass();
					$('#puzzleHolder').addClass('step4Links');
					$(this).addClass('onState');
				}else{
					$("#firstPart a").removeClass('onState');
					}
							
				  
			 
				 $('.answerHolder').hide();
				e.preventDefault();
		});
	/*------------------------END LINK HOVERS----------------------------------------------*/
	 
	 
	 
	/*------------------------START LINK CLICK----------------------------------------------*/ 
		$(".steps a.showAnswer").click(function(e) { 
		
			$(this).hide();
			$(this).parent().find('.answerHolder').fadeIn();
			$('#firstPart').removeClass();
			$('#firstPart').addClass('answerLinks');
			e.preventDefault();
			
		 });
	/*------------------------END LINK CLICK------------------------------------------------*/ 
	 
	 
		
	/*------------------------START CALL OF OUTOF BOUNDS TIMER-------------------------------*/	
		$(".showAnswer, .goToLink").hover(
			function() {
				clearTimeout(oobTimeout);
			},
			function() {
				oobTimeout = initOutOfBoundsTimer();
			}
		);
	/*------------------------END CALL OF OUTOF BOUNDS TIMER--------------------------------*/ 
 
 
 
 
 
 
 
 
});
/*------------------------END DOCUMENT READY----------------------------------------------*/	


















 
