$(document).ready(function() {

	// and highlight current sf tabs
	var str=location.href.toLowerCase();
	$('#topnav li a, #contact li a').each(function() {
		if (str.indexOf(this.href.toLowerCase()) > -1) {
			$(this).parent().addClass("current");
		}
	});
	$('li.current').parents().each(function(){
		if ($(this).is('li')){
			$(this).addClass("current");
		}
	});

	$(window).bind('resize',function(){
		window.location.href = window.location.href;
	});

	if ($(window).width() < 1025){
		$('#header_wrapper').stop().delay(4000).animate({'marginTop':'-296px'},500);

		$('#header_wrapper').hover(
			function () {
				$(this).stop(true).animate({'marginTop':'0'},500);
			},
			function () {
				$(this).stop().delay(500).animate({'marginTop':'-296px'},500);
			}
		)
		//ipad and iphone fix
		if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
			$('#header_wrapper').bind('touchstart', function(){
				$(this).stop(true).animate({'marginTop':'0'},500);
			});
			$('#header_wrapper').bind('touchend', function(){
				$(this).delay(5000).animate({'marginTop':'-296px'},500);
			});
		}
	}
	else{
		$('#header_wrapper').stop().delay(4000).animate({'marginTop':'-80px'},500);
	
		$('#header_wrapper').hover(
			function () {
				$(this).stop(true).animate({'marginTop':'0'},500);
			},
			function () {
				$(this).stop().delay(500).animate({'marginTop':'-80px'},500);
			}
		);
	}

	$('#footer_wrapper').stop().delay(4000).animate({'marginBottom':'-184px'},500);

	$('#footer_wrapper').hover(
		function () {
			$(this).stop(true).animate({'marginBottom':'0'},500);
		},
		function () {
			$(this).stop().delay(500).animate({'marginBottom':'-184px'},500);
		}
	);

	//ipad and iphone fix
	if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
		$('#footer_wrapper').bind('touchstart', function(){
			$(this).stop(true).animate({'marginBottom':'0'},500);
		});
	
		$('#footer_wrapper').bind('touchend', function(){
			$(this).delay(5000).animate({'marginBottom':'-184px'},500);
		});
	}

});
