
/*
this code was for the counter. we are commenting it out for now
function initGlassesPouredCounter() {
	
	counter_text_node = document.getElementById(counter_text_id);	// get the node for the counter
	
	counter_interval = setInterval('updateGlassesPouredCounter()', counter_time_period);		// set the counter update function to be called periodically
}
*/

//--------------------------------------------------------------------------------------------------------------

/*
this code was for the counter. we are commenting it out for now
function updateGlassesPouredCounter() {
	// get the current string value
	var current_value = counter_text_node.firstChild.nodeValue;
	// strip out all comma formatting
	current_value = current_value.replace(/,/g, '');
	//alert(current_value2);
	// increment the number
	current_value = (parseInt(current_value) + 1);		// cast the text value to an interger and add 1.
	// add comma formating
	current_value = addCommas(current_value);
	// place new value into html
	counter_text_node.firstChild.nodeValue = current_value;
}
*/

//--------------------------------------------------------------------------------------------------------------

function addCommas(nStr) {
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}


//--------------------------------------------------------------------------------------------------------------

function initTimeline() {
	content_div_node = document.getElementById(content_div_id);
}

//--------------------------------------------------------------------------------------------------------------

/*function hideTimelineContent() {
	content_div_node.style.display = 'none';
}*/

//--------------------------------------------------------------------------------------------------------------

function displayTimelineContent(img_id, position_egde, offset_x, offset_y, content_div_node_width) {
	

	// get the image node clicked on
	var img = document.getElementById(img_id);

	
	var coords = findPos(img);

	
	
	// clean out any child node from the display div
	if (content_div_node.childNodes[0]) {
		while (content_div_node.childNodes[0]) {
			content_div_node.removeChild(content_div_node.childNodes[0]);
		}
	}
	
	// get the id of the content we will clone
	var node_id = img.id + 'Content';

	
	// get the content's node
	var content_node;
	// if there is content for the image
	if (content_node = document.getElementById(node_id)) {
		// clone the node
		var cloned_node = content_node.cloneNode(true);
		// set an event handler of the node
		cloned_node.onclick = removeNode;
		// add the cloned content to the div where we will display the content
		content_div_node.appendChild(cloned_node);
		// show the clone content
		cloned_node.style.display = 'block';
		
		
		// set the positioning of the containing node
		if (position_egde == 'left') {
			content_div_node.style.left = (parseInt(coords[0]) + parseInt(offset_x)) + 'px';
		} else {
			content_div_node.style.left = (parseInt(coords[0]) + parseInt(offset_x) - content_div_node_width) + 'px';
		}
		
		content_div_node.style.top = (parseInt(coords[1]) + parseInt(offset_y)) + 'px';
		// set the width of the node
		content_div_node.style.width = content_div_node_width + 'px';
		// display the node
		content_div_node.style.display = 'block';	
		
	}
	
	
}

//--------------------------------------------------------------------------------------------------------------



function removeNode() {
	content_div_node.style.display = 'none';
	this.parentNode.removeChild(this);
	
}

//--------------------------------------------------------------------------------------------------------------

function findPos(obj) {
	
	
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	//return [curleft,curtop];
	var coords = new Array(curleft,curtop);
	return coords;
}

//--------------------------------------------------------------------------------------------------------------


//--------------------------------------------------------------------------------------------------------------