﻿// JavaScript Document
/*1st class*/
function tableMouseOverBackground(table_id, css_over, css_normal) {

this.table_id = table_id;
this.css_over = css_over;
this.css_normal = css_normal;

this.mOver = function (cell_id) {
	cell = document.getElementById(cell_id);
	cell.setAttribute("className",this.css_over);
	/*
	isto tako sto je u IE className, a ne class
	tako je i div.style zapravo :
		div.currentStyle ali programski
	*/
}

this.mOut = function (cell_id) {
	cell = document.getElementById(cell_id);
	cell.setAttribute("className",this.css_normal);
}

this.enable = function () {
	table = document.getElementById(this.table_id);
	cells = table.getElementsByTagName("TD");
	for (i=0; i<cells.length;i++) {
		var eachCell = cells[i];
		var cell_id = table_id + "_c" + i;
		eachCell.setAttribute("id",cell_id);
		
		//setiraj css odmah da poslije bude konzistentno
		//nakom mouse outa
		eachCell.setAttribute("className",this.css_normal);
		
		/*lookup tako da event handler zna sto ce zvati*/
		eachCell.crx_eventHandlerLookup = this;
		
		eachCell.onmouseover =  function () {
			/*eval to i to*/
			eval("this.crx_eventHandlerLookup."+"mOver('"+this.id+"');");
      	};
		
		eachCell.onmouseout = function () {
			eval("this.crx_eventHandlerLookup."+"mOut('"+this.id+"');");
      	};
    }
}
}
