
jQuery.leModal={jOverlay:null,jOverlayClicker:null,jModalWin:null,_currentSettings:null,_hasSetWindowEvents:false,_isVisible:false,show:function(settings){var cc=this;cc._currentSettings=jQuery.extend({modalTopAdjustment:10,overlayOpacity:0.5,overlayBackground:'black',modalWinBackground:'white',zIndex:5000,showAnimationType:'fadeIn',showAnimationSpeed:'normal',clickBackgroundToHide:true,setContentCallBack:null,beforeShowCallBack:null,beforeHideCallBack:null},settings);if(cc.jOverlay==null){cc.jOverlay=jQuery('<div id="LeModalOverlay" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: '+cc._currentSettings.zIndex+'; background: '+cc._currentSettings.overlayBackground+';"></div>');if(cc._currentSettings.clickBackgroundToHide){cc.jOverlayClicker=jQuery('<div id="LeModalOverlayClicker" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></div>');cc.jOverlayClicker.appendTo(cc.jOverlay).click(function(){cc.hide();});}
cc.jOverlay.bgiframe().hide().css('opacity',cc._currentSettings.overlayOpacity).appendTo('body');}
if(cc.jModalWin==null){cc.jModalWin=jQuery('<div id="LeModalWin" style="position: absolute; top: 0; left: 0; width: auto; height: auto; z-index: '+cc._currentSettings.zIndex+'; background: '+cc._currentSettings.modalWinBackground+';"></div>');cc.jModalWin.hide().appendTo('body');}
cc.jModalWin.css({width:'auto',height:'auto'});if(typeof cc._currentSettings.setContentCallBack=='function'){cc._currentSettings.setContentCallBack(cc.jModalWin,cc.jOverlay);jQuery('.close',cc.jModalWin).click(function(){cc.hide();return false;});}
cc.setDimensions();if(typeof cc._currentSettings.beforeShowCallBack=='function'){cc._currentSettings.beforeShowCallBack(cc.jModalWin,cc.jOverlay);}
cc.jOverlay.show();cc._isVisible=true;if(cc._currentSettings.showAnimationType=='slideDown'){cc.jModalWin.slideDown(cc._currentSettings.showAnimationSpeed,function(){checkWindowEvents();});}
else if(cc._currentSettings.showAnimationType=='show'){cc.jModalWin.show(cc._currentSettings.showAnimationSpeed,function(){checkWindowEvents();});}
else{cc.jModalWin.fadeIn(cc._currentSettings.showAnimationSpeed,function(){checkWindowEvents();});}
function checkWindowEvents(){if(!cc._hasSetWindowEvents){cc._hasSetWindowEvents=true;jQuery(window).resize(function(){if(cc._isVisible)cc.setDimensions();});}}},hide:function(){var cc=this;cc.jModalWin.stop();if(typeof cc._currentSettings.beforeHideCallBack=='function'){cc._currentSettings.beforeHideCallBack(cc.jModalWin,cc.jOverlay);}
if(cc.jOverlay!=null){cc.jOverlay.hide();}
if(cc.jModalWin!=null){cc.jModalWin.hide();}
cc._isVisible=false;},setDimensions:function(){var cc=this;cc._setModalWinDimensions();cc._setOverlayDimensions();},_setModalWinDimensions:function(){var cc=this;var top=jQuery(window).scrollTop()+cc._currentSettings.modalTopAdjustment;if(cc.jModalWin.height()>jQuery(window).height()){top=jQuery(window).scrollTop();}
var left=parseInt((jQuery('body').width()-cc.jModalWin.width())/2);var width=cc.jModalWin.width();var height=cc.jModalWin.height();cc.jModalWin.css({top:top+'px',left:left+'px',width:width+'px',height:height+'px'});},_setOverlayDimensions:function(){var cc=this;var bodyHeight=jQuery(document).height();var checkHeight=parseInt(cc.jModalWin.css('top'))+cc.jModalWin.height();var height=bodyHeight;var modalTopAdjustment=cc._currentSettings.modalTopAdjustment;if(cc.jModalWin.height()>jQuery(window).height()){modalTopAdjustment=jQuery(window).scrollTop();}
if(checkHeight>bodyHeight){height=checkHeight+modalTopAdjustment;}
if(cc.jOverlay!=null){cc.jOverlay.height(height).width(jQuery('body').width());}}};