/*Browsercheck object*/
function Busca(){
	mapwindow = window.open('modules/pages/busca.php','Procura','height=300, width=325, scrollbars=no, toolbar=no');
	mapwindow.moveTo(550, 240)
	if(window.focus){ 
		mapwindow.focus();
	}
	intervalo = window.setInterval("BuscaFocus()",5);
}
function BuscaFocus(){
	
	try{
		if(mapwindow.closed){
			window.clearInterval(intervalo);
			return;
		}
		mapwindow.focus();
	}
	catch(everything){
		
	}
}
function Volta(){
	var acc = document.getElementById("busca")
	var conta = acc.options[acc.selectedIndex].value;
	window.opener.SetLoginValues(conta);
	self.close();
}
function SetLoginValues(login){ 
	var conta = document.getElementById("conta");
	conta.value = login;
}

function BuscaChar(){
	mapwindow = window.open('modules/pages/busca.php?action=char','Procura','height=300, width=325, scrollbars=no, toolbar=no');
	mapwindow.moveTo(550, 240)
	if(window.focus){ 
		mapwindow.focus();
	}
	intervalo = window.setInterval("BuscaCharFocus()",5);
}
function BuscaCharFocus(){
	
	try{
		if(mapwindow.closed){
			window.clearInterval(intervalo);
			return;
		}
		mapwindow.focus();
	}
	catch(everything){
		
	}
}
function VoltaChar(){
	var character = document.getElementById("busca")
	var char = character.options[character.selectedIndex].value;
	window.opener.SetCharacterValues(char);
	self.close();
}
function SetCharacterValues(character){ 
	var char = document.getElementById("char");
	char.value = character;
}
//

function BuscaGuild(){
	mapwindow = window.open('modules/pages/busca.php?action=guild','Procura','height=300, width=325, scrollbars=no, toolbar=no');
	mapwindow.moveTo(550, 240)
	if(window.focus){ 
		mapwindow.focus();
	}
	intervalo = window.setInterval("BuscaGuildFocus()",5);
}
function BuscaGuildFocus(){
	
	try{
		if(mapwindow.closed){
			window.clearInterval(intervalo);
			return;
		}
		mapwindow.focus();
	}
	catch(everything){
		
	}
}
function VoltaGuild(){
	var guilde = document.getElementById("busca")
	var guild = guilde.options[guilde.selectedIndex].value;
	window.opener.SetGuildValues(guild);
	self.close();
}
function SetGuildValues(guilde){ 
	var guild = document.getElementById("guild");
	guild.value = guilde;
}

function Verifica(campo){
	if(document.getElementById(campo).checked){
		document.getElementById(campo).value = 1;
	}
	else{
		document.getElementById(campo).value = 2;
	}
}
function Pedido(id){
	Verifica("acao");
	var act = document.getElementById("acao").value;
	if(act == 1){
		if(confirm("Voce tem certeza que deseja aceitar esse pedido?\nEssa acao nao tera mais volta.")){
			location = 'index.php?page=pedido&action=pendentes&act=1&id='+ id
		}
	}
	if(act == 2){
		if(confirm("Voce tem certeza que deseja recusar esse pedido?\nEssa acao nao tera mais volta.")){
			location = 'index.php?page=pedido&action=pendentes&act=2&id='+ id
		}
	}
}

function RemoverDownload(id){
	if(confirm("Voce tem certeza que deseja remover esse downoad?\nEssa acao nao tera mais volta.")){
		location = 'index.php?page=downloads&action=remover&id='+ id
	}
}

function RemoverVideo(id){
	if(confirm("Voce tem certeza que deseja remover esse video?\nEssa acao nao tera mais volta.")){
		location = 'index.php?page=video&action=remover&id='+ id
	}
}

function RemoverScreenshot(id){
	if(confirm("Voce tem certeza que deseja remover essa screenshot?\nEssa acao nao tera mais volta.")){
		location = 'index.php?page=screenshot&action=remover&id='+ id
	}
}

