fields = {
	empty : function(which){
		fields.initialValue = $(which).attr('value');
		
		if($(which).attr('value') == fields.initialValue){
			$(which).attr('value', '');
		}

		$(which).bind("blur", function(){
			if(this.value == ""){ this.value = fields.initialValue; }
		});
	}
}


editorsPicks = {
	init : function(w){
		editorsPicks.currentLi = 0;
		editorsPicks.w = w;
		// Set all the li positions
		$.each($('#editorsPicks ul li'), function(i){
			$('#editorsPicks ul li:eq('+i+')').css({
				'position' : 'absolute',
				'left' : editorsPicks.w * i
			});
		});
		
	},
	next : function(){
		$.each($('#editorsPicks ul li'), function(i){
			$('#editorsPicks ul li:eq('+i+')').animate({
			   left: (i * editorsPicks.w) - editorsPicks.w
			 }, 500, function(){
				$.each($('#editorsPicks ul li'), function(i){
					$('#editorsPicks ul li:eq('+i+')').css({
						'position' : 'absolute',
						'left' : editorsPicks.w * i
					});
				});
			});
		});

		$('#editorsPicks ul li:first-child').appendTo($('#editorsPicks ul'));
	},
	previous : function(){
		$('#editorsPicks ul li:last-child').css('left', -editorsPicks.w);
		$('#editorsPicks ul li:last-child').prependTo($('#editorsPicks ul'));
		
		$.each($('#editorsPicks ul li'), function(i){
			$('#editorsPicks ul li:eq('+i+')').animate({
			   left: (i * editorsPicks.w)
			 }, 500);
		});
	}
}

shoppingAlerts = {
	init : function(){
		shoppingAlerts.currentLi = 0;

		// Set all the li positions
		$.each($('#shoppingAlerts ul li'), function(i){
			$('#shoppingAlerts ul li:eq('+i+')').css({
				'position' : 'absolute',
				'left' : 140 * i
			});
		});
		
	},
	next : function(){
		$.each($('#shoppingAlerts ul li'), function(i){
			$('#shoppingAlerts ul li:eq('+i+')').animate({
			   left: (i * 140) - 140
			 }, 500, function(){
				$.each($('#shoppingAlerts ul li'), function(i){
					$('#shoppingAlerts ul li:eq('+i+')').css({
						'position' : 'absolute',
						'left' : 140 * i
					});
				});
			});
		});

		$('#shoppingAlerts ul li:first-child').appendTo($('#shoppingAlerts ul'));
	},
	previous : function(){
		$('#shoppingAlerts ul li:last-child').css('left', - 140);
		$('#shoppingAlerts ul li:last-child').prependTo($('#shoppingAlerts ul'));
		
		$.each($('#shoppingAlerts ul li'), function(i){
			$('#shoppingAlerts ul li:eq('+i+')').animate({
			   left: (i * 140)
			 }, 500);
		});
	}
}

hotItems = {	
	init : function(){
		$("a[@rel=hot]").bind('mouseover', function(event){
			hotItems.create();
			hotItems.positionItem(event);
		});
		
		$("a[@rel=hot]").bind('mouseout', function(){
			hotItems.hide(this);
		});
		
		$("a[@rel=hot]").bind('mousemove', function(event){
			hotItems.positionItem(event);
		});
	},
	create : function(caller){
		$('body').append('<span id="hotItem" class="hotItem">Hot!</span>');
	},
	hide : function(){
		$('#hotItem').remove();
	},
	positionItem : function(eventObject){
		if($.browser.msie){
			hotItems.cursorX = eventObject.x;
			hotItems.cursorY = eventObject.y + document.documentElement.scrollTop - 40;
		}else{
			hotItems.cursorX = eventObject.pageX;
			hotItems.cursorY = eventObject.pageY - 30;
		}

		$('#hotItem').css({
			'left' : hotItems.cursorX,
			'top' : hotItems.cursorY
		});
	}
}

