/* Author: Rocky SIGNAVONG
*/

function isDisplayed(object)
{
	// if the object is visible return true
	if($(object).css('display') == 'block')
	{
		return true;
	}

	// if the object is not visible return false
	return false;
}

$(document).ready(function() {
	var Intuition = new INTUITION();
	Intuition.loadAll();
	
	$('#logo,#logotxt,#footer').bind('click', function(){
		if ($(':animated').length || $(this).hasClass('current')) {
			return false;
		}
		
		$(location).attr('href',"http://www.intuitionparis.fr");
	});
	
	$('#collections,#intuition,#contact').hover(
		function () {
			if ($(':animated').length) {
				$(this).css('cursor', 'default');
				return false;
			}
			$(this).css('cursor', 'pointer');
			if (!$(this).hasClass('selected'))
				$(this).addClass('current', 200);
			if ($(this).attr('id') == 'collections')
				$('#subcollections').fadeIn(300);
		},
		function () {
			if ($(':animated').length) {
				return false;
			}
			if (!$(this).hasClass('selected') && $(this).attr('id') != 'collections')
				$(this).removeClass('current', 200);
		}
	);
	

	$('#subcollections').mouseenter(
		function () {
			if ($(':animated').length) {
				return false;
			}
			$('#collections').addClass('current');
		}
	);

	var leavecollection = function () {
		if ($(':animated').length) {
			return false;
		}
		$('#collections').removeClass('current', 200);
		$('#subcollections').fadeOut(300);	
	}
	
	$('#subcollections').bind('mouseleave', leavecollection);

	$('#mcatalogue,#mlookbook11').hover(
			function () {
				if ($(':animated').length) {
					return false;
				}
				if (!$(this).hasClass('selected'))
					$(this).addClass('current', 200);
			},
			function () {
				if ($(':animated').length) {
					return false;
				}
				if (!$(this).hasClass('selected'))
					$(this).removeClass('current', 200);
			}
	);
	
	$('#mcatalogue,#mlookbook11,#mlookbook10').bind('click', function(){
		if ($(':animated').length || $(this).hasClass('selected')) {
			return false;
		}
		var selected = $(this);
		$('.selected').removeClass('selected', 200);
		$('#subcollections').unbind('mouseleave');
		$('#subcollections').find('li').removeClass('selected');
		$('#collections').addClass('selected');
		$('#subcollections ul li').removeClass('current');
		$(this).addClass('selected');
		$('#content').fadeOut(1000, function() {
			$('#content').load($(selected).attr('id')+'.html', function() {
				$('#content').fadeIn(1000);
			});

		});
	});
	
	$('#intuition,#contact').bind('click', function(){
		if ($(':animated').length || $(this).hasClass('selected')) {
			return false;
		}
		
		var selected = $(this);
		
		$('#content').fadeOut(1000, function() {
			if ($(selected).attr('id') == "intuition" || $(selected).attr('id') == "contact") {
				$('#content').load($(selected).attr('id')+'.html', function() {
					$('#content').fadeIn(1000);
				});
			}
		});
		if ($(this).attr('id') != 'collections') {
			$('#subcollections').bind('mouseleave',leavecollection);
			$('#subcollections').fadeOut(300);
		}
		$('.current').removeClass('current', 200);
		$('.selected').removeClass('selected', 200);
		$(this).addClass('selected');
		$('li').removeClass('current', 200);
	});
	
	$('a').live('click', function() {
		var selected = $(this);

		$('#content').fadeOut(1000, function() {
			$('#content').load($(selected).attr('href'), function() {
				$('#content').fadeIn(1000);
			});
		});
		return false;
	});
	
});
