(
		function(a){
	
			a.belowthefold = function(c,d)
			{ 
				var b=a(window).height()+a(window).scrollTop();
				return b<=a(c).offset().top-d.threshold
			};
			
			a.abovethetop=function(b,c)
			{
				var d=a(window).scrollTop();
				return d>=a(b).offset().top+a(b).height()-c.threshold
			};
			
			a.rightofscreen=function(c,d)
			{
				var b=a(window).width()+a(window).scrollLeft();
				return b<=a(c).offset().left-d.threshold
			};
		
			a.leftofscreen=function(b,c){
				var d=a(window).scrollLeft();
				return d>=a(b).offset().left+a(b).width()-c.threshold
				};
				
			a.inviewport=function(b,c){
				return !a.rightofscreen(b,c)&&!a.leftofscreen(b,c)&&!a.belowthefold(b,c)&&!a.abovethetop(b,c)
				
			};
			
			a.extend(a.expr[":"],{
				"below-the-fold":function(c,d,b){return a.belowthefold(c,{threshold:0})},
				"above-the-top":function(c,d,b){return a.abovethetop(c,{threshold:0})},
				"left-of-screen":function(c,d,b){return a.leftofscreen(c,{threshold:0})},
				"right-of-screen":function(c,d,b){return a.rightofscreen(c,{threshold:0})},
				"in-viewport":function(c,d,b){return a.inviewport(c,{threshold:0})}})})(jQuery);

			var Core={
					positionChecker:null,
					positionChecked:false,
					navPosition:"#home",
					navigation:{"#home":{prev:null,next:"#about"},
								"#about":{prev:"#",next:"#travel"},
								"#travel":{prev:"#about",next:"#program"},
								"#program":{prev:"#travel",next:"#register"},
								"#register":{prev:"#program",next:null}},
					TOP_AREA:0,
					
								
					position:function(a){
						Core.navPosition=a},
					
				 goNext:function(){
					 var a=Core.navigation[Core.navPosition].next;
					 if(a!=null){
						 Core.scrollTo(a)}
					 },
					 
			    goPrev:function(){
			    	var a=Core.navigation[Core.navPosition].prev;
			    	if(a!=null){
			    		if(a=="#home"){
			    			$("html,body").animate({scrollTop:0},1200)}
			    		else{
			    			Core.scrollTo(a)}
			    		}
			    	},
			    
			    scrollTo:function(d,c){
			    	var a=$(d);
			    	c=typeof c!=="undefined"?parseInt(c,10):0;
			    	a=a.length&&a;
			    	if(a.length){
			    		var b=a.offset().top-c;
			    		if($.browser.opera){
			    			$("html").animate({scrollTop:b},1200)}
			    		else{
			    			$("html,body").animate({scrollTop:b},1200)}
			    		}
			    	},
			    	
			    	scrollUp:function(){$(window).scrollTop(0)},
			    	
			    	doAtTop:function()
			    	{ 
			    		var a=null;
			    	
			    		if(typeof window.scrollY==="undefined")
			    		{
			    			a=parseInt(document.documentElement.scrollTop,0)
			    		}
			    		else
			    		{
			    			a=parseInt(window.scrollY,0)
			    		}
			    		if(!Core.positionChecked && a<=Core.TOP_AREA)
			    		{
			    			if(!$("header a span").is(":animated"))
			    			{
			    			//	$("header a span").stop().pulse()
			    			}
			    			Core.positionChecked=true;
			    			Core.position("#home")
			    		}	
			    			else{Core.positionChecked=false}
			    		}
			};/*end var core*/
			
			
			$(document).ready(function(){
											
				$("a[href*=#]").click(function(e){ 
							
					if(location.pathname.replace(/^\//,"")==this.pathname.replace(/^\//,"")&&location.hostname==this.hostname)
					{ 
						
						if(!$(this).hasClass('selected'))							
							Core.scrollTo($(this.hash))
						
					}
					else if(location.pathname.replace(/^\//,"")!='') return true; // comes from another page different from home
					
					return false;});
				
				var c=$.browser=="msie"&&$.browser.version<7;
			
			
				if(!c){
					var d=$("#access ul").offset().top-parseFloat($("#access ul").css("margin-top").replace(/auto/,0));

					$(window).scroll(function(e){	
						var f=$(this).scrollTop(); 
						if(f>=d){
							$("#access ul").addClass("sticky")}
						else{
							$("#access ul").removeClass("sticky")}
							})
						}
				
				
				$(window).scroll(function(){
					
					var g="#"+$("body .target a:in-viewport").parent().attr("id"),e=$("#access ul li a").filter("[href*="+g+"]");
					
					var f=true;
					if($.browser.msie&&$.browser.version=="7.0")
					{
						if(parseInt(document.documentElement.scrollTop,10)<6300&&g=="#register"){f=false}
					}
					
					
					if(e.length && !e.is(".active"))
					{ 
						
						$("#access ul li.active a").parent("li").removeClass("active");
						
						if(f){
							e.parent("li").addClass("active")
							
						}
					}
					
			});
				
			$("#sub-spinner").activity({segments:10,width:2,space:0,length:3,color:"#fff",speed:1.5});
				$(".toggle").click(function()
					{
						if(!$("#lopd").is(":visible"))
						{
							$("#lopd").fadeIn();
							Core.scrollTo("#lopd",($(window).height()-$("#lopd").height()-50))
						}
					});
				
				var b=document.createElement("input");
				var a="placeholder" in b;
				
				if(!a){
					$(":input[placeholder]").each(function(){
						
						var e=$(this);
						if(e.val()===""){
							e.addClass("placeholder");
							e.val(e.attr("placeholder"))
							}
						
						e.focus(function(){
							e.addClass("focus");
							if(e.val()===e.attr("placeholder")){
								
								e.val("");e.removeClass("placeholder")}
							}).blur(function(){
								e.removeClass("focus");
								if(e.val()===""){
									e.addClass("placeholder");
									e.val(e.attr("placeholder"))}})}
					)
					}
			/*	Core.teaserInit()*/
				
			/*Sets homepage link as active*/	
				
			if(location.pathname =='/') // only sets home as active if we are loading the homepage
			{ 	
				var	a = $("#access ul li a").filter("[href*=#home]")
				a.parent("li").addClass("active");
			}	
		
				/* Tabs Activiation
				================================================== */

				var tabs = $('nav.tabs'); 

				tabs.each(function(i) {

					//Get all tabs
					var tab = $(this).find('> a');
					tab.click(function(e) { 

						
						//Get Location of tab's content
						var contentLocation = $(this).attr('href');

						
						//Let go if not a hashed one
						if(contentLocation.charAt(0)=="#") {

							e.preventDefault();

							//Make Tab Active
							tab.removeClass('selected');
							$(this).addClass('selected');

							//Show Tab Content & add active class
							$(contentLocation).show().addClass('selected').siblings().hide().removeClass('selected');

						}
					});
				});
			
				
				/*tooltip stuff*/
				 $('.bubbleInfo').each(function () { 
					    // options
					    var distance = 15;
					    var time = 250;
					    var hideDelay = 500;

					    var hideDelayTimer = null;

					    // tracker
					    var beingShown = false;
					    var shown = false;
					    
					    var trigger = $('.trigger', this); //console.log(trigger);
					    var popup = $('.popup', this).css('opacity', 0); //console.log(popup);
					    
					    
					    // set the mouseover and mouseout on both element
					    $([trigger.get(0), popup.get(0)]).mouseover(function () { 
					    
					      // stops the hide event if we move from the trigger to the popup element
					      if (hideDelayTimer) clearTimeout(hideDelayTimer);

					      // don't trigger the animation again if we're being shown, or already visible
					      if (beingShown || shown) { //alert('ja estou vou sair');
					        return;
					      } else {// alert('ainda n estou mas vou estar');
					        beingShown = true;

					        // reset position of popup box
					        popup.css({
					          top: 15,
					          left: 0,
					          display: 'block' // brings the popup back in to view
					        })

					        // (we're using chaining on the popup) now animate it's opacity and position
					        .animate({
					     /*     top: '+=' + distance + 'px',*/
					          left:  '-=' +distance + 'px',
					          opacity: 1
					        }, time, 'swing', function() {
					          // once the animation is complete, set the tracker variables
					          beingShown = false;
					          shown = true;
					        });
					      }
					    }).mouseout(function () {
					      // reset the timer if we get fired again - avoids double animations
					      if (hideDelayTimer) clearTimeout(hideDelayTimer);
					      
					      // store the timer so that it can be cleared in the mouseover if required
					      hideDelayTimer = setTimeout(function () {
					        hideDelayTimer = null;
					        popup.animate({
					        /*  top: '-=' + distance + 'px',*/
					        	left: '+=' + distance + 'px',
					        	opacity: 0
					        	
					        }, time, 'swing', function () {
					          // once the animate is complete, set the tracker variables
					          shown = false;
					          // hide the popup entirely after the effect (opacity alone doesn't do the job)
					          popup.css('display', 'none');
					        });
					      }, hideDelay);
					    });
					  });
				
				
				
			
			});
					
					
					
			 
					
					
					
					
					
					
					
					
					
					
					
					
					
					
