var oBasicConfig=function(){this.httpBase="";this.bDebug=false;this.icons={}};oBasicConfig.prototype.getIcoPath=function(c){if(this.icons.hasOwnProperty(c))return this.httpBase+this.stylePath+this.imagesPath+this.icons[c]};oBasicConfig.prototype.addIcoToList=function(c,a){this.icons[c]=a};var oBasic=function(){this.iconCache={};this.bDocReady=false;this.cacheQueue=[]};
oBasic.prototype._cacheIco=function(c){if(c&&!this.iconCache.hasOwnProperty(c)){var a=new Image;a.src=BasicConfig.icons.hasOwnProperty(c)?BasicConfig.getIcoPath(c):c;this.iconCache[c]=a}};oBasic.prototype.loadQueue=function(){if(this.cacheQueue.length>0)for(var c=0;c<this.cacheQueue.length;c++)this._cacheIco(this.cacheQueue[c])};oBasic.prototype.cahceIco=function(c){this.bDocReady?this._cacheIco(c):this.cacheQueue.push(c)};oBasic.prototype.getCachedIco=function(c){if(c&&this.iconCache.hasOwnProperty(c))return this.iconCache[c]};
var BasicConfig=new oBasicConfig,Basic=new oBasic;$(document).ready(function(){Basic.bDocReady=true;Basic.loadQueue()});BasicConfig.stylePath="style/";BasicConfig.imagesPath="images/";BasicConfig.icons={loadingIcon:"box.ico.loading.gif",slideshowCtrl:"slideshow.icons.gif"};BasicConfig.slideshowImageFadeOut=false;var Debuger={outputElement:null,show:false,ready:false,instance:0,hideTraces:[]};Debuger.showConsole=function(){$("#error-container").show();$("#error-container").draggable({cancel:"#error-output"}).resizable();Debuger.show=true};
Debuger.createWin=function(){$("body").append('<div id="error-container"><div id="error-caption">Debug console<a title="Close" class="close"></a><a title="Clean" class="clean"></a></div><div id="error-output"></div></div>');Debuger.outputElement=$("#error-output");$("#error-caption a.close").click(function(){$("#error-container").remove()});$("#error-caption a.clean").click(function(){$("#error-output").empty()});Debuger.ready=true;if(Debuger.hideTraces.length>0){Debuger.showConsole();for(var c=0;c<
Debuger.hideTraces.length;c++)Debuger.trace(Debuger.hideTraces[c][0],Debuger.hideTraces[c][1])}};Debuger.init=function(){$(document).ready(function(){BasicConfig.bDebug&&Debuger.createWin()})};Debuger.trace=function(c,a){if(BasicConfig.bDebug){if(Debuger.ready)Debuger.show||Debuger.showConsole();else{Debuger.hideTraces.push([c,a]);return Debuger}if(a){a=$(a).get(0);c+="<br />tag: "+a.tagName+" class:"+a.className+" id:"+a.id+" name:"+a.name+""}Debuger.writeLn(c);return Debuger}};
Debuger.writeLn=function(c){$(Debuger.outputElement).prepend("<p>"+c+"</p>")};Debuger.traceObj=function(c){var a;for(a in c)Debuger.writeLn(a+" = "+c[a]);return Debuger};Debuger.nextInst=function(){$(Debuger.outputElement).prepend("<hr />");$(Debuger.outputElement).prepend("<p>"+Debuger.instance+"</p>");Debuger.instance++};Debuger.doBreak=function(){if(BasicConfig.bDebug){Debuger.trace("Break!");Event.preventDefault()}};Debuger.init();Basic.timer=function(c,a){var b={id:null,callback:a};b.interval=c||100;if(!b.callback)return null;b.stop=function(){clearInterval(b.id)};b.internalCallback=function(){Debuger.trace("timer callback");b.callback(b)};b.reset=function(d){d=d||100;b.id&&clearInterval(b.id);b.id=setInterval(b.internalCallback,d)};b.start=function(){b.id=setInterval(b.internalCallback,b.interval)};b.start();return b};var PageHelper={};PageHelper.checkLimits=function(c,a){var b={w:c.w,h:c.h};if(a.length>0)if(a[0]>0&&a[0]<c[0])b.w=a[0];if(a.length>1)if(a[1]>0&&a[1]<c[1])b.h=a[1];return b};
PageHelper.getPageSize=function(){var c,a,b,d;if(window.innerHeight&&window.scrollMaxY){c=window.innerWidth+window.scrollMaxX;a=window.innerHeight+window.scrollMaxY}else if(document.body.scrollHeight>document.body.offsetHeight){c=document.body.scrollWidth;a=document.body.scrollHeight}else{c=document.body.offsetWidth;a=document.body.offsetHeight}if(self.innerHeight){b=document.documentElement.clientWidth?document.documentElement.clientWidth:self.innerWidth;d=self.innerHeight}else if(document.documentElement&&
document.documentElement.clientHeight){b=document.documentElement.clientWidth;d=document.documentElement.clientHeight}else if(document.body){b=document.body.clientWidth;d=document.body.clientHeight}return{pw:c<b?c:b,ph:a<d?d:a,ww:b,wh:d}};
PageHelper.getPageScroll=function(){var c,a;if(self.pageYOffset){a=self.pageYOffset;c=self.pageXOffset}else if(document.documentElement&&document.documentElement.scrollTop){a=document.documentElement.scrollTop;c=document.documentElement.scrollLeft}else if(document.body){a=document.body.scrollTop;c=document.body.scrollLeft}return{xs:c,ys:a}};
PageHelper.getPageSize2=function(){var c=PageHelper.getWindowSize(),a,b=c[0],d=c[1];if(window.innerHeight&&window.scrollMaxY){c=window.innerWidth+window.scrollMaxX;a=window.innerHeight+window.scrollMaxY}else if(document.body.scrollHeight>document.body.offsetHeight){c=document.body.scrollWidth;a=document.body.scrollHeight}else{c=document.body.offsetWidth;a=document.body.offsetHeight}return[c<b?c:b,a<d?d:a,b,d]};
PageHelper.getWindowSize=function(){var c=0,a=0;if(typeof window.innerWidth=="number"){c=window.innerWidth;a=window.innerHeight}else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){c=document.documentElement.clientWidth;a=document.documentElement.clientHeight}else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){c=document.body.clientWidth;a=document.body.clientHeight}return[c,a]};
PageHelper.getScrollXY=function(){var c=0,a=0;if(typeof window.pageYOffset=="number"){a=window.pageYOffset;c=window.pageXOffset}else if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){a=document.body.scrollTop;c=document.body.scrollLeft}else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){a=document.documentElement.scrollTop;c=document.documentElement.scrollLeft}return[c,a]};
PageHelper.passRectToRect=function(c,a){var b={w:c.w,h:c.h},d=false;if(a.w<c.w||a.h<c.h){d=true;var e=c.w/c.h;if(e<a.w/a.h){c=c.h-a.h;b.w-=Math.round(c*e);b.h-=c}else{c=c.w-a.w;b.w-=c;b.h-=Math.round(c*(1/e))}}return{rect:b,state:d}};Basic.cacheImagesManager=function(c){var a={images:[],position:0};a.setCacheSize=function(b){a.images.length=b};a.push=function(b,d){if(d!=undefined){if(d>=a.images.length)a.images.length=d;a.images[d]=b}else a.images.push(b)};a.isLast=function(){if(a.position>=a.images.length-1)return true;return false};a.isFirst=function(){if(a.position<=0)return true;return false};a.hasMany=function(){if(a.images.length>1)return a.images.length;return false};a.getNext=function(){if(a.position<a.images.length-1){a.position++;
return a.images[a.position]}return null};a.getPrev=function(){if(a.position>0){a.position--;return a.images[a.position]}return null};a.rewind=function(){a.position=0;return a.images[a.position]};a.cacheClean=function(){if(a.images.length>0)for(var b=0;b<a.images.length;b++){a.images[b].src="";a.images[b]=null}a.images=[];a.rewind()};a.getLength=function(){return a.images.length};a.getImageOnPos=function(b){if(b>=0&&b<a.getLength()){a.position=b;return a.images[b]}};c&&a.setCacheSize(c);return a};Basic.imagesPreloader=function(c,a,b){var d=Basic.cacheImagesManager(b);d.createCallback=c;d.onLoadCallback=a;d.defOnLoadCallback=function(){if(this.complete||this.readyState=="complete"){this.onload=function(){};if(this.userOnLoad)if(this.userOnLoad(this))d.position=this.pos;this.onload=function(){};return true}return false};d.addImage=function(e,h,g){var f=new Image;d.push(f,g);f.userOnLoad=d.onLoadCallback;f.pos=g!=undefined?g:d.getLength();if(d.createCallback!=null)f=d.createCallback(f,h);f.onload=
d.defOnLoadCallback;f.src=e;return d.getLength()};return d};BasicConfig.boxWin={overlayOpacity:0.7,overlayBgColor:"#000",containerBorderColor:"#FFFFFF",containerBorderSize:10,containerBorderSizeUnits:"px",containerResizeTpPx:2,containerResizeSpeed:800,fadeTime:1200,sizeLimit:{w:0,h:0},keepAspect:true,topPaddingMultiple:10,resizeHandle:null};
Basic.boxWin=function(c){var a={};a.settings=$.extend({},BasicConfig.boxWin,c||{});a.bWasMinimized=false;a.borderIncome=a.settings.containerBorderSize*2;a.handleClose=null;a.aspectRatio=1;a.floatHeight=false;a.bAutoSize=false;a.hideConflictObjects=function(){$("embed, object, select").css({visibility:"hidden"})};a.showConflictObjects=function(){$("embed, object, select").css({visibility:"visible"})};a.createOverlay=function(){if(!$("#box-win-overlay").length){Debuger.trace("Add overlay");$("body").append('<div id="box-win-overlay"></div>')}a.hideConflictObjects();
$("#box-win-overlay").css({backgroundColor:a.settings.overlayBgColor,opacity:a.settings.overlayOpacity}).fadeIn()};a.closeBox=function(){a.handleClose!=null&&a.handleClose(true);$("#box-win").remove();$("#box-win-overlay").fadeOut(function(){$("#box-win-overlay").remove()});a.showConflictObjects()};a.handleClicks=function(){$("#box-win-overlay, #box-win").click(a.closeBox);$("#box-container").click(function(){return false})};a.getBoxSize=function(b){if(b==null){b=$("#box-border");b={w:b.width(),h:b.height()}}return b};
a.getAvaiblePlace=function(){var b=PageHelper.getPageSize(),d=b.wh/a.settings.topPaddingMultiple;return{avaible:PageHelper.checkLimits({w:b.pw,h:b.ph-(d+a.borderIncome)},a.settings.sizeLimit),original:b,diff:d}};a.placeOverlay=function(b){$("#box-win-overlay").css({width:b.pw,height:b.ph})};a.fixPosition=function(b){$("#box-win").css({top:b.x,left:b.y}).addClass("fix-pos")};a.placeBox=function(){var b=a.getAvaiblePlace(),d=b.avaible,e=a.getBoxSize();a.placeOverlay(b.original);if(d.w<e.w||d.h<e.h||
a.bWasMinimized){e=PageHelper.passRectToRect(e,d);a.bWasMinimized=e.status;!a.floatHeight&&!a.bAutoSize?$("#box-border").css({width:e.rect.w,height:e.rect.h}).find("#box-container").css({width:e.rect.w-a.borderIncome,height:e.rect.h-a.borderIncome}):$("#box-border").css({width:e.rect.w}).find("#box-container").css({width:e.rect.w-a.borderIncome})}if(a.bAutoSize||a.floatHeight)a.setMaxHeight(d.h);a.settings.resizeHandle!=null&&a.settings.resizeHandle(d,this);d=PageHelper.getPageScroll();$("#box-win").css({top:d.ys+
b.diff,left:d.xs})};a.resize=function(b){var d=a.getAvaiblePlace();b=PageHelper.passRectToRect({w:b.w+a.borderIncome,h:b.h+a.borderIncome},d.avaible);$("#box-border").css({width:b.rect.w,height:b.rect.h}).find("#box-container").css({width:b.rect.w-a.borderIncome,height:b.rect.h-a.borderIncome,paddingTop:a.settings.containerBorderSize,paddingLeft:a.settings.containerBorderSize})};a.resizeSmoot=function(b,d){var e=a.getAvaiblePlace();b=PageHelper.passRectToRect({w:b.w+a.borderIncome,h:b.h+a.borderIncome},
e.avaible);if(d)d=a.settings.containerResizeSpeed;else{d=$("#box-border");d=Math.sqrt(Math.pow(b.rect.w-d.width(),2)+Math.pow(b.rect.h-d.height(),2));d=a.settings.containerResizeTpPx*Math.abs(d)}$("#box-border").animate({width:b.rect.w+"px",height:b.rect.h+"px"},d,"swing").find("#box-container").animate({width:b.rect.w-a.borderIncome+"px",height:b.rect.h-a.borderIncome+"px"},d,"swing").css({paddingTop:a.settings.containerBorderSize+"px",paddingLeft:a.settings.containerBorderSize+"px"})};a.createBox=
function(){a.createOverlay();$("body").append('<div id="box-win"><div id="box-border"><div id="box-container-outline"><div id="box-container"></div></div></div></div>');$("#box-border").show().css({backgroundColor:a.settings.containerBorderColor});a.handleClicks();a.placeBox();$(window).resize(a.placeBox)};a.setContent=function(b){return $("#box-container").html(b)};a.getContainer=function(){return $("#box-container")};a.autoSize=function(){a.bAutoSize=true;$("#box-border").css({width:"auto",height:"auto"}).find("#box-container").css({width:"auto",
height:"auto"})};a.setMaxHeight=function(b){$("#box-container").css({maxHeight:b})};a.makeHeightDynamic=function(){a.floatHeight=true;var b=a.getAvaiblePlace();a.setMaxHeight(b.avaible.h);return b.avaible.h};a.appendContent=function(b){return $("#box-container").append(b)};return a};BasicConfig.boxLoadingWin={w:250,h:250};Basic.cahceIco("loadingIcon");
Basic.boxLoadingWin=function(c){var a=Basic.boxWin(c),b="";a.loadingSettings=$.extend({},BasicConfig.boxLoadingWin,c||{});c=Basic.getCachedIco("loadingIcon");Debuger.trace(c);if(c)b='<div id="iz-loading"><a id="iz-loading-link" style="width: '+c.width+"px; height: "+c.height+'px;"><img src="'+c.src+'" width="'+c.width+'" height="'+c.height+'" /></a></div>';a.showLoading=function(){$("#iz-loading").show()};a.hideLoading=function(){$("#iz-loading").hide()};a.createBox();a.setContent(b).click(a.close);
a.resize(a.loadingSettings);a.showLoading();return a};

