// Olettaa headista tulevan seuraavat vakiot:
//
// CELLCOUNT

/*
var mouseout_id = '';

function mouseoutraw()
{
	// firefox-bugin kierto, 
	// jossa se lähetää virheellisiä onmouseout- ja onmouseover-viestejä
	if ( mouseout_id != '')
	{
		thisElement = document.getElementById(mouseout_id);
//		changeBorderStyle(thisElement, "0");
		makePassive();
		mouseout_id = '';
	}
}
*/
function selCell_onmouseover(thisElement)
{  
   if (thisElement.className == "emptyCellWithTopBorder")
   {  
       thisElement.className = "emptyCellWithTopBorderHover";
       selTrySelect(thisElement.id);
   }
   else if (thisElement.className.indexOf("emptyCell") == 0)
   {   
       thisElement.className = "emptyCellHover";
       selTrySelect(thisElement.id);
   }
   if (thisElement.className.indexOf("reservation") > -1)
   {
//       changeBorderStyle(thisElement, "1px solid black");
//       activatePopupOnce("tab1-" + selGetCellNumber(thisElement.id), thisElement.id);
//       changeClass("tab-" + selGetCellNumber(thisElement.id), "active");
		activize(document.getElementById("tab-" + selGetCellNumber(thisElement.id)),
				 thisElement);
   }
   if (thisElement.className.indexOf("rawCell") > -1)
   {
   /*
       if ( thisElement.id == mouseout_id )
       {
           mouseout_id = '';
       }   
       else
       {*/
//           changeBorderStyle(thisElement, "1px solid black");
//	   	   changeClass("tab-" + selGetCellNumber(thisElement.id), "active");
			activize(document.getElementById("tab-" + selGetCellNumber(thisElement.id)),
					 thisElement);
   /*    } */
   }
}

function selCell_onmouseout(thisElement)
{
   if (thisElement.className == "emptyCellWithTopBorderHover")
   {   
       thisElement.className = "emptyCellWithTopBorder";
//       selTrySelect(thisElement.id);
   }
   if (thisElement.className == "emptyCellHover")
   {
       thisElement.className = "emptyCell";
//       selTrySelect(thisElement.id);
   }
   /*
   if (thisElement.className.indexOf("reservation") > -1)
   {
//       changeBorderStyle(thisElement, "1px solid white");
       makePassive();
   }
   if (thisElement.className.indexOf("rawCell") > -1)
   {
       mouseout_id = thisElement.id;
       setTimeout('mouseoutraw()',10);
   }*/
}

function selCell_onmousedown(thisElement)
{
    if (thisElement.className.indexOf("emptyCell") > -1)
    {
        selActivate(thisElement.id);
    }
}

function selCell_onmouseup(thisElement)
{   
    if (thisElement.className.indexOf("emptyCell") > -1)
    {  
        selDeactivate(thisElement.id);
    }
}
/*
function selCell_onmousemove(thisElement)
{  
   if (thisElement.className.indexOf("emptyCell") > -1)
   {   
       _doPassive();   
   }
}*/

function setCellProperties()
{
    for (var i = 0; i < CELLCOUNT; i++)
    {
        var element = document.getElementById('selCell-' + i);
        
        if (element != undefined)
        {
            element.onmouseover = function() {selCell_onmouseover(this);};
            element.onmouseout = function() {selCell_onmouseout(this);};
            element.onmousedown = function() {selCell_onmousedown(this);};
            element.onmouseup = function() {selCell_onmouseup(this);};
//            element.onmousemove = function() {selCell_onmousemove(this);};
        }
    }
}

function unsetCellProperties()
{
    for (var i = 0; i < CELLCOUNT; i++)
    {
        var element = document.getElementById('selCell-' + i);
		//alert(element);
        if (element != undefined)
        {
            element.onmouseover = null;
            element.onmouseout = null;
            element.onmousedown = null;
            element.onmouseup = null;
            element.onmousemove = null;
        }
    }
}
