var inativo=20;
function comprar_item(id,nome,modo)
{
 nome=nome.toUpperCase();	
 if(confirm('Tem certeza que deseja comprar o item '+nome+' ?'))
 {
  document.getElementById('item').value=id;	
  document.getElementById('modo').value=modo;	
  document.getElementById('formulario').submit();	  
 }	
}


function getXmlHttpRequestObject()
{
	//verifica se o browser tem suporte a ajax
	try
	{
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			return new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(ex)
		{
			try
			{
				return new XMLHttpRequest();
			}
			catch(exc)
			{
				alert("Esse browser não tem recursos para uso do Ajax");
				return null;
			}
		}
	}
}
function chat(x)
{
 if(inativo==0)
  self.location="http://www.oslutadores.com/jogo_inicial.php";
 else
 {
  inativo-=1;
 }
	var c = document.getElementById('chat');
	var chat = getXmlHttpRequestObject();
	if(x==undefined)
	 chat.open("GET", "/jogo_chat.php?x=1", true);
	else if(x==1)
	 chat.open("GET", "/jogo_cla_chat.php?x=1", true);
	chat.onreadystatechange = function()
	{
		if (chat.readyState == 4)
		{
			c.innerHTML=chat.responseText;			
		}
	};
	chat.send(null);
	if(x==undefined)
	 setTimeout("chat()",35000);
	else if(x==1)
	 setTimeout("chat(1)",25000);
}

function rank_mod(x)
{
 var c = document.getElementById('ajx');
 var rank = getXmlHttpRequestObject();
 rank.open("GET", "/jogo_rank_mod_ajax.php?arte="+x, true);
 rank.onreadystatechange = function()
 {
  if (rank.readyState == 4)
  {
	c.innerHTML=rank.responseText;			
  }
  else
  { 
  	c.innerHTML="<img src='/ico_crgd.gif' style='margin: auto; display: block; width: 120px; height: 40px;' />";
  }
 };
 rank.send(null);
}

function lot(x)
{
 var c = document.getElementById('ajx');
 var loto = getXmlHttpRequestObject();
 loto.open("GET", "/jogo_loteria_ajax.php?loto="+x, true);
 loto.onreadystatechange = function()
 {
  if (loto.readyState == 4)
  {
	c.innerHTML=loto.responseText;			
  }
  else
  { 
  	c.innerHTML="<img src='/ico_crgd.gif' style='margin: auto; display: block; width: 120px; height: 40px;' />";
  }
 };
 loto.send(null);
}

function camp(id,arte)
{
 var c = document.getElementById('ajx');
 var camp = getXmlHttpRequestObject();
 camp.open("GET", "/ajax_camp.php?id="+id+"&arte="+arte, true);
 camp.onreadystatechange = function()
 {
  if (camp.readyState == 4)
  {
	c.innerHTML=camp.responseText;			
  }
  else
  { 
  	c.innerHTML="<img src='/ico_crgd.gif' style='margin: auto; display: block; width: 120px; height: 40px;' />";
  }
 };
 camp.send(null);
}
function conta_char(x,y)
{
 z=document.getElementById("contador");
 if (x.value.length>y)
 { alert("Você já digitou os "+y+" caracteres permitidos");
 x.value=x.value.substring(0,y);}
  z.innerHTML=(y-x.value.length)+' caracteres restantes'; 
}

function atributos(original,quan,atrib,atrib2)
{
  var x=document.getElementById(atrib);
  var y=document.getElementById(atrib2);
  var pendente=document.getElementById("atributos");
  var novo=parseFloat(x.innerHTML)+quan;
  if(original>novo)
  {
   alert('Você não pode diminuir o atributo inicial.');	
  }
  else
  {
   if(parseFloat(pendente.innerHTML)-quan<0)
   {
   	alert('Você não tem atributos pendentes para essa operação.');
   }
   else
   {
   	x.innerHTML=novo;
   	y.value=novo-original;
   	pendente.innerHTML=parseFloat(pendente.innerHTML)-quan;
   }
  }
  return false;
}

function desab(){
var inputs = document.getElementsByTagName('input');
for (var i=0; i<inputs.length; i++){
  var input = inputs[i];
  var imp = input.getAttribute('type');
  if (imp && imp == 'submit'){
   input.style.visibility='hidden';
  }
 }
}

function verid()
{
 var user = document.getElementById('id').value;
 var c = document.getElementById('msg1');
 var check = getXmlHttpRequestObject();
 check.open("GET", "/ajax_denuncia.php?x="+user, true);
 check.onreadystatechange = function()
 {
  if (check.readyState == 4)
  {
	c.innerHTML=check.responseText;			
  }
 }
 check.send(null);	
}

function denunciar(x)
{
 document.getElementById('msg1').innerHTML='';	
 if(x==1)
 {
  document.getElementById('checkb').style.visibility='hidden';
  document.getElementById('id').readOnly=true;	
  document.getElementById('msg1').innerHTML='<label>Motivo:</label><select id="motivo"><option value="0">Escolha um dos motivos</option><option value="1">Ofensas através das mensagens privadas</option><option value="2">Ofensas através do chat</option><option value="3">Flood no chat</option><option value="4">Assunto envolvendo futebol no chat(de forma OFENSIVA)</option><option value="5">Múltiplas contas</option><option value="6">Avatar irregular</option></select><input type="button" onclick="denunciar2();" id="btmot" class="submit-corpo" value="Selecionar">';
 }
 else
 {
  document.getElementById('id').value='';		
 }
}

