$(document).ready(function(){ 
		var j = 0;
		$('body').append("<div id='insymaOverlay' style='display:none;'></div>");
		$('#insymaOverlay').hide();
		$('#insymaOverlayContent').hide();
		$('.insymaSpecialOverlay').click(function() {
 		 	_getInsymaLayer(this);
		});
		$(document).bind('keydown', function(e) { 
			if (e.keyCode == 27) { //ESC
				_closeInsymaOverlay()
			}
    	}); 
		//var html = "<div id='insymaOverlay' style='display: none;'></div><div id='insymaOverlayContent' style='display: none;'></div>";
		//$('body').append(html);
	});
var insymaUtil = {
    getPageSize: function () {
        var xScroll, yScroll;
        if (window.innerHeight && window.scrollMaxY) {
            xScroll = window.innerWidth + window.scrollMaxX;
            yScroll = window.innerHeight + window.scrollMaxY
        } else if (document.body.scrollHeight > document.body.offsetHeight) {
            xScroll = document.body.scrollWidth;
            yScroll = document.body.scrollHeight
        } else {
            xScroll = document.body.offsetWidth;
            yScroll = document.body.offsetHeight
        }
        var windowWidth, windowHeight;
        if (self.innerHeight) {
            if (document.documentElement.clientWidth) {
                windowWidth = document.documentElement.clientWidth
            } else {
                windowWidth = self.innerWidth
            }
            windowHeight = self.innerHeight
        } else if (document.documentElement && document.documentElement.clientHeight) {
            windowWidth = document.documentElement.clientWidth;
            windowHeight = document.documentElement.clientHeight
        } else if (document.body) {
            windowWidth = document.body.clientWidth;
            windowHeight = document.body.clientHeight
        }
        if (yScroll < windowHeight) {
            pageHeight = windowHeight
        } else {
            pageHeight = yScroll
        }
        if (xScroll < windowWidth) {
            pageWidth = xScroll
        } else {
            pageWidth = windowWidth
        }
        arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight);
        return arrayPageSize
    }
   
};

var closespan = '<a id="close" href="JavaScript:_closeInsymaOverlay()">Fenster schliessen</a>';

function _getVid(aId)
{
	$('.insymaOverlayContent').remove().appendTo('body');
	$('#insymaOverlay').show().css('width', '100%').css('height', insymaUtil.getPageSize()[1]+"px");
	$('.notoverlay').hide();
	$('#insymaVideo_' + aId).show();
	$('#viddiv_' + aId).show();
	//$('#insymaOverlayContent').html(closespan + $("#overlayContent_" + aId).html()).css({'background-color':'#FFF','width':'auto','position':'absolute', 'top': ($("#movie_" + aId).offset().top) + "px",'left': '50%', 'z-index': '91'});
	$('.insymaOverlayContent').css({'border':'1px solid #fff','width':'auto','position':'absolute', 'top': ($("#imagelink_" + aId).offset().top)-200 + "px",'left': '50%', 'z-index': '191'});
	$('.insymaOverlayContent').css({'margin-left': '-350px'}).show("slow");
	$('#insymaOverlay').click(function() {
 		 	_closeInsymaOverlay()
		});
}
function _closeInsymaOverlay()
{
	$('.insymaOverlayContent').attr("style", "").hide();
	$('#insymaOverlay').hide();
	$('.notoverlay').show();
}
