/*
change_css_onelement javascript
written by frank hess
---------------------------------------------------------
tested on: internet explorer 6

herangehensweise: 
das gew&uuml;nschte html-element ist mit einer eindeutigen ID zu versehen.. 

<tr id="zeile1">

und mit onmouseover, onmouseout und falls gew&uuml;nscht mit onclick zu versehen..

<tr id="zeile1" onmouseover="change_css_onelement(this.id,new_css_classname)" 
				onmouseout="change_css_onelement(this.id,new_css_classname)" 
				onclick="whatever_you_like_to_do_onclick_function">

zudem kann die vorbereitete variable selected_id mit einem wert vordefiniert werden,
um zum beispiel bei einem bestimmtem (z.b. dem bereits "aktiven") element den css-wechsel
auszuschliessen.




*/
selected_id = null; //(request_var && request_var["selectedrow"])? request_var["selectedrow"]:null;
change = null;

selected_area = new Array();

function change_css_onelement(id,new_css,override)
	{
	if ( override || id != selected_id )  change = document.getElementById(id);
		
		
	else change = null;
	if (change)	{change.className = new_css;}
	return false;
	}

function select_element(area, id, new_css)
	{
	c = document.getElementById(id);
	if (c && selected_area[area])
		{
		old_css = c.className;
		change_css_onelement(selected_area[area], old_css, 1);
		}
	change_css_onelement(id, new_css, 1);
	selected_area[area] = id;
	}	
	
	
effect = true;	
hold_index = null;
hold_id = null;
color_off = new Array();

function get_dom(layer_index)
	{
	// id : tag ID 
	// layer_index : index of cme_layer. 
	
	if (layer_index && layer_index != "undefined" && layer_index != "document") { doc = eval("cme_layer['"+layer_index+"'].doc"); }
	else doc = document;
	return doc
	}

function change_row(id,newColor,baseColor,layer_index)
	{
	elm = get_dom(layer_index).getElementById(id);
	if (elm && id != selected_id && ( effect ||  hold_index != layer_index )) 
		{
		if (!color_off[id]) color_off[id] = baseColor;
		elm.setAttribute('bgcolor', newColor, 0);
		}
	return true;
	}

function set_height(id, newHeight, layer_index)
	{
	elm = get_dom(layer_index).getElementById(id);
	
	if (elm) elm.setAttribute('height', newHeight, 0);
	}
	
function set_size(id, newWidth, newHeight, layer_index)
	{
	elm = get_dom(layer_index).getElementById(id);
	
	if (elm)
		{
		if (newHeight) elm.setAttribute('height', newHeight, 0);
		if (newWidth)  elm.setAttribute('width', newWidth, 0);
		}
	}	

function display_switch(id, s, dom)
	{
	if (!dom) dom= "document";

	
	// toggle display if no preset submitted
	if (!s) s = elm.getAttribute("display",false) == "none" ? "inline":"none";
	
	// elm = eval(dom+".all."+id+".style");
	elm = document.getElementById(id);
	if (elm) elm.style["display"] = s;
	// elm.setAttribute("display", s, false);
	return;	
	}	
	
function set_fragment(identifier)
	{
	document.location.hash = "#"+identifier;
	}	

function hold_effect(layer_index,id) 
	{ 
	
	hold_index = layer_index;
	hold_id = id; 
	effect = false; 
	}

function release_effect() 
	{
	if (hold_index)
		{
		elm = get_dom(hold_index).getElementById(hold_id);
		if(color_off[hold_id]!= "") elm.setAttribute('bgcolor', color_off[hold_id], 0);
		else elm.removeAttribute('bgcolor',0);
		color_off[hold_id] = null;
		}
	effect = true; 
	hold_index = null;
	hold_id = null;
	}



/*
function release single()
	{
	// unselect 
	// change_row
	mouseeffect = true;
	}
	*/
/*	USE FUNC. change_row(); 
function editor_change_row(id,newColor){
	if (id != selected_id){
		
		elm = cme_layer["dragbox_cm_edit_content"].doc.getElementById(id);
		if (elm) elm.setAttribute('bgcolor', newColor, 0);
     	}
	return true;

	}		
*/

	
function css_click(id){
	if (selected_id != null){
		change = document.getElementById(selected_id);
		if (change) change.className = "cmeMenuRowLo";
		}
	if (id != "row0"){
		selected_id = id;
		change = document.getElementById(selected_id);
		if (change) change.className = "cmeMenuRowHi";
		}
	}

function click_row(row){
	if (row != selectedrow){
		document.forms[row].selectedrow.value = row;
		document.forms[row].submit();
		}
	}
