/** JSpacked on 26.01.12 10:59 */ var spt={tempTitle:null,show:function(item){var item=$(item);var tip=$('tooltip_box');var item_offset=item.cumulativeOffset();var viewport_top=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop;var viewport_bottom=viewport_top+document.viewport.getHeight();if(item.hasClassName('middle')){var x=(item_offset['left']+item.getWidth()/2)-(tip.getWidth()/2);}else{var x=item_offset['left']+item.getWidth()+2;}
if(item.hasClassName('above')){var y=item_offset['top']-tip.getHeight()-2;tip.removeClassName('below');tip.addClassName('above');}else{var y=item_offset['top']+item.getHeight()+2;tip.removeClassName('above');tip.addClassName('below');}
this.tempTitle=item.title;item.title='';if(y+tip.getHeight()>viewport_bottom-10){y=item_offset['top']-tip.getHeight()-2;tip.removeClassName('below');tip.addClassName('above');}
if(y<viewport_top+10){y=item_offset['top']+item.getHeight()+2;tip.removeClassName('above');tip.addClassName('below');}
tip.style.left=x+"px";tip.style.top=y+"px";tip.show();},hide:function(item){var item=$(item);var tip=$('tooltip_box');tip.hide();item.title=this.tempTitle;tip.removeClassName('above');tip.removeClassName('below');},showPopup:function(element_id,width){var item=$(element_id);var modal=$('popup_box');$('popup_content').innerHTML=item.innerHTML;this.displayPopup(0,0,0,true,width);},showPopupRemote:function(remote_url,width){var modal=$('popup_box');$('popup_content').innerHTML='';this.displayPopup(0,0,0,true,width);new Ajax.Updater('popup_content',remote_url,{asynchronous:true,evalScripts:true,onLoading:function(){showPopupLoader('modal_box_inner')},onComplete:function(){hidePopupLoader('modal_box_inner')}});},displayPopup:function(attach_to,offset_x,offset_y,is_modal,box_width){var modal=$('popup_box');var modal_back=$('popup_back');var iframe=$('modal_iframe');var width=document.body.offsetWidth||window.innerWidth||document.documentElement.clientWidth||0;var height=document.body.offsetHeight||window.innerHeight||document.documentElement.clientHeight||0;var scrollOffset=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop;if(!box_width){box_width=400;}
modal.setStyle({width:box_width+'px'});modal_back.style.height=height+'px';if(attach_to!=0){modal.style.left=(findPosX($(attach_to))+offset_x)+"px";modal.style.top=(findPosY($(attach_to))+offset_y)+"px";}else{modal.style.left=(width/2-modal.getWidth()/2)+'px';modal.style.top=(scrollOffset+screen.availHeight/7)+'px';}
iframe.style.display='block';iframe.style.width=width+'px';iframe.style.height=height+'px';iframe.style.left=0;iframe.style.top=0;new Effect.Appear(modal,{duration:0.5});if(is_modal){new Effect.Appear(modal_back,{duration:0.7,from:0.0,to:0.5});}},hideModalPopup:function(){var modal=$('popup_box');var modal_back=$('popup_back');new Effect.Fade(modal,{duration:0.7});new Effect.Fade(modal_back,{duration:0.5,from:0.5,to:0.0});$('modal_iframe').style.display='none';},simpleHandler:function(item){$('tooltip_box').innerHTML="<div id='"+item.id+"_tooltip' class='simple_tooltip'>"+item.title+"</div>";this.show(item);},styledHandler:function(item){$('tooltip_box').innerHTML=$(item.title.substr(1)).innerHTML;this.show(item);},remoteHandler:function(item){$('tooltip_box').innerHTML='';this.show(item);new Ajax.Updater($('tooltip_box'),item.href,{asynchronous:true,evalScripts:true,onLoading:function(){showPopupLoader('tooltip_box')},onComplete:function(){hidePopupLoader('tooltip_box')}});},popupHandler:function(item){this.showPopup(item.getAttribute('href').substr(1),item.getAttribute('rel'));},popupRemoteHandler:function(item){this.showPopupRemote(item.href,item.getAttribute('rel'));},initTooltips:function(){var items=$$('.spt');var tooltip;for(i=0;i<items.length;i++){if(items[i].getAttribute('rel')){items[i].observe('mouseover',function(){spt.remoteHandler(this);});}else if(items[i].getAttribute('title')[0]=='#'){if(tooltip=$(items[i].getAttribute('title').substr(1))){items[i].observe('mouseover',function(){spt.styledHandler(this);});tooltip.hide();}}else{items[i].observe('mouseover',function(){spt.simpleHandler(this);});}
items[i].observe('mouseout',function(){spt.hide(this);});items[i].removeClassName('spt');}},initPopups:function(){var items=$$('.spp');var popup;for(i=0;i<items.length;i++){if(items[i].getAttribute('href')[0]=='#'){if(popup=$(items[i].getAttribute('href').substr(1))){items[i].observe('click',function(event){spt.popupHandler(this);event.stop();});popup.hide();}}else{items[i].observe('click',function(event){spt.popupRemoteHandler(this);event.stop();});}
items[i].removeClassName('spp');}},init:function(){this.initTooltips();this.initPopups();}}
document.observe("dom:loaded",function(){spt.init();});
