﻿function iniciar() {
	if (document.forms[0].imprimir) {
		var	qsExterno = "";
		if (document.forms[0].externo) {
			var ext = document.forms[0].externo.value;
			if (ext != "") { qsExterno = "?externo=" + ext; }
		}

		var	qsCA = "";
		if (document.forms[0].downline) {
			var dwl = document.forms[0].downline.value;
			if (dwl != "") { 
				if (qsExterno.lenght > 0) {
					qsCA = "&ca=" + dwl.substr(0, dwl.indexOf(",")); 
				} else {
					qsCA = "?ca=" + dwl.substr(0, dwl.indexOf(",")); 
				}
			}
		}
		
		addEvent( document.getElementById("exportar"), 'click', function() { location = "/sites-indicados/informacoes/exportar/" + qsCA; } );
		addEvent( document.getElementById("imprimir"), 'click', function() { location = "/sites-indicados/informacoes/imprimir/" + qsExterno + qsCA; } );
	}
}

function seguir(divName, evt) {
	if(document.getElementById(divName)) {
		var obj = document.getElementById(divName);
		var mX = parseInt(mouseX(evt));
		var mY = parseInt(mouseY(evt));
		var recuo = 86;
		obj.style.display = "block";

		if (screen.width > (mX + 240 - recuo + 30)) {
			obj.style.left = mX - recuo + "px";
		}
		else {
			obj.style.left = screen.width - 240 - 30 + "px";
		}
		obj.style.top = mY - (parseInt(externalCSS(obj, "height", "height"))) - 5 + "px";
		
		//Browsers ajustes
		if(navigator.userAgent.indexOf("Opera")!=-1) { obj.style.top = parseInt(obj.style.top) - 10 + "px"; }
		if((navigator.appVersion.indexOf("MSIE")!=-1) && (!navigator.userAgent.indexOf("Opera")!=-1)) { obj.style.top = parseInt(obj.style.top) + 8 + "px"; }
	}
}

function maisCampos(acao, c1, c2, c3, c4, c5, c6, c7, c8, c9, event) {
	if(document.getElementById("mais-campos")) {
		if (acao == 1) {
			seguir("mais-campos", event);
			document.getElementById("mais-patrocinador").innerHTML = c1;
			document.getElementById("mais-sexo").innerHTML = c2;
			document.getElementById("mais-idade").innerHTML = c3;
			document.getElementById("mais-telefone").innerHTML = c4;
			document.getElementById("mais-celular").innerHTML = c5;
			document.getElementById("mais-cidade").innerHTML = c6;
			document.getElementById("mais-estado").innerHTML = c7;
			document.getElementById("mais-ativo").innerHTML = c8;
			document.getElementById("mais-criacao").innerHTML = c9;
		}
		else {
			document.getElementById("mais-campos").style.display = "none";
		}
	}
}

addEvent(window, 'load', iniciar);