var box = {};
var overlay = {};


function getWindowXY() {
	var myWidth = 0, myHeight = 0;

	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	return new Array(myWidth, myHeight);
}

function isSet (variable) {
	return( typeof( variable ) != 'undefined' );
}

function mbReplace () {
	pictureId = jQuery(this).attr('index');
	orgImage = jQuery(this).attr('src');
	bigImage = orgImage;
	bigImage = bigImage.replace('-kl-','');
 	bigImage = bigImage.replace('.jpg','-gr.jpg');
	bigImage = bigImage.replace('.png','-gr.png');
	bigImage = bigImage.replace('.gif','-gr.gif');
	bigImage = bigImage.replace('-kl.jpg','-gr.jpg');
	bigImage = bigImage.replace('-kl.png','-gr.png');
	bigImage = bigImage.replace('-kl.gif','-gr.gif');
}

function mbInit () {
	imgTitle = jQuery(this).attr('title');
	jQuery('img',this).each(mbReplace);
	jQuery(this).html(
		' <a href="' + bigImage + '" class="multibox ' + pictureId + '" title="' + imgTitle + '" id="bild-' + pictureId + '-link" index="' + pictureId + '">' + jQuery(this).html() + '</a>'
	);
}


function putMBRequirements() {
	try {
		jQuery('span.mbinit').each(mbInit);
	}
	catch (e) {
		//Fehlerbehandlung
	}
}

function loadMultibox() {
	 window.addEvent('domready', function(){
	 	//Es muss ein Element mit Klasse mbinit vorhanden sein zum automatischen Ausfuehren
	 	if ($$('.mbinit').length > 0 || $$('.multibox').length > 0) {
		 	putMBRequirements();
			box = new MultiBox('multibox', {
				useOverlay: true,
				showNumbers: true,
				showControls: true,
				contentColor : 'black',
				slideshow: false,
				windowResize: false,
				rotate: true,
				path: 'others/js/multibox/player/'
			});
		}
	});
}

function openMultibox(id) {
	box.open(id);
}


loadMultibox();

