//reworked these scripts to work with a the table instead of a select; old ones are below in comment
function styleSelected(style)
{
	// 13.04.2005 Emil - return false if we receive a null - bug 3187
	if(!style)
		return false;
	if(style.backgroundColor == "rgb(0,0,136)" || style.backgroundColor == "rgb(0, 0, 136)")
		return true;
	if((window.opera) && style.backgroundColor == "#000088")
		return true;//28.10.2005 Svetoslav - rgb not supported under Opera
	return false;
}

function updateLocFromString(locTableName, locStringName)
{
	locs = document.getElementById(locStringName).value.split(";");
	locTable = document.getElementById(locTableName);
	
	if (isIExplorer())
		while(locTable.rows.length > 0)
			locTable.deleteRow();
	else
		while(locTable.rows.length > 0)
			locTable.deleteRow(0);
			
	var text;
	var row;
	var cell;
	var i;
	
	//always have 1 bogus row to keep the width of the table constant
	if (isIExplorer())
	{
		row = locTable.insertRow();
		cell = row.insertCell();
	}
	else
	{
		row = locTable.insertRow(0);
		cell = row.insertCell(0);
	}
	
	cell.innerHTML = "<div style='overflow : hidden; cursor: default; width: 185px; height: 1px'>&nbsp;</div>";

	for (i = 0; i < locs.length; i++)
	{
		text = locs[i].substr(0, locs[i].indexOf(':'));
		if (isIExplorer())
		{
			row = locTable.insertRow();
			cell = row.insertCell();
		}
		else
		{
			row = locTable.insertRow(locTable.rows.length);
			cell = row.insertCell(0);
		}

		cell.innerHTML = "<div id='sp' onselectstart='javascript:if(isIExplorer()) event.returnValue=false;' style='text-overflow: ellipsis; overflow : hidden; cursor: default; width: 185px'>" + text + "</div>";
		cell.title = text;
		cell.onclick = selectLoc;
		cell.style.backgroundColor = "#ffffff";
		cell.style.color = "#000000";
		cell.noWrap = true;
	}
}

function selectLoc()
{
	var	cell = getEventSrcElement();
	var	tableBody;
	var	myspan;
	
	if (isIExplorer())
	{
		tableBody =	cell.parentElement.parentElement.parentElement;
		myspan = tableBody.parentElement.parentElement;
	}
	else
	{
		cell = cell.parentNode.parentNode;
		tableBody =	cell.parentNode.parentNode.parentNode;
		myspan = tableBody.parentNode;
	}
	
	var	i;
	var	pin;

	if (isIExplorer())
	{
		for	(i = 0; i < myspan.all.length; i++)
		{
			if (myspan.all[i].tagName.toUpperCase() == "INPUT")
			{
				pin = myspan.all[i];
				break;
			}
		}
	}
	
	if (isIExplorer() && event.shiftKey)
	{
		var	ourcell	= -1;
		for(i=1; i<tableBody.rows.length; i++)
		{
			if(i ==	cell.parentElement.parentElement.sectionRowIndex)
			{
				if(pin.value ==	"")
				{
					cell.style.backgroundColor = "#000088";
					cell.style.color = "#ffffff";
					pin.value =	i;
					return;
				}
				else
				{
					ourcell	= i;
				}
			}
		}
		var	min;
		var	max;
		if (ourcell<pin.value)
		{
			min=ourcell;
			max=pin.value;
		}
		else
		{
			min=pin.value;
			max=ourcell;
		}
		for(i=1; i<tableBody.rows.length; i++)
		{
			if ( min<=i	&& i<=max )
			{
				tableBody.rows[i].cells[0].all.sp.style.backgroundColor	= "#000088";
				tableBody.rows[i].cells[0].all.sp.style.color =	"#ffffff";
			}
			else
			{
				tableBody.rows[i].cells[0].all.sp.style.backgroundColor	= "#ffffff";
				tableBody.rows[i].cells[0].all.sp.style.color =	"#000000";
			}
		}
		
		return;
	}
	
	if (isIExplorer() && event.ctrlKey)
	{
		for(i=1; i<tableBody.rows.length; i++)
		{
			if(i ==	cell.parentElement.parentElement.sectionRowIndex)
			{
				pin.value =	i;
				break;
			}
		}
		
		if(cell.style.backgroundColor != "#000088")
		{
			cell.style.backgroundColor = "#000088";
			cell.style.color = "#ffffff";
		}
		else
		{
			cell.style.backgroundColor = "#ffffff";
			cell.style.color = "#000000";
		}
		
		return;
	}
	
	if (isIExplorer())
	{
		for (i = 1; i < tableBody.rows.length; i++)
		{
			if(i ==	cell.parentElement.parentElement.sectionRowIndex)
			{
				cell.style.backgroundColor = "#000088";
				cell.style.color = "#ffffff";
				pin.value =	i;
			}
			else
			{
				tableBody.rows[i].cells[0].all.sp.style.backgroundColor	= "#ffffff";
				tableBody.rows[i].cells[0].all.sp.style.color =	"#000000";
			}
		}
	}
	else
	{
		// 13.04.2005 Emil - set style where it exists - bug 3187
		if(cell.childNodes[0].style)
		{
			if(styleSelected(cell.childNodes[0].style))
			{
				cell.childNodes[0].style.backgroundColor = "#ffffff";
				cell.childNodes[0].style.color = "#000000";
			}
			else
			{
				cell.childNodes[0].style.backgroundColor = "#000088";
				cell.childNodes[0].style.color = "#ffffff";
			}
		}
		else if(styleSelected(cell.style))
		{
			cell.style.backgroundColor = "#ffffff";
			cell.style.color = "#000000";
		}
		else
		{
			cell.style.backgroundColor = "#000088";
			cell.style.color = "#ffffff";
		}
	}
}

