function openAjax() {
var ajax;
try{
ajax = new XMLHttpRequest();
}catch(ee){
try{
ajax = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
ajax = new ActiveXObject("Microsoft.XMLHTTP");
}catch(E){
alert('Seu navegador não possui suporte a XMLHttpRequest');
ajax = false;
}
}
}
return ajax;
}

window.status = "VICIOGAME - Campeonato Retrô-Games.";


function campo_contorno_on(campo)
	{
		campo.style.border = "1px solid red";
	}

function campo_contorno_off(campo)
	{
		campo.style.border = "1px solid black";
	}


	
//LISTA

function MoveUp(combo)
{	
	i=combo.selectedIndex;
	if (i>0)
	{
		swap(combo,i,i-1);
		combo.options[i-1].selected=true;
		combo.options[i].selected=false;
	}
}

function MoveDown(combo)
{
	i=combo.selectedIndex;

	if (i<combo.length-1 && i>-1)
	{
		swap(combo,i+1,i);
		combo.options[i+1].selected=true;
		combo.options[i].selected=false;
	}
}

//this function is used to swap between elements
function swap(combo,index1, index2)
{
	var savedValue=combo.options[index1].value;
	var savedText=combo.options[index1].text;

	combo.options[index1].value=combo.options[index2].value;
	combo.options[index1].text=combo.options[index2].text;

	combo.options[index2].value=savedValue;
	combo.options[index2].text=savedText;
}

function MoveToTop(combo)
{
	i=combo.selectedIndex;
	
	for (;i>0;i--)
	{
		swap(combo,i,i-1);
		combo.options[i-1].selected=true;
		combo.options[i].selected=false;
	}
}

function MoveToBottom(combo)
{
	i=combo.selectedIndex;
	
	if (i>-1)
	{
		for (;i<combo.length-1;i++)
		{
			swap(combo,i+1,i);
			combo.options[i+1].selected=true;
			combo.options[i].selected=false;
		}
	}
}

//moves options from one selection box (combo box) to another
//removes the all selected options from one combo box and adds them to the second combo box
function MoveElements(FromCombo,ToCombo)
{
	var to_remove_counter=0; //number of options that were removed (num selected options)

	//move selected options to right select box (to)
	for (var i=0;i<FromCombo.options.length;i++)
	{
		if (FromCombo.options[i].selected==true)
		{
			var addtext=FromCombo.options[i].text;
			var addvalue=FromCombo.options[i].value;
			ToCombo.options[ToCombo.options.length]=new Option(addtext,addvalue);
			FromCombo.options[i].selected=false;
			++to_remove_counter;
		}
		else
		{
			FromCombo.options[i-to_remove_counter].selected=false;
			FromCombo.options[i-to_remove_counter].text=FromCombo.options[i].text;
			FromCombo.options[i-to_remove_counter].value=FromCombo.options[i].value;
		}
	}

	//now cleanup the last remaining options 
	var numToLeave=FromCombo.options.length-to_remove_counter;
	for (i=FromCombo.options.length-1;i>=numToLeave;i--) 
	{ 
		FromCombo.options[i]=null;
	}
}

function SelectAll(combo)
{
	for (var i=0;i<combo.options.length;i++)
	{
		combo.options[i].selected=true;
	}
}


//ORDENA LISTA
function sortlist(escolhe) {
var lb = document.getElementById(escolhe);
arrTexts = new Array();

for(i=0; i<lb.length; i++)  {
  arrTexts[i] = lb.options[i].text;
}

arrTexts.sort();

for(i=0; i<lb.length; i++)  {
  lb.options[i].text = arrTexts[i];
  lb.options[i].value = arrTexts[i];
}
}

//mostra bestgamer
function mostra_bestgamer_h()
{
		document.getElementById('bestgamer_container').style.display = "none";
		document.getElementById('bestgamer_container2').style.display = "none";
}

function mostra_bestgamer_b()
{
		document.getElementById('bestgamer_container').style.display = "block";
		document.getElementById('bestgamer_container2').style.display = "block";
}

//RECEBE LISTA
function pega_lista()
{
	var modalidade = "";
	valor = "<br>Taxa de inscrição: R$ " + document.getElementById('right_select').options.length *2 + ",00";
	document.getElementById('mensagem').value = "";
	
	if(document.modalidade_form.modalidade_h.checked == true)
	{
	document.getElementById('mensagem').value = "Modalidade: Hardcore Gamer - PROMOÇÃO RELÂMPAGO!<br><br>Taxa de inscrição: R$ 25,00";
	}
	
	else if(document.modalidade_form.modalidade_b.checked == true)
	{
	contador = document.getElementById('right_select').options.length
	while (contador != "0")
	{
		document.getElementById('right_select').options.selectedIndex = contador -1;
		document.getElementById('mensagem').value = document.getElementById('mensagem').value + document.getElementById('right_select').options[document.getElementById('right_select').selectedIndex].value + "<br>";
		contador--;
	}
	document.getElementById('mensagem').value = "Modalidade: Best Gamer<br><br>" + document.getElementById('mensagem').value + "<br>Taxa de inscrição: R$ " + document.getElementById('right_select').options.length *2 + ",00";
	}

	//document.getElementById('mensagem').value = document.getElementById('right_select').selectedIndex;
    //for (var i = 0; i < listLength; i++) { 
   // } 
}

//info

function info(id)
{
	if (id == "telefone")
	{
	document.getElementById('form_inscricao_info').innerHTML = "Exemplo de preenchimento: (XX) XXXX-XXXX";
	}
	if (id == "nomeremetente")
	{
	document.getElementById('form_inscricao_info').innerHTML = "Preencha seu nome completo.";
	}
	if (id == "apelido")
	{
	document.getElementById('form_inscricao_info').innerHTML = "Esta será sua identificação no campeonato!";
	}
	if (id == "emailremetente")
	{
	document.getElementById('form_inscricao_info').innerHTML = "Você receberá uma confirmação neste endereço.";
	}
	if (id == "email_confirmacao")
	{
	document.getElementById('form_inscricao_info').innerHTML = "Digite novamente para confirmar.";
	}
}

//tooltips

function mostra_logo(opcao)
{
	if (opcao == "atari")
	{
	document.getElementById('console_info').innerHTML = "<img src='imgs/logo_atari.png'/>";
	}
	if (opcao == "master")
	{
	document.getElementById('console_info').innerHTML = "<img src='imgs/logo_master.png'/>";
	}
	if (opcao == "nes")
	{
	document.getElementById('console_info').innerHTML = "<img src='imgs/logo_nes.png'/>";
	}
	if (opcao == "snes")
	{
	document.getElementById('console_info').innerHTML = "<img src='imgs/logo_snes.png'/>";
	}
	if (opcao == "mega")
	{
	document.getElementById('console_info').innerHTML = "<img src='imgs/logo_mega.png'/>";
	}
}

function oculta_logo()
{
	document.getElementById('console_info').innerHTML = "<img src='imgs/voltar.png' id='voltar' name='voltar' /><br /><span class='voltar'>Voltar</span>";
}