function RemoverContaLanhouse(id){
	if(confirm("Voce tem certeza que deseja remover essa conta de lanhouse?\nEssa acao nao tera mais volta.")){
		location = 'index.php?page=lanhouse&action=removerconta&id='+ id
	}
}

function RemoverShop(id){
	if(confirm("Voce tem certeza que deseja remover esse item do shop?\nEssa acao nao tera mais volta.")){
		location = 'index.php?page=shop&action=remover&id='+ id
	}
}

function RemoverNoticia(id){
	if(confirm("Voce tem certeza que deseja remover essa noticia?\nEssa acao nao tera mais volta.")){
		location = 'index.php?page=novidades&action=remover&id='+ id
	}
}

function RemoverLeilao(id){
	if(confirm("Voce tem certeza que deseja remover esse leilao?\nEssa acao nao tera mais volta.")){
		location = 'index.php?page=leilao&action=remover&id='+ id
	}
}

function FinalizarLeilao(id){
	if(confirm("Voce tem certeza que deseja finazilar esse leilao?\nEssa acao nao tera mais volta.")){
		location = 'index.php?page=leilao&action=finalizar&id='+ id
	}
}

function RemoverLance(id, lance){
	if(confirm("Voce tem certeza que deseja remover esse lance?\nEssa acao nao tera mais volta.")){
		location = 'index.php?page=leilao&action=removerlance&id=' + id + '&lanceid=' + lance
	}
}

function BuscaImagem(){
	mapwindow = window.open('modules/pages/busca.php?action=imagem','Procura','height=300, width=325, scrollbars=no, toolbar=no');
	mapwindow.moveTo(550, 240)
	if(window.focus){ 
		mapwindow.focus();
	}
	intervalo = window.setInterval("BuscaImagemFocus()",5);
}
function BuscaImagemFocus(){
	
	try{
		if(mapwindow.closed){
			window.clearInterval(intervalo);
			return;
		}
		mapwindow.focus();
	}
	catch(everything){
		
	}
}
function DirChangeCat(){
	var i=0;
	var diretorio = document.getElementById('diretorio');
	location = "busca.php?action=imagem&dir="+diretorio.options[diretorio.selectedIndex].value;
}

function DirSubChangeCat(){
	var i=0;
	var diretorio = "";
	var subc = "";
	var objl = document.getElementById('diretorio');
	var objc = document.getElementById('sub');

	diretorio = objl.options[objl.selectedIndex].value;
	subc = objc.options[objc.selectedIndex].value;
	
	location = "busca.php?action=imagem&dir=" + diretorio + "&sub=" + subc;
}

function DirChangeCat2(image){
	var i=0;
	var diretorio = document.getElementById('diretorio');
	location = "busca.php?action=imagem&dir="+diretorio.options[diretorio.selectedIndex].value;
}

function DirSubChangeCat2(imagem){
	var i=0;
	var diretorio = "";
	var subc = "";
	var objl = document.getElementById('diretorio');
	var objc = document.getElementById('sub');

	diretorio = objl.options[objl.selectedIndex].value;
	subc = objc.options[objc.selectedIndex].value;
	
	location = "busca.php?action=imagem&imagem="+imagem+"&dir=" + diretorio + "&sub=" + subc;
}
function Volta(mini,foto){
		window.opener.f_mini = mini;
		window.opener.f_foto = foto;
		window.opener.SetPhotoValues(mini, foto);
		self.close();
}

function SetPhotoValues(d_mini, d_foto){
	var mini = document.getElementById("mini");
	var foto = document.getElementById("foto");
	//var foto = document.getElementById("i_foto");
	var fotow = document.getElementById("produto");

	mini.value = d_mini;
	foto.value = d_foto;
	fotow.innerHTML = '<img src='+d_mini+'>';
}

