// Timer-Druck-Dialog
var secs;
var timerID = null;
var timerRunning = false;
var delay = 1000;

function InitializePrintTimer() {
	// Set the length of the timer, in seconds
  secs = 2;
  StopTheClock();
  StartTheTimer();
}

function StopTheClock() {
  if(timerRunning)
    clearTimeout(timerID);
  timerRunning = false;
}

function StartTheTimer() {
  if (secs==0) {
    StopTheClock();
		window.print();
  } else {
    self.status = secs;
    secs = secs - 1;
    timerRunning = true;
    timerID = self.setTimeout("StartTheTimer()", delay);
  }
}

//function getNavigation(cid, pid) {
//	if ($('background').style.backgroundImage != "url(images/"+cid+".jpg)") {
//		$('background').style.backgroundImage = "url(images/"+cid+".jpg)";
//	}
//	if ($('headline').style.backgroundImage != "url(images/de/head_"+cid+""+(parseInt(pid)+1)+".jpg)") {
//		$('headline').style.backgroundImage = "url(images/de/head_"+cid+""+(parseInt(pid)+1)+".jpg)";
//	}
//
//	url =	'nav.php?cid='+cid+'&pid='+pid+'';
//	new Ajax.Request(url, {
//		method: 'get',
//		onSuccess: function(transport) {
//			$('navigation').innerHTML = transport.responseText;
//			evalAJAXRequest($('navigation'));
//			new Effect.Opacity('copy', { from: 1, to: 0, duration: 0.2, afterFinish:getContent});
//		}
//	});
//}
//
//function getContent() {
//	url =	'content.php';
//	new Ajax.Request(url, {
//		method: 'get',
//		onSuccess: function(transport) {
//			$('copy').innerHTML = transport.responseText;
//			evalAJAXRequest($('copy'));
//			new Effect.Opacity('copy', { from: 0, to: 1, duration: 0.2});
//		}
//	});
//}
//
//function evalAJAXRequest(obj) {
//	var x = obj.getElementsByTagName("script");
//	for(var i=0;i<x.length;i++) {
//		eval(x[i].text);
//	}
//}

function mousepos(e) {
    if (!e) { var e = window.event; }

    if (e.pageX || e.pageY) {
        posx = e.pageX;
        posy = e.pageY;
    }
    else if (e.clientX || e.clientY) {
        posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
        posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
    }
		return new Array(posx, posy);
} 

function initToolTips(objStr) {
	var entries = $$('.'+objStr+'');
	for (var i=0; i<entries.length; i++) {
		entries[i].observe('mouseover', showToolTip);
		entries[i].observe('mouseout', hideToolTip);
		entries[i].observe('mousemove', moveToolTip);
	}
}

function showToolTip(event) {
	var element = event.element();
	tip = $('ToolTip');
	tip.innerHTML = arrTips[element.id];
	
	tip.style.display = "block";
	moveToolTip(event);
	tip.style.display = "none";
	
	tip.style.display = "block";
}

function hideToolTip(event) {
	tip.style.display = 'none';
}

function moveToolTip(event) {
	pos = mousepos(event);
	tip = $('ToolTip');
	tip.style.top = (pos[1] - 10 - tip.offsetHeight) + "px";
	if (pos[0] > 500) {
		tip.style.left = (pos[0] + 10 - tip.offsetWidth) + "px";	
	} else {
		tip.style.left = (pos[0] + 10) + "px";
	}
}

// Funktion sucht URL aus Thumbnail und gibt URL aus Original zurück
function showLocat(image){
	var url = image.src;
	var arrURL = url.split("/");
	imgName = arrURL[arrURL.length-1].replace(/_t/g, "");
	newWindow = window.open("imagePopup.php?img="+imgName,"_blank", "status,menubar,scrollbars,height=100,width=100");
	newWindow.focus( );
}

//Funktion zum öffnen der eigentlichen Broschuere
function openBrosch(lc){
	brosch = window.open('broschuere.php?lc='+lc, '_blank', 'width=800,height=552,scrollbars=no');	
	brosch.focus();
}