/* DHTML-Bibliothek */

var ie, nn4, dom;
var mr=null;
var tt = null;
var i;
var fade;
var col = 0;

//document.onmousedown = clickMF;
document.onmousemove = updateTT;

if(document.all)
{
	ie = true
}
else
{
	ie = false
	if(document.layers)
	{
		nn4 = true
	}
	else
	{
		nn4 = false
	}
}

if(document.getElementById)
{
	dom = true
}
else
{
	dom = false
}

/*function clickMF (ereignis)
{
	if (!ereignis)   ereignis = window.event;

	if (ereignis.button==2)
	{
		alert('Nice try !');
	}
}*/

function img_change (bild,id)
{
	var img = new Image()
	img.src = bild;
	var neuesbild = document.getElementById(id);
	neuesbild.height = neuesbild.height;
	neuesbild.width = neuesbild.width;
	neuesbild.src = img.src;
}

function navi_show(element)
{
	document.getElementById(element).style.display='block';
}

function navi_hide(element)
{
	document.getElementById(element).style.display='none';
}

function updateTT(e)
{
	x = (document.all) ? window.event.x + document.body.scrollLeft : e.pageX;
	y = (document.all) ? window.event.y + document.body.scrollTop  : e.pageY;
	if(tt != null)
	{
		document.getElementById("tooltip").style.left	= (x + 20) + "px";
		document.getElementById("tooltip").style.top	= (y + 20) + "px";
	}

	if(mr !=null)
	{
		document.getElementById("frame").style.left	= (x - 75) + "px";
		document.getElementById("frame").style.top	= (y - 75) + "px";
	}
}

function showTT(text)
{
	tt = 1;
	document.getElementById("tooltip_inner").innerHTML = text;
	if(text != '')	window.setTimeout('delayTT()', 1000);
}

function hideTT()
{
	tt = null;
	document.getElementById("tooltip").style.display = "none";
}

function delayTT()
{
	if(tt != null)
	{
		i=0;
		document.getElementById('tooltip').style.display = 'block';
	}
}

function show_window(id)
{
	document.getElementById(id).style.display = 'block';
}

function close_window(id)
{
	document.getElementById(id).style.display = 'none';
}

function minimize_window(id)
{
	if(document.getElementById(id + '_sub').style.display!='none')	document.getElementById(id + '_sub').style.display = 'none';
	else															document.getElementById(id + '_sub').style.display = 'inline';
}

function toggle_obj(id)
{
	if(document.getElementById(id).style.display!='none')	document.getElementById(id).style.display = 'none';
	else													document.getElementById(id).style.display = 'block';
}

function confirm_link(link, text)
{
	if(confirm(text)) document.location.href = link;
}

function box_toggle(image, checkbox, value)
{
	if(image.name==1)
	{
		image.src='style/gfx/box_grey.png';
		image.name=0;
		document.getElementById(checkbox).value=0;

	}
	else
	{
		image.src='style/gfx/box_checked.png';
		image.name=1;
		document.getElementById(checkbox).value=value;
	}
}

function box_highlight(image)
{
	if(image.name==0)
	{
		image.src='style/gfx/box_blue.png';
	}
	else
	{
		image.src='style/gfx/box_blue_checked.png';
	}
}

function box_dehighlight(image)
{
	if(image.name==0)
	{
		image.src='style/gfx/box_grey.png';
	}
	else
	{
		image.src='style/gfx/box_checked.png';
	}
}

function toggle_grey(image)
{
	var name = image.src;

	if(image.name==0)
	{
		name = name.substring(name.lastIndexOf("/")+1, name.lastIndexOf("_grey.png"));
		image.src='style/icons/' + name + '.png';
		image.name=1;
	}
	else
	{
		name = name.substring(name.lastIndexOf("/")+1, name.lastIndexOf(".png"));
		image.src='style/icons/' + name + '_grey.png';
		image.name=0;
	}
}

function open_popup(adresse, name)
{
	Fenster = window.open(adresse, name, "width=130,height=140,left=100,top=200,status=no,dependent=yes");
	Fenster.focus();
}

function open_pictures(adresse, name, width, height)
{
	var pifo_id = document.getElementById('pifo_select').value;

	Fenster = window.open(adresse + "?pifo_id=" + pifo_id, name, "width= " + width + ",height=" + height + ",left=100,top=200,status=no,dependent=yes,scrollbars=no");
	Fenster.focus();
}

function open_help(adresse)
{
	Fenster = window.open("help.php?topic=" + adresse, "Hilfe", "width=600,height=400,left=100,top=200,status=no,dependent=yes,scrollbars=auto");
	Fenster.focus();
}

function pictures_add(id)
{
	var align;
	if(document.ausrichtung.align[0].checked)	align = "left";
	if(document.ausrichtung.align[1].checked)	align = "right";

	opener.document.getElementById('smilies').value += "[thu " + id + "][" + align + "]";
}

function set_date(date, id)
{
	opener.document.getElementById(id).value = date;
	window.close();
}

function set_color(element, id)
{
	var color = element.style.backgroundColor;

	var sub_color = color.split("rgb(");
		sub_color = sub_color[1].split(")");
		sub_color = sub_color[0].split(", ");

	color = "#" + d2h(sub_color[0]) + d2h(sub_color[1]) + d2h(sub_color[2]);

	opener.document.getElementById(id).value = color;

	window.close();

}

function open_popup2(adresse, name, width, height, left, top)
{
	Fenster = window.open(adresse, name, "width=" + width + ",height=" + height + ",left=" + left + ",top=" + top +",status=no,dependent=yes");
	Fenster.focus();
}

function highlight(id, color)
{
	document.getElementById(id).style.backgroundColor = color;
}

// basic functions

function d2h(d)
{
	var HexChars="0123456789ABCDEF";
	var a = 0;
	var HexZahl = "";
	while (d>>a != 0)
	{
		HexZahl = HexChars.charAt((d>>a)&0xf) + HexZahl;
		a+=4;
	}
	
	if(d==0)	return "00";
	else		return HexZahl
}

function h2d(h)
{
	return parseInt(h,16);
}

function set_col(colum)
{
	col = colum;
}

function handle(delta)
{
	if(col != 0)
	{
		if (delta < 0)	step_scroll('col_' + col, 0);
		else			step_scroll('col_' + col, 1);
	}
}

function wheel(event){
	var delta = 0;
	if (!event) event = window.event;
	if (event.wheelDelta) {
		delta = event.wheelDelta/120; 
		if (window.opera) delta = -delta;
	} else if (event.detail) {
		delta = -event.detail/3;
	}
	if (delta)
		handle(delta);
        if (event.preventDefault)
                event.preventDefault();
        event.returnValue = false;
}

/* Initialization code. */
if (window.addEventListener)
	window.addEventListener('DOMMouseScroll', wheel, false);
window.onmousewheel = document.onmousewheel = wheel;

/*

function show_frame()
{
	document.getElementById("frame").style.display = "block";
	mr = 1;
}

function hide_frame()
{
	document.getElementById("frame").style.display = "none";
	mr = null;
}


if (window.addEventListener)	window.addEventListener('DOMMouseScroll', wheel, false);
window.onmousewheel = document.onmousewheel = wheel;
*/
