var popup=null;
var trackDecline=false;
var iframeLoaded=false;
jQuery.fn.jPop=function(B){var A={overlayID:"#jPopOverlay",popupCont:"jPopCont",popupDiv:".jPopContent",popupLoader:"jPopLoader",popupIframe:"jPopIframe",closeButton:"jPopupClose",height:392,width:662,speed:500,animatedResize:false,hideBMB:false};
jQuery.extend(A,B);
jQuery(this).each(function(){jQuery(this).click(function(C){C.preventDefault();
popup=new Popup(A,{type:jQuery(this).attr("rel"),url:jQuery(this).attr("href")});
popup.Create()
})
});
jQuery("a."+A.closeButton).unbind("click").live("click",function(){popup.Close();
popup=null
})
};
function Popup(A,B){jQuery.extend(A,B);
var C={$this:null,content:null,id:A.id||null,type:A.type||null,url:A.url||null,UseSize:function(D){return(D=="h")?(jQuery.browser.msie)?jQuery("body").height():jQuery("html").height():jQuery("body").width()
},CreateId:function(){return"popup-"+Math.ceil(Math.random()*100000)
},Create:function(){iframeLoaded=true;
var D=(C.UseSize("h")<jQuery(window).height())?jQuery(window).height():C.UseSize("h");
this.id=this.CreateId();
jQuery("<div></div>").attr({id:A.overlayID.replace("#",""),className:A.popupLoader}).height(D).width(C.UseSize("w")).prependTo("body");
this.$this=jQuery('<div><a class="'+A.closeButton+'" href="javascript:;">Close</a><table><tr class="jPopupTop"><td class="jPopupTopLeft">&nbsp;</td><td class="jPopupTopMiddle">&nbsp;</td><td class="jPopupTopRight">&nbsp;</td></tr><tr class="jPopupMiddle"><td class="jPopupMiddleLeft"><img src="/bravia/image/layout/content/jpop/corner-left-middle.png"></td><td class="jPopupMiddleMiddle"><div class="jPopContent"></div></td><td class="jPopupMiddleRight"><img src="/bravia/image/layout/content/jpop/corner-right-middle.png"></td></tr><tr class="jPopupBottom"><td class="jPopupBottomLeft">&nbsp;</td><td class="jPopupBottomMiddle">&nbsp;</td><td class="jPopupBottomRight">&nbsp;</td></tr></table></div>').attr({className:A.popupCont,id:C.id}).insertAfter(A.overlayID).css("position",function(){if(jQuery.browser.msie&&parseInt(jQuery.browser.version)<=6){jQuery('<iframe src="javascript:false;document.write(\'\');" class="'+A.popupIframe+'"></iframe>').prependTo(A.overlayID).css({opacity:0});
return"absolute"
}});
this.Loading.Show();
switch(this.type){case"iframe":this.content=this.Mode.Iframe();
break
}C.content.appendTo(C.$this.find(A.popupDiv));
document.onkeyup=C.ManageKeyboard
},Loading:{Show:function(){jQuery("."+A.popupLoader).css("background-position","50% "+(jQuery(window).height()-16)/2+"px");
jQuery(A.overlayID).addClass(A.popupLoader);
window.scrollTo(0,0)
},Hide:function(){setTimeout(function(){jQuery("."+A.popupCont).css("visibility","visible");
jQuery(A.overlayID).removeClass(A.popupLoader)
},500)
}},Resize:function(E,D){A.width=E;
A.height=D;
C.Loading.Show();
this.Animate.Start(function(){if(C.Animate.isFinish){C.$this.find("a."+A.closeButton).show();
C.Loading.Hide()
}})
},Animate:{$this:null,isFinish:false,Start:function(E){this.$this=C.$this;
var D=(parseInt(jQuery(A.popupDiv).css("padding-top"))+parseInt(jQuery(A.popupDiv).css("padding-bottom")));
var F=(parseInt(jQuery(A.popupDiv).css("padding-left"))+parseInt(jQuery(A.popupDiv).css("padding-right")));
if(A.height>jQuery(window).height()){A.height=jQuery(window).height()-100
}if(A.width>jQuery(window).width()){A.width=jQuery(window).width()-100
}if(A.animatedResize){this.$this.animate({marginTop:-((A.height+20)/2),marginLeft:-((A.width+20)/2)},A.speed);
this.$this.find(A.popupDiv).animate({height:A.height,width:A.width},A.speed,function(){C.Animate.isFinish=true;
E()
})
}else{this.$this.css({marginTop:-((A.height+20)/2),marginLeft:-((A.width+20)/2)});
this.$this.find(A.popupDiv).css({height:A.height,width:A.width});
C.Animate.isFinish=true;
E()
}this.isFinish=false
}},Mode:{parent:C,Iframe:function(){return jQuery('<iframe application="yes" trusted="yes" frameborder="0"></iframe>').attr({className:"jIframe",src:C.Format.Url()})
}},Format:{Url:function(){return(C.url.indexOf("?")>-1)?C.url+"&nocache="+C.CreateId():C.url+"?nocache="+C.CreateId()
}},Close:function(){document.onkeyup=null;
if(trackDecline){customDeclineAutoInterruptTracker();
trackDecline=false
}this.$this=C.$this;
this.$this.animate({opacity:0},A.speed/3,function(){C.$this.remove();
jQuery(A.overlayID).fadeOut("fast",function(){jQuery(this).remove()
})
});
iframeLoaded=false;
if(A.hideBMB){showBMBDivisions()
}},ManageKeyboard:function(D){D=D||window.event;
keycode=D.keyCode||D.which;
switch(keycode){case 27:popup.Close();
break
}}};
return C
}function closeJPop(){popup.Close()
};
