/*
 * imagePopup - $ plugin for SiteWare image popups
 *
 * Copyright 2010-2011 COMMUNITOR Internetservice GmbH
 * Snippets from http://www.softcomplex.com/docs/get_window_size_and_scrollbar_position.html
 *
 */
(function(a){a.imagePopup=function(d){a.imagePopup.init=function(){var h=a(this).metadata(),i,f=800,g=600;if(typeof h.src!="undefined"){if(a.isArray(h.src)){i=h.src[0];f=h.src[1];g=h.src[2]}else{i=h.src}a(this).attr("imagePopupLink",i);a(this).attr("imagePopupWidth",f);a(this).attr("imagePopupHeight",g);a(this).click(a.imagePopup.open)}};var c=function(){return b(window.innerWidth?window.innerWidth:0,document.documentElement?document.documentElement.clientWidth:0,document.body?document.body.clientWidth:0)};var e=function(){return b(window.innerHeight?window.innerHeight:0,document.documentElement?document.documentElement.clientHeight:0,document.body?document.body.clientHeight:0)};var b=function(i,f,g){var h=i?i:0;if(f&&(!h||(h>f))){h=f}return g&&(!h||(h>g))?g:h};a.imagePopup.open=function(){var i={left:0,top:0},h=a(this).attr("imagePopupLink"),f=parseInt(a(this).attr("imagePopupWidth")),g=parseInt(a(this).attr("imagePopupHeight"));if(typeof window.outerWidth!=="undefined"){f+=window.outerWidth-c()}if(typeof window.outerHeight!=="undefined"){g+=window.outerHeight-e()}if(screen.availWidth){if(screen.availWidth<f){f=screen.availWidth}i.left=parseInt((screen.availWidth-f)/2)}if(screen.availHeight){if(screen.availHeight<g){g=screen.availHeight}i.top=parseInt((screen.availHeight-g)/2)}window.open(h,"imgwnd","width="+f+",height="+g+",left="+i.left+",top="+i.top+",resizable,scrollbars=yes");return false};a(document).ready(function(){a(d).each(a.imagePopup.init)})}})(jQuery);
