/**
 * @author simon
 */
aiOneVariant={};  /* global object container */ 
aiOneVariant.global=function() {
	

	
	var init=function() {
		aiOutlet();
		aiHomePageSlider();
		aiColorSwatch();
		aiButtonHover();
	};

	var aiOutlet=function() {
		$(".block-category-navigation ul li a:contains('outlet')").css('color','#BF0000');
	}
	
	var aiHomePageSlider=function() {
		if ($('#aiSliderWrap').length > 0) {
			$('#aiSliderWrap').cycle({
				fx : 'scrollRight',
				timeout : 8000,
				delay : 1000,
				speed : 1500
			});	
		}	
	}

	var aiColorSwatch=function() {
		$('.attributes div table td').each(function(){
			var color;
			var $label=$(this).find('label');
			var labelText=$label.text();
			switch (labelText) {			
				case 'visón': case 'mink':
					color="#C19A6B";
					break;	
				case 'nácar': case 'pearl':
					color="#FAEBD7";
					break;
				case 'negro': case 'black':
					color="#000000";
					break;				
				case 'blanco': case 'white':
					color="#ffffff";
					break;				
				case 'marino': case 'navy':
					color="#000080";
					break;			
				case 'azul eléctrico': case 'azure':
					color="#2A52BE";
					break;	
				case 'rosa carmín': case 'crimson':
					color="#DC143C";
					break;	
				case 'malva': case 'violet':
					color="#E0B0FF";
					break;	
				case 'morado': case 'mauve':
					color="#8F00FF";
					break;			
				case 'hierba seca': case 'moss':
					color="#465945";
					break;			
				case 'rojo': case 'red':
					color="#FF0000";
					break;			
				case 'marrón choco': case 'chocolate':
					color="#321414";
					break;			
				case 'gris': case 'gray':
					color="#BEBEBE";
					break;				
				case 'granate':case 'garnet':
					color="#65000B";					
					break;		
				case 'plata':case 'silver':
					color="#C0C0C0";					
					break;		
				case 'rosa pastel':case 'rose':
					color="#FFC0CB";					
					break;		
				case 'lyon':
					color="#704214";					
					break;		
				case 'natural':
					color="#FFE5B4";					
					break;		
				case 'turkesa':case 'turquoise':
					color="#30D5C8";					
					break;		
				case 'verde almendra':case 'pistachio':
					color="#93C572";					
					break;		
				case 'naranja':case 'orange':
					color="#FF7F00";					
					break;		
				case 'amarillo':case 'yellow':
					color="#FFFF00";					
					break;		
				case 'celeste':case 'sky-blue':
					color="#87CEEB";					
					break;		
				case 'arena':case 'sandy':
					color="#EDC9AF";
					break;	
				case 'beig': case 'beige':
					color="#C19A6B";
					break;		
				case 'verde': case 'green':
					color="#8DB600";
					break;		
				case 'azul': case 'blue':
					color="#007FFF";
					break;		
				case 'azul índigo': case 'indigo':
					color="#00416A";
					break;		
				case 'marfil': case 'ivory':
					color="#FAD6A5";
					break;																																																																									
			}
			$label.text('').attr('title',labelText).css('backgroundColor',color);
		});
	}
/*
 * Add hover to buttons
 */
	var aiButtonHover=function() {

		$('.productvariantaddtocartbutton,.productvariantaddtowishlistbutton').hover(
		  function () {
		    $(this).addClass("hover");
		  },
		  function () {
		    $(this).removeClass("hover");
		  }
		);
	}
	var aiPopUp=function(asset) {
		var aiPopWin="/aitallas.html";
		if (asset=='envios') {
			aiPopWin="/aienvios.html";
		}
		popupWin = window.open(aiPopWin,
 		'open_window',
 		'menubar, status, scrollbars, resizable, dependent, width=510, height=720, left=0, top=0')
	}
/*
 * Expose init,aiPopUp
 */
	return {
		init: init,aiPopUp: aiPopUp
	}; 	
}();
$(document).ready(function(){
	aiOneVariant.global.init(); 
});
