function chamaImagem(img) {
	aj('trimaniaAmpliada','ajax_imagem.php?img='+img);
	var DivRef = document.getElementById('trimaniaAmpliada');
	DivRef.style.display = "block";
}

function MostraDiv(img,state) {
	var DivRef = document.getElementById('trimaniaAmpliada');
	var IfrRef = document.getElementById('DivMestra');
	if(state) {
		DivRef.style.display = "block";
		IfrRef.style.width = DivRef.offsetWidth;
		IfrRef.style.height = DivRef.offsetHeight;
		IfrRef.style.top = DivRef.style.top;
		IfrRef.style.left = DivRef.style.left;
		IfrRef.style.zIndex = DivRef.style.zIndex - 1;
		IfrRef.style.display = "block";
		aj('trimaniaAmpliada','ajax_imagem.php?img='+img,1);
	} else {
		DivRef.style.display = "none";
		IfrRef.style.display = "none";
	}
}

function EfetuarLogout(total) {
	total = document.getElementById('quantidade').innerHTML;
	if(total == '0') {
		window.location.href = 'logout.php';
	} else {
		if(confirm("Ao efetuar o logout do site você perderá sua compra se ela\nnão foi finalizada. Deseja sair ?")){
			window.location.href = 'logout.php';
		}
	}
}
function fechaEscolhaPraca(Praca,pagina){
	if (pagina == 'selecione_praca') {
		 document.getElementById('Pracas').style.display = 'none';
		 document.getElementById('SelecionaPraca').style.display = 'none';
		 window.location.href='troca_praca.php?praca='+Praca;
	} else {
		var quantidade = document.getElementById("quantidade").innerHTML;
		if(quantidade > 0) {
			if(confirm('Trocando de Praça você perderá sua compra se ela\nnão foi finalizado. Deseja mesmo trocar de praça ?')) {
			 document.getElementById('Pracas').style.display = 'none';
			 document.getElementById('SelecionaPraca').style.display = 'none';
			 window.location.href='troca_praca.php?praca='+Praca;
			} else {
				if(document.getElementById('CombinacoesHome')) {
					document.getElementById('CombinacoesHome').style.display = '';				
				}
				fechaPraca();
			}		
		} else {
			 document.getElementById('Pracas').style.display = 'none';
			 document.getElementById('SelecionaPraca').style.display = 'none';
			 window.location.href='troca_praca.php?praca='+Praca;
		}
		

	}
}
function trocaPraca(){
	if(document.getElementById('CombinacoesHome')) {
		document.getElementById('CombinacoesHome').style.display = 'none';				
	}
	document.getElementById('Pracas').style.display = 'block';
	document.getElementById('SelecionaPraca').style.display = 'block';
}
var controleBusca = false;

function fcFocus(id){
 	if(controleBusca == false){
 		document.getElementById(id).value = '';
		//document.frm_buscaDezenasHome.dezenas.value = '';
		controleBusca = true;
	} 
}
function fcZero(id,type){
 	if(document.getElementById(id).value == ''){
		if(type == 'dezenas') {
			document.getElementById(id).value = 'EX: 02-10-18-20-22-34-36-48-50-56';
		} else {
			document.getElementById(id).value = 'EX: 83307';
		}
		controleBusca = false;
	}
	//alert(controleBusca);
}
function fechaPraca() {
	document.getElementById('Pracas').style.display = 'none';
	document.getElementById('SelecionaPraca').style.display = 'none';
	document.getElementById('CombinacoesHome').style.display = '';
}

function explode(itemm,delimiter,retorno) {
	tempArray = new Array(1);
	var Count = 0;
	var tempString = new String(itemm);
	while (tempString.indexOf(delimiter)>0) {
		tempArray[Count]=tempString.substr(0,tempString.indexOf(delimiter));
		tempString=tempString.substr(tempString.indexOf(delimiter)+1,tempString.length-tempString.indexOf(delimiter)+1);
		Count=Count+1
	}
	tempArray[Count]=tempString;
	if(retorno == "array") {
		return tempArray;
	} else {
		return Count;
	}	
} 


function verifica(valor) {
	//var possiveis = " ,/,;,:,,";
	var tamanho = valor.length;
	var teste = valor.substr(tamanho-1,tamanho);
	if(teste == '-') {
		delimitador = "-";
		var novo = explode(valor,delimitador,"array");
		var cont = explode(valor,delimitador,"count");
		if((novo[cont-1] > 60) || (novo[cont-1] < 0)) {
			novo.pop();
			cont--;
		}
		var contadorWhile = 0;
		var novoValue = "";
		while(contadorWhile < cont) {
			novoValue += novo[contadorWhile]+delimitador;			
			contadorWhile++;
		}
		document.frmDezenas.dezenas.value = novoValue;
	}
	/*else if(teste == '/') {
		delimitador = "/";
	} else if(teste == ';') {
		delimitador = ";";
	} else if(teste == ':') {
		delimitador = ":";
	} else if(teste == ',') {
		delimitador = ",";
	}*/	
}

function verifica2(valor) {
	//var possiveis = " ,/,;,:,,";
	var tamanho = valor.length;
	var teste = valor.substr(tamanho-1,tamanho);
	if(teste == '-') {
		delimitador = "-";
		var novo = explode(valor,delimitador,"array");
		var cont = explode(valor,delimitador,"count");
		if((novo[cont-1] > 60) || (novo[cont-1] < 0)) {
			novo.pop();
			cont--;
		}
		
		var contadorWhile = 0;
		var novoValue = "";
		while(contadorWhile < cont) {
			novoValue += novo[contadorWhile]+delimitador;			
			contadorWhile++;
		}
		document.frm_buscaDezenasHome.dezenas.value = novoValue;
	}
}

