(function($){
var _2=[];
var _3=false;
var _4=[];
var _5={screenLockerBackground:"#000",screenLockerOpacity:"0.5"};
$.setupJMPopups=function(_6){
_5=jQuery.extend(_5,_6);
return this;
};
$.openPopupLayer=function(_7){
if(typeof (_7.name)!="undefined"&&!checkIfItExists(_7.name)){
_7=jQuery.extend({width:"auto",height:"auto",parameters:{},target:"",success:function(){
},error:function(){
},beforeClose:function(){
},afterClose:function(){
},reloadSuccess:null,cache:false},_7);
loadPopupLayerContent(_7,true);
return this;
}
};
$.closePopupLayer=function(_8){
if(_8){
for(var i=0;i<_2.length;i++){
if(_2[i].name==_8){
var _a=_2[i];
_2.splice(i,1);
_a.beforeClose();
$("#popupLayer_"+_8).fadeOut(function(){
$("#popupLayer_"+_8).remove();
_4.pop();
if(_4.length>0){
$(_4[_4.length-1]).focus();
}
_a.afterClose();
hideScreenLocker(_8);
});
break;
}
}
}else{
if(_2.length>0){
$.closePopupLayer(_2[_2.length-1].name);
}
}
return this;
};
$.reloadPopupLayer=function(_b,_c){
if(_b){
for(var i=0;i<_2.length;i++){
if(_2[i].name==_b){
if(_c){
_2[i].reloadSuccess=_c;
}
loadPopupLayerContent(_2[i],false);
break;
}
}
}else{
if(_2.length>0){
$.reloadPopupLayer(_2[_2.length-1].name);
}
}
return this;
};
function setScreenLockerSize(){
if(_3){
$("#popupLayerScreenLocker").height($(document).height()+"px");
$("#popupLayerScreenLocker").width($(document.body).outerWidth(true)+"px");
}
}
function checkIfItExists(_e){
if(_e){
for(var i=0;i<_2.length;i++){
if(_2[i].name==_e){
return true;
}
}
}
return false;
}
function showScreenLocker(){
if($("#popupLayerScreenLocker").length){
if(_2.length==1){
_3=true;
setScreenLockerSize();
$("#popupLayerScreenLocker").fadeIn();
}
if($.browser.msie&&$.browser.version<7){
$("select:not(.hidden-by-jmp)").addClass("hidden-by-jmp hidden-by-"+_2[_2.length-1].name).css("visibility","hidden");
}
$("#popupLayerScreenLocker").css("z-index",parseInt(_2.length==1?999:$("#popupLayer_"+_2[_2.length-2].name).css("z-index"))+1);
}else{
$("body").append("<div id='popupLayerScreenLocker'><!-- --></div>");
$("#popupLayerScreenLocker").css({position:"absolute",background:_5.screenLockerBackground,left:"0",top:"0",opacity:_5.screenLockerOpacity,display:"none"});
showScreenLocker();
$("#popupLayerScreenLocker").click(function(){
//$.closePopupLayer();
});

}
}
function hideScreenLocker(_10){
if(_2.length==0){
screenlocker=false;
$("#popupLayerScreenLocker").fadeOut();
}else{
$("#popupLayerScreenLocker").css("z-index",parseInt($("#popupLayer_"+_2[_2.length-1].name).css("z-index"))-1);
}
if($.browser.msie&&$.browser.version<7){
$("select.hidden-by-"+_10).removeClass("hidden-by-jmp hidden-by-"+_10).css("visibility","visible");
}
}
function setPopupLayersPosition(_11,_12){
if(_11){
if(_11.width()<$(window).width()){
var _13=(document.documentElement.offsetWidth-_11.width())/2;
}else{
var _13=document.documentElement.scrollLeft+5;
}
if(_11.height()<$(window).height()){
var _14=document.documentElement.scrollTop+($(window).height()-_11.height())/2;
}else{
var _14=document.documentElement.scrollTop+5;
}
var _15={left:_13+"px",top:_14+"px"};
if(!_12){
_11.css(_15);
}else{
_11.animate(_15,"slow");
}
setScreenLockerSize();
}else{
for(var i=0;i<_2.length;i++){
setPopupLayersPosition($("#popupLayer_"+_2[i].name),true);
}
}
}
function showPopupLayerContent(_17,_18,_19){
var _1a="popupLayer_"+_17.name;
if(_18){
showScreenLocker();
$("body").append("<div id='"+_1a+"'><!-- --></div>");
var _1b=parseInt(_2.length==1?1000:$("#popupLayer_"+_2[_2.length-2].name).css("z-index"))+2;
}else{
var _1b=$("#"+_1a).css("z-index");
}
var _1c=$("#"+_1a);
_1c.css({visibility:"hidden",width:_17.width=="auto"?"":_17.width+"px",height:_17.height=="auto"?"":_17.height+"px",position:"absolute","z-index":_1b});
var _1d="<a href='#' class='jmp-link-at-top' style='position:absolute; left:-9999px; top:-1px;'>&nbsp;</a><input class='jmp-link-at-top' style='position:absolute; left:-9999px; top:-1px;' />";
var _1e="<a href='#' class='jmp-link-at-bottom' style='position:absolute; left:-9999px; bottom:-1px;'>&nbsp;</a><input class='jmp-link-at-bottom' style='position:absolute; left:-9999px; top:-1px;' />";
_1c.html(_1d+_19+_1e);
setPopupLayersPosition(_1c);
_1c.css("display","none");
_1c.css("visibility","visible");
if(_18){
_1c.fadeIn();
}else{
_1c.show();
}
$("#"+_1a+" .jmp-link-at-top, "+"#"+_1a+" .jmp-link-at-bottom").focus(function(){
$(_4[_4.length-1]).focus();
});
var _1f=$("#"+_1a+" a:visible:not(.jmp-link-at-top, .jmp-link-at-bottom), "+"#"+_1a+" *:input:visible:not(.jmp-link-at-top, .jmp-link-at-bottom)");
if(_1f.length==0){
var _20="<a href='#' class='jmp-link-inside-popup' style='position:absolute; left:-9999px;'>&nbsp;</a>";
_1c.find(".jmp-link-at-top").after(_20);
_4.push($(_1c).find(".jmp-link-inside-popup")[0]);
}else{
_1f.each(function(){
if(!$(this).hasClass("jmp-link-at-top")&&!$(this).hasClass("jmp-link-at-bottom")){
_4.push(this);
return false;
}
});
}
$(_4[_4.length-1]).focus();
_17.success();
if(_17.reloadSuccess){
_17.reloadSuccess();
_17.reloadSuccess=null;
}
}
function loadPopupLayerContent(_21,_22){
if(_22){
_2.push(_21);
}
if(_21.target!=""){
showPopupLayerContent(_21,_22,$("#"+_21.target).html());
}else{
$.ajax({url:_21.url,data:_21.parameters,cache:_21.cache,dataType:"html",method:"GET",success:function(_23){
showPopupLayerContent(_21,_22,_23);
},error:_21.error});
}
}
$(window).resize(function(){
setScreenLockerSize();
setPopupLayersPosition();
});
$(document).keydown(function(e){
if(e.keyCode==27){
$.closePopupLayer();
}
});
})(jQuery);


