function swapOver(nome,over){
	var obj = document.getElementById('img_'+nome);
	if(obj){
		if(over){
			var arr = obj.src.split('.');
			var newSrc = '';
			for(var x=0;x<arr.length-1;x++){
				newSrc += arr[x];
				if((x+1) <arr.length-1){
					newSrc += '.';
				}
			}
			obj.src = newSrc+'_over.'+arr[arr.length-1];
		} else {
			obj.src = obj.src.replace('_over','');
		}
	}
}

function showDescricao(element,action) {
	if (action == 'focus') {
		if (element.value == element.defaultValue) {
			element.value = '';
		}
	} else {
		if (element.value == '') {
			element.value = element.defaultValue;
		}
	}
}

function changeProduto(idproduto,idcategoria) {
	var a = new Ajax();
	
	a.onLoad = function() {
		$('div_quadroprodutos').innerHTML = this.html;
	}
		
	a.get('../../inc/routines/routines.php?action=changeProduto&idcategoria='+idcategoria+'&idproduto='+idproduto);

	indiceatual = 0;
}

var indiceatual = 0;
function mudaImagem(idproduto,imagem,indice) {
	$('td_imagemprodutopequena'+indiceatual).className = 'alpha50';

	indiceatual = indice;

	$('img_imagemprodutogrande').src = "../../../_system/scripts/image.php?file=upload/site_projeto/"+idproduto+"/"+imagem+"&w=360&h=300&resize=1";
	
	$('td_imagemprodutopequena'+indiceatual).className = '';
}

function moveProjetoLeft(){
	move_left();
	if (movePosition == 0) {
		$('td_setaleftprojetos').style.visibility = 'hidden';
	} else {
		$('td_setaleftprojetos').style.visibility = 'visible';
	}
	
	$('td_setarightprojetos').style.visibility = 'visible';
}

function moveProjetoRight(){
	move_right();
	if (movePosition == -movePositionTotal) {
		$('td_setarightprojetos').style.visibility = 'hidden';
	} else {
		$('td_setarightprojetos').style.visibility = 'visible';
	}
	
	$('td_setaleftprojetos').style.visibility = 'visible';
}

function swapImagem(action) {
	if (action == 'anterior') {
		$('#span_imagem_'+indiceatual).hide();
		indiceatual--;
		$('#span_imagem_'+indiceatual).show();
		
		if (indiceatual == 0) {
			$('#span_botaoanterior').hide();
			$('#span_botaoproxima').show();
		}else{
			$('#span_botaoanterior').show();
			$('#span_botaoproxima').hide();
			
		}
		
	} else {
		$('#span_imagem_'+indiceatual).hide();
		indiceatual++;
		$('#span_imagem_'+indiceatual).show();

		if (indiceatual == (totalimagens-1)) {
			$('#span_botaoproxima').hide();
		}
		$('#span_botaoanterior').show();
	}
	
}

/*function esconde_div(id){
	if(id == 'ferrovias'){
		document.getElementById('ferrovias').style.display = '';
		document.getElementById('agricultura').style.display = 'none';
		document.getElementById('avicultura').style.display = 'none';
		document.getElementById('ferraduras').style.display = 'none';
		document.getElementById('brincos').style.display = 'none';
	}else if(id == 'agricultura'){
		document.getElementById('ferrovias').style.display = 'none';
		document.getElementById('agricultura').style.display = '';
		document.getElementById('avicultura').style.display = 'none';
		document.getElementById('ferraduras').style.display = 'none';
		document.getElementById('brincos').style.display = 'none';
	}else if(id == 'avicultura'){
		document.getElementById('ferrovias').style.display = 'nome';
		document.getElementById('agricultura').style.display = 'none';
		document.getElementById('avicultura').style.display = '';
		document.getElementById('ferraduras').style.display = 'none';
		document.getElementById('brincos').style.display = 'none';
	}else if(id == 'ferraduras'){
		document.getElementById('ferrovias').style.display = 'none';
		document.getElementById('agricultura').style.display = 'none';
		document.getElementById('avicultura').style.display = 'none';
		document.getElementById('ferraduras').style.display = '';
		document.getElementById('brincos').style.display = 'none';
	}
	else if(id == 'brincos'){
		document.getElementById('ferrovias').style.display = 'none';
		document.getElementById('agricultura').style.display = 'none';
		document.getElementById('avicultura').style.display = 'none';
		document.getElementById('ferraduras').style.display = 'none';
		document.getElementById('brincos').style.display = '';
	}
}

*/
