// Show comments
sc = {
	init : function() {
		if (!document.getElementById) { return; }
		var i;
		// Get all links and add events to them
		var links = $$('.view_comment img');
		for (i = 0; i < links.length; i++) {
			DOMhelp.addEvent(links[i], 'mouseover', sc.show_comment, false);
			DOMhelp.addEvent(links[i], 'mouseout', sc.hide_comment, false);
		}
	},
	show_comment : function(e) {
		var t = DOMhelp.getTarget(e);
		var xCoord, yCoord;
		// Get mouse coordinates
		if (document.layers) {
			xCoord = e.x;
			yCoord = e.y;
		} else if (document.all) {
			xCoord = event.clientX;
			yCoord = event.clientY;
		}
		else if (document.getElementById) {
			xCoord = e.clientX;
			yCoord = e.clientY;
		}
		sc.parent = t.parentNode;
		while (sc.parent.nodeName.toLowerCase() != 'td') {
			sc.parent = sc.parent.parentNode;
		}
		var comment_td = DOMhelp.closestSibling(sc.parent, -1);
		var comment = comment_td.innerHTML;
		
		if (comment == '') {
			comment = "There are no comments yet";
		}
		
		xCoord = xCoord - 230;
		// Create comment div
		var cont = document.createElement('div');
		cont.id = "show_comment";
		cont.innerHTML = comment;
		//var styles = "position: absolute; top:0; right: 0;";
		//cont.setAttribute('style', 'left: 615px; top: 185px;');
		
		var isOpera = false;
		var isIE = false;
		if(typeof(window.opera) != 'undefined'){
			isOpera = true;
		}
		if(!isOpera && navigator.userAgent.indexOf('Internet Explorer')){
			isIE = true;
		}
		var styleData = 'top: 0; left: -215px;'; //top:' + yCoord + 'px;'; //left:' + xCoord + 'px; 
		if (BrowserDetect.browser == "Explorer") {
			cont.style.setAttribute('cssText', styleData);
		} else {
			cont.setAttribute('style', styleData);
		}

		sc.paul = sc.parent.getElementsByTagName('div')[0];
		sc.paul.appendChild(cont);
		
		t.onmousemove = function(e) {
			if (document.layers) {
				yCoord = e.y;
			} else if (document.all) {
				yCoord = event.clientY;
			}
			else if (document.getElementById) {
				yCoord = e.clientY;
			}
			//var cont_height = ;
			var cont_height = cont.offsetHeight;
			var cont_height = Math.round(cont_height / 2);
			yCoord = yCoord - cont_height;
			var styleData = 'top: 0; left: -215px;'; //top:' + yCoord + 'px;' //'left:' + xCoord + 'px;'
			
			if (BrowserDetect.browser == "Explorer") {
			cont.style.setAttribute('cssText', styleData);
			} else {
				cont.setAttribute('style', styleData);
			}
		}
	},
	hide_comment : function(e) {
		var container = $('show_comment');
		sc.paul.removeChild(container);
	},
	get_mouse_coords : function(e) {
		
		}
}
DOMhelp.addEvent( window, 'load', sc.init, false );