
(function($){ 
     $.fn.extend({  
         animateTab: function( callback ) {
      var that = this;
			
			function getHref(el){
				hash = $(el).find('a').attr('href');
				hash = hash.substring(0,hash.length-4);
				return hash;
			}
			
		 	function setActive(el){
		 		
				$(el).addClass('active');
				$(el).animate({opacity: 1}, 200);
				
				//$(getHref(el)).show();
				$(el).siblings('li').each(function(){
					if ($(this).hasClass('active')) {
						$(this).animate({opacity: 0.6}, 200);
						$(this).removeClass('active');
						$(getHref(this)).fadeOut(200, function(){
							$(getHref(el)).fadeIn(200);
						});
					}

				});
			}
						
			return this.each(function() {
			
				var self = this;
				var	callbackArguments 	=	{'ul':$(self)};
					
				$(this).find('li a').each(function(){
					$(this).attr('href',$(this).attr('href') + '-tab');
				});
				
				
				function handleHash(){
					
					if(location.hash && $(self).find('a[href=' + location.hash + ']').length > 0){
						setActive($(self).find('a[href=' + location.hash + ']').parent());
					}
				}
				
				function introFade() {
					$(that).find('li').animate({opacity: 0.6}, 2000);
				}
				
				if(location.hash){
					handleHash();
				}
					
				setTimeout(introFade, 1000);
				
				$(this).find('li').each(function(){
					if($(this).hasClass('active')){
						$(getHref(this)).show();
					} else {
						$(getHref(this)).hide();
					}
					
					$(this).click(function (){
						setTimeout(handleHash, 100);
					});
					
					// TK opacity
					$(this).hover(function(e){
						$(this).animate({opacity: 1}, 200);
					}, function(e){
						if (!$(this).hasClass('active')) {
							$(this).animate({opacity: 0.6}, 200);
						}
					});
				});
				
				if(callback){
					callback(callbackArguments);
				}	
				
            }); 
        } 
    }); 
})(jQuery);

$(document).ready(function() {
	// slide show
	$( '#ing_menu' ).animateTab();
	var platform = navigator.platform;
	var isTablet = (platform.indexOf("iPad") != -1) ||
		(platform.indexOf("iPhone") != -1) ||
    (platform.indexOf("iPod") != -1);
	
	// window readjustment for small browser windows
	var windowHeight = $(window).height();
	if (!isTablet && windowHeight < 750) {
		$('body').addClass('small_window');
	}
	
	// add class for iPad and iPhone etc
	if (isTablet) {
		$('body').addClass('tablet');
	}
	
	// for large browser windows, increase the top margin
	if (windowHeight > 870) {
		var margin = (windowHeight - 735) / 2;
		$('#page').css('margin-top', margin+'px')
	}
	
});

