$(function(){
	new Main();
});

var Main = function()
{
	mainClass = this;
	
	var _nav = null;
	var _footer = $('#footer');
	
//  Initialisation
	  this.init = function()
  	{
  		  initLinks();
    		transitionIn();
  	};
	
  	var transitionIn = function()
  	{
        var delay = $('body').hasClass('home') ? 1000 : 50;
        
    		setTimeout(function(){
    			$('#header').css({ '-webkit-transform' : 'translateY(0)' });
    			$('.page').animate({ opacity: 1 }, 900);
    		}, delay);
  	};
	
//	Bloc links
	  var initLinks = function()
	  {
  		  $('a').live('click keyup blur', function(e){
    			switch(e.type) {
    				case 'click':
    					var href = $(this).attr('href');
    					var ieHackHref = href.charAt(href.length-1);
    					if (href == '#' || ieHackHref == '#') return false;
    				break;
				
    				case 'keyup':
    					if (e.which == 9) $(this).addClass('focus');
    				break;
				
    				case 'focusout':
    					$(this).removeClass('focus');
    				break;
    			}
    		});
  	};
	
//	Utils
	  this.isMobile = function(allTypes)
  	{
  		  if (allTypes == null) allTypes = ['iPhone', 'iPad', 'iPod'];
    		var isMobile = false;
    		
    		for ( var i=0; i < allTypes.length; i++ ) {
    			if ( navigator.platform.indexOf(allTypes[i]) != -1 ) isMobile = true;
    		}
		
    		return isMobile;
  	};
	
  	this.hasCSSMatrix = function() { return (typeof WebKitCSSMatrix == "object"); };
	
// 	Constructor
	(function() {
		mainClass.init();
    })();
};
