var rootpath = "http://www.itgo.com.br/";

function open_window(URL,WIDTH,HEIGHT){
	LEFT = (screen.width) ? (screen.width-WIDTH)/2 : 0;
	TOP = (screen.height) ? (screen.height-HEIGHT)/2 : 0;
	URL = rootpath+URL;
	window.open(URL,'page','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left='+LEFT+',top='+TOP+',width='+WIDTH+'px,height='+HEIGHT+'px');
}

function cls_input(value){
	if(window.document.getElementById(value).value == value){
		window.document.getElementById(value).value = '';		
	}
}
function rst_input(value){
	if(window.document.getElementById(value).value == ''){
		window.document.getElementById(value).value = value;		
	}
}
	function verificar(){
		if(document.getElementById('icDominio').checked == true){
			abrir_dominio('DominioRegistrar');
			fechar_dominio('DominioProprio');				
		}
		else{
			abrir_dominio('DominioProprio');			
			fechar_dominio('DominioRegistrar');	
		}
	}

	function abrir_dominio(label){
		document.getElementById(label).style.display="inline";
	}
	
	function fechar_dominio(label){
		document.getElementById(label).style.display="none";
	}
	
	
	//FUNÇÃO PARA O CONTROLE DE PAGAMENTOS DO PAINEL DO FUNCIONARIO
	function pgtoCtrl(lkn){
		var pagctrl;
		
		if(window.XMLHttpRequest){
			pagctrl = new XMLHttpRequest();	
		}
		else if(window.ActiveXObject){
			pagctrl = new ActiveXObject("Microsoft.XMLHTTP");
		}
		
		var url = lkn;
		
		pagctrl.open("Get", url, true);
				
		pagctrl.onreadystatechange = function(){
			
			if(pagctrl.readyState == 1){
				//document.getElementById('pagFavoritos').innerHTML = '<img src="../imagem/loading.gif" /> Aguarde...';	
			}
			
			if(pagctrl.readyState == 4 && pagctrl.status == 200){
				var resposta = pagctrl.responseText;
				document.getElementById('pagamentosControl').innerHTML = resposta;
			}
		}
		pagctrl.send(null);	
	}
	
	// ADICIONA CLICK PARA AS TAGS DA NUVEM DE TAGS
	function addClique(id){

		var add;
		
		if(window.XMLHttpRequest){
			add = new XMLHttpRequest();	
		}
		else if(window.ActiveXObject){
			add = new ActiveXObject("Microsoft.XMLHTTP");
		}
		
		var url = "tagAddClique.php?id="+id;
		
		add.open("Get", url, true);
				
		add.onreadystatechange = function(){
			
			if(add.readyState == 1){
				
			}
			
			if(add.readyState == 4 && add.status == 200){
				var resposta = add.responseText;
			}
		}
		add.send(null);	
	}
	
	//CHAMA PARA VERIFICAR DOMINIO
	function registro(){
		var dmo;
		var dominio = document.getElementById("dominio").value;
		var dom = document.getElementById("dom").value;
		
		if(window.XMLHttpRequest){
			dmo = new XMLHttpRequest();	
		}
		else if(window.ActiveXObject){
			dmo = new ActiveXObject("Microsoft.XMLHTTP");
		}
		
		var url = "registrover.php?dominio="+dominio+"&dom="+dom;
		
		dmo.open("Get", url, true);
				
		dmo.onreadystatechange = function(){
			
			if(dmo.readyState == 1){
				//document.getElementById('pagFavoritos').innerHTML = '<img src="../imagem/loading.gif" /> Aguarde...';	
			}
			
			if(dmo.readyState == 4 && dmo.status == 200){
				var resposta = dmo.responseText;
				document.getElementById('verificar_dominio').innerHTML = resposta;				
			}
		}
		dmo.send(null);	
	}
	

