/*
 * global PHONAK ADMIN namespace & jquery noconflict
 */
var kAIRin = {
	debug: false,
	validation: true
};

/*
 * Initialize page when it finished loading DOM
 */
kAIRin.init = function() {
  	
  	$(document).ready(function() {
  	
		kAIRin.theLayout.binder();
		kAIRin.theContent.binder();
    
  	});

} ();
/*
 * Handles Startpage
 */
kAIRin.theLayout = {

	binder: function() {
		if ((navigator.platform.indexOf("iPhone") != -1) || (navigator.platform.indexOf("iPod") != -1)) {
		
		} else {
			this.backGround();
		}
		        
		 
		
		//this.navInfo();
	},
	
	backGround: function () {
			$('img.bgmaximage').maxImage({
				isBackground: true,
				overflow: 'auto'
			});
			
	},
	navInfo: function () {
			var info = "";
			var meInfo = "About me and my Bikes.";
			var photoInfo = "My Bike Pix here.";
			var videoInfo = "A video how I ride.";
			var storiesInfo = "My personal bike experience";
			var wall = "My blog posts";
			
		
			
			$('.nav li').live('mouseover', function(event) {
				if ($(event.target).is('.page-item-2')) {
				  	info = meInfo;
					$('.nav').find('div.bubble').remove();
					$(event.target).append('<div class="bubble">' + info + '</div>').fadeIn();
				} else if ($(event.target).is('.page-item-1541')) {
					info = photoInfo;
					$('.nav').find('div.bubble').remove();
					$(event.target).append('<div class="bubble">' + info + '</div>').fadeIn();
				} 
				
					
			});
		
			
	}
},
kAIRin.theContent = {

	binder: function() {
		//this.twitter();
		this.sideBar();
		this.readMore();
	},
	
	twitter: function () {
			$("#twitter").getTwitter({
				userName: "bikAIRin",
				numTweets: 3,
				loaderText: "Loading tweets...",
				slideIn: true,
				showHeading: true,
				headingText: "Latest Tweets",
				showProfileLink: true
			});
	},
	readMore: function () {
			//$('.more').hide();
			$('.readMore').live('click', function() {
				$(this).next('.more').slideDown('800');
				
				return false;
			});
	},
	sideBar: function () {
		$('.right ul ul').hide();
		$('.right ul ul ul').show();
		$('.right ul li h3').toggle(function() {
			$('ul li').removeClass('active');
			$('.right ul ul').slideUp('800');
			$(this).next().slideDown('800');
			$(this).parent().addClass('active');
		}, function() {
			$(this).next().slideUp('800');
			$('ul li').removeClass('active');
		});
		
		
		$('li.cat-item').click(function(event) {
			if ($(event.target).next().is('ul')) {
				$('.right ul ul').slideUp('800');
				$(this).find('ul').slideDown('800');
				return false;
				
			}
			if ($('li.cat-item li').next().is('a')) {
				//console.info('hallo');
				return true;
				
			}
		});
		/*$('li.cat-item').toggle(function() {
			//$('li.cat-item').removeClass('active');
			$('.right ul ul').slideUp('800');
			$(this).find('ul').slideDown('800');
			$(this).parent().addClass('active');
		}, function() {
			$(this).next('ul').slideUp('800');
			$('.right ul li.cat-item').removeClass('active');
		});*/
		
	
		
		if($('.right li').hasClass('current-cat')) {
			//console.info('ja');
			$('li.current-cat').parent().show();
			}	
	}
};