function LogoGuild(){
	var logo = document.getElementById("logo");
	mapwindow = window.open('modules/pages/eguild.php?codigo='+logo.value,'EditarGuild','height=300, width=325, scrollbars=no, toolbar=no');
	mapwindow.moveTo(550, 240)
	if(window.focus){ 
		mapwindow.focus();
	}
	intervalo = window.setInterval("LogoGuildFocus()",5);
}

function LogoGuildFocus(){
	
	try{
		if(mapwindow.closed){
			window.clearInterval(intervalo);
			return;
		}
		mapwindow.focus();
	}
	catch(everything){
		
	}
}
function VoltaLogo(){
	var str = "";
	var i = 0;
	var obj;
	
	var frm = document.forms['formLogo'];
	var inputs = frm.elements.length;
	for(i=0 ; i < inputs ; i++){
		obj = frm.elements[i].id;
		if(obj.substring(0,1) == 'v'){
			str += frm.elements[i].value;
		}
	}
	window.opener.SetLogoValues(str);
	self.close();
}
function SetLogoValues(codigo){ 
	var logo = document.getElementById("logo");
	var glogo = document.getElementById("glogo");
	logo.value = codigo;
	glogo.innerHTML = '<img src="modules/view.logo.php?code=' + codigo + '">';
}

function AtualizarCor(){

	var objc = document.getElementById('cor');
	var scor = objc.options[objc.selectedIndex].value;
	var prv = document.getElementById('preview');
	var inside = "&nbsp;";
	
	var cor = "#CCCCCC";
	
	if(scor == "0"){
		cor = "#CCCCCC";
		inside = "Transparente";
	}
	
	if(scor == "1"){cor = "#000000";}
	if(scor == "2"){cor = "#8c8a8d";}
	if(scor == "3"){cor = "#ffffff";}
	if(scor == "4"){cor = "#fe0000";}
	if(scor == "5"){cor = "#ff8a00";}
	if(scor == "6"){cor = "#ffff00";}
	if(scor == "7"){cor = "#8cff01";}
	if(scor == "8"){cor = "#00ff00";}
	if(scor == "9"){cor = "#01ff8d";}
	if(scor == "A"){cor = "#00ffff";}
	if(scor == "B"){cor = "#008aff";}
	if(scor == "C"){cor = "#0000fe";}
	if(scor == "D"){cor = "#8c00ff";}
	if(scor == "E"){cor = "#ff00fe";}
	if(scor == "F"){cor = "#ff008c";}
	prv.innerHTML = '<div align="center" style="background-color: '+cor+'; width: 79px;">'+inside+'</div>';

}
function mudarcor(id){

	var objc = document.getElementById('cor');
	var scor = objc.options[objc.selectedIndex].value;
	var dive = document.getElementById(id);
	
	var cHide = document.getElementById('v'+id);
	
	var cor = "#000000";
	
	if(scor == "0"){cor = "#CCCCCC";}
	if(scor == "1"){cor = "#000000";}
	if(scor == "2"){cor = "#8c8a8d";}
	if(scor == "3"){cor = "#ffffff";}
	if(scor == "4"){cor = "#fe0000";}
	if(scor == "5"){cor = "#ff8a00";}
	if(scor == "6"){cor = "#ffff00";}
	if(scor == "7"){cor = "#8cff01";}
	if(scor == "8"){cor = "#00ff00";}
	if(scor == "9"){cor = "#01ff8d";}
	if(scor == "A"){cor = "#00ffff";}
	if(scor == "B"){cor = "#008aff";}
	if(scor == "C"){cor = "#0000fe";}
	if(scor == "D"){cor = "#8c00ff";}
	if(scor == "E"){cor = "#ff00fe";}
	if(scor == "F"){cor = "#ff008c";}
	cHide.value = scor;
	dive.innerHTML = '<div style="background-color: ' + cor + ';"><img src="../../images/spacer.gif" alt=" " width="20" height="20" onclick="javascript:mudarcor(\''+id+'\');" /> </div>';
	
}