reloadAdsys = 0;

function getInf(){

	dataCheck2();
	getGraph();
//	setInterval(dataCheck2, 55000);
	setInterval(getGraph, 60000);
//	setInterval(adsysTop, 120000);

}



function dataCheck2(){


	var xmlhttp = false;

	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}
	
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
	}


	randParameter=parseInt(Math.random()*99999999);  
	var serverPage = "datacheck2.php?" + "rand=" + randParameter;
	xmlhttp.open("GET", serverPage);
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		resultado = xmlhttp.responseText;
		
		var dataTrigger = resultado.split(",");
		
		
		var onlineUsers = dataTrigger[0];
		
		var obj = document.getElementById("onlineUsersDiv");
		obj.innerHTML = onlineUsers;
		

		}
	}
	xmlhttp.send(null);

}








function clearText3(){

	if (document.all.msgText.value == "Digite uma mensagem e aperte a tecla Enter") {
		document.all.msgText.value = "";
	}
	
}

function autoTab(element, nextElement) {

    if (element.value.length == element.maxLength && nextElement != null) {
        element.form.elements[nextElement].focus();
    }
}


function goBottom (){
	var objDiv = document.getElementById("outerChatText");
	objDiv.scrollTop = objDiv.scrollHeight;
}





// -------------------------- S E N D   C H A T --------------------------

function sendChat(){

	var xmlhttp = false;

	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}
	
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
	}


	
	var msgAutor = escape(document.getElementById('msgAutor').value);
	var msgText = escape(document.getElementById('msgText').value);
	
		msgText = msgText.replace(/[+]/gi,'1plus1');
	
		randParameter=parseInt(Math.random()*99999999);
		var serverPage = "sendchat.php?" + "msgAutor=" + msgAutor + "&msgText=" + msgText + "&rand=" + randParameter;
	
		xmlhttp.open("GET", serverPage);
		xmlhttp.send(null);
	
		document.getElementById("msgText").value = "";
		return false;
	

}

function adsys(){
	var f = document.getElementById('adsystem');
	f.contentWindow.location.reload(true);
}




// -------------------------- G E T  G R A P H I C S --------------------------

function getGraph(){

	randParameter = parseInt(Math.random()*99999999);
	

	var input00 = document.getElementById("gInputSlot00");
	var image00 = document.getElementById("gSlot00");
	
	var input01 = document.getElementById("gInputSlot01");
	var image01 = document.getElementById("gSlot01");
	
	var input02 = document.getElementById("gInputSlot02");
	var image02 = document.getElementById("gSlot02");

	
	var image03 = document.getElementById("gSlot03");
	var image04 = document.getElementById("gSlot04");
	
	
	
	image00.src = "http://br.advfn.com/p.php?pid=staticchart&s=BOV%5E" + input00.value.toUpperCase() + "&p=0&t=23&rand=" +randParameter;
	image01.src = "http://br.advfn.com/p.php?pid=staticchart&s=BOV%5E" + input01.value.toUpperCase() + "&p=0&t=23&rand=" +randParameter;
	image02.src = "http://br.advfn.com/p.php?pid=staticchart&s=BOV%5E" + input02.value.toUpperCase() + "&p=0&t=23&rand=" +randParameter;
	image03.src = "http://br.advfn.com/p.php?pid=staticchart&s=BOV%5EIBOV&p=0&t=23&rand=" +randParameter;
	image04.src = "http://br.advfn.com/p.php?pid=staticchart&s=" + "DJI%5EI%5CDJI" + "&p=0&t=23&rand=" +randParameter;



}

function getSlot00(){

	randParameter = parseInt(Math.random()*99999999);


	var input00 = document.getElementById("gInputSlot00");
	var image00 = document.getElementById("gSlot00");
	
	image00.src = "http://br.advfn.com/p.php?pid=staticchart&s=BOV%5E" + input00.value.toUpperCase() + "&p=0&t=23&rand=" +randParameter;

}


function getSlot01(){

	randParameter = parseInt(Math.random()*99999999);


	var input01 = document.getElementById("gInputSlot01");
	var image01 = document.getElementById("gSlot01");
	
	image01.src = "http://br.advfn.com/p.php?pid=staticchart&s=BOV%5E" + input01.value.toUpperCase() + "&p=0&t=23&rand=" +randParameter;

}



function getSlot02(){

	randParameter = parseInt(Math.random()*99999999);


	var input02 = document.getElementById("gInputSlot02");
	var image02 = document.getElementById("gSlot02");
	
	image02.src = "http://br.advfn.com/p.php?pid=staticchart&s=BOV%5E" + input02.value.toUpperCase() + "&p=0&t=23&rand=" +randParameter;

}


function adsysTop(){
	document.getElementById("topAdsys").contentWindow.location.reload(true);
}