var chartID = 0;
var xmlHttpLine;
var xmlHttpBar;
var xmlHttpPie;

function showCustomer(cod, option, target, host, xmlHttp) { 

	if (xmlHttp==null) {
	  alert ("Seu navegador n�o suporta AJAX!");
	  return;
	}
	
	//var url = "http://"+host+"/";
	var url = "../../jsp/serverRequest.jsp";
	
	if(target=="cooperado"){
		url=url+"?call=CooperadosCharts.do"; 

	}else if(target=="empresa"){
		url=url+"?call=EmpresaCharts.do"; 
	}
	
	url=url+"&option="+option;
	url=url+"&cod="+cod;
	
	if( option=="line" )
		xmlHttp.onreadystatechange=getLinha;
	
	else if( option=="bar" )
		xmlHttp.onreadystatechange=getBar;
	
	else if( option=="pie" )
		xmlHttp.onreadystatechange=getPie;
	
	xmlHttp.open("GET",url,true);
	
	xmlHttp.send(null);
}

function getLinha() { 

	if (xmlHttpLine.readyState==4) {
		var xml = xmlHttpLine.responseText;
		buildChart( "line",xml );
	}
}

function getBar() { 

	if (xmlHttpBar.readyState==4) {
		var xml = xmlHttpBar.responseText;
		buildChart( "bar",xml );
	}
}

function getPie() { 

	if (xmlHttpPie.readyState==4) {
		var xml = xmlHttpPie.responseText;
		buildChart( "pie",xml );
	}
}
//parametro call na url � obrigat�rio
function call(xmlHttp,url,callbackFunction) { 

	if (xmlHttp==null) {
	  alert ("Seu navegador n�o suporta AJAX!");
	  return;
	}
	
	xmlHttp.onreadystatechange=callbackFunction;
	
	xmlHttp.open("GET",url,true);
	
	xmlHttp.send(null);
}

function GetXmlHttpObject() {
	
	var xmlHttp = null;
	
	try {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  
	} catch (e){
	  // Internet Explorer
	  try {
	    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	    
	    } catch (e) {
	    	xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	    
	    }
	}
	
	return xmlHttp;
}