function trocarFoto(foto){
		
	var so = new SWFObject("flash/viewer.swf", "fotoPrincipal", "360", "360", "8", "#FFFFFF");
	so.addVariable("img", foto);
	so.write("fotoPrincipal");
	
}

function trocarRelated(qual){
	
	var els = $$('a.tabRelated');
	var tbls = $$('.tabelaRelated');
	
	for(i=0; i<els.length; i++){
		els[i].className = 'tabRelated';
	}
	for(i=0; i<tbls.length; i++){
		tbls[i].setStyle('display', 'none');
	}
	$('related_'+qual).setStyle('display', 'block');
	try {
		$('related_'+qual).setStyle('display', 'table');
	} catch(e) {}
	$('related_'+qual).setOpacity(0);
	$('related_'+qual).fade('in');
	$('tab_'+qual).className = 'tabRelated sel';
	$('tab_'+qual).blur();
	
	/*var myFx = new Fx.Scroll('scrollRelated').set(0,0);*/



}

function relatedDireita(){
	
	/*var myFx = new Fx.Scroll('scrollRelated', {
		duration: 3000,
		wait: false
	}).toRight();*/
	
	new Fx.Scroll('scrollRelated', {
		duration: 3000,
		wait: false
	}).set(100, 0);
	//var myFx = new Fx.Scroll('scrollRelated').start(200,0);

	
}

function fadein(id){
	$(id).setOpacity(0); 
	$(id).fade("in");
}

function changeSize(codigo, tid, sel){

	$('sizeOptions').innerHTML = '<img src="imagens/loadingBranco.gif" class="icon" />';
	xajax_changeSize(codigo, tid, sel);
	
}

function addItemToCart(){
	
	$('addToCart').innerHTML = '<img src="imagens/loadingBranco.gif" class="icon" />';
	xajax_adicionarCarrinho(xajax.getFormValues('formAddToCart'));

}

function getConteudoCarrinho(msg){
	
	$('conteudoCarrinho').innerHTML = '<img src="imagens/loadingBranco.gif" class="icon" />'+msg;
	xajax_getCartContents();
	
}

function confirmDeleteCart(id, tid, message){
	
	if(confirm(message)){
		
		$('opt'+id+'_'+tid).innerHTML = '<img src="imagens/loadingBranco.gif" class="icon" />';
		xajax_eliminarCarrinho(id, tid);
	}
	
}

function changedCountry(pais){
	
	$('selectCountryCart').innerHTML = '<img src="imagens/loadingBranco.gif" class="icon" />';
	xajax_mudouPaisCarrinho(pais);
	
}

function register(){
	
	var form = $('formRegister');
	
	for(var i=0; i<form.elements.length; i++){
		form.elements[i].className = '';
	}
	$('errosRegister').style.display = 'none';
	
	$('botaoRegister').innerHTML = '<img src="imagens/loadingBranco.gif" class="icon" />';
	xajax_pRegister(xajax.getFormValues('formRegister'));
}

function processarLogin(){
	
	$('botaoLogin').innerHTML = '<img src="imagens/loadingBranco.gif" class="icon" />';
	xajax_pLogin(xajax.getFormValues('formLogin'));
	
}

function processarPagamento(){
	
	var form = $('formPayment');
	
	for(var i=0; i<form.elements.length; i++){
		form.elements[i].className = '';
	}
	$('errosPayment').style.display = 'none';
	$('botaoPayment').innerHTML = '<img src="imagens/loadingBranco.gif" class="icon" />';
	xajax_pPagamento(xajax.getFormValues('formPayment'));
	
}

function enterLogin(e){
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;

	if (keycode == 13){
		processarLogin();
		return false;
	} else return true;
}

function togglePassword(){
	
	$('profileDivPassword').style.display = ($('profileChangePassword').checked) ? 'block' : 'none';
	if($('profileDivPassword').style.display == 'block'){
		//fadein('profileDivPassword');
	}
}
function toggleEmail(){
	
	$('profileDivEmail').style.display = ($('profileChangeEmail').checked) ? 'block' : 'none';
	if($('profileDivEmail').style.display == 'block'){
		//fadein('profileDivEmail');
	}
}

function changeProfile(){
	var form = $('formProfile');
	
	for(var i=0; i<form.elements.length; i++){
		form.elements[i].className = '';
	}
	$('errosProfile').style.display = 'none';
	
	$('botaoProfile').innerHTML = '<img src="imagens/loadingBranco.gif" class="icon" />';
	xajax_pProfile(xajax.getFormValues('formProfile'));
}

function forgotPassword(){

	$('errosPassword').style.display = 'none';
	
	$('botaoPassword').innerHTML = '<img src="imagens/loadingBranco.gif" class="icon" />';
	xajax_pPassword(xajax.getFormValues('formPassword'));
	
}

function formularioEstatica(){

	var form = $('formFormulario');
	var campos = Array();
	for(var i=0; i<form.elements.length; i++){
		form.elements[i].className = '';
		campos.push(Array(form.elements[i].name, form.elements[i].id));
	}
	$('errosFormulario').style.display = 'none';
	
	var bantes = $('botaoFormulario').innerHTML;
	$('botaoFormulario').innerHTML = '<img src="imagens/loadingBranco.gif" class="icon" />';
	xajax_pFormulario(xajax.getFormValues('formFormulario'), campos, bantes);

}

function updateSelectorCount(){
		
	$('selectorResults').innerHTML = '<img src="imagens/loadingBranco.gif" class="icon" />';
	
	xajax_updateSelectorCount(xajax.getFormValues('formSelector'));
}

function updateSelector(res){
	
	if(res){
		$('selectorInf').value = 0;
	}
		
	$('selectorShoes').innerHTML = '<div id="selectorLoading"><img src="imagens/loadingBranco.gif" class="icon" /></div>';
	
	xajax_updateSelector(xajax.getFormValues('formSelector'));
	
	return false;
}

function selectorChange(valor){
	
	$('selectorInf').value = valor;
		
	updateSelector(false);
}

function ligarSlideshow(id){
	
	  var showDuration = 6000;
	  var container = $(id);
	  var images = container.getElements('.artigoPequeno');
	  var currentIndex = 0;
	  var interval;
	  /* opacity and fade */
	  images.each(function(img,i){ 
		if(i > 0) {
		  img.set('opacity',0);
		}
	  });
	  /* worker */
	  var show = function() {
		images[currentIndex].fade('out');
		images[currentIndex = currentIndex < images.length - 1 ? currentIndex+1 : 0].fade('in');
	  };
	  /* start once the page is finished loading */
	  window.addEvent('load',function(){
		interval = show.periodical(showDuration);
	  });
	
}
