var base_url = "";
var sym, chartWidth, chartHeight, chartDivID;
var cnt=0;

function loadAjaxChart(site_base_url,my_symbol, divId, w, h)
{
	base_url = site_base_url;
	sym = my_symbol;
	chartWidth = w;
	chartHeight = h;
	chartDivID = divId;



 	$.ajax({
	   type: "GET",
	   //url: "http://marketlive.in/cgi-bin/getdata-for-compquote?symbol="+symbol,
	   url: "http://marketlive.in/cgi-bin/getdata-newsite-comp?symbol="+sym + "&first_time=1",
	   processData: false,
	   dataType: "html",
	   success: handleChartDataResponse,
	   error:  handleChartDataError
	 });	

	cnt++;

	setInterval("refreshChart()", 10000);

}

function refreshChart(is_first_time)
{
	if(is_first_time==1)
		first_time=1;
	else
		first_time=0;

 	$.ajax({
	   type: "GET",
	   //url: "http://marketlive.in/cgi-bin/getdata-for-compquote?symbol="+symbol,
	   url: "http://marketlive.in/cgi-bin/getdata-newsite-comp?symbol="+sym + "&first_time="+first_time,
	   processData: false,
	   dataType: "html",
	   success: updateChartDataResponse,
	   error:  updateChartDataError
	 });	
	
	cnt++;

}

function handleChartDataResponse(data)
{
	data = data.replace("<br />", "");

	var chart1 = new FusionCharts(base_url + "/php-include/flash-chart/marketlive_area.swf", "chart1Id", chartWidth, chartHeight, "0", "0");
        chart1.setDataXML(data);

        chart1.render(chartDivID);

//	alert(data);
}

function handleChartDataError(xmlError, textError)
{
        //alert("Error");
}

function updateChartDataResponse(data)
{
	data = data.replace("<br />", "");
	updateChartXML("chart1Id", data);

}

function updateChartDataError(xmlError, textError)
{
        //alert("Error");
}