tendanceItems = {	
	init : function(){
		$("a[@rel=tendance]").bind('mouseover', function(event){
			tendanceItems.create();
			tendanceItems.positionItem(event);
		});
		
		$("a[@rel=tendance]").bind('mouseout', function(){
			tendanceItems.hide(this);
		});
		
		$("a[@rel=tendance]").bind('mousemove', function(event){
			tendanceItems.positionItem(event);
		});
	},
	create : function(caller){
		$('body').append('<span id="tendanceItem" class="tendanceItem">Tendance</span>');
	},
	hide : function(){
		$('#tendanceItem').remove();
	},
	positionItem : function(eventObject){
		if($.browser.msie){
			tendanceItems.cursorX = eventObject.x;
			tendanceItems.cursorY = eventObject.y + document.documentElement.scrollTop - 40;
		}else{
			tendanceItems.cursorX = eventObject.pageX;
			tendanceItems.cursorY = eventObject.pageY - 30;
		}

		$('#tendanceItem').css({
			'left' : tendanceItems.cursorX,
			'top' : tendanceItems.cursorY
		});
	}
}

subitem = {
	open : function(caller){
		// Get the longest item with
		currentLength = 0;
		$.each($(caller).find('ul li a'), function(i){
			currentText = $(caller).find('ul li a:eq('+i+')').text();
			if(currentText.length > currentLength){
				currentLength = currentText.length;
			}
		});
		
		$.each($(caller).find('ul li a'), function(i){
			$(caller).find('ul li a:eq('+i+')').width(currentLength * 7);
			$(caller).find('ul li:eq('+i+')').width(currentLength * 7);
			$(caller).find('ul').width(currentLength * 7);
		});
		
		$(caller).find('ul').show();
	},
	close : function(caller){
		$(caller).find('ul').hide();
	}
}


var obj = null;
var tooltipZindex = 3;

clothesViewer = {
	init : function(){
		$("a[@rel=plus]").hover(function() {
			if (obj) {
				obj.hide();
				obj = null;
			} //if
			$(this).parent().css('z-index',tooltipZindex++);
			$(this).next().show();
		},
		function() {
			obj = $(this).next();
			setTimeout("clothesViewer.checkHover()",1000);
		});
		
		$("a[@rel=plus]").next().hover(function() {
			clearTimeout();
			if (obj) {
				obj.hide();
				obj = null;
			} //if
			$(this).show();
		},
		function() {
			obj = $(this);
			setTimeout("clothesViewer.checkHover()",100);
		});
	},
	checkHover : function(caller){
		if(obj){
			obj.hide();
		}
	}
}

gallery = {
	init : function(){
		$("a[@rel=gallery]").hover(function() {
			if (obj) {
				obj.hide();
				obj = null;
			} //if
			$(this).parent().parent().parent().css('z-index',tooltipZindex++);
			$(this).parent().parent().next().show();    
		},
		function() {
			obj = $(this).parent().parent().next();
			setTimeout("gallery.checkHover()",1000);
		});
		
		$("a[@rel=gallery]").parent().parent().next().hover(function() {
			clearTimeout();
			if (obj) {
				obj.hide();
				obj = null;
			} //if
			$(this).show();
		},
		function() {
			obj = $(this);
			setTimeout("gallery.checkHover()",100);
		});
	},
	checkHover : function(caller){
		if(obj){
			obj.hide();
		}
	}
}

flyout = {
	open : function(){
		$('#flyoutBox').show();
	},
	close : function(){
		$('#flyoutBox').hide();
	}
}

/*===========================================
============================
removeExternal
Information : Enlève les icônes de lien externe aux liens avec image
============================
===========================================*/

function removeExternal()
{
	var a = document.getElementsByTagName("a");
	for (var i=0;i<a.length;i++)
	{
	var string = a[i].innerHTML;
	if(string.substring(0,4) == "<img" || string.substring(0,4) == "<IMG")
		{
		a[i].style.background = 'none';
		a[i].style.padding = '0';
		}
	} 
}

// ========================================	