// ----------------------
//  Client information
// ----------------------

var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var clientVer = parseInt(navigator.appVersion); // Get browser version

var isOPERA = (clientPC.indexOf('Opera') != -1)? true : false;
var useIE    = (document.all && !isOPERA)? true : false;
var useDOM   = (document.getElementById && !useIE && !isOPERA)? true : false;

var is_ie = ((clientPC.indexOf("msie") != -1) && !isOPERA);
var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1)
                && (clientPC.indexOf('compatible') == -1) && !isOPERA
                && (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));
var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));
var is_mac = (clientPC.indexOf("mac")!=-1);


var cnt_InfoBoxes = 0;

function PopUp(id) {
  newwin = window.open('infopopup.php?info='+id,'PopUp','width=300,height=450,scrollbars');
  newwin.focus();
  return false;
}
function getCharCnt(element,label) {
	var ref = document.getElementById(label);
	var test = element.value;
	ref.childNodes[0].nodeValue=test.length;
}


function createInfoBox(msg) {
	cnt_InfoBoxes++
	msg = String(msg);
	
	if (useDOM) {
		var Div = document.getElementById('infowindow');
	}
	else if (useIE) {
		var Div = document.all['infowindow'];
	}
	
	var newDiv = document.createElement('div');
	newDiv.innerHTML = msg.replace(/\{LINK\}/, '<a href="#closeinfo" OnClick="BlendOut(\'infobox'+cnt_InfoBoxes+'\');\" >Ausblenden</a>');
	//newDiv.onmousedown = function() { this.style.display = 'none'; };
	var divid = document.createAttribute("id");
	divid.nodeValue = 'infobox'+cnt_InfoBoxes;
	newDiv.setAttributeNode(divid);
	Div.appendChild(newDiv);
}

function BlendOut(object) {
	if (useDOM) {
		document.getElementById(object).style.display = 'none';
	}
	else if (useIE) {
		document.all[object].style.display = 'none';
	}
}

/*
function RepositionInfoBox() {
	for(var id = 1; id <= 10; id--) {
		MoveInfoBox(id);
	}
}

function MoveInfoBox(view_id) {
	var parent = null;
	if (useDOM) {
		var object = document.getElementById('infobox'+view_id);
	}
	else if (useIE) {
		var object = document.all['infobox'+view_id];
	}
	var found = null;
	for(var id = view_id-1; id >= 1; id--) {
		if (useDOM) {
			parent = document.getElementById('infobox'+id);
		}
		else if (useIE) {
			parent = document.all['infobox'+id];
		}
		found = id;
		if (parent == null || parent.style.display != 'none') break;
	};
	
	if (found != null) {
		document.getElementById('infobox'+view_id).style.top = parseInt(document.getElementById('infobox'+found).style.top) + 100 +'px';
		object.innerHTML = object.innerHTML+"object "+found;
	}
	else {
		document.getElementById('infobox'+view_id).style.top = 300+'px';
		object.innerHTML = object.innerHTML+"object root "+view_id;
	}
}*/



var marked_row = new Array;
var skip_row = new Array;
var pointer_color = '#e3c781';
var mark_color = '#f5d78b';

function smartlistSkipped(theRowNum) {
	skip_row[theRowNum] = true;
	return true;
}

function smartlistColors(thePointerColor, theMarkColor) {
	pointer_color = thePointerColor;
	mark_color = theMarkColor;
	return true;
}

function smartlistPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor)
{
    var theCells = null;

    if (typeof(theRow.style) == 'undefined') {
        return false;
    }
	
	if (typeof(thePointerColor) != 'undefined') {
        pointer_color = thePointerColor;
    }

    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     = null;
	
	if (theAction == 'out') {
		if (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum]) {
			newColor = theDefaultColor;
		}
	}
	else if (theAction == 'over') {
		if (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum]) {
			newColor = pointer_color;
		}
	}
	else if (theAction == 'click') {
		if (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum]) {
			newColor = mark_color;
			marked_row[theRowNum] = true;
		}
		else {
			newColor = theDefaultColor;
			marked_row[theRowNum] = null;
		}
	}
	if (newColor != null) {
		var c = null;
	
		for (c = 0; c < rowCellsCnt; c++) {
			if (typeof(skip_row[c]) == 'undefined' || !skip_row[c])
				theCells[c].style.backgroundColor = newColor;
		}
	}
    return true;
}

