function markTable(tableElement, tagTypes, depth)
{
	var elements = getChildsByTagName(tableElement, tagTypes);
	for(var j=0; j<elements.length; j++)
	{
		element = elements[j];
		if(j==0) element.className += ' first';
		if(j==(elements.length-1)) element.className += ' last';
		element.className += j % 2 == 0 ? ' odd' : ' even';
		if(depth-1 > 0) markTable(element,tagTypes, depth-1);
	}	
}
function getChildsByTagName(element, tagTypes)
{
	var childs = [];
	for(var j = 0; j < element.childNodes.length; j++)
	{
		if(tagTypes[element.childNodes[j].nodeName.toLowerCase()])
		{
			childs[childs.length]=element.childNodes[j];
		}
	}		
	return childs;
}	
function initTables()
{
	//Tabellenzeilen markieren
	if(!document.getElementsByTagName) return;
	var tables = document.getElementsByTagName("table");
	var tagTypes = {"tr": true, "td" : true, "th": true};
	for (var i=0; i<tables.length; i++)
	{
		var table = tables[i];
		
		var thead = getChildsByTagName(table, {'thead' : true})[0];
		if(thead) markTable(thead,tagTypes,2);

		var tbody = getChildsByTagName(table, {'tbody' : true})[0];
		if(tbody) markTable(tbody,tagTypes,2);
	}
}

function initPage() {
	
	$("div.small a.zoom").each(function(i){
		this.onclick = function () { 
			$("div.big").show();
			return false;
		}
	});

	$("div.big a.zoom").each(function(i){
		this.onclick = function () { 
			$("div.big").hide();
			return false;
		}
	});
	
	$("input[@type=radio]").addClass('radio');
	$("input[@type=checkbox]").addClass('checkbox');
	
	$("table.industries td.text").each(function(i){
		this.onmouseover = function() {
			$(this).addClass('hover');
		}
		this.onmouseout = function() {
			$(this).removeClass('hover');
		}
	});
}

$(document).ready(function() {
	// 5.9.2007 rd	
	if(self.location.href.indexOf('print_preview')>-1) {
		$('a').each(function() {
			var p = $('.print').attr('href');
			$(this).attr("href","#");
			$(this).removeAttr('href');
			$(this).removeAttr('target');
			$('.print').attr('href',p);
		})
	}
	else { 
		initTables();
		initPage();
		}
		
	$('.tooltips div').hide();
	
	$('select#sensors').change(function(){
		try { window.open($(this).attr('value')); }
		catch (e){}
	});
	
	$('#serviceblock li a').each(function(){
		var tip = $(this).attr('id').replace('#','t');
		$(this).mouseover(function(e){
			$('#'+tip).css('top',(e.pageY-($('#'+tip).height()/100*90))+'px');
			$('#'+tip).css('left',(e.pageX+50)+'px');
			$('#'+tip).fadeIn('normal');
			$('#sensors').hide();
		});
		$(this).mouseout(function(){	
			$('#sensors').show();		
			$('#'+tip).fadeOut('normal');
		});		
	});
	
	$('.print').click(function(){
		window.open($(this).attr("href"),'print','width=800,height=600,dependent=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
		return false;
	})
});