
var rows = new Array;

function mySetSelected(theRow, index, myvalue, formElement)
{
    var theCells = null;
    rows[index] = !rows[index];
    
    // hozzaadjuk:
    if(rows[index])
    {
    	switch(formElement)
	{
	    case '0': 
		parent.document.mainform.post_areas.value = parent.document.mainform.post_areas.value + ";" + myvalue;
		break;
	    case '1':
		parent.document.mainform.post_agency.value = parent.document.mainform.post_agency.value + ";" + myvalue;
		break;
	    case '2':
		parent.document.mainform.post_types.value = parent.document.mainform.post_types.value + ";" + myvalue;
		break;
	    default:
		break;
	}
	
    }
    // levesszuk:
    else
    {
	switch(formElement)
	{
	    case '0':
		parent.document.mainform.post_areas.value = parent.document.mainform.post_areas.value.replace(';' + myvalue, '');
		break;
	    case '1':
		parent.document.mainform.post_agency.value = parent.document.mainform.post_agency.value.replace(';' + myvalue, '');
		break;
	    case '2':
		parent.document.mainform.post_types.value = parent.document.mainform.post_types.value.replace(';' + myvalue, '');
		break;
	    
	}
	
    }
    
    
    
    //alert('hello');
    
    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    var rowCellsCnt  = theCells.length;
    
    
    //var newColor = '#ff0000';
    var newStyle;
    if(!rows[index]) 
    {
	newColor='#fef9e6';
	newStyle='';
    }
    else 
    {
	newColor='#f7eccc';
	//newColor='#b36b52';
	newStyle='stylered2';
    }

    
    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.2 ... with other browsers
        if(false)
	{
	} else
	{
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
		theCells[c].setAttribute('class', newStyle, 0);
            }
        }
    } // end 5
    
    
}


function setColor(theRow, color, index)
{
    if(rows[index]) return;

    var theCells = null;
    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }
    var rowCellsCnt  = theCells.length;
    
    if (color) {
        var c = null;
        // 5.2 ... with other browsers
        if(false)
	{
	} else
	{
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = color;
            }
        }
    } // end 5
    
}