function removeLocation(locTableName, locStringName) 
{
	locStr = document.forms[0].elements[locStringName];
	locTable = document.getElementById(locTableName);

	if (locStr.value.length == 0) return;
	
	locs = locStr.value.split(";");
	locStr.value = "";
	
	var i;
	
	if (isIExplorer())
	{
		for (i = 0; i < locs.length; i++) 
		{
			if (locTable.rows[i+1].cells[0].all.sp.style.backgroundColor != "#000088") 
			{
				locStr.value += ";" + locs[i]; 
			}
		}
	}
	else
	{
		for (i = 0; i < locs.length; i++) 
		{
			if (styleSelected(locTable.rows[i+1].cells[0].childNodes[0].style)
				|| styleSelected(locTable.rows[i+1].cells[0].style))
					continue;

			locStr.value += ";" + locs[i];
		}
	}
	
	//remove ';' before first location
	if(locStr.value.length > 0)
		locStr.value = locStr.value.substr(1);	

	updateLocFromString(locTableName, locStringName);
}

function clearLocations(locTableName, locStringName) 
{
	locTable = document.getElementById(locTableName);
	
	if (isIExplorer())
		while(locTable.rows.length > 0)
			locTable.deleteRow();
	else
		while(locTable.rows.length > 0)
			locTable.deleteRow(0);
	
	//always have 1 bogus row to keep the width of the table constant
	var row;
	var cell;
	
	if (isIExplorer())
	{
		row = locTable.insertRow();
		cell = row.insertCell();
	}
	else
	{
		row = locTable.insertRow(0);
		cell = row.insertCell(0);
	}
	
	cell.innerHTML = "<div style='overflow : hidden; cursor: default; width: 185px; height: 1px'>&nbsp;</div>";

	document.getElementById(locStringName).value = "";
}

function MM_openBrWindow(theURL,stateName)
{
	window.open(theURL+'&TID='+getTimeID(),'','width=600,height=525,resizable=1,status=0');
}

Xoffset= 1;
Yoffset= 20;

var old,skn,iex=(document.all),yyy=-1000;

var ns4=document.layers
var ns6=document.getElementById&&!document.all
var ie4=document.all

var loaded = false;

/*function setlayers()
{
if (ns4)
skn=document.dek
else if (ns6)
skn=document.getElementById("dek").style
else if (ie4)
skn=document.all.dek.style
if(ns4)document.captureEvents(Event.MOUSEMOVE);
else{
skn.visibility="visible"
skn.display="none"
document.onmousemove=get_mouse;
loaded = true;
}
}
window.onload=setlayers;

function popup(msg,cnt){
if(msg == "" || !loaded) return;
var content="<select class=tooltip size="+cnt+">"+msg+"</select>";
yyy=Yoffset;
 if(ns4){skn.document.write(content);skn.document.close();skn.visibility="visible"}
 if(ns6){document.getElementById("dek").innerHTML=content;skn.display=''}
 if(ie4){document.all("dek").innerHTML=content;skn.display=''}
}

function get_mouse(e){
var x=(ns4||ns6)?e.pageX:event.x+document.body.scrollLeft;
skn.left=x+Xoffset;
var y=(ns4||ns6)?e.pageY:event.y+document.body.scrollTop;
skn.top=y+yyy;
}*/

function kill(){
yyy=-1000;
if(ns4){skn.visibility="hidden";}
else if (ns6||ie4)
skn.display="none"
}

/*function displayTip(src)
{
	var msg = "";
	var cnt = 0;
	var len = src.options.length;
	for(i = 0; i < len; i++)
	{
		if(src.options[i].text != "")
		{
			msg += "<option>" + src.options[i].text + "</option>";
			cnt++;
		}
	}
	popup(msg,cnt);
}*/

