function registerFormNewsSubmit() {
	function showAlertModal(txt){
		var email = $('#stEmail').val();
		var male = $('#rbMem:checked').val();
		var female = $('#rbWoman:checked').val();
		var sport = $('#selSport').val();
		var team = $('#selTime').val();
		$(this).modal({
			url: '/locales/global/modal/alerta-validacao.jsp?email=' + encodeURIComponent(email) + '&female=' + encodeURIComponent(female) + '&sport=' + encodeURIComponent(sport) + '&team=' + encodeURIComponent(team) + '&male=' + encodeURIComponent(male),
			autoOpen: true
		});
		$(this).bind('onOpen', function(e, extra){
			$('.simpleTitle', extra).text(txt);
		});
	}
	
	function showAlertModalWithError(txt){
		$(this).modal({
			url: '/locales/global/modal/alerta-validacao.jsp',
			autoOpen: true
		});
		$(this).bind('onOpen', function(e, extra){
			$('.simpleTitle', extra).text(txt);
		});
	}
	
	$('#stEmail').focus(function(){
		if( $(this).val() == 'Digite seu email' )
			$(this).val('')
	}).blur(function(){
		if( $(this).val() == '' )
			$(this).val('Digite seu email')
	})
	
	$('.btParticipate').click(function(){
		var fldEmail = $(this).parent().find('#stEmail');
		var regMail = /^[\w!#$%&amp;'*+\/=?^`{|}~-]+(\.[\w!#$%&amp;'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
		
		if(fldEmail.val() != ''){
			if ( regMail.test(fldEmail.val()) ) {
				var selected = false;
				for(var i=0; i<2; i++){
					if( $('input[name=rbGender]').eq(i).attr('checked') ){
						selected = true;
					}
				}
				if( selected ){
					$('.part1').hide();
					$('.part2').fadeIn();
					return false;
				} else {
					showAlertModalWithError('Por favor, selecione o campo "Sexo"');
					return false;
				}
			} else {
				showAlertModalWithError('E-mail Inválido');
				return false;
			}
		} else {
			showAlertModalWithError('Por favor, preencha o campo E-mail!');
			return false;
		}
		return false;
	})
	
	$("#frmNews").submit( function() {
		showAlertModal('E-mail cadastrado com sucesso!')
		$('.part2').hide();
		$('.part1').fadeIn();
		$(this).find('#stEmail').val('Digite seu email')
		for(var i=0; i<2; i++){
			$('input[name=rbGender]').eq(i).attr('checked', false)
		}
		return false;
	})
}

function carrosselSubMenuInit(){
	/*Homens*/
	carrosselSubMenu.init('#lstmen')
	/*Mulheres*/
	carrosselSubMenu.init('#lstwomen')
	/*Crianï¿½as*/
	carrosselSubMenu.init('#lstchildren')
	/*Compre por Marca*/
	carrosselSubMenu.init('#lstshopByBrand')
	/*Compre por Esporte*/
	carrosselSubMenu.init('#lstshopBySport')
	/*Lojas Especiais*/
	carrosselSubMenu.init('#lstcat120004')
}
$(document).ready(function() {
/**
	Funtion to change Menu and Submenu Tabs
	
	@author Diego Neitzel
	@version 14:05 21/10/2009
*/
//{
	/*****
	$("#shopBySport").addClass("on");
	$(".subMenu").hide();
	$(".subMenu[title=shopBySport]").show();
	*****/
	
	var t;

	$(".menuCategories li a").hover(function() {
		
		var subCat = $(this).attr("id");
		t = setTimeout(function(){
			$(".menuCategories li a").removeClass("on");
			$(".menuCategories li a[id="+ subCat +"]").addClass("on");
			
			$(".subMenu").hide();
			$(".subMenu[title="+ subCat +"]").show();
		},150);
		
	}, function() {
		clearTimeout(t)
	});
//}



/**
	Function to open Popup Shop Cart
	
	@author Diego Neitzel
	@version 14:05 21/10/2009
*/
//{
	$('#popUpShopCart').hide();
	
	var initPopUpShopCart;
	$(function() {
		initBuyEarnBox = setTimeout(function(){
			$('.buyEarnBoxDetail').slideUp('slow');
		},5000);
	});
	
	$(".btShopCartHolder").hover(function() {
		initBuyEarnBox = setTimeout(function(){
			if(!$("#popUpShopCart").hasClass('opened')){
				$("#popUpShopCart").addClass('opened')
				$('#popUpShopCart').slideDown('slow');
			}
		},200);
	}, function() {
		clearTimeout(initBuyEarnBox)
	});
	
	$("#popUpShopCart").hover(function() {
		$('#popUpShopCart').show();
	}, function() {
		$('#popUpShopCart').slideUp('slow');
		$("#popUpShopCart").removeClass('opened')
	});
//}



/**
	Function to open "buy and earn" box in product page
	
	@author Diego Neitzel
	@version 14:05 21/10/2009
*/
//{
	
	var initBuyEarnBox;
	$(function() {
		initBuyEarnBox = setTimeout(function(){
			$('.buyEarnBoxDetail').slideUp('slow');
		},5000);
	});
	
	$('.buyEarnBox a').hover( function(){
		$('.buyEarnBoxDetail').slideDown('slow');
	});
	
	$('.boxPromotion').hover( function(){
		//$('.buyEarnBoxDetail').slideDown('slow');
	}, function(){
		$('.buyEarnBoxDetail').slideUp('slow');
	});
	
	$('.buyEarnBoxDetail').hover( function(){
		//$('.buyEarnBoxDetail').show();
	}, function(){
		$('.buyEarnBoxDetail').slideUp('slow');
	});
	
	$('.pagination li').hover( function(){
		$(this).addClass("over");
	}, function(){
		$(this).removeClass("over");
	});
});

/**
	Function to change the product thumb on hover product color. It also changes the "amplifyed" href link	
	@author Diego Neitzel
	@version 14:40 9/11/2009
*/
//{
var changeThumb;
function addThumbColors() {
	jQuery.each($('.lstProducts li ul.lstProductsColor'), function(indexUls, itemUls) {
		jQuery.each($(itemUls).children('li'), function(index, item) {
			$(this).hover(function(e) {
				var _intex = index;
				var _arr = window['arr_' + $(this).parent().parent().attr('id')];
				var _this = $(this);
				
				changeThumb = setTimeout(function(){
					_this.parent('ul').prev('p').children('a').children('img').hide(1).fadeIn('slow').attr('src',_arr[_intex]);
					_this.parent('ul').children('li').removeClass('selected');
					_this.addClass('selected');
					
					/* Change Link */
					var url = _this.children('a').attr('href');
					var urlAtual = _this.parent().parent().children('p').children('a').attr('href', url);
				},300);
				
				/* Change Photo */
				
				/* Change Price */
				var _skuCode = $(this).children('a').attr('href');
				var _pos = _skuCode.lastIndexOf('/');
				_skuCode = _skuCode.substring(_pos + 1, _skuCode.length);
				var _productCode = _skuCode.substring(0, 8);
				var _campaign = $('#campaign' + _productCode).html();
				var _prodPriceFrom = $(this).parent().parent().find('p').filter('[class=prodPriceFrom]');
				var _prodPriceTo = $(this).parent().parent().find('p').filter('[class=prodPriceTo]');
				var _prodPriceDiv = $(this).parent().parent().find('p').filter('[class=prodPriceDiv]');
				
				$.ajax({url:"/categoria/productPriceInfoAjax.jsp?skuCode=" + _skuCode + "&campaign=" + _campaign, success:function(result){
					result = result.replace(/^\s+|\s+$/g,"");
					var elements = result.split("|");
					var de = elements[0].replace(/^\s+|\s+$/g,"");
					var por = elements[1].replace(/^\s+|\s+$/g,"");
					var semJuros = elements[2].replace(/^\s+|\s+$/g,"");
					_prodPriceFrom.html(de);
					_prodPriceTo.html(por);
					_prodPriceDiv.html(semJuros);
				}});
				/* End Change Price */
				
			}, function(){
				clearTimeout(changeThumb)
			});
			
			$(this).click(function(e) {
				var url = $(this).children('a').attr('href');
				document.location.href = url;
			});
		});
	});
};
//}

/**
	Function to change the product thumb on change product color of buy together
	@author Diego Neitzel
	@version 15:45 4/2/2010
*/
//{

$(function(){
	$('.lstBuyTogether select.color').change(function(){
		var _id = $(this).attr('id'); //alert($(this).attr('id'))
		var _arr = window['arr_' + _id]; //console.info(_arr)
		var index = $(this).val();
		var idLink = _id + '_img'; //console.info(_link)
		
		$('.lstBuyTogether a[id='+idLink+']').children('img').attr('src', _arr[index]);
	})
});

function reformatBreadCrumb() {
	var tot = $(".breadCrumbs").children("li").length;
	$(".breadCrumbs").children("li").each(function(index) {
		var currItem = tot-index;
		if(currItem > 3) {
			$(this).addClass("hide");
		}
		if(currItem == 3) {
			var tmp=$(this).children(0).remove();
			$(this).append(tmp);
			$(this).append($(document.createElement("span")).html("&nbsp;/"));
		}
		if(currItem == 2) {
			var tmp=$(this).children(0).remove();
			$(this).append(tmp);
			$(this).append($(document.createElement("span")).html("&nbsp;/"));
		}
		if(currItem == 1) {
			var htm = $(this).children(0).html();
			$(this).children(0).remove();
			if(tot >= 3)
				$(this).append($(document.createElement("H1")).html(htm));
			else
				$(this).html(htm);				
		}
	});
}

function redirectToGenericError() { 
	window.location="/error.jsp";
}
function registerMoreResults() {
//	$('.viewAll').unbind('click');
	$('.viewAll').each(function() { 
		if ( $(this).hasClass('VABrands')) {
			var txt = '+ Marcas';
		} else {
			var txt = 'Ver Todos';
		}
		if(!$(this).hasClass('hideAll')){
			$(this).parent().children('ul').slideUp('fast');
			$(this).removeClass('hideAll');
			$(this).removeClass('exp');
			$(this).html(txt);
		}
	});
	$('.viewAll').click(function() {
		if ( $(this).hasClass('VABrands')) {
			var txt = '+ Marcas';
		} else {
			var txt = 'Ver Todos';
		}
		if ( $(this).hasClass('hideAll') ) {
			$(this).parent().children('ul').slideUp('fast');
			$(this).removeClass('hideAll');
			$(this).removeClass('exp');
			$(this).html(txt);
		} else {
			$(this).parent().children().slideDown('fast');
			$(this).addClass('hideAll');
			$(this).addClass('exp');
			$(this).html('Ocultar');
		}
	});
}

//}

/**
	Function to show more results on side menu
	@author Diego Neitzel
	@version 15:45 4/2/2010
*/
//{

$(document).ready(function() {
	$('.viewAll').unbind('click');
	$('.moreResults').hide();
	$('.viewAll').click(function() {
		if ( $(this).hasClass('VABrands')) {
			var txt = '+ Marcas';
		} else {
			var txt = 'Ver Todos';
		}
		if ( $(this).hasClass('hideAll') ) {
			$(this).parent().children('ul').slideUp('fast');
			$(this).removeClass('hideAll');
			$(this).removeClass('exp');
			$(this).html(txt);
		} else {
			$(this).parent().children().slideDown('fast');
			$(this).addClass('hideAll');
			$(this).addClass('exp');
			$(this).html('Ocultar');
		}
	});
});

//}


/**
	Function carrossel submenu
	@author Diego Neitzel
	@version 10:08 25/2/2010
*/
//{

var carrosselSubMenu = {
	init : function(elm){
		var li = $(elm).find('li')
		var size = 0
		
		li.each(function(i){
			$(this).parents('.subMenu').show()
			size+= $(this).outerWidth()
			$(this).parents('.subMenu:not(.show)').hide()
		})
		size = size + 6;
		if ( size < 845 ) {
			$(elm).parent().parent().parent().children('.arrowLeft').children('.prev').hide()
			$(elm).parent().parent().parent().children('.arrowRight').children('.next').hide()
		} else {
			li.parent().parent().width( size )
		}
		this.move(elm)
	},
	
	move: function(elm){ 
		var leftArrow = $(elm).parent().parent().parent().children('.arrowLeft').children('.prev');
		var rightArrow = $(elm).parent().parent().parent().children('.arrowRight').children('.next');
		var ul = $(elm);
		var cont = 0;
		var clock = null;
		if (!cont){
			$(leftArrow).parent().removeClass('lftOn')
			$(leftArrow).parent().addClass('lftOff')
		}
		
		$(leftArrow).hover(function(){
			if( !cont ) return 
			clock = setInterval(function(){
				$(rightArrow).parent().addClass('on')
				$(rightArrow).parent().removeClass('off')
				ul.css({
				'margin-left':cont 
				})
				cont+=2
				if( !cont ) {
					$(leftArrow).parent().removeClass('lftOn')
					$(leftArrow).parent().addClass('lftOff')
					clearInterval(clock)
				}
			},10)
		}, function(){
			clearInterval(clock)
		});
		
		$(rightArrow).hover(function(){
			if( -cont >= ul.parent().width() - 845 )
				return false
			clock = setInterval(function(){
				$(leftArrow).parent().removeClass('lftOff')
				$(leftArrow).parent().addClass('lftOn')
				ul.css({
				'margin-left':cont 
				})
				cont-=2
				if( -cont >= ul.parent().width() - 845 ) {
					$(rightArrow).parent().removeClass('on')
					$(rightArrow).parent().addClass('off')
					clearInterval(clock)
				}
			},10)
		}, function(){
			clearInterval(clock)
		});
	}
}
//}


/**
	Function to hide input type=hidden
	@author Diego Neitzel
	@version 09:32 5/3/2010
*/
//{

$(function(){$('input[type=hidden]').addClass('dn');})

//}


/**
	Function to amplify the link area in list of products
	
	@author Diego Neitzel
	@version 14:05 21/10/2009
*/
//{

	var amplifyLinkArea = {
		over: function(lstCl){
			$('.'+lstCl+' li:not(.iecb)').hover( function(){
				switch(true){
					case ($(this).hasClass('prodNikeSpecial')):
						$(this).addClass('overNikeSpecial');
						break;
					case ($('.'+lstCl+'').hasClass('productsHome')):
						$(this).addClass('overHome');
						break;
					case ($('.'+lstCl+'').hasClass('lstFullPage')):
						$(this).addClass('overFullPage');
						break;
					default:
						$(this).addClass('overProduct');
						break;
				}
			},function (){
				$(this).removeClass('overProduct overFullPage overHome overNikeSpecial');
			});
			
			$('.'+lstCl+' li:not(.iecb)').click( function(e){
				var link = $('a', this)[0].href;
				e.preventDefault(); // prevent double request (default and the next)
				setTimeout(function() { // make it assynchronous
					document.location.href = link;
				}, 10);
			});
		}
	}
	
	$(function(){ amplifyLinkArea.over('lstProducts'); });
	
//}

/**
	View All
	
	@author Diego Neitzel
*/
//{
function registerViewAll() {
	$('.hideItem').hide();
	$('.viewAllItens').unbind("click");
	$('.viewAllItens').click(function() {
		if ( $(this).hasClass('VABrands')) {
			var txt = '+ Marcas';
		} else {
			var txt = 'Ver Todos';
		}
		if ( $(this).hasClass('hideAllItens') ) {
			$(this).parent().parent().children('li.hideItem').slideUp(100);
			$(this).removeClass('hideAllItens');
			$(this).html(txt);
		} else {
			$(this).parent().parent().children('li.hideItem').slideDown(100);
			$(this).addClass('hideAllItens');
			$(this).html('Ocultar');
		}
	});
}
$(document).ready(function(){
	registerViewAll();
})

//}
function addSpace() {
		var fld=document.getElementById('fldBusca');
	if (fld.value == null || fld.value == "")
		fld.value = " ";
}

function submitSearchForm() {
	addSpace();
	changeFormAction();
    return false;
}

function changeFormAction() {
	if( $('.fldBusca')[0].value == "" ){
		return;
	}
	$("#searchForm").attr("action" , encodeURI("/busca/?q=" + $('.fldBusca')[0].value));
}

/**
	DHTML
	
	@author Diego Neitzel
*/
//{

var dhtml = {
	open: function(urlBanner, elmWidth, elmHeight, elmTop, container){
		var _container = null;
		(container == null) ? _container = 'body' : _container = container;
		
		var _center = 0;
		_center = (elmWidth / 2);
		
		$(document.createElement('div'))
			.attr('id', 'bannerDhtmlHolder')
			.css({position: 'absolute', zIndex: '99999', top: elmTop+'px', left: '50%', marginLeft: '-'+_center+'px', display: 'none'})
			.appendTo(_container);
		
		$(document.createElement('div'))
			.attr('id', 'bannerDhtml')
			.appendTo('#bannerDhtmlHolder');
			
		$("#bannerDhtml").html('<script type="text/javascript">swfobject.embedSWF("'+urlBanner+'", "bannerDhtml", "'+elmWidth+'", "'+elmHeight+'", "9.0.0", "/locales/global/swf/expressInstall.swf", {}, {wmode: "transparent"});</script>')
			
			
		this.show();
	},
	close:function(){
		$('#bannerDhtmlHolder').hide();
		setTimeout(function(){
			$('#bannerDhtmlHolder').remove();
		},250);
	},
	show:function(){
		$('#bannerDhtmlHolder').show();
		setTimeout(function(){$('#bannerDhtmlHolder').remove()},12000);
	}
}

//}

/**
	Size Table
	
	@author Diego Neitzel
*/
//{
var sizeTable = {
	populate: function(selBrand, selGender, getInfoTable, imgBrand, urlXml){
		var imgSrc = '/locales/global/img/sizetable/';
		
		var brandSel;
		
		if( $('#'+selBrand+'').val() != 0 ){
			brandSel = $('#'+selBrand+'').val() //pega o value com o nome da marca
			$('#'+getInfoTable+' tr').remove() //reseta a tabela
			
			$('#'+selGender+' option').remove();
			$('#'+selGender+'').append('<option value="0">G&ecirc;nero</option>'); //reseta o select de generos
			
			$.ajax({  
				type: 'GET',
				dataType: 'xml',
				url: urlXml,
				success: function(xml){
					var select = $('marca[id='+brandSel+']', xml).attr('id'); //pega no xml a tag da marca selecionada
					
					/* preenche o select de "generos" com as opcoes disponiveis */
					$('marca[id='+brandSel+'] generos', xml).each(function(i){
						var brandGenders = $(this).attr('rel')
						var options = '<option value="'+brandGenders+'">'+brandGenders+'</option>'
						$('#'+selGender+'').append(options)
					});
					
					/* troca imagem da marca */
					var brandSelLower = brandSel.toLowerCase();
					$('.'+imgBrand+' img')
						.attr('src', imgSrc + 'ico_tbl_tamanho_' + brandSelLower + '.jpg')
						.attr('alt', brandSel)
						.attr('title', brandSel)
				}
			});
		}
		
		$('#'+selBrand+'').change(function(){
			brandSel = $(this).val(); //pega o value com o nome da marca
			$('#'+getInfoTable+' tr').remove() //reseta a tabela
			
			if(brandSel == 0) {
				$('#'+selGender+' option').remove();
				$('#'+selGender+'').append('<option value="0">G&ecirc;nero</option>'); //reseta o select de generos
			} else {
				$('#'+selGender+' option').remove();
				$('#'+selGender+'').append('<option value="0">G&ecirc;nero</option>'); //reseta o select de generos
				
				$.ajax({  
					type: 'GET',
					dataType: 'xml',
					url: urlXml,
					success: function(xml){
						var select = $('marca[id='+brandSel+']', xml).attr('id'); //pega no xml a tag da marca selecionada
						
						/* preenche o select de "generos" com as opcoes disponiveis */
						$('marca[id='+brandSel+'] generos', xml).each(function(i){
							var brandGenders = $(this).attr('rel')
							var options = '<option value="'+brandGenders+'">'+brandGenders+'</option>'
							$('#'+selGender+'').append(options)
						});
						
						/* troca imagem da marca */
						var brandSelLower = brandSel.toLowerCase();
						$('.'+imgBrand+' img')
							.attr('src', imgSrc + 'ico_tbl_tamanho_' + brandSelLower + '.jpg')
							.attr('alt', brandSel)
							.attr('title', brandSel)
					}
				});
				
			}
		})
		
		$('#'+selGender+'').change(function(){
			var selected2 = $(this).val();
			$('#'+getInfoTable+' tr').remove()
			
			$.ajax({  
				type: 'GET',
				dataType: 'xml',
				url: urlXml,
				success: function(xml){
					var _titulos = $('marca[id='+brandSel+'] generos[rel='+selected2+'] tipoTamanho', xml)
					
					var _tamanhoLen = $('marca[id='+brandSel+'] generos[rel='+selected2+'] tipoTamanho:eq(0) tamanho', xml).length;
					
					var _tamanhoTd = parseInt(100 / _titulos.length);
					
					/* insere os titulos na tabela */
					$('#'+getInfoTable+' thead').append('<tr></tr>')
					var _tit;
					$('marca[id='+brandSel+'] generos[rel='+selected2+'] tipoTamanho', xml).each(function(i){
						_tit = $(this).attr('rel');
						
						var tituloTbl = '<td width="'+_tamanhoTd+'%">'+_tit+'</td>';
						
						$('#'+getInfoTable+' thead tr').append(tituloTbl);
					});
					
					/* cria estrutura da tabela */
					for(var i=0; i<_tamanhoLen; i++){
						$('#'+getInfoTable+' tbody').append('<tr></tr>');
						for(var z=0; z<_titulos.length; z++){
							$('#'+getInfoTable+' tbody tr').eq(i).append('<td></td>');
						}
					}
					
					/* insere os dados na tabela */
					for(var y=0; y<_titulos.length; y++){
						var _tipoTamanho = $('marca[id='+brandSel+'] generos[rel='+selected2+'] tipoTamanho', xml).eq(y)
						
						for(var i=0; i<_tamanhoLen; i++){
							var _tamanho = _tipoTamanho.children('tamanho').eq(i).text();
							$('#'+getInfoTable+' tbody tr').eq(i).children('td').eq(y).append(_tamanho);
						}
					}
					
					/* insere a class com a linha divisoria */
					var _tr = $('#'+getInfoTable+' tr');
					var _trLen = $('#'+getInfoTable+' tr').length;
					for(var i=0; i<_trLen; i++){
						_tr.eq(i).children('td').eq(0).addClass('first');
					}
				}
			});
		})
	}
};
//}

/**
	Change Background
	
	@author Diego Neitzel
	@usage background.apply('imagem.jpg', '#000', 'repeat')
*/
//{

var background = {
	apply: function(img, color, repeat){
		if(!img){
			var imgBG = 'none'
		} else {
			var imgBG = 'url('+img+')'
		}
		
		if(!color){
			color = 'transparent'
		}
		
		if(!repeat){
			repeat = 'no-repeat'
		}
		
		$('.specialStore')
			.css({background: color+' '+imgBG+' center top '+repeat})
	}
}

//}

/**
	Expansible Banner
	
	@author Diego Neitzel
	@usage 	
*/
//{
var expansibleBanner = {
	current: {
		id: null,
		initWidth: 0,
		initHeight: 0,
		finalWidth: 0,
		finalHeight: 0,
		direction: null,
		open: false
	},
	
	create: function(data){
		var defaults = {
			id: null,
			bannerUrl: null, 
			initWidth: 0,
			initHeight: 0,
			finalWidth: 0,
			finalHeight: 0,
			direction: 'top',
			open: false,
			flashVars: {}
		}
		var settings = $.extend(defaults, data);
		
		var flashVars = settings.flashVars;
			params = { menu: "false", scale: "noScale", allowFullscreen: "true", allowScriptAccess: "always", wmode: "transparent"};
			attributes = {id: settings.id};
			_this = this;
		
		swfobject.embedSWF(settings.bannerUrl, settings.id, settings.finalWidth, settings.finalHeight, "9.0.0", "/locales/global/swf/expressInstall.swf", flashVars, params, attributes, function(){
			_this.apply(settings);
			
			$('#'+settings.id).mouseover(function(){
				_this.current.id = this;
				_this.current.initWidth = settings.initWidth;
				_this.current.initHeight = settings.initHeight;
				_this.current.finalWidth = settings.finalWidth;
				_this.current.finalHeight = settings.finalHeight;
				_this.current.direction = settings.direction;
			})
		});
	},
	
	apply: function(settings){
		var _this = this;
			wrapper = $('#'+settings.id).parent().parent();
			holder = $('#'+settings.id).parent();
		
		wrapper.css({
			height: settings.initHeight+'px',
			width: settings.initWidth+'px'
		})
		
		holder.css({
			height: settings.finalHeight+'px',
			width: settings.finalWidth+'px'
		})
		
		if(settings.open == true){
			_this.clip(settings, holder, 'onOpen');
		}else {
			_this.clip(settings, holder, 'onClose');
		}
		
	},
	
	open: function(){
		var _this = this;
		setTimeout(function(){
			var holder = $(_this.current.id).parent();
			
			_this.clip(_this.current, holder, 'onOpen')
		}, 17)
	},
	
	close: function(){
		var _this = this;
		setTimeout(function(){
			var holder = $(_this.current.id).parent();
			
			_this.clip(_this.current, holder, 'onClose')
		}, 17)
	},
	
	clip: function(settings, holder, pos){
		switch(settings.direction){
			case 'left':
				setTimeout(function(){
					if( pos == 'onClose' ){
						var clipLeft = settings.finalWidth - settings.initWidth;
						holder.css({
							top: 0,
							right: 0,
							clip: 'rect(0 '+settings.finalWidth+'px '+settings.initHeight+'px '+clipLeft+'px)'
						})
						
					} else if( pos == 'onOpen' ){
						holder.css({
							top: 0,
							right: 0,
							clip: 'rect(0 '+settings.finalWidth+'px '+settings.finalHeight+'px 0)'
						})
					}
				}, 1)
				break;
				
			case 'right':
				setTimeout(function(){
					if( pos == 'onClose' ){
						holder.css({
							top: 0,
							left: 0,
							clip: 'rect(0 '+settings.initWidth+'px '+settings.initHeight+'px 0)'
						})
					} else if( pos == 'onOpen' ){
						holder.css({
							top: 0,
							left: 0,
							clip: 'rect(0 '+settings.finalWidth+'px '+settings.finalHeight+'px 0)'
						})
					}
				}, 1)
				break;
				
			case 'bottom':
				setTimeout(function(){
					if( pos == 'onClose' ){
						holder.css({
							top: 0,
							left: 0,
							clip: 'rect(0 '+settings.initWidth+'px '+settings.initHeight+'px 0)'
						})
					} else if( pos == 'onOpen' ){
						holder.css({
							top: 0,
							left: 0,
							clip: 'rect(0 '+settings.finalWidth+'px '+settings.finalHeight+'px 0)'
						})
					}
				}, 1)
				break;
				
			case 'top':
				setTimeout(function(){
					if( pos == 'onClose' ){
						var clipTop = settings.finalHeight - settings.initHeight;
						holder.css({
							bottom: 0,
							left: 0,
							clip: 'rect('+clipTop+'px '+settings.initWidth+'px '+settings.finalHeight+'px 0)'
						})
						
					} else if( pos == 'onOpen' ){
						holder.css({
							bottom: 0,
							left: 0,
							clip: 'rect(0 '+settings.finalWidth+'px '+settings.finalHeight+'px 0)'
						})
					}
				}, 1)
				break;
			
			case 'leftBottom':
				setTimeout(function(){
					if( pos == 'onClose' ){
						var clipLeft = settings.finalWidth - settings.initWidth;
						holder.css({
							top: 0,
							right: 0,
							clip: 'rect(0 '+settings.finalWidth+'px '+settings.initHeight+'px '+clipLeft+'px)'
						})
						
					} else if( pos == 'onOpen' ){
						holder.css({
							top: 0,
							right: 0,
							clip: 'rect(0 '+settings.finalWidth+'px '+settings.finalHeight+'px 0)'
						})
					}
				}, 1)
				break;
				
			default:
				//alert('erro')
		}
	}
}
//}

/**
	Share on Twitter, Facebook, Orkut
	
	@author Diego Neitzel
	@usage 	
*/
//{
var socialBookmark = {
	share: function(data){
		if(data.url){
			var url = data.url;
		} else {
			var url = document.location.href;
		}
		var description = data.description;
		
		if(data.tracker)url+=data.tracker;
		
		if(description.length > 200) description=description.substring(0,197)+'...';
		
		switch (data.service.toLowerCase()){
			case 'orkut':
				if(_gaq){
					_gaq.push(['_trackSocial', 'orkut', 'compartilhe', document.location.href]);					
				}
				window.open('http://promote.orkut.com/preview?nt=orkut.com&tt='+data.title+'&du='+url+'&tn='+data.thumb+'&cn='+description);		
				break;
				
			case 'facebook':
				if(_gaq){
					_gaq.push(['_trackSocial', 'facebook', 'compartilhe', document.location.href]);					
				}
				window.open('http://www.facebook.com/share.php?u='+url+'&t='+data.title);
				break;
				
			case 'twitter':
				if(_gaq){
					_gaq.push(['_trackSocial', 'twitter', 'compartilhe', document.location.href]);					
				}
				window.open('http://twitter.com/share?url='+encodeURIComponent(url)+'&text='+encodeURIComponent(data.title)+' '+encodeURIComponent(data.txtTwitt)+'&via=SigaNetshoes');
				break;
		}
	}
}
//}

/**
	Show youtube videos
	
	@author Diego Neitzel
*/
//{
var youtube = {
	init: function(url, target, pag){
		var _this = this;
		
		$.getJSON(
			url,
			function(data){
				_this.showVideos(data, target, pag);
			}
		)
	},
	showVideos: function(data, target, pag){
		var entries = data.feed.entry;
		var _this = this;
		
		$(entries).each(function(i, elm){
			var title = entries[i].title.$t;
			var thumbnailUrl = entries[i].media$group.media$thumbnail[0].url;
			var playerUrl = entries[i].media$group.media$content[0].url;
			var html = '<li><a href="'+playerUrl+'"><img src="'+thumbnailUrl+'" title="'+title+'" alt="'+title+'" width="120" height="90"></a><p>'+title+'</p></li>';

			$(target+' ul').append(html)
		})
		$(target+' ul li').eq(0).addClass('first');
		
		this.onClick(target, pag)
	},
	onClick: function(target, pag){
		var _this = this;
		
		$(target+' ul li').click(function(){
			var videoCode = _this.videoCode(this);
			var url = location.href+'tv-netshoes.jsp?v='+videoCode;
			if(pag){
				document.location.href = url;
				return false;
			} else {
				_this.insertVideo(videoCode)
				return false;
			}
		})
	},
	videoCode: function(elm){
		return $(elm).children('a').attr('href').substring(25, 36);
	},
	insertVideo: function(videoCode){
		$('.videoWrapper .videoHolder').html('<object width="540" height="386"><embed src="http://www.youtube.com/v/'+videoCode+'&hl=pt_BR&fs=1&color1=0x3a3a3a&color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="540" height="386" wmode="transparent"></embed></object>')
	}
}
//}

function openPopHelp(){
	window.open("http://netshoesnew.neoassist.com/?th=netshoesnew&action=answer&id=988335&match_number=1&question=&cat=200881", "Chat" , "status , scrollbars=no ,width=498, height=536 , top=0 , left=0");
}

function openPopHelpEsteira(){
	window.open("http://www10.directtalk.com.br/chat31/?idd=EC4D000634A450017406", "Chat" , "status , scrollbars=no ,width=498, height=536 , top=0 , left=0");
}
