/*
www.schober.co.at
loesungsmodule
main javascript lib
11 2008 erik wunderlich
*/
var d = document;
var w3c = (d.documentElement) ? true:false;
var winID = 0;
var popUp = new Array();


//div object containing the mo frame grafx for module mo effect
var modulefxObj = '#modulemofx';

// shadowbox setup
// for ie 6 and 5 load the modified standard skin
// all others get the optimized skin
Shadowbox.loadSkin(((lowIE) ? 'schober_lowIE' : 'schober'), 'shadowbox/skin');
var sbOptions = {
		overlayOpacity:	0.3,
		onClose: resetSBNavi
};

// standard popup fenster
function fensterAuf(inhalt, breite, hoehe, winname) {
  var xOff = 10;
  var yOff = 10;
  if (parseInt(navigator.appVersion)>=4) {
    xOff = (screen.width-breite)/2;
    yOff = (screen.height-(hoehe))/2;
    yOff -= 20;
  }
  
  popUp[winID] = window.open(inhalt, winname, 'toolbar=no,status=no,location=no,directories=no,resizable=no,scrollbars=yes,width='+breite+',height='+hoehe+',left='+xOff+',top='+yOff);
  winID++;
}


// utility - print the contents of the shadowbox iframe
function printBoxcontent() {
	var href = (window.Shadowbox) ? window.Shadowbox.getCurrent().content : null;
	if (href != null) {
		fensterAuf(href, 720,520,'modulprint');
	}
}

// utility - reset the shadowbox navi using setShadowBoxNavi
function resetSBNavi() {
	setShadowboxNavi('default');
}


// change the contents of the shadowbox navi
function setShadowboxNavi() {
	if (w3c && arguments.length > 0) {

		// defaults for w and h
		var w = (arguments.length > 1) ? arguments[1] : 200;
		var h = (arguments.length > 2) ? arguments[2] : 200;
		var href = (arguments.length > 3) ? arguments[3] : '';
		var sbNavObj = (d.getElementById('shadowbox_nav')) ? d.getElementById('shadowbox_nav') : null;
		var navicode = '';
		
		// navicode default
		if (arguments[0] == 'default') {
			navicode = '<a id="shadowbox_nav_close" title="Schließen" onclick="Shadowbox.close()"></a>';
		}

		// navicode variante 1 - navi fuer modul-seite
		if (arguments[0] == 'modul') {
			// mit PRINT link
			navicode = '<a id="shadowbox_nav_close" title="Schließen" onclick="Shadowbox.close()"></a><a id="shadowbox_nav_print" onclick="printBoxcontent()">Druckansicht</a>';
			// ohne PRINT link
			//navicode = '<a id="shadowbox_nav_close" title="Schließen" onclick="Shadowbox.close()"></a>';
		}

		// navicode variante 2 - navi fuer grafik-seite
		if (arguments[0] == 'grafik') {
			// mit PRINT link
			navicode = '<a href="' + href + '" id="shadowbox_nav_close" title="Zurück" onclick="openShadowLink(this.href, ' + w + ', ' + h + ');return false"></a><a id="shadowbox_nav_print" onclick="printBoxcontent()">Druckansicht</a>';
			// ohne PRINT link
			//navicode = '<a href="' + href + '" id="shadowbox_nav_close" title="Zurück" onclick="openShadowLink(this.href, ' + w + ', ' + h + ');return false"></a>';
		}

		if (sbNavObj != null) sbNavObj.innerHTML = navicode;
	}
}


$(document).ready(function(){
	// shadowbox starten
	Shadowbox.init(sbOptions);

  // mouseover effect fuer loesungsmodule
  $("#moduleanchorgrid a").hover(function() {
    $(modulefxObj).addClass(this.id + "fx");
  },function(){
    $(modulefxObj).removeClass(this.id + "fx");
  });
});