function registro2(){
		var dmo;
		var dominio = document.getElementById("dominio").value;
		var dom = document.getElementById("dom").value;
		
		if(window.XMLHttpRequest){
			dmo = new XMLHttpRequest();	
		}
		else if(window.ActiveXObject){
			dmo = new ActiveXObject("Microsoft.XMLHTTP");
		}
		
		var url = "registrover2.php?dominio="+dominio+"&dom="+dom;
		
		dmo.open("Get", url, true);
				
		dmo.onreadystatechange = function(){
			
			if(dmo.readyState == 1){
				//document.getElementById('pagFavoritos').innerHTML = '<img src="../imagem/loading.gif" /> Aguarde...';	
			}
			
			if(dmo.readyState == 4 && dmo.status == 200){
				var resposta = dmo.responseText;
				document.getElementById('verificar_dominio').innerHTML = resposta;				
			}
		}
		dmo.send(null);	
	}
	
	function confirmation(URL) {
		$con = window.confirm("Tem certeza?");
		if ($con==true){
			window.location = URL;
		}else{
			window.location = "pagamentos_controle.php";
		}
	}
		

	function abrir_gerar_boleto(ID){
			document.getElementById("gerar-boleto"+ID).style.display="table-row";
	}
	function fechar_gerar_boleto(ID){
			document.getElementById("gerar-boleto"+ID).style.display="none";
	}
	
	
	function gerar_boleto(ID){
		var boleto;
		var dtVenc = document.getElementById("txt_dtVenc"+ID).value;
		var vlBoleto = document.getElementById("txt_vlBoleto"+ID).value;
		
		
		if(window.XMLHttpRequest){
			boleto = new XMLHttpRequest();	
		}
		else if(window.ActiveXObject){
			boleto = new ActiveXObject("Microsoft.XMLHTTP");
		}
		
		var url = "pagamentos_novo3.php?idp="+ID+"&dtv="+dtVenc+"&vlb="+vlBoleto;
		
		boleto.open("Get", url, true);
				
		boleto.onreadystatechange = function(){
			
			if(boleto.readyState == 1){
				//document.getElementById('pagFavoritos').innerHTML = '<img src="../imagem/loading.gif" /> Aguarde...';	
			}
			
			if(boleto.readyState == 4 && boleto.status == 200){
				var resposta = boleto.responseText;
				document.getElementById('resposta'+ID).innerHTML = resposta;				
			}
		}
		boleto.send(null);	
	}
	
	function alterar_funcionario(ID){
		var func;
		var nmFunc = document.getElementById("input"+ID+"_nm").value;
		var dsEmail = document.getElementById("input"+ID+"_ds").value;
		var icTipo = document.getElementById("input"+ID+"_ic").value;
		
		if(window.XMLHttpRequest){
			func = new XMLHttpRequest();	
		}
		else if(window.ActiveXObject){
			func = new ActiveXObject("Microsoft.XMLHTTP");
		}
		
		var url = "listFunc2.php?id="+ID+"&nmFunc="+nmFunc+"&dsEmail="+dsEmail+"&icTipo="+icTipo;
		
		func.open("Get", url, true);
				
		func.onreadystatechange = function(){
			
			if(func.readyState == 1){
				//document.getElementById('pagFavoritos').innerHTML = '<img src="../imagem/loading.gif" /> Aguarde...';	
			}
			
			if(func.readyState == 4 && func.status == 200){
				var resposta = func.responseText;
				document.getElementById('resposta'+ID).innerHTML = resposta;				
			}
		}
		func.send(null);	
	}
	
	
	function ajax_false(lkn){
		var ajax;
		
		if(window.XMLHttpRequest){
			ajax = new XMLHttpRequest();	
		}
		else if(window.ActiveXObject){
			ajax = new ActiveXObject("Microsoft.XMLHTTP");
		}
		
		var url = lkn;
		
		ajax.open("Get", url, true);
				
		ajax.onreadystatechange = function(){
			
			if(ajax.readyState == 1){
				//document.getElementById('pagFavoritos').innerHTML = '<img src="../imagem/loading.gif" /> Aguarde...';	
			}
			
			if(ajax.readyState == 4 && ajax.status == 200){
				var resposta = ajax.responseText;
				//document.getElementById('resposta'+ID).innerHTML = resposta;				
			}
		}
		ajax.send(null);	
	}
	
	function buscar_cidade(value){
		var ajax;
				
		if(window.XMLHttpRequest){
			ajax = new XMLHttpRequest();	
		}
		else if(window.ActiveXObject){
			ajax = new ActiveXObject("Microsoft.XMLHTTP");
		}
		
		var url = rootpath+"includes/buscar_cidade.php?idEstado="+value;
		
		ajax.open("Get", url, true);
				
		ajax.onreadystatechange = function(){
			
			if(ajax.readyState == 1){
				//document.getElementById('pagFavoritos').innerHTML = '<img src="../imagem/loading.gif" /> Aguarde...';	
			}
			
			if(ajax.readyState == 4 && ajax.status == 200){
				var resposta = ajax.responseText;
				document.getElementById("Cidades").innerHTML = resposta;				
			}
		}
		ajax.send(null);	
	}
	
	function buscarCidade(value){
		var ajax;
				
		if(window.XMLHttpRequest){
			ajax = new XMLHttpRequest();	
		}
		else if(window.ActiveXObject){
			ajax = new ActiveXObject("Microsoft.XMLHTTP");
		}
		
		var url = rootpath+"includes/buscarCidade.php?idEstado="+value;
		
		ajax.open("Get", url, true);
				
		ajax.onreadystatechange = function(){
			
			if(ajax.readyState == 1){
				//document.getElementById('pagFavoritos').innerHTML = '<img src="../imagem/loading.gif" /> Aguarde...';	
			}
			
			if(ajax.readyState == 4 && ajax.status == 200){
				var resposta = ajax.responseText;
				document.getElementById("Cidades").innerHTML = resposta;				
			}
		}
		ajax.send(null);	
	}
	
	function contato_produto(){
		var ajax;
				
		if(window.XMLHttpRequest){
			ajax = new XMLHttpRequest();	
		}
		else if(window.ActiveXObject){
			ajax = new ActiveXObject("Microsoft.XMLHTTP");
		}
		
		var url = "contato_produto.php";
		
		ajax.open("Get", url, true);

		ajax.onreadystatechange = function(){
			
			if(ajax.readyState == 1){
				//document.getElementById('pagFavoritos').innerHTML = '<img src="../imagem/loading.gif" /> Aguarde...';	
			}
			
			if(ajax.readyState == 4 && ajax.status == 200){
				var resposta = ajax.responseText;
				document.getElementById("contato_produto").innerHTML = resposta;				
			}
		}
		ajax.send(null);	
	}
	
	function buscar_detalhes_hospedagem(VALUE){
		var ajax;
				
		if(window.XMLHttpRequest){
			ajax = new XMLHttpRequest();	
		}
		else if(window.ActiveXObject){
			ajax = new ActiveXObject("Microsoft.XMLHTTP");
		}
		
		var url = "buscar_detalhes_hospedagem.php?id="+VALUE;
		
		ajax.open("Get", url, true);

		ajax.onreadystatechange = function(){
			
			if(ajax.readyState == 1){
				//document.getElementById('pagFavoritos').innerHTML = '<img src="../imagem/loading.gif" /> Aguarde...';	
			}
			
			if(ajax.readyState == 4 && ajax.status == 200){
				var resposta = ajax.responseText;
				document.getElementById("dsHospedagem").innerHTML = resposta;				
			}
		}
		ajax.send(null);	
	}
