function updateChart(DOMId, offset) {	
	offset = eval(offset);
	var now = new Date();
	// convert to msec since Jan 1 1970
	var localTime = now.getTime();
	// obtain local UTC offset and convert to msec
	var localOffset = now.getTimezoneOffset() * 60 * 1000;
	// obtain UTC time in msec
	utc = localTime + localOffset;
	// modify the time to the one for the location 
	var locationTime = utc + (60 * 60 * 1000 * offset);
	var locationNow = new Date(locationTime); 
	
	var minutes = locationNow.getMinutes();
	var seconds = locationNow.getSeconds();
	var hours_digital = locationNow.getHours();
	var hours_analog = eval(hours_digital);
	if (hours_analog > 12){
    	hours_analog = hours_analog - 12;
    }
	if (hours_analog == 0){
		hours_analog = 12;
	}

	hours_analog = (hours_analog * 5) + parseInt(minutes / 12);

	var seconds_digital_display = formatValue(seconds);
	var minutes_digital_display = formatValue(minutes);
	var hours_digital_display = formatValue(hours_digital);
	
    document.getElementById('hour_id_'+DOMId).innerHTML = hours_digital_display;
    document.getElementById('minute_id_'+DOMId).innerHTML = minutes_digital_display;
    document.getElementById('second_id_'+DOMId).innerHTML = seconds_digital_display; 
    
    // -- code for digital clock ends --- 
    
    var chartRef = getChartFromId(DOMId);
	chartRef.setData(1,hours_analog);
    chartRef.setData(2,minutes);  
    chartRef.setData(3,seconds);
    	  
  	setTimeout("updateChart('"+DOMId+"', '"+offset+"')", 500);
}

function formatValue(val) {
	if (val < 10) {
		return "0" + val; 
	} else {
		return val;
	}
}

function FC_Rendered(DOMId){

	if (DOMId == 'c1') {
		updateChart(DOMId, offset_c1);
		return;
	} else if (DOMId == 'c2') {
		updateChart(DOMId, offset_c2);
		return;
	} else if (DOMId == 'c3') {
		updateChart(DOMId, offset_c3);
		return;
	} else if (DOMId == 'c4') {
		updateChart(DOMId, offset_c4);
		return;
	} else if (DOMId == 'c5') {
		updateChart(DOMId, offset_c5);
		return;
	} else if (DOMId == 'c6') {
		updateChart(DOMId, offset_c6);
		return;
	} else if (DOMId == 'c7') {
		updateChart(DOMId, offset_c7);
		return;
	} 
}