var h_cont=557;
$(document).ready(function() {
	// hover
	$('.link1 span').each(function(){
		color = $(this).parent().css('color');
		$(this).css({background:color})
	})
	
	$('.link1').hover(function(){
		$(this).find('span').css({left:'0', right:'auto'}).stop().animate({width:'100%'},500,'easeOutCirc')				   
	}, function(){
		$(this).find('span').css({right:'0', left:'auto'}).stop().animate({width:0},500,'easeOutCirc')				   
	})
	
	$('.button1 strong').css({opacity:0})
	
	$('.button1').hover(function(){
		$(this).find('strong').stop().animate({opacity:1})						 
	}, function(){
		$(this).find('strong').stop().animate({opacity:0})						 
	})
	
	$('#splash_menu a span strong').css({opacity:0})
	
	$('#splash_menu a').hover(function(){
		$(this).find('img').stop().animate({top:0})
		$(this).find('strong').stop().animate({opacity:1})
		$(this).find('span').stop().animate({top:418})
	}, function(){
		$(this).find('img').stop().animate({top:-418})
		$(this).find('strong').stop().animate({opacity:0})
		$(this).find('span').stop().animate({top:210})
	})
	
	$('#icons .img_act').css({opacity:0})
	
	$('#icons a').hover(function(){
		$(this).find('.img_act').stop().animate({opacity:1})						 
	}, function(){
		$(this).find('.img_act').stop().animate({opacity:0})						 
	})
	
	$('.partners .img_act').css({opacity:0})
	
	$('.partners a').hover(function(){
		$(this).find('.img_act').stop().animate({opacity:1}, function(){$(this).css({opacity:'none'})})							
	}, function(){
		$(this).find('.img_act').stop().animate({opacity:0})							
	})
	
	$('#content > ul >li').each(function(){
		$(this).data({height:$(this).height()})								 
	})
	
	
	$('ul#menu').superfish({
      delay:       600,
      animation:   {height:'show'},
      speed:       600,
      autoArrows:  false,
      dropShadows: false
    });
	
	
 });
$(window).load(function() {	
	
	//content switch
	var content=$('#content'),
		nav=$('.menu');
	nav.navs({
		useHash:true,
		hoverIn:function(li){
			$('> span',li).stop().animate({height:85}, function(){
				$('strong',li).stop().animate({opacity:1})
			})
			$('> a',li).stop().animate({paddingTop:25, paddingBottom:31})
		},
		hoverOut:function(li){
			if (!li.hasClass('with_ul') || !li.hasClass('sfHover')) {
				$('strong',li).stop().animate({opacity:0})
				$('> span',li).stop().animate({height:8})
				$('> a',li).stop().animate({paddingTop:31, paddingBottom:25})
			}
		}						   
	})	
	nav.navs(function(n, _){
		content.cont_sw(n);
	})
	content.cont_sw({
		showFu:function(){
			var _=this
			$.when(_.li).then(function(){
				if (_.next.attr('id')=='page_Contacts') {
					$('#map').html('<iframe width="310" height="273" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.ca/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=Hines+Management,+Toronto,+ON&amp;aq=0&amp;oq=hines+manageme&amp;sll=49.891235,-97.15369&amp;sspn=44.73264,135.263672&amp;ie=UTF8&amp;hq=Hines+Management,&amp;hnear=Toronto,+Toronto+Division,+Ontario&amp;ll=43.647503,-79.398286&amp;spn=0.006094,0.016512&amp;t=m&amp;z=14&amp;iwloc=A&amp;cid=5893726139598403749&amp;output=embed"></iframe>');
				}
				_.next.css({display:'block'}).stop().animate({height:_.next.data('height')},600,'easeInCirc');
			});
			h_cont=_.next.data('height')+85;
			centre();
			$('#content').stop().animate({height:h_cont}, function(){})
			$('#splash').stop().animate({height:8}, function(){
				$('.menu').css({display:'block'}).stop().animate({height:85})											 
			})
			
		},
		hideFu:function(){
			var _=this	
			_.li.stop().animate({height:0},600,'easeOutCirc', function(){
				_.li.css({display:'none'});
			})
			$('#splash').stop().animate({height:h_cont})
		},
		preFu:function(){
			var _=this
			_.li.css({position:'absolute', display:'none'});
			$('.menu').css({height:0, display:'none'})
		}
	})
	var m_top=50
	function centre() {
		var h=$(window).height();
		if (h>h_cont+300) {
			m_top=(h-h_cont-300)/2+50;
		} else {
			m_top=50
		}
		
			$('header').stop().animate({paddingTop:m_top})		
		
	}
	centre();
	$(window).resize(centre);
	
})
