
// !!!!!!!!!!!!!!!!!!!!		ATTENTION		!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
//	the functions in this script depend on the following scripts
//
//		MBF_BasicEvtHandling.js
//
//	they should be loaded into the page before this script
//
// !!!!!!!!!!!!!!!!!!!!		END ATTENTION	!!!!!!!!!!!!!!!!!!!!!!!!!!!!

var states = new Array();
if (navigator.appVersion.indexOf("MSIE") == -1){
	states[0] = 'none';
	states[1] = 'rgba(220,130,0,0.5)';
	states[2] = 'rgba(230,70,0,0.5)';
	states[3] = 'rgba(220,130,0,0.5)';
}
else {
	states[0] = 'none';
	states[1] = 'rgb(241,188,118)';
	states[2] = 'rgb(241,145,118)';
	states[3] = 'rgb(241,188,118)';
}

function tableCellOver(evt){
	
	var e = grabEvent(evt);
	
	var targ = getEventTargetForNav(e);
	
	//alert('MBF_Tb_AMEvtsTCs: performing mouseover for' + targ);

	targ.style.backgroundColor = states[1];
}

function tableCellDown(evt){
	
	var e = grabEvent(evt);
	
	var targ = getEventTargetForNav(e);
	
	//alert('MBF_Tb_AMEvtsTCs: performing mouseover for' + targ);

	targ.style.backgroundColor = states[2];
}

function tableCellUp(evt){
	
	var e = grabEvent(evt);
	
	var targ = getEventTargetForNav(e);
	
	//alert('MBF_Tb_AMEvtsTCs: performing mouseover for' + targ);

	targ.style.backgroundColor = states[3];
}

function tableCellOut(evt){
	
	var e = grabEvent(evt);
	
	var targ = getEventTargetForNav(e);
	
	//alert('MBF_Tb_AMEvtsTCs: performing mouseover for' + targ);

	targ.style.background = states[0];
}

function addMouseOverEventsToTables(){
	
	var tables = document.getElementsByTagName('table')
		
	//alert('MBF_Tb_AMEvtsTCs: num of tables in page is ' + tables.length);
	
	for(var t = 0; t < tables.length; t++){
		
		if(tables[t].className == 'ifc'){
		
			//alert('MBF_Tb_AMEvtsTCs: rows in table = ' + tables[t].rows.length);
				
			for(var r = 0; r < tables[t].rows.length; r++){
					
				for(var c = 0; c < tables[t].rows[r].cells.length; c++){
						
					//alert('MBF_Tb_AMEvtsTCs: adding events to row ' + r + ' cell ' + c);
						
					if(navigator.appVersion.indexOf("MSIE") == -1){
						
						tables[t].rows[r].cells[c].addEventListener('mouseover', tableCellOver,false);
						tables[t].rows[r].cells[c].addEventListener('mousedown', tableCellDown,false);
						tables[t].rows[r].cells[c].addEventListener('mouseup', tableCellUp,false);
						tables[t].rows[r].cells[c].addEventListener('mouseout', tableCellOut,false);
					}
					else {
						tables[t].rows[r].cells[c].attachEvent('onmouseover', tableCellOver);
						tables[t].rows[r].cells[c].attachEvent('onmousedown', tableCellDown);
						tables[t].rows[r].cells[c].attachEvent('onmouseup', tableCellUp);
						tables[t].rows[r].cells[c].attachEvent('onmouseout', tableCellOut);
					}
					
					//alert('MBF_Tb_AMEvtsTCs: added events to row ' + r + ' cell ' + c);
				}
			}
		}
	}
}

function resizeTableAndDoc(){
	
	//alert('MBF_T_IFC: resize');
	
	var controllingTable = document.getElementById('ifc_table');
	var tableDiv = document.getElementById('ifc_table_div');
	var frame = document.getElementById('table_iframe');
	var main = document.getElementById('main_div');
	
	var tableHeight = controllingTable.offsetHeight;
	
	//alert('MBF_T_IFC: table height is ' + tableHeight);
	
	var frameHeight = frame.contentDocument.body.scrollHeight;
	
	//alert('MBF_T_IFC rszTableAndDoc: frame height is ' + frameHeight);
	
	if (frameHeight > tableHeight){
		
		//alert('MBF_T_IFC: frame height is greater than table height');

		tableDiv.style.height = frameHeight + 'px';
		frame.style.height = frameHeight + 'px';
	}
	else {
		
		//alert('MBF_T_IFC: frame height is less than table height');
	}
}



