jQuery.noConflict();jQuery(document).ready(function(){jQuery("div#sites li").mouseover(function(){jQuery(this).addClass("selected");jQuery(this).find("div p").show();});jQuery("div#sites li").mouseout(function(){jQuery(this).removeClass("selected");if(!jQuery(this).hasClass("active")){jQuery(this).find("div p").hide();}});var nbBandeau=0;var delay=6700;jQuery("#btnBandeau").text("");var list=jQuery(".imgBandeau a").map(function(){nbBandeau++;html="<div class='widgetBtn' id='btn"+nbBandeau+"' rel='"+nbBandeau+"'>"+nbBandeau+"<div>"
jQuery("#btnBandeau").append(html);jQuery("#btn"+nbBandeau).click(function(){clearTimeout(timing);left=(jQuery(this).text()*930)*-1+930;currentLeft=left;jQuery(".widgetBtn").css("opacity","0.5");jQuery(".widgetBtn").css("background-color","transparent");jQuery("#btn"+jQuery(this).text()).css("opacity","1");jQuery("#btn"+jQuery(this).text()).css("background-color","#FF6600");num=jQuery(this).text();if(currentLeft==0){direction="right";}
jQuery("#widgetBandeau").animate({"left":left+"px"},"fast");timing=setTimeout(scroll,delay);});});var currentLeft=0;var limitLeft=(nbBandeau*930)*-1+930;var timing;var direction="right";var num=1;function scroll(){jQuery(".widgetBtn").css("opacity","0.5");jQuery(".widgetBtn").css("background-color","transparent");if(currentLeft>limitLeft&&direction=="right"){num++;currentLeft-=930;jQuery("#widgetBandeau").animate({"left":currentLeft+"px"},"slow");jQuery("#btn"+num).css("opacity","1");jQuery("#btn"+num).css("background-color","#FF6600");}
else{direction="left";currentLeft+=930;num--;jQuery("#widgetBandeau").animate({"left":currentLeft+"px"},"slow");jQuery("#btn"+num).css("opacity","1");jQuery("#btn"+num).css("background-color","#FF6600");if(currentLeft==0){direction="right";}}
timing=setTimeout(scroll,delay);}
timing=setTimeout(scroll,delay);jQuery("#btn1").css("opacity","1");jQuery("#btn1").css("background-color","#FF6600");});;var Opentip={Version:'1.3.1',REQUIRED_PROTOTYPE_VERSION:'1.6.0',REQUIRED_SCRIPTACULOUS_VERSION:'1.8.0',STICKS_OUT_TOP:1,STICKS_OUT_BOTTOM:2,STICKS_OUT_LEFT:1,STICKS_OUT_RIGHT:2,cached:{},debugging:false,load:function(){function getComparableVersion(version){var v=version.split('.');return parseInt(v[0])*100000+parseInt(v[1])*1000+parseInt(v[2]);}
if((typeof Prototype==='undefined')||(typeof Element==='undefined')||(typeof Element.Methods==='undefined')||(getComparableVersion(Prototype.Version)<getComparableVersion(Opentip.REQUIRED_PROTOTYPE_VERSION))){throw("Opentip requires the Prototype JavaScript framework >= "+Opentip.REQUIRED_PROTOTYPE_VERSION);}
Opentip.useCss3Transitions=Opentip.supports('transition');Opentip.useScriptaculousTransitions=!Opentip.useCss3Transitions;if((typeof Scriptaculous==='undefined')||(typeof Effect==='undefined')||(getComparableVersion(Scriptaculous.Version)<getComparableVersion(Opentip.REQUIRED_SCRIPTACULOUS_VERSION))){Opentip.debug('No scriptaculous available. Disabling scriptaculous transitions.');Opentip.useScriptaculousTransitions=false;}},debug:function(){if(this.debugging&&typeof console!=='undefined'&&typeof console.debug!=='undefined')console.debug.apply(console,arguments);},IEVersion:function(){if(typeof Opentip.cached.IEVersion!=='undefined')return Opentip.cached.IEVersion;if(Prototype.Browser.IE){var version=navigator.userAgent.match('MSIE ([\\d.]+)');var IEVersion=version?(parseFloat(version[1])):false;}
else IEVersion=false;Opentip.cached.IEVersion=IEVersion;return IEVersion;},objectIsEvent:function(obj){return(typeof(obj)=='object'&&obj.type&&obj.screenX);},useIFrame:function(){return Opentip.IEVersion()?(Opentip.IEVersion()<=6):false;},lastTipId:1,lastZIndex:100,documentIsLoaded:false,postponeCreation:function(createFunction){if(Opentip.documentIsLoaded||!Opentip.IEVersion())createFunction();else{Event.observe(window,'load',createFunction);}},element:function(tagName,attributes,children){if(Object.isArray(attributes)||Object.isString(attributes)||Object.isElement(attributes)){children=attributes;attributes=null;}
var element=new Element(tagName,attributes||{});if(attributes&&attributes['className']){attributes['className'].split(' ').each(function(class_name){element.addClassName(class_name);});}
if(children){if(Object.isArray(children)){children.each(function(child){element.insert({bottom:child});});}
else{element.insert({bottom:children});}}
return element;},vendors:'Khtml Ms O Moz Webkit'.split(' '),testDiv:document.createElement('div'),supports:function(prop){if(prop in Opentip.testDiv.style)return true;prop=prop.ot_ucfirst();return Opentip.vendors.any(function(vendor){return vendor+prop in Opentip.testDiv.style;});}};String.prototype.ot_ucfirst=function(){return this.replace(/^\w/,function(val){return val.toUpperCase();});};Opentip.load();Opentip.styles={standard:{title:null,className:'standard',stem:false,delay:null,hideDelay:0.1,fixed:false,showOn:'mouseover',hideTrigger:'trigger',hideOn:null,offset:[0,0],containInViewport:true,autoOffset:true,showEffect:'appear',fallbackShowEffect:'appear',hideEffect:'fade',fallbackHideEffect:'appear',showEffectDuration:0.3,hideEffectDuration:0.2,stemSize:8,tipJoint:['left','top'],target:null,targetJoint:null,ajax:false,group:null,escapeHtml:false,style:null},slick:{className:'slick',stem:true},rounded:{className:'rounded',stem:true},glass:{className:'glass'}};Opentip.defaultStyle='standard';Event.observe(window,Opentip.IEVersion()?'load':'dom:loaded',function(){Opentip.documentIsLoaded=true;var htmlOptionNames=[];for(var i in Opentip.styles.standard){htmlOptionNames.push(i.underscore().dasherize());}
$$('[ot]').each(function(element){var options={};element=$(element);var content=element.readAttribute('ot');if(content===''||content==='true'||content==='yes'){content=element.readAttribute('title');element.title='';}
content||(content='');htmlOptionNames.each(function(optionName){var optionValue;if(optionValue=element.readAttribute('ot-'+optionName)){try{optionValue=optionValue.gsub("'",'"').evalJSON();}
catch(err){}
options[optionName.camelize()]=optionValue;}});element.addTip(content,options);});});var Tips={list:[],append:function(tip){this.list.push(tip);},remove:function(element){if(!element.element)var tip=this.list.find(function(t){return t.triggerElement===element});else var tip=this.list.find(function(t){return t===element});if(tip){tip.deactivate();tip.destroyAllElements();this.list=this.list.without(tip);}},add:function(element,evt){if(element._opentipAddedTips){var tip=this.list.find(function(t){return(t.triggerElement===element);});if(tip.options.showOn=='creation')tip.show();tip.debug('Using an existing opentip.');return;}else setTimeout(function(){element._opentipAddedTips=true;},1);Opentip.debug('Creating new opentip');var tipArguments=[];$A(arguments).each(function(arg,idx){if(idx==1&&!Opentip.objectIsEvent(arg))tipArguments.push(null);tipArguments.push(arg);});var self=this;var createTip=function(){self.append(new TipClass(tipArguments[0],tipArguments[1],tipArguments[2],tipArguments[3],tipArguments[4]));}
Opentip.postponeCreation(createTip);return;},hideGroup:function(groupName){this.list.findAll(function(t){return(t.options.group==groupName);}).invoke('doHide');},abortShowingGroup:function(groupName){this.list.findAll(function(t){return(t.options.group==groupName);}).invoke('abortShowing');}};var Tip=function(){Tips.add.apply(Tips,arguments);return;};Element.addMethods({addTip:function(element){element=$(element);Tips.add.apply(Tips,arguments);return element;},setCss3Style:function(element){element=$(element);var style={};for(var propertyName in arguments[1]){var css3PropertyName=propertyName.ot_ucfirst();var css3PropertyValue=arguments[1][propertyName];Opentip.vendors.each(function(vendor){style[vendor+css3PropertyName]=css3PropertyValue;element.setStyle(style);});}
return element;}});var TipClass=Class.create({debug:function(){var newArguments=Array.from(arguments);newArguments.unshift('ID:',this.id,'|');Opentip.debug.apply(Opentip,newArguments);},initialize:function(element,evt){this.id=Opentip.lastTipId++;element=$(element);this.triggerElement=element;this.loaded=false;this.loading=false;this.visible=false;this.waitingToShow=false;this.waitingToHide=false;this.lastPosition={left:0,top:0};this.dimensions=[100,50];var options={};this.content='';if(typeof(arguments[2])=='object'){this.content='';options=arguments[2];}
else if(typeof(arguments[3])=='object'){this.content=arguments[2];options=arguments[3];}
else if(typeof(arguments[4])=='object'){this.content=arguments[2];options=arguments[4];options.title=arguments[3];}
else{if(Object.isString(arguments[2])||Object.isFunction(arguments[2]))this.content=arguments[2];if(Object.isString(arguments[3]))options.title=arguments[3];}
if(!options.showOn&&evt)options.showOn=evt.type;if(options.ajax&&!options.ajax.url){if(this.triggerElement.tagName.toLowerCase()=='a'){if(typeof(options.ajax)!='object')options.ajax={};options.ajax.url=this.triggerElement.href;}else{options.ajax=false;}}
if(options.showOn=='click'&&this.triggerElement.tagName.toLowerCase()=='a'){if(evt){evt.stop();}this.triggerElement.observe('click',function(e){e.stop();});}
options.style||(options.style=Opentip.defaultStyle);var styleOptions=Object.extend({},Opentip.styles.standard);if(options.style!='standard')Object.extend(styleOptions,Opentip.styles[options.style]);options=Object.extend(styleOptions,options);options.target&&(options.fixed=true);if(options.stem===true)options.stem=options.tipJoint;if(options.target===true)options.target=this.triggerElement;else if(options.target)options.target=$(options.target);this.currentStemPosition=options.stem;if(options.delay===null){if(options.showOn=='mouseover')options.delay=0.2;else options.delay=0}
if(Opentip.useScriptaculousTransitions){if(options.showEffect&&!Effect[options.showEffect.ot_ucfirst()]){this.debug('Using fallback show effect "'+options.fallbackShowEffect+'" instead of "'+options.showEffect+'"');options.showEffect=options.fallbackShowEffect;}
if(options.hideEffect&&!Effect[options.hideEffect.ot_ucfirst()]){this.debug('Using fallback hide effect "'+options.fallbackHideEffect+'" instead of "'+options.hideEffect+'"');options.hideEffect=options.fallbackHideEffect;}}
if(options.targetJoint==null){options.targetJoint=[];options.targetJoint[0]=options.tipJoint[0]=='left'?'right':(options.tipJoint[0]=='right'?'left':'center');options.targetJoint[1]=options.tipJoint[1]=='top'?'bottom':(options.tipJoint[1]=='bottom'?'top':'middle');}
this.options=options;this.buildContainer();this.options.showTriggerElementsWhenHidden=[];if(this.options.showOn&&this.options.showOn!='creation'){this.options.showTriggerElementsWhenHidden.push({element:this.triggerElement,event:this.options.showOn});}
this.options.showTriggerElementsWhenVisible=[];this.options.hideTriggerElements=[];if(this.options.hideTrigger){var hideOnEvent=null;var hideTriggerElement=null;switch(this.options.hideTrigger){case'trigger':hideOnEvent=this.options.hideOn?this.options.hideOn:'mouseout';hideTriggerElement=this.triggerElement;break;case'tip':hideOnEvent=this.options.hideOn?this.options.hideOn:'mouseover';hideTriggerElement=this.container;break;case'target':hideOnEvent=this.options.hideOn?this.options.hideOn:'mouseover';hideTriggerElement=this.options.target;break;case'closeButton':break;default:hideOnEvent=this.options.hideOn?this.options.hideOn:'mouseover';hideTriggerElement=$(this.options.hideTrigger);break;}
if(hideTriggerElement){this.options.hideTriggerElements.push({element:hideTriggerElement,event:hideOnEvent});if(hideOnEvent=='mouseout'){this.options.showTriggerElementsWhenVisible.push({element:hideTriggerElement,event:'mouseover'});}}}
this.activate();if(evt||this.options.showOn=='creation')this.show(evt);},activate:function(){this.bound={};this.bound.doShow=this.doShow.bindAsEventListener(this);this.bound.show=this.show.bindAsEventListener(this);this.bound.doHide=this.doHide.bindAsEventListener(this);this.bound.hide=this.hide.bindAsEventListener(this);this.bound.position=this.position.bindAsEventListener(this);if(this.options.showEffect||this.options.hideEffect)this.queue={limit:1,position:'end',scope:this.container.identify()};this.setupObserversForReallyHiddenTip();this.setupObserversForHiddenTip();},deactivate:function(){this.doHide();this.setupObserversForReallyHiddenTip();},buildContainer:function(){this.container=$(Opentip.element('div',{className:'ot-container ot-completely-hidden style-'+this.options.className+(this.options.ajax?' ot-loading':'')+(this.options.fixed?' ot-fixed':'')}));if(Opentip.useCss3Transitions){this.container.setCss3Style({'transitionDuration':'0s'});this.container.addClassName('ot-css3');if(this.options.showEffect){this.container.addClassName('ot-show-'+this.options.showEffect);}
if(this.options.hideEffect){this.container.addClassName('ot-hide-'+this.options.hideEffect);}}
if(Opentip.useScriptaculousTransitions)this.container.setStyle({display:'none'});},buildElements:function(){if(this.options.stem){var stemOffset='-'+this.options.stemSize+'px';this.container.appendChild(Opentip.element('div',{className:'stem-container '+this.options.stem[0]+' '+this.options.stem[1]},Opentip.element('div',{className:'stem'},Opentip.element('div'))));}
var self=this;var content=[];var headerContent=[];if(this.options.title)headerContent.push(Opentip.element('div',{className:'title'},this.options.title));content.push(Opentip.element('div',{className:'header'},headerContent));content.push($(Opentip.element('div',{className:'content'})));if(this.options.ajax){content.push($(Opentip.element('div',{className:'loadingIndication'},Opentip.element('span','Loading...'))));}
this.tooltipElement=$(Opentip.element('div',{className:'opentip'},content));this.container.appendChild(this.tooltipElement);var buttons=this.container.appendChild(Opentip.element('div',{className:'ot-buttons'}));if(this.options.hideTrigger=='closeButton')buttons.appendChild(Opentip.element('a',{href:'javascript:undefined',className:'close'},Opentip.element('span','x')));if(Opentip.useIFrame())this.iFrameElement=this.container.appendChild($(Opentip.element('iframe',{className:'opentipIFrame',src:'javascript:false;'})).setStyle({display:'none',zIndex:100}).setOpacity(0));document.body.appendChild(this.container);},updateContent:function(){var contentDiv=this.container.down('.content');if(contentDiv){contentDiv.update(this.options.escapeHtml?this.content.escapeHTML():this.content);}
this.storeAndFixDimensions();},storeAndFixDimensions:function(){this.container.setStyle({width:'auto',left:'0px',top:'0px'});this.dimensions=this.container.getDimensions();this.container.setStyle({width:this.dimensions.width+'px',left:this.lastPosition.left+'px',top:this.lastPosition.top+'px'});},destroyAllElements:function(){if(this.container)this.container.remove();},clearShowTimeout:function(){window.clearTimeout(this.timeoutId);},clearHideTimeout:function(){window.clearTimeout(this.hideTimeoutId);},clearTimeouts:function(){window.clearTimeout(this.visibilityStateTimeoutId);this.clearShowTimeout();this.clearHideTimeout();},setupObserversForReallyVisibleTip:function(){this.options.showTriggerElementsWhenVisible.each(function(pair){$(pair.element).observe(pair.event,this.bound.show);},this);},setupObserversForVisibleTip:function(){this.options.hideTriggerElements.each(function(pair){$(pair.element).observe(pair.event,this.bound.hide);},this);this.options.showTriggerElementsWhenHidden.each(function(pair){$(pair.element).stopObserving(pair.event,this.bound.show);},this);Event.observe(document.onresize?document:window,"resize",this.bound.position);Event.observe(window,"scroll",this.bound.position);},setupObserversForReallyHiddenTip:function(){this.options.showTriggerElementsWhenVisible.each(function(pair){$(pair.element).stopObserving(pair.event,this.bound.show);},this);},setupObserversForHiddenTip:function(){this.options.showTriggerElementsWhenHidden.each(function(pair){$(pair.element).observe(pair.event,this.bound.show);},this);this.options.hideTriggerElements.each(function(pair){$(pair.element).stopObserving(pair.event,this.bound.hide);},this);Event.stopObserving(document.onresize?document:window,"resize",this.bound.position);Event.stopObserving(window,"scroll",this.bound.position);},show:function(evt){this.abortHiding();if(this.visible)return;this.debug('Showing in '+this.options.delay+'s.');if(this.options.group)Tips.abortShowingGroup(this.options.group);this.waitingToShow=true;this.setupObserversForVisibleTip();this.followMousePosition();this.position(evt);if(!this.options.delay)this.bound.doShow(evt);else this.timeoutId=this.bound.doShow.delay(this.options.delay);},abortShowing:function(){if(this.waitingToShow){this.debug('Aborting showing.');this.clearTimeouts();this.stopFollowingMousePosition();this.waitingToShow=false;this.setupObserversForHiddenTip();}},doShow:function(){this.clearTimeouts();if(this.visible)return;this.debug('Showing!');if(this.options.group)Tips.hideGroup(this.options.group);this.visible=true;this.waitingToShow=false;if(Object.isFunction(this.content)){this.debug('Executing content function.');this.content=this.content(this);}
if(!this.tooltipElement)this.buildElements();this.updateContent();if(this.options.ajax&&!this.loaded){this.loadAjax();}
this.searchAndActivateHideButtons();this.ensureElement();this.container.setStyle({zIndex:Opentip.lastZIndex+=1});this.setupObserversForReallyVisibleTip();this.setupObserversForVisibleTip();if(Opentip.useScriptaculousTransitions){if(this.options.showEffect||this.options.hideEffect)this.cancelEffects();if(!this.options.showEffect||!this.container[this.options.showEffect])this.container.show();else this.container[this.options.showEffect]({duration:this.options.showEffectDuration,queue:this.queue,afterFinish:this.afterShowEffect.bind(this)});if(Opentip.useIFrame())this.iFrameElement.show();}
this.position();this.container.removeClassName('ot-hidden').addClassName('ot-becoming-visible');var startShowEffect=function(){if(Opentip.useCss3Transitions){this.container.setCss3Style({'transitionDuration':this.options.showEffectDuration+'s'});}
this.container.removeClassName('ot-becoming-visible').addClassName('ot-visible');if(this.options.showEffect&&this.options.showEffectDuration){this.visibilityStateTimeoutId=(function(){this.removeClassName('ot-visible').addClassName('ot-completely-visible');}).bind(this.container).delay(this.options.showEffectDuration);}
else{this.container.removeClassName('ot-visible').addClassName('ot-completely-visible');}
this.activateFirstInput();};(function(){this.container.removeClassName('ot-completely-hidden');(startShowEffect).bind(this).defer();}).bind(this).defer();},loadAjax:function(){if(this.loading)return;this.loading=true;this.container.addClassName('ot-loading');this.debug('Loading content from '+this.options.ajax.url+'.');new Ajax.Request(this.options.ajax.url,Object.extend({onComplete:function(){this.container.removeClassName('ot-loading');this.loaded=true;this.loading=false;this.updateContent();this.searchAndActivateHideButtons();this.activateFirstInput();this.position();}.bind(this),onSuccess:function(transport){this.debug('Loading successfull.');this.content=transport.responseText;}.bind(this),onFailure:function(){this.debug('There was a problem downloading the file.');this.options.escapeHtml=false;this.content='<a class="close">There was a problem downloading the content.</a>';}.bind(this)},this.options.ajax.options||{}));},afterShowEffect:function(){this.activateFirstInput();this.position();},activateFirstInput:function(){var input=this.container.down('input');var textarea=this.container.down('textarea');if(input){input.focus();}
else if(textarea)textarea.focus();},searchAndActivateHideButtons:function(){if(this.options.hideTrigger=='closeButton'||!this.options.hideTrigger){this.options.hideTriggerElements=[];this.container.select('.close').each(function(el){this.options.hideTriggerElements.push({element:el,event:'click'});},this);if(this.visible)this.setupObserversForVisibleTip();}},hide:function(afterFinish){this.abortShowing();if(!this.visible)return;this.debug('Hiding in '+this.options.hideDelay+'s.');this.waitingToHide=true;this.setupObserversForHiddenTip();this.hideTimeoutId=this.bound.doHide.delay(this.options.hideDelay,afterFinish);},abortHiding:function(){if(this.waitingToHide){this.debug('Aborting hiding.');this.clearTimeouts();this.waitingToHide=false;this.setupObserversForVisibleTip();}},doHide:function(afterFinish){this.clearTimeouts();if(!this.visible)return;this.debug('Hiding!');this.visible=false;this.waitingToHide=false;this.deactivateElementEnsurance();this.setupObserversForReallyHiddenTip();this.setupObserversForHiddenTip();if(!this.options.fixed)this.stopFollowingMousePosition();if(Opentip.useScriptaculousTransitions){if(this.options.showEffect||this.options.hideEffect)this.cancelEffects();if(!this.options.hideEffect||!this.container[this.options.hideEffect])this.container.hide();else{var effectOptions={duration:this.options.hideEffectDuration,queue:this.queue};if(afterFinish&&Object.isFunction(afterFinish))effectOptions.afterFinish=afterFinish;this.container[this.options.hideEffect](effectOptions);}
if(Opentip.useIFrame())this.iFrameElement.hide();}
if(Opentip.useCss3Transitions){this.container.setCss3Style({'transitionDuration':this.options.hideEffectDuration+'s'});}
this.container.removeClassName('ot-visible').removeClassName('ot-completely-visible').addClassName('ot-hidden');if(this.options.hideEffect&&this.options.hideEffectDuration){this.visibilityStateTimeoutId=(function(){this.setCss3Style({'transitionDuration':'0s'});this.removeClassName('ot-hidden').addClassName('ot-completely-hidden');}).bind(this.container).delay(this.options.showEffectDuration);}
else{this.container.removeClassName('ot-hidden').addClassName('ot-completely-hidden');}},cancelEffects:function(){Effect.Queues.get(this.queue.scope).invoke('cancel');},followMousePosition:function(){if(!this.options.fixed)$(document.body).observe('mousemove',this.bound.position);},stopFollowingMousePosition:function(){if(!this.options.fixed)$(document.body).stopObserving('mousemove',this.bound.position);},positionsEqual:function(position1,position2){return(position1.left==position2.left&&position1.top==position2.top);},position:function(evt){var evt=evt||this.lastEvt;this.currentStemPosition=this.options.stem;var position=this.ensureViewportContainment(evt,this.getPosition(evt));if(this.positionsEqual(position,this.lastPosition)){this.positionStem();return;}
this.lastPosition=position;if(position){var style={'left':position.left+'px','top':position.top+'px'};this.container.setStyle(style);if(Opentip.useIFrame()&&this.iFrameElement){this.iFrameElement.setStyle({width:this.container.getWidth()+'px',height:this.container.getHeight()+'px'});}
var container=this.container;(function(){container.style.visibility="hidden";var redrawFix=container.offsetHeight;container.style.visibility="visible";}).defer();}
this.positionStem();},getPosition:function(evt,tipJ,trgJ,stem){var tipJ=tipJ||this.options.tipJoint;var trgJ=trgJ||this.options.targetJoint;var position={};if(this.options.target){var tmp=this.options.target.cumulativeOffset();position.left=tmp[0];position.top=tmp[1];if(trgJ[0]=='right'){if(typeof this.options.target.getBoundingClientRect!='undefined'){position.left=this.options.target.getBoundingClientRect().right+$(document.viewport).getScrollOffsets().left;}
else{position.left=position.left+this.options.target.getWidth();}}
else if(trgJ[0]=='center'){position.left+=Math.round(this.options.target.getWidth()/2);}
if(trgJ[1]=='bottom'){position.top+=this.options.target.getHeight();}
else if(trgJ[1]=='middle'){position.top+=Math.round(this.options.target.getHeight()/2);}}else{if(!evt)return;this.lastEvt=evt;position.left=Event.pointerX(evt);position.top=Event.pointerY(evt);}
if(this.options.autoOffset){var stemSize=this.options.stem?this.options.stemSize:0;var offsetDistance=(stemSize&&this.options.fixed)?2:10;var additionalHorizontal=(tipJ[1]=='middle'&&!this.options.fixed)?15:0;var additionalVertical=(tipJ[0]=='center'&&!this.options.fixed)?15:0;if(tipJ[0]=='right')position.left-=offsetDistance+additionalHorizontal;else if(tipJ[0]=='left')position.left+=offsetDistance+additionalHorizontal;if(tipJ[1]=='bottom')position.top-=offsetDistance+additionalVertical;else if(tipJ[1]=='top')position.top+=offsetDistance+additionalVertical;if(stemSize){var stem=stem||this.options.stem;if(stem[0]=='right')position.left-=stemSize;else if(stem[0]=='left')position.left+=stemSize;if(stem[1]=='bottom')position.top-=stemSize;else if(stem[1]=='top')position.top+=stemSize;}}
position.left+=this.options.offset[0];position.top+=this.options.offset[1];if(tipJ[0]=='right'){position.left-=this.container.getWidth();}
if(tipJ[0]=='center'){position.left-=Math.round(this.container.getWidth()/2);}
if(tipJ[1]=='bottom'){position.top-=this.container.getHeight();}
if(tipJ[1]=='middle'){position.top-=Math.round(this.container.getHeight()/2);}
return position;},ensureViewportContainment:function(evt,position){if(!this.visible)return position;var sticksOut=[this.sticksOutX(position),this.sticksOutY(position)];if(!sticksOut[0]&&!sticksOut[1])return position;var tipJ=this.options.tipJoint.clone();var trgJ=this.options.targetJoint.clone();var viewportScrollOffset=$(document.viewport).getScrollOffsets();var dimensions=this.dimensions;var viewportOffset={left:position.left-viewportScrollOffset.left,top:position.top-viewportScrollOffset.top};var viewportDimensions=document.viewport.getDimensions();var reposition=false;if(viewportDimensions.width>=dimensions.width){if(viewportOffset.left<0){reposition=true;tipJ[0]='left';if(this.options.target&&trgJ[0]=='left'){trgJ[0]='right';}}
else if(viewportOffset.left+dimensions.width>viewportDimensions.width){reposition=true;tipJ[0]='right';if(this.options.target&&trgJ[0]=='right'){trgJ[0]='left';}}}
if(viewportDimensions.height>=dimensions.height){if(viewportOffset.top<0){reposition=true;tipJ[1]='top';if(this.options.target&&trgJ[1]=='top'){trgJ[1]='bottom';}}
else if(viewportOffset.top+dimensions.height>viewportDimensions.height){reposition=true;tipJ[1]='bottom';if(this.options.target&&trgJ[1]=='bottom'){trgJ[1]='top';}}}
if(reposition){var newPosition=this.getPosition(evt,tipJ,trgJ,tipJ);var newSticksOut=[this.sticksOutX(newPosition),this.sticksOutY(newPosition)];var revertedCount=0;for(var i=0;i<=1;i++){if(newSticksOut[i]&&newSticksOut[i]!=sticksOut[i]){revertedCount++;tipJ[i]=this.options.tipJoint[i];if(this.options.target){trgJ[i]=this.options.targetJoint[i];}}}
if(revertedCount<2){this.currentStemPosition=tipJ;return this.getPosition(evt,tipJ,trgJ,tipJ);}}
return position;},sticksOut:function(position){return this.sticksOutX(position)||this.sticksOutY(position);},sticksOutX:function(position){var viewportScrollOffset=$(document.viewport).getScrollOffsets();var viewportOffset={left:position.left-viewportScrollOffset.left,top:position.top-viewportScrollOffset.top};if(viewportOffset.left<0)return Opentip.STICKS_OUT_LEFT;if(viewportOffset.left+this.dimensions.width>document.viewport.getDimensions().width){return Opentip.STICKS_OUT_RIGHT;}},sticksOutY:function(position){var viewportScrollOffset=$(document.viewport).getScrollOffsets();var viewportOffset={left:position.left-viewportScrollOffset.left,top:position.top-viewportScrollOffset.top};if(viewportOffset.top<0)return Opentip.STICKS_OUT_TOP;if(viewportOffset.top+this.dimensions.height>document.viewport.getDimensions().height)return Opentip.STICKS_OUT_BOTTOM;},getStemElement:function(){return this.container.down('.stem');},stemPositionsEqual:function(position1,position2){return(position1&&position2&&position1[0]==position2[0]&&position1[1]==position2[1]);},positionStem:function(){if(this.options.stem){var stemElement=this.getStemElement();if(stemElement&&!this.stemPositionsEqual(this.lastStemPosition,this.currentStemPosition)){this.debug('Setting stem style');this.lastStemPosition=this.currentStemPosition;var stem=this.currentStemPosition;var stemSize=this.options.stemSize;var stemsImageSize=[320,160];var style={width:stemSize+'px',height:stemSize+'px'};style.left=style.top='0';switch(stem[0]){case'center':style.width=stemSize*2+'px';case'left':style.left='-'+stemSize+'px';break;}
switch(stem[1]){case'middle':style.height=stemSize*2+'px';case'top':style.top='-'+stemSize+'px';break;}
if(stem[0]!='center'&&stem[1]!='middle')style.width=style.height=stemSize*2+'px';var imageStyle={left:0,top:0};switch(stem[0]+'-'+stem[1]){case'left-middle':imageStyle.left='-'+Math.round(stemsImageSize[0]*(1/2))+'px';imageStyle.top='-'+Math.round(stemsImageSize[1]*(1/2)-stemSize)+'px';break;case'center-top':imageStyle.left='-'+Math.round(stemsImageSize[0]*(3/4)-stemSize)+'px';break;case'center-bottom':imageStyle.left='-'+Math.round(stemsImageSize[0]*(3/4)-stemSize)+'px';imageStyle.top='-'+Math.round(stemsImageSize[1]-stemSize)+'px';break;case'right-middle':imageStyle.left='-'+Math.round(stemsImageSize[0]-stemSize)+'px';imageStyle.top='-'+Math.round(stemsImageSize[1]/2-stemSize)+'px';break;case'left-top':break;case'right-top':imageStyle.left='-'+Math.round(stemsImageSize[0]*(1/2)-stemSize*2)+'px';style.top='-'+stemSize+'px';style.left='-'+stemSize+'px';break;case'right-bottom':imageStyle.left='-'+Math.round(stemsImageSize[0]*(1/2)-stemSize*2)+'px';imageStyle.top='-'+Math.round(stemsImageSize[1]-stemSize*2)+'px';style.left='-'+stemSize+'px';style.top='-'+stemSize+'px';break;case'left-bottom':imageStyle.top='-'+Math.round(stemsImageSize[1]-stemSize*2)+'px';style.left='-'+stemSize+'px';style.top='-'+stemSize+'px';break;}
stemElement.down('div').setStyle(imageStyle);stemElement.setStyle(style);stemElement._appliedStyle=true;stemElement.up('.stem-container').removeClassName('left').removeClassName('right').removeClassName('center').removeClassName('top').removeClassName('bottom').removeClassName('middle').addClassName(stem[0]+' '+stem[1]);}}},ensureElementInterval:1000,ensureElement:function(){this.deactivateElementEnsurance();if(!this.triggerElement.parentNode||!this.triggerElement.visible()||!this.triggerElement.descendantOf(document.body)){this.deactivate();}
this.ensureElementTimeoutId=setTimeout(this.ensureElement.bind(this),this.ensureElementInterval);},deactivateElementEnsurance:function(){clearTimeout(this.ensureElementTimeoutId);}});
