var show=false;

function properties_set(description){
	if (description.length>0){
		document.all.menu.innerHTML = description;	
		timerID=setTimeout('document.all.menu.style.visibility = "visible"',100);
		show=true;
	}
}
function properties_out(){
	if (show){
	clearTimeout(timerID)
	document.all.menu.style.visibility = "hidden"
	document.all.menu.innerHTML = ''
	show=false;
	}
}
function properties() {
	if (show){
	document.all.menu.style.top = event.y
	document.all.menu.style.left = event.x+15
	}
}

function download(type, target){
	location.href='download.php?type='+type+'&target_id='+target;
}

function openIT (theURL,W,H, wtype){
	if (document.all){
		var xMax = screen.width, yMax = screen.height;
	}
	else{
		if (document.layers){
			var xMax = window.outerWidth, yMax = window.outerHeight;
		}
		else{
			var xMax = 640, yMax=480;
		}
	}
	var xOffset = (xMax - W)/2, yOffset = (yMax - H)/2;
	open(theURL, wtype, 'scrollbars=yes,resizible=yes,width='+W+',height='+H+',top='+yOffset+',left='+xOffset);
}

function jump(menu, who) { 
	if (who==1){
		ref=menu.choice.options[menu.choice.selectedIndex].value; 
		splitc=ref.lastIndexOf("&"); 
	}
	else if (who==2){
		ref=menu.choice2.options[menu.choice2.selectedIndex].value; 
		splitc=ref.lastIndexOf("&"); 
	}
	if (ref != "") {
		window.open("http://"+ref);
	} 
}

function mailingliste(word) {
      if(word.value == "YOUREMAILHERE") {
      document.forma.mailinglist.value = ""}
	  else if (word.value == "") {
      document.forma.mailinglist.value = "YOUREMAILHERE"}
	  }
      
      
      
      
function doResize()
{
    $('#backgroundBox').css({
        'width': '0px',
        'height': '0px'
    });

	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY || window.scrollMaxX)
	{
        if (window.scrollMaxY)
        {
            scrollBarWidth = getScrollbarWidth();
        }
        else
        {
            scrollBarWidth = 0;
        }
		xScroll = window.innerWidth + window.scrollMaxX - scrollBarWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	}
	else if (document.body.scrollHeight > document.body.offsetHeight || document.body.scrollWidth > document.body.offsetWidth)
	{ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	}
	else
	{ // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;

	if (self.innerHeight)
	{	// all except Explorer
		if(document.documentElement.clientWidth)
		{
			windowWidth = document.documentElement.clientWidth;
		}
		else
		{
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{ // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{ // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	// for small pages with total height less then height of the viewport
	if (yScroll < windowHeight)
	{
		pageHeight = windowHeight;
	}
	else
	{
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if (xScroll < windowWidth)
	{
		pageWidth = windowWidth;
	}
	else
	{
		// pageWidth = windowWidth;
		pageWidth = xScroll;
	}

    $('#backgroundBox').css({
        'width': pageWidth + 'px',
        'height': pageHeight + 'px'
    });
}

function getScrollbarWidth()
{
    // look for cached version
    if (typeof window.scrollbarWidth == 'number')
    {
        return window.scrollbarWidth;
    }

    // create test container and inner overflow box
    var outerBox = document.createElement('div');
    outerBox.style.position = 'absolute';
    outerBox.style.top      = '100px';
    outerBox.style.left     = '100px';
    outerBox.style.width    = '200px';
    outerBox.style.height   = '200px';
    outerBox.style.overflow = 'hidden';

    var innerBox = document.createElement('div');
    innerBox.style.width    = '100%';
    innerBox.style.height   = '400px'; // cause overflow

    outerBox.appendChild(innerBox);
    document.body.appendChild(outerBox);

    // measure inner box size with overflow hidden
    var sizeWithNoScrollbar = innerBox.offsetWidth;

    // measure width with overflow scroll
    outerBox.style.overflow = 'auto';
    var sizeWithScrollbar = innerBox.offsetWidth;
    outerBox.parentNode.removeChild(outerBox);

    window.scrollbarWidth = sizeWithNoScrollbar - sizeWithScrollbar;

    return window.scrollbarWidth;
}
