var popupStatus=0;var popupWindowId="#popup-window-element";var popupWindow=".popup-window-main";var popupBackground=".popup-background-settings";var popupWindowOpen=".popup-window-open";var popupContent=".popup-content";var popupWindowClose=".popup-window-close";var loadingImg="/images/hce-loading.gif";var backgOpacity=0.9;var classSeparator="___";var classPrefix="win-class";$(document).ready(function(){$("body").append('<div id="'+popupWindowId.substring(1)+'" class="'+popupWindow.substring(1)+'"><div class="top-2"><div class="top-1"><div class="'+popupWindowClose.substring(1)+'"><a href="#"></a></div></div></div><div class="body"><div class="legend"></div><div class="'+popupContent.substring(1)+' center"></div></div><div class="bottom-2"><div class="bottom-1">&nbsp;</div></div></div><div class="'+popupBackground.substring(1)+'"></div>');$(popupWindowOpen).live("click",function(){$(popupBackground).showBackground();$(this).loadPopup();return false});$(popupWindowClose).click(function(){$(popupBackground).disablePopup();return false});$(popupBackground).click(function(){$(popupBackground).disablePopup();return false});$(document).keypress(function(a){if((a.keyCode==27)&&(popupStatus==1)){$(popupBackground).disablePopup();return false}});$(window).resize(function(){$(popupWindowId).centerPopup()})});jQuery.fn.loadPopup=function(){if(popupStatus==0){popupStatus=1;var a=$(this).attr("id");var b=addCallBack($(this).attr("href"))+"&scr_w="+screen.width+"&scr_h="+screen.height;var c=$(this).getPopupWindowClass();$(popupWindowId).attr("class",popupWindow.substring(1)+" "+c);$(popupWindowId).centerPopup();$(popupWindowId+" .legend").html($(this).attr("title"));$(popupContent).html("");$(popupWindowId).fadeIn("normal",function(){$(popupContent).html('<img src="'+loadingImg+'" />').fadeIn("normal");$.getJSON(b,function(d,e){$(popupContent).fadeOut("normal",function(){$(popupContent).html(d.data).fadeIn("normal");$(popupContent).bindSubmitProccess();$(popupWindowId).centerPopup();return false})})});return false}};jQuery.fn.getPopupWindowClass=function(){var f=$(this).attr("class");var d=f.split(/ /);var e=new RegExp("^"+classPrefix,"i");for(var c=0;d[c];c++){if(d[c].match(e)){var b=d[c];var a=new RegExp(classSeparator,"gi");b=b.replace(e,"");b=b.replace(a," ");return b}}return""};jQuery.fn.bindSubmitProccess=function(){$(this).find("form").each(function(){$(this).submit(function(){var b=$(this).serialize();var a=addCallBack($(this).attr("action"));$(popupContent).html('<img src="'+loadingImg+'" />').fadeIn("normal");$.getJSON(a,b,function(c){$(popupContent).fadeOut("normal",function(){if(c.action=="refresh"){var d=addParameter(window.location.search,"popup","reload");window.location.replace(d);return false}$(popupContent).html(c.data).fadeIn("normal");$(popupContent).bindSubmitProccess();$(popupWindowId).centerPopup();if(c.timer>0){$(popupContent).delay(c.timer,function(){$(popupContent).disablePopup()})}})});return false})})};jQuery.fn.centerPopup=function(){var i=$(window).width();var d=$(window).height();var g=$(this).width();var e=$(this).height();var c=$(this).position();var a=$(this).offset();var f=-(a.top-c.top);var h=-(a.left-c.left);var b=document.documentElement.scrollTop;if(!b){b=document.body.scrollTop}$(this).css({top:0+f+d/2-e/2+b,left:0+h+i/2-g/2+document.documentElement.scrollLeft})};jQuery.fn.showBackground=function(){$(this).css({opacity:backgOpacity}).fadeIn("slow");if($.browser.msie&&$.browser.version<7){var d=$(this).position();var c=$(this).offset();var a=-(c.top-d.top);var b=-(c.left-d.left);$(this).css({top:0+a,left:0+b,height:$(document).height(),width:$(document).width()-20,position:"absolute"})}};jQuery.fn.disablePopup=function(){if(popupStatus==1){$(popupWindowId).hide();$(popupBackground).fadeOut("normal");$(popupContent).html("");popupStatus=0}};jQuery.fn.delay=function(b,a){return this.each(function(){setTimeout(a,b)})};function addCallBack(a){if(/\?/.test(a)){a=a+"&"}else{a=a+"?"}return a+"callback=?"}function addParameter(b,c,e){c=escape(c);e=escape(e);var a=c+"="+e;var d=new RegExp("(&|\\?)"+c+"=[^&]*");b=b.replace(d,"$1"+a);if(!RegExp.$1){b+=(b.length>0?"&":"?")+a}return b};