function denunciar2()
{
 var c=document.getElementById('motivo');
 var x=c.value;
 if(x>0)
 {
  if(confirm('Tem certeza que escolheu o motivo certo?'))
  {
  	document.getElementById('msg1').innerHTML='<label>Motivo:</label><b>'+c.options[x].text+'</b><input type="hidden" name="mot" value="'+x+'">';
    if(x!=5)
    {
     document.getElementById('msg1').innerHTML+='<br class="clearfix"/><label>Data(ex: 06/09/2008):</label><input type="text" name="data" id="data">';	
    }
    if(x==2||x==3||x==4)
    {
    document.getElementById('msg1').innerHTML+='<br class="clearfix"/><label>Qual chat?</label><select name="chat"><option value="por">Brasil</option><option value="eng">Americano</option><option value="ppt">Portugal</option></select>';
    }
    document.getElementById('msg1').innerHTML+='<br class="clearfix"/><p>Digite no quadro abaixo QUALQUER informação que você ache necessária para ajudar na denúncia.ex: As outras conta do usuário, a frase que realmente te ofendeu, hora da ofensa, hora do flood, etc...</p><textarea name="obs" rows="10" cols="50" onkeyup="conta_char(this,250)"></textarea><span id="contador">250 caracteres</span><br /><input type="submit" class="submit-corpo" value="Denunciar" onclick="return denunciar3();">';	
  }
 }
 else
 {
  alert('Escolha um motivo!');	
 }
}
function denunciar3()
{
 if(confirm("Tem certeza que deseja efetuar essa denuncia?"))
 {	
  if(valida_data(document.getElementById("data").value))
  {
   return true;
  }
  else
  {
   alert("Data Inválida para denuncia.");	
  }
 }
 return false;
}

function valida_data(data){
	aux = new Date();
	var er = new RegExp(/^((0?[1-9]|[12]\d)\/(0?[1-9]|1[0-2])|30\/(0?[13-9]|1[0-2])|31\/(0?[13578]|1[02]))\/(19|20)?\d{2}$/);
	if(er.test(data)){
		var pedacos = data.split('/');
			if(parseInt(pedacos[2]) > aux.getFullYear())
				return false;
			else if(parseInt(pedacos[2]) == aux.getFullYear()){
				if(parseInt(pedacos[1]) > aux.getMonth()+1)
					return false;
				else if((parseInt(pedacos[1]) == aux.getMonth()+1)){
					if(parseInt(pedacos[0]) > aux.getDate())
						return false;
				}
			}
		if(parseInt(pedacos[2])%4 == 0){
			if(parseInt(pedacos[1]) == 2){
				if(parseInt(pedacos[0]) > 29)
					return false;
			}
		}
		else{
			if(parseInt(pedacos[1]) == 2){
				if(parseInt(pedacos[0]) >= 29)
					return false;
			}
		}
		return true;
	}
	return false;
}

function rend()
{
 var c = document.getElementById('ajx');
 var valor = document.getElementById('vlrend').value;
 var calc = getXmlHttpRequestObject();
 calc.open("GET", "/jogo_calc_banco.php?valor="+valor, true);
 calc.onreadystatechange = function()
 {
  if (calc.readyState == 4)
  {
	c.innerHTML=calc.responseText;			
  }
  else
  { 
  	c.innerHTML="<img src='/ico_crgd.gif' style='margin: auto; display: block; width: 120px; height: 40px;' />";
  }
 };
 calc.send(null);
}

function cipoder()
{
 var c = document.getElementById('ajx');
 var ci = getXmlHttpRequestObject();
 ci.open("GET", "/ajax_bsc.php?tipo=1", true);
 ci.onreadystatechange = function()
 {
  if (ci.readyState == 4)
  {
	c.innerHTML=ci.responseText;			
  }
  else
  { 
  	c.innerHTML="<img src='/ico_crgd.gif' style='margin: auto; display: block; width: 120px; height: 40px;' />";
  }
 };
 ci.send(null);
}

function youvideo(id)
{
 var c = document.getElementById('ajx');
 var video = getXmlHttpRequestObject();
 video.open("GET", "/ajax_bsc.php?tipo=2&id_video="+id, true);
 video.onreadystatechange = function()
 {
  if (video.readyState == 4)
  {
	c.innerHTML=video.responseText;			
  }
  else
  { 
  	c.innerHTML="<img src='/ico_crgd.gif' style='margin: auto; display: block; width: 120px; height: 40px;' />";
  }
 };
 video.send(null);
}

function itemMostrar(id, classe){
var Id = id;
document.getElementById(Id).className=classe;
}

function pega_banner(tp)
{
 var c = document.getElementById('bbb'+tp);
 var banner = getXmlHttpRequestObject();
 banner.open("GET", "/ajax_bsc.php?tipo=3&tp="+tp, true);
 banner.onreadystatechange = function()
 {
  if (banner.readyState == 4)
  {
	c.innerHTML=banner.responseText;			
  }
  else
  { 
  	c.innerHTML="<img src='/ico_crgd.gif' style='margin: auto; display: block; width: 120px; height: 40px;' />";
  }
 };
 banner.send(null);
}

function mostrar_esconder(ac,nome)
{
 if(ac==1)
 {
  document.getElementById(nome).style.display='block';	
 }
 else
 {
  document.getElementById(nome).style.display='none';	
 }
}


function pride_aviso()
{
 if(confirm("Se você está inscrevendo uma conta que não é sua no PRIDE, lembre-se que caso nao haja situações de extremas necessidades, isso poderá ser considerado MULTIPLAS CONTAS e ambas contas serem punidas. Caso a conta seja realmente a sua, desconsidere essa mensagem."))
 {
  desab();	 
  return true;	
 }
 else
 {
  return false;	
 }
	
	
}