/* * jQuery UI 1.7.1 * * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT (MIT-LICENSE.txt) * and GPL (GPL-LICENSE.txt) licenses. * * http://docs.jquery.com/UI */ jQuery.ui||(function(c){var i=c.fn.remove,d=c.browser.mozilla&&(parseFloat(c.browser.version)<1.9);c.ui={version:"1.7.1",plugin:{add:function(k,l,n){var m=c.ui[k].prototype;for(var j in n){m.plugins[j]=m.plugins[j]||[];m.plugins[j].push([l,n[j]])}},call:function(j,l,k){var n=j.plugins[l];if(!n||!j.element[0].parentNode){return}for(var m=0;m0){return true}m[j]=1;l=(m[j]>0);m[j]=0;return l},isOverAxis:function(k,j,l){return(k>j)&&(k<(j+l))},isOver:function(o,k,n,m,j,l){return c.ui.isOverAxis(o,n,j)&&c.ui.isOverAxis(k,m,l)},keyCode:{BACKSPACE:8,CAPS_LOCK:20,COMMA:188,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38}};if(d){var f=c.attr,e=c.fn.removeAttr,h="http://www.w3.org/2005/07/aaa",a=/^aria-/,b=/^wairole:/;c.attr=function(k,j,l){var m=l!==undefined;return(j=="role"?(m?f.call(this,k,j,"wairole:"+l):(f.apply(this,arguments)||"").replace(b,"")):(a.test(j)?(m?k.setAttributeNS(h,j.replace(a,"aaa:"),l):f.call(this,k,j.replace(a,"aaa:"))):f.apply(this,arguments)))};c.fn.removeAttr=function(j){return(a.test(j)?this.each(function(){this.removeAttributeNS(h,j.replace(a,""))}):e.call(this,j))}}c.fn.extend({remove:function(){c("*",this).add(this).each(function(){c(this).triggerHandler("remove")});return i.apply(this,arguments)},enableSelection:function(){return this.attr("unselectable","off").css("MozUserSelect","").unbind("selectstart.ui")},disableSelection:function(){return this.attr("unselectable","on").css("MozUserSelect","none").bind("selectstart.ui",function(){return false})},scrollParent:function(){var j;if((c.browser.msie&&(/(static|relative)/).test(this.css("position")))||(/absolute/).test(this.css("position"))){j=this.parents().filter(function(){return(/(relative|absolute|fixed)/).test(c.curCSS(this,"position",1))&&(/(auto|scroll)/).test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0)}else{j=this.parents().filter(function(){return(/(auto|scroll)/).test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0)}return(/fixed/).test(this.css("position"))||!j.length?c(document):j}});c.extend(c.expr[":"],{data:function(l,k,j){return !!c.data(l,j[3])},focusable:function(k){var l=k.nodeName.toLowerCase(),j=c.attr(k,"tabindex");return(/input|select|textarea|button|object/.test(l)?!k.disabled:"a"==l||"area"==l?k.href||!isNaN(j):!isNaN(j))&&!c(k)["area"==l?"parents":"closest"](":hidden").length},tabbable:function(k){var j=c.attr(k,"tabindex");return(isNaN(j)||j>=0)&&c(k).is(":focusable")}});function g(m,n,o,l){function k(q){var p=c[m][n][q]||[];return(typeof p=="string"?p.split(/,?\s+/):p)}var j=k("getter");if(l.length==1&&typeof l[0]=="string"){j=j.concat(k("getterSetter"))}return(c.inArray(o,j)!=-1)}c.widget=function(k,j){var l=k.split(".")[0];k=k.split(".")[1];c.fn[k]=function(p){var n=(typeof p=="string"),o=Array.prototype.slice.call(arguments,1);if(n&&p.substring(0,1)=="_"){return this}if(n&&g(l,k,p,o)){var m=c.data(this[0],k);return(m?m[p].apply(m,o):undefined)}return this.each(function(){var q=c.data(this,k);(!q&&!n&&c.data(this,k,new c[l][k](this,p))._init());(q&&n&&c.isFunction(q[p])&&q[p].apply(q,o))})};c[l]=c[l]||{};c[l][k]=function(o,n){var m=this;this.namespace=l;this.widgetName=k;this.widgetEventPrefix=c[l][k].eventPrefix||k;this.widgetBaseClass=l+"-"+k;this.options=c.extend({},c.widget.defaults,c[l][k].defaults,c.metadata&&c.metadata.get(o)[k],n);this.element=c(o).bind("setData."+k,function(q,p,r){if(q.target==o){return m._setData(p,r)}}).bind("getData."+k,function(q,p){if(q.target==o){return m._getData(p)}}).bind("remove",function(){return m.destroy()})};c[l][k].prototype=c.extend({},c.widget.prototype,j);c[l][k].getterSetter="option"};c.widget.prototype={_init:function(){},destroy:function(){this.element.removeData(this.widgetName).removeClass(this.widgetBaseClass+"-disabled "+this.namespace+"-state-disabled").removeAttr("aria-disabled")},option:function(l,m){var k=l,j=this;if(typeof l=="string"){if(m===undefined){return this._getData(l)}k={};k[l]=m}c.each(k,function(n,o){j._setData(n,o)})},_getData:function(j){return this.options[j]},_setData:function(j,k){this.options[j]=k;if(j=="disabled"){this.element[k?"addClass":"removeClass"](this.widgetBaseClass+"-disabled "+this.namespace+"-state-disabled").attr("aria-disabled",k)}},enable:function(){this._setData("disabled",false)},disable:function(){this._setData("disabled",true)},_trigger:function(l,m,n){var p=this.options[l],j=(l==this.widgetEventPrefix?l:this.widgetEventPrefix+l);m=c.Event(m);m.type=j;if(m.originalEvent){for(var k=c.event.props.length,o;k;){o=c.event.props[--k];m[o]=m.originalEvent[o]}}this.element.trigger(m,n);return !(c.isFunction(p)&&p.call(this.element[0],m,n)===false||m.isDefaultPrevented())}};c.widget.defaults={disabled:false};c.ui.mouse={_mouseInit:function(){var j=this;this.element.bind("mousedown."+this.widgetName,function(k){return j._mouseDown(k)}).bind("click."+this.widgetName,function(k){if(j._preventClickEvent){j._preventClickEvent=false;k.stopImmediatePropagation();return false}});if(c.browser.msie){this._mouseUnselectable=this.element.attr("unselectable");this.element.attr("unselectable","on")}this.started=false},_mouseDestroy:function(){this.element.unbind("."+this.widgetName);(c.browser.msie&&this.element.attr("unselectable",this._mouseUnselectable))},_mouseDown:function(l){l.originalEvent=l.originalEvent||{};if(l.originalEvent.mouseHandled){return}(this._mouseStarted&&this._mouseUp(l));this._mouseDownEvent=l;var k=this,m=(l.which==1),j=(typeof this.options.cancel=="string"?c(l.target).parents().add(l.target).filter(this.options.cancel).length:false);if(!m||j||!this._mouseCapture(l)){return true}this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){k.mouseDelayMet=true},this.options.delay)}if(this._mouseDistanceMet(l)&&this._mouseDelayMet(l)){this._mouseStarted=(this._mouseStart(l)!==false);if(!this._mouseStarted){l.preventDefault();return true}}this._mouseMoveDelegate=function(n){return k._mouseMove(n)};this._mouseUpDelegate=function(n){return k._mouseUp(n)};c(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);(c.browser.safari||l.preventDefault());l.originalEvent.mouseHandled=true;return true},_mouseMove:function(j){if(c.browser.msie&&!j.button){return this._mouseUp(j)}if(this._mouseStarted){this._mouseDrag(j);return j.preventDefault()}if(this._mouseDistanceMet(j)&&this._mouseDelayMet(j)){this._mouseStarted=(this._mouseStart(this._mouseDownEvent,j)!==false);(this._mouseStarted?this._mouseDrag(j):this._mouseUp(j))}return !this._mouseStarted},_mouseUp:function(j){c(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;this._preventClickEvent=(j.target==this._mouseDownEvent.target);this._mouseStop(j)}return false},_mouseDistanceMet:function(j){return(Math.max(Math.abs(this._mouseDownEvent.pageX-j.pageX),Math.abs(this._mouseDownEvent.pageY-j.pageY))>=this.options.distance)},_mouseDelayMet:function(j){return this.mouseDelayMet},_mouseStart:function(j){},_mouseDrag:function(j){},_mouseStop:function(j){},_mouseCapture:function(j){return true}};c.ui.mouse.defaults={cancel:null,distance:1,delay:0}})(jQuery);;/* * jQuery UI Slider 1.7.1 * * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT (MIT-LICENSE.txt) * and GPL (GPL-LICENSE.txt) licenses. * * http://docs.jquery.com/UI/Slider * * Depends: * ui.core.js */ (function(a){a.widget("ui.slider",a.extend({},a.ui.mouse,{_init:function(){var b=this,c=this.options;this._keySliding=false;this._handleIndex=null;this._detectOrientation();this._mouseInit();this.element.addClass("ui-slider ui-slider-"+this.orientation+" ui-widget ui-widget-content ui-corner-all");this.range=a([]);if(c.range){if(c.range===true){this.range=a("
");if(!c.values){c.values=[this._valueMin(),this._valueMin()]}if(c.values.length&&c.values.length!=2){c.values=[c.values[0],c.values[0]]}}else{this.range=a("
")}this.range.appendTo(this.element).addClass("ui-slider-range");if(c.range=="min"||c.range=="max"){this.range.addClass("ui-slider-range-"+c.range)}this.range.addClass("ui-widget-header")}if(a(".ui-slider-handle",this.element).length==0){a('').appendTo(this.element).addClass("ui-slider-handle")}if(c.values&&c.values.length){while(a(".ui-slider-handle",this.element).length').appendTo(this.element).addClass("ui-slider-handle")}}this.handles=a(".ui-slider-handle",this.element).addClass("ui-state-default ui-corner-all");this.handle=this.handles.eq(0);this.handles.add(this.range).filter("a").click(function(d){d.preventDefault()}).hover(function(){a(this).addClass("ui-state-hover")},function(){a(this).removeClass("ui-state-hover")}).focus(function(){a(".ui-slider .ui-state-focus").removeClass("ui-state-focus");a(this).addClass("ui-state-focus")}).blur(function(){a(this).removeClass("ui-state-focus")});this.handles.each(function(d){a(this).data("index.ui-slider-handle",d)});this.handles.keydown(function(i){var f=true;var e=a(this).data("index.ui-slider-handle");if(b.options.disabled){return}switch(i.keyCode){case a.ui.keyCode.HOME:case a.ui.keyCode.END:case a.ui.keyCode.UP:case a.ui.keyCode.RIGHT:case a.ui.keyCode.DOWN:case a.ui.keyCode.LEFT:f=false;if(!b._keySliding){b._keySliding=true;a(this).addClass("ui-state-active");b._start(i,e)}break}var g,d,h=b._step();if(b.options.values&&b.options.values.length){g=d=b.values(e)}else{g=d=b.value()}switch(i.keyCode){case a.ui.keyCode.HOME:d=b._valueMin();break;case a.ui.keyCode.END:d=b._valueMax();break;case a.ui.keyCode.UP:case a.ui.keyCode.RIGHT:if(g==b._valueMax()){return}d=g+h;break;case a.ui.keyCode.DOWN:case a.ui.keyCode.LEFT:if(g==b._valueMin()){return}d=g-h;break}b._slide(i,e,d);return f}).keyup(function(e){var d=a(this).data("index.ui-slider-handle");if(b._keySliding){b._stop(e,d);b._change(e,d);b._keySliding=false;a(this).removeClass("ui-state-active")}});this._refreshValue()},destroy:function(){this.handles.remove();this.range.remove();this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-slider-disabled ui-widget ui-widget-content ui-corner-all").removeData("slider").unbind(".slider");this._mouseDestroy()},_mouseCapture:function(d){var e=this.options;if(e.disabled){return false}this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()};this.elementOffset=this.element.offset();var h={x:d.pageX,y:d.pageY};var j=this._normValueFromMouse(h);var c=this._valueMax()-this._valueMin()+1,f;var k=this,i;this.handles.each(function(l){var m=Math.abs(j-k.values(l));if(c>m){c=m;f=a(this);i=l}});if(e.range==true&&this.values(1)==e.min){f=a(this.handles[++i])}this._start(d,i);k._handleIndex=i;f.addClass("ui-state-active").focus();var g=f.offset();var b=!a(d.target).parents().andSelf().is(".ui-slider-handle");this._clickOffset=b?{left:0,top:0}:{left:d.pageX-g.left-(f.width()/2),top:d.pageY-g.top-(f.height()/2)-(parseInt(f.css("borderTopWidth"),10)||0)-(parseInt(f.css("borderBottomWidth"),10)||0)+(parseInt(f.css("marginTop"),10)||0)};j=this._normValueFromMouse(h);this._slide(d,i,j);return true},_mouseStart:function(b){return true},_mouseDrag:function(d){var b={x:d.pageX,y:d.pageY};var c=this._normValueFromMouse(b);this._slide(d,this._handleIndex,c);return false},_mouseStop:function(b){this.handles.removeClass("ui-state-active");this._stop(b,this._handleIndex);this._change(b,this._handleIndex);this._handleIndex=null;this._clickOffset=null;return false},_detectOrientation:function(){this.orientation=this.options.orientation=="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(d){var c,h;if("horizontal"==this.orientation){c=this.elementSize.width;h=d.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)}else{c=this.elementSize.height;h=d.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)}var f=(h/c);if(f>1){f=1}if(f<0){f=0}if("vertical"==this.orientation){f=1-f}var e=this._valueMax()-this._valueMin(),i=f*e,b=i%this.options.step,g=this._valueMin()+i-b;if(b>(this.options.step/2)){g+=this.options.step}return parseFloat(g.toFixed(5))},_start:function(d,c){var b={handle:this.handles[c],value:this.value()};if(this.options.values&&this.options.values.length){b.value=this.values(c);b.values=this.values()}this._trigger("start",d,b)},_slide:function(f,e,d){var g=this.handles[e];if(this.options.values&&this.options.values.length){var b=this.values(e?0:1);if((e==0&&d>=b)||(e==1&&d<=b)){d=b}if(d!=this.values(e)){var c=this.values();c[e]=d;var h=this._trigger("slide",f,{handle:this.handles[e],value:d,values:c});var b=this.values(e?0:1);if(h!==false){this.values(e,d,(f.type=="mousedown"&&this.options.animate),true)}}}else{if(d!=this.value()){var h=this._trigger("slide",f,{handle:this.handles[e],value:d});if(h!==false){this._setData("value",d,(f.type=="mousedown"&&this.options.animate))}}}},_stop:function(d,c){var b={handle:this.handles[c],value:this.value()};if(this.options.values&&this.options.values.length){b.value=this.values(c);b.values=this.values()}this._trigger("stop",d,b)},_change:function(d,c){var b={handle:this.handles[c],value:this.value()};if(this.options.values&&this.options.values.length){b.value=this.values(c);b.values=this.values()}this._trigger("change",d,b)},value:function(b){if(arguments.length){this._setData("value",b);this._change(null,0)}return this._value()},values:function(b,e,c,d){if(arguments.length>1){this.options.values[b]=e;this._refreshValue(c);if(!d){this._change(null,b)}}if(arguments.length){if(this.options.values&&this.options.values.length){return this._values(b)}else{return this.value()}}else{return this._values()}},_setData:function(b,d,c){a.widget.prototype._setData.apply(this,arguments);switch(b){case"orientation":this._detectOrientation();this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+this.orientation);this._refreshValue(c);break;case"value":this._refreshValue(c);break}},_step:function(){var b=this.options.step;return b},_value:function(){var b=this.options.value;if(bthis._valueMax()){b=this._valueMax()}return b},_values:function(b){if(arguments.length){var c=this.options.values[b];if(cthis._valueMax()){c=this._valueMax()}return c}else{return this.options.values}},_valueMin:function(){var b=this.options.min;return b},_valueMax:function(){var b=this.options.max;return b},_refreshValue:function(c){var f=this.options.range,d=this.options,l=this;if(this.options.values&&this.options.values.length){var i,h;this.handles.each(function(p,n){var o=(l.values(p)-l._valueMin())/(l._valueMax()-l._valueMin())*100;var m={};m[l.orientation=="horizontal"?"left":"bottom"]=o+"%";a(this).stop(1,1)[c?"animate":"css"](m,d.animate);if(l.options.range===true){if(l.orientation=="horizontal"){(p==0)&&l.range.stop(1,1)[c?"animate":"css"]({left:o+"%"},d.animate);(p==1)&&l.range[c?"animate":"css"]({width:(o-lastValPercent)+"%"},{queue:false,duration:d.animate})}else{(p==0)&&l.range.stop(1,1)[c?"animate":"css"]({bottom:(o)+"%"},d.animate);(p==1)&&l.range[c?"animate":"css"]({height:(o-lastValPercent)+"%"},{queue:false,duration:d.animate})}}lastValPercent=o})}else{var j=this.value(),g=this._valueMin(),k=this._valueMax(),e=k!=g?(j-g)/(k-g)*100:0;var b={};b[l.orientation=="horizontal"?"left":"bottom"]=e+"%";this.handle.stop(1,1)[c?"animate":"css"](b,d.animate);(f=="min")&&(this.orientation=="horizontal")&&this.range.stop(1,1)[c?"animate":"css"]({width:e+"%"},d.animate);(f=="max")&&(this.orientation=="horizontal")&&this.range[c?"animate":"css"]({width:(100-e)+"%"},{queue:false,duration:d.animate});(f=="min")&&(this.orientation=="vertical")&&this.range.stop(1,1)[c?"animate":"css"]({height:e+"%"},d.animate);(f=="max")&&(this.orientation=="vertical")&&this.range[c?"animate":"css"]({height:(100-e)+"%"},{queue:false,duration:d.animate})}}}));a.extend(a.ui.slider,{getter:"value values",version:"1.7.1",eventPrefix:"slide",defaults:{animate:false,delay:0,distance:0,max:100,min:0,orientation:"horizontal",range:false,step:1,value:0,values:null}})})(jQuery);;$(document).ready(function(){ $("#content-slider").slider({ animate: true, change: handleSliderChange, slide: handleSliderSlide }); }); function handleSliderChange(e, ui) { villaScrollPos = ui.value; var maxScroll = $("#content-scroll").attr("scrollWidth") - $("#content-scroll").width(); $("#content-scroll").animate({scrollLeft: ui.value * (maxScroll / 100) }, 1000); } function handleSliderSlide(e, ui) { villaScrollPos = ui.value; var maxScroll = $("#content-scroll").attr("scrollWidth") - $("#content-scroll").width(); $("#content-scroll").attr({scrollLeft: ui.value * (maxScroll / 100) }); } var villaScrollPos = 0; function scrollContent(value) { villaScrollPos+=value; if(villaScrollPos > 100) { villaScrollPos = 100; } else if(villaScrollPos < 0) { villaScrollPos = 0; } $(".ui-slider-handle").css("left",villaScrollPos+"%"); var maxScroll = $("#content-scroll").attr("scrollWidth") - $("#content-scroll").width(); $("#content-scroll").animate({scrollLeft: villaScrollPos * (maxScroll / 100) }, 1000); } var map; var bounds; var markerArr = new Array(); var bubbleArr = new Array(); var boundArray = new Array(); var countryArray = new Array(); var countryDataArray = new Array(); var currentView = "price"; var dotArray = new Array(); var markerS = new Array(); var markerP = new Array(); function initialize() { var stylez = [ { featureType: "water", elementType: "geometry", stylers: [ { saturation: -100 }, { gamma: 0.26 }, { visibility: "on" }, { lightness: 63 } ] },{ featureType: "transit", elementType: "geometry", stylers: [ { saturation: -100 }, { gamma: 0.21 }, { visibility: "on" }, { invert_lightness: true } ] },{ featureType: "road.local", elementType: "geometry", stylers: [ { saturation: -100 }, { gamma: 1.2 }, { visibility: "simplified" }, { lightness: -6 } ] },{ featureType: "transit.line", elementType: "all", stylers: [ { visibility: "off" } ] },{ featureType: "road.arterial", elementType: "geometry", stylers: [ { visibility: "on" }, { saturation: -96 }, { gamma: 0.81 } ] },{ featureType: "all", elementType: "geometry", stylers: [ { saturation: -79 }, { lightness: 0 }, { invert_lightness: true }, { visibility: "on" } ] },{ featureType: "landscape.man_made", elementType: "geometry", stylers: [ { saturation: -100 }, { lightness: 0 }, { gamma: 0.04 }, { visibility: "on" } ] },{ featureType: "all", elementType: "all", stylers: [ { saturation: -99 } ] },{ featureType: "poi.park", elementType: "geometry", stylers: [ { gamma: 0.56 }, { invert_lightness: true }, { visibility: "simplified" }, { lightness: -81 } ] },{ featureType: "administrative", elementType: "labels", stylers: [ { invert_lightness: true } ] },{ featureType: "road.highway", elementType: "all", stylers: [ { visibility: "on" }, { lightness: -59 } ] },{ featureType: "poi.medical", elementType: "all", stylers: [ { visibility: "off" } ] },{ featureType: "poi.business", elementType: "all", stylers: [ { visibility: "off" } ] },{ featureType: "poi.school", elementType: "all", stylers: [ { visibility: "off" } ] },{ featureType: "landscape.natural", elementType: "geometry", stylers: [ { visibility: "on" } ] },{ featureType: "road.local", elementType: "labels", stylers: [ { invert_lightness: true } ] },{ featureType: "road.arterial", elementType: "labels", stylers: [ { invert_lightness: true } ] },{ featureType: "poi.attraction", elementType: "geometry", stylers: [ { visibility: "simplified" }, { lightness: -80 } ] },{ featureType: "poi", elementType: "labels", stylers: [ { invert_lightness: true } ] },{ featureType: "transit.station", elementType: "labels", stylers: [ { visibility: "off" } ] },{ featureType: "landscape.natural", elementType: "geometry", stylers: [ { visibility: "on" } ] },{ featureType: "landscape.man_made", elementType: "all", stylers: [ ] },{ featureType: "water", elementType: "labels", stylers: [ { invert_lightness: true } ] },{ featureType: "administrative.land_parcel", elementType: "all", stylers: [ { visibility: "off" } ] },{ featureType: "landscape.man_made", elementType: "labels", stylers: [ { invert_lightness: true }, { visibility: "on" } ] } ]; //alert($(document).height()); //alert($(window).height()); //alert($("#searchmap").height()); $("#map").height($(document).height()); var myOptions = { zoom: 2, //center: new google.maps.LatLng(61.834031, -88.046875), mapTypeId: google.maps.MapTypeId.ROADMAP, sensor: 'true', navigationControl: false, mapTypeControl: false, scaleControl: false } map = new google.maps.Map(document.getElementById("map"), myOptions); bounds = new google.maps.LatLngBounds(); var styledMapOptions = { map: map, maxZoom: 16, minZoom: 3, name: "tips4phpHip-Hop" } var testmap = new google.maps.StyledMapType(stylez,styledMapOptions); map.mapTypes.set('tips4php', testmap); map.setMapTypeId('tips4php'); map.controls[google.maps.ControlPosition.BOTTOM_LEFT].push(new missouristate.web.ZoomPanControl(map)); //addMarkers('',''); if(isUniExp != '') { showScreen('uniqueexperience'); } else { if (directarea) { //var tu=setTimeout("showScreen('searchmap')",0); var t=setTimeout("setDropdowns(directarea,directlocation)",120); directSearch(); } } } $(function(){ $(window).resize(function(){ if(map != null && map != "undefined") { //alert("now"); $("#map").height($(document).height()); //map.checkResize(); } }); }); function showBubble(id) { if(document.getElementById(id)) { document.getElementById(id).style.display = "block"; } } function hideBubble(id) { if(document.getElementById(id)) { alert(id); document.getElementById(id).style.display = "none"; } } function addMarkers(orderby,country,directId) { if (!directId) var directId;; if(directId != "" && directId != 'undefined' && directId != null ) { showScreen("searchmap"); showBigInfo(directId); //return true; } //clearMarkers(); google.maps.event.trigger(map, 'resize'); if(country == "" || country == "undefined" || country == null) { var country = $('#drpCountry2').val(); } countryArray.push(country); $.ajax({ type: "POST", url: "ajax.php", data: "q=c&search=1&country="+country+"&orderby="+orderby, success: function(msg){ var markers = msg.documentElement.getElementsByTagName("marker"); if(markers.length > 0) { for (var i = 0; i < markers.length; i++) { var lat = parseFloat(markers[i].getAttribute("lat")); var lng = parseFloat(markers[i].getAttribute("lng")); var html = markers[i].getAttribute("html"); var label = markers[i].getAttribute("label"); var id = markers[i].getAttribute("villaid"); var name = markers[i].getAttribute("name"); var price = markers[i].getAttribute("price"); var bedroom = markers[i].getAttribute("bedroom"); var focalpoint = markers[i].getAttribute("focalpoint"); var zoomlevel = markers[i].getAttribute("zoomlevel"); var bookmarktitle = markers[i].getAttribute("bookmarktitle"); var bookmarkurl = markers[i].getAttribute("bookmarkurl"); //alert(lat); var latLng = new google.maps.LatLng(lat,lng); var hpart = html.split("||"); var marker = new google.maps.Marker({ position:latLng, map: map, visible:true, icon:"http://www.capprive.com/images/marker.png" }); markerArr.push(marker); bounds.extend(latLng); createBubble(marker,hpart,label,id,name,price,bedroom,bookmarktitle,bookmarkurl); markerS[id]=latLng; if(focalpoint == "1" && zoomlevel != "") { var countryVillaData = new Array(); countryVillaData[0]= lat; countryVillaData[1]= lng; countryVillaData[2]= zoomlevel; } } boundArray.push(bounds); map.fitBounds(bounds); countryDataArray.push(countryVillaData); if(countryVillaData != null && countryVillaData.length > 0) { //alert("lat:"+countryVillaData[0]+" long:"+countryVillaData[1]+" zoom:"+countryVillaData[2]); var newCenter = new google.maps.LatLng(countryVillaData[0], countryVillaData[1]); //alert(newCenter); map.setCenter(newCenter); if(countryVillaData[2] != "") { //alert("Zoom = "+countryVillaData[2]); //alert("old zoom: "+map.getZoom()); map.setZoom(parseInt(countryVillaData[2])); //alert("new zoom:"+map.getZoom()); } countryVillaData = null; } bounds = new google.maps.LatLngBounds(); if(boundArray.length == 1) { //setTimeout(function(){ map.fitBounds(boundArray[0]); },5000); } // $("#lblzoom").html("center:"+map.getCenter()+"|zoom:"+map.getZoom()); } else { alert("Sorry! No Villas available for " +country ); } } }); } function createBubble(marker,hpart,label,id,villaname,villaprice,villabedroom,bookmarktitle,bookmarkurl,istop) { if (!istop){ var istop; } google.maps.event.addListener(marker, "mouseover", function(e) { // var infoBox = new InfoBox({latlng: marker.getPosition(), map: map,src:hpart[0],img:hpart[2],lbl:label,villaid:id,name:villaname,price:villaprice,bedroom:villabedroom,bmtitle:bookmarktitle, bmurl:bookmarkurl,marker:marker}); //dotArray[id] = new InfoBox({latlng: marker.getPosition(), map: map,src:hpart[0],img:hpart[2],lbl:label,villaid:id,name:villaname,price:villaprice,bedroom:villabedroom,bmtitle:bookmarktitle, bmurl:bookmarkurl}); //alert('map'+map+'marker='+marker+' hpart='+hpart+' label='+label+' id='+id+' villaname='+villaname+' price='+villaprice+' bedroom='+villabedroom+' bookmarktite='+bookmarktitle+' bookmarkurl='+bookmarkurl); dotArray[id] = new InfoBox({latlng: marker.getPosition(), map: map,src:hpart[0],img:hpart[2],lbl:label,villaid:id,name:villaname,price:villaprice,bedroom:villabedroom,bmtitle:bookmarktitle, bmurl:bookmarkurl,marker:marker}); bubbleArr.push(dotArray[id]); }); google.maps.event.addListener(marker, "mouseout", function(e) { // var infoBox = new InfoBox({latlng: marker.getPosition(), map: map,src:hpart[0],img:hpart[2],lbl:label,villaid:id,name:villaname,price:villaprice,bedroom:villabedroom,bmtitle:bookmarktitle, bmurl:bookmarkurl,marker:marker}); //var infoBox = new InfoBox({latlng: marker.getPosition(), map: map,src:hpart[0],img:hpart[2],lbl:label,villaid:id,name:villaname,price:villaprice,bedroom:villabedroom,bmtitle:bookmarktitle, bmurl:bookmarkurl,marker:marker}); //var infoBox= new InfoBox; //bubbleArr.push(infoBox); clearMarkers(); popDownBubble(id,istop) }); // google.maps.event.trigger(marker, "click"); google.maps.event.addListener(marker, "click", function(e) { showSmallInfo(id,label,hpart[2],bookmarkurl,bookmarktitle) }); } function clearMarkers() { for(var i=0; i") data = data.replace("[break]","
") $("#txtId").val(villaid); $('#img343210').attr("src",""); $('#lblInfo').html(""); $('#img343210').attr("src",img); $('#dvInfo').css('display','block'); $('#lblInfo').html(data); return false; } function popUpBubble(div,istop) { var villaid = div; //alert (marker[villaid]); if (!istop) { var istop; } var itemInfo = document.getElementById("item-"+div); $("#frame-"+villaid).css("background-color","#90CE32"); $("#item-"+villaid).css("position","absolute"); $("#item-"+villaid).css("display","block"); $("#itemtxt-"+villaid).css("position","absolute"); $("#itemtxt-"+villaid).css("display","block"); if(currentView == "price") { $("#price-"+villaid).css("display","block"); $("#bedrooms-"+villaid).css("display","none"); $("#price1-"+villaid).css("display","block"); $("#bedrooms1-"+villaid).css("display","none"); } else { $("#price-"+villaid).css("display","none"); $("#bedrooms-"+villaid).css("display","block"); $("#price1-"+villaid).css("display","none"); $("#bedrooms1-"+villaid).css("display","block"); } //$("#bubbleItemText-"+villaid).css("display","block"); //$("#bubbleItemInfoText-"+villaid).css("display","block"); //var infoBox = new InfoBox({latlng: marker.getPosition(), map: map,src:hpart[0],img:hpart[2],lbl:label,villaid:id,name:villaname,price:villaprice,bedroom:villabedroom,bmtitle:bookmarktitle, bmurl:bookmarkurl,marker:marker}); //alert(markerS[villaid]); var latLng=markerS[villaid]; //markerP[villaid] = new google.maps.Marker({ position:latLng, map: map, visible:true, icon:"http://www.capprive.com/images/close.png" }); // google.maps.event.addListener(marker, "mouseover", function(e) { if (istop) { markerP[villaid] = new google.maps.Marker({ position:latLng, map: map, visible:true, icon:"http://www.capprive.com/images/marker2.png" }); } // }); //// hi.hide(); //var bubble = document.getElementById(div); //bubble.style.zIndex = zIndex; //$("#"+villaid).css("background-image","url(bubble-highlighted.png)"); //alert('vil'); zIndex = zIndex +1; return false; } function popDownBubble(div,istop) { if (!istop){ var istop; } //var itemInfo = document.getElementById("item-"+div); //itemInfo.style.display = 'none'; if(currentView == "price") { $("#price-"+div).css("display","block"); $("#bedrooms-"+div).css("display","none"); } else { $("#price-"+div).css("display","none"); $("#bedrooms-"+div).css("display","block"); } //$("#bubbleItemText-"+div).css("display","none"); //$("#bubbleItemInfoText-"+div).css("display","none"); $("#frame-"+div).css("background-color","#ffffff"); $("#item-"+div).css("display","none"); $("#item-"+div).css("position","relative"); $("#itemtxt-"+div).css("display","none"); $("#itemtxt-"+div).css("position","relative"); //$("#"+div).css("background-image","url(bubble.png)"); //wtf?? if (istop) { var mx=markerP[div]; mx.setMap(null); } return false; } $(document).ready(function() { // for fetch villa data $('#drpContinent').change(function() { var country = $(this).val(); $.ajax({ type: "POST", url: "ajax.php", data: "vila=1&country="+country, success: function(msg){ $('#drpContinent2').val($('#drpContinent').val()); $('#drpContinent3').val($('#drpContinent').val()); $('#drpCountry').html(msg); $('#drpCountry2').html(msg); $('#drpCountry3').html(msg); } }); }); $('#drpContinent2').change(function() { var country = $(this).val(); $.ajax({ type: "POST", url: "ajax.php", data: "vila=1&country="+country, success: function(msg){ $('#drpContinent3').val($('#drpContinent2').val()); $('#drpContinent').val($('#drpContinent2').val()); $('#drpCountry').html(msg); $('#drpCountry2').html(msg); $('#drpCountry3').html(msg); } }); }); $('#drpContinent3').change(function() { var country = $(this).val(); $.ajax({ type: "POST", url: "ajax.php", data: "vila=1&country="+country, success: function(msg){ $('#drpContinent').val($('#drpContinent3').val()); $('#drpContinent2').val($('#drpContinent3').val()); $('#drpCountry').html(msg); $('#drpCountry2').html(msg); $('#drpCountry3').html(msg); } }); }); $('#drpCountry').change(function() { var country = $(this).val(); $('#drpCountry2').val(country); $('#drpCountry3').val(country); }); $('#drpCountry2').change(function() { var country = $(this).val(); $('#drpCountry').val(country); $('#drpCountry3').val(country); }); $('#drpCountry3').change(function() { var country = $(this).val(); $('#drpCountry').val(country); $('#drpCountry2').val(country); }); // for search hide/show $("#searchbtn1").click(function(){ $("#searchbtn1").css("display","none") ; $("#search_div").slideDown(200); }); $("#searchbtnup").click(function(){ $("#search_div").slideUp(200); $("#searchbtn1").css("display","block") ; }); // for search hide/show $("#browsebtn1").click(function(){ $("#browsebtn1").css("display","none") ; $("#browse_div").slideDown(200); }); $("#browsebuttonup").click(function(){ $("#browse_div").slideUp(200); $("#browsebtn1").css("display","block") ; }); loadLocation(); $('#price').click(function() { currentView = "price"; sortimages('','villa_standard_price'); }); $('#bedrooms').click(function() { currentView = "bedrooms"; sortimages('','number_bedrooms'); }); Galleria.loadTheme('galleria/themes/classic/galleria.classic.js'); jQuery.preLoadImages("images/bg-uniqueexperience1.jpg","images/bg-about-contact1.jpg","images/bg-villarental1.jpg","images/bg-sking1.jpg","images/sking.png","images/bg-uniqe-box.png","images/bg-safari1.jpg","images/safari.png","images/bg-winecountry1.jpg", "images/winecountry.png","images/bg-golf1.jpg","images/golf.png","images/bg-highlands1.jpg","images/highlands.png","images/bg-privateisland1.jpg","images/privateisland.png"); }); function loadLocation() { var country = $('#drpContinent').val(); $.ajax({ type: "POST", url: "ajax.php", data: "vila=1&country="+country, success: function(msg){ $('#drpCountry').html(msg); $('#drpCountry2').html(msg); $('#drpCountry3').html(msg); } }); } function loadimages(country,orderby) { $.ajax({ type: "POST", url: "ajax.php", data: "loadimage=1&country="+country+"&orderby"+orderby, success: function(msg){ $('#content-holder').html(msg); } }); var villaScrollPos = 0; $(".ui-slider-handle").css("left",villaScrollPos+"%"); var maxScroll = $("#content-scroll").attr("scrollWidth") - $("#content-scroll").width(); $("#content-scroll").animate({scrollLeft: villaScrollPos * (maxScroll / 100) }, 1000); } function sortimages(country,orderby) { if(country == "") { var country = $("#drpCountry2").val(); } $.ajax({ type: "POST", url: "ajax.php", data: "loadimage=1&country="+country+"&orderby="+orderby, success: function(msg){ $('#content-holder').html(msg); } }); } function hideinfo(obj) { $('#'+obj).css('display','none'); return false; } function showBigInfo(directId) { if (!directId) { var directId; } var id = $("#txtId").val(); if(directId != "" && directId != 'indefined' && directId != null ) { id = directId; } else { id = $("#txtId").val(); } $.ajax({ type: "POST", url: "ajax.php", data: "showinformation=1&id="+id, success: function(msg){ hideinfo("dvInfo") ; $('#dvBiginfoCon').html(msg); $('#dvBiginfo').css('display','block'); //$('#dvvilladescription').jScrollPane(); $("#dvvilladescription").css("width","495"); //$('#dvvilladescription')[0].scrollTo(0); //$('#dvvillaintroduction').jScrollPane(); //$('#dvvillaintroduction')[0].scrollTo(0); var TabbedPanels1 = new Spry.Widget.TabbedPanels("TabbedPanels1"); $('.images').galleria({height:400,thumbnails:true,thumb_crop:false,thumb_fit:false,preload:1}); //$('.images').galleria({height:400}); if($$('.load_cal')){ $$('.load_cal').each(function(el){ var this_date=el.get('id'); var data=this_date.split('_'); load_calendar(el,data[0],data[1]); }); // once drawn, make calendars clickable activate_dates(); // calendar next and back buttons calendar_nav(); } } }); return false; } function submitBookNow() { var name = $("#booknowname").val(); var email = $("#booknowemail").val(); var phone = $("#booknowphone").val(); var message = $("#booknowmessage").val(); var villa_name = $("#hdnTxtName").val(); if(name == "" || name == "Your name") { $("#lblmessage1").css("color","#FF0000"); $("#lblmessage1").css("display","block"); $("#lblmessage1").html("Please enter your name"); return false; } if(email == "" || email == "Your email") { $("#lblmessage1").css("color","#FF0000"); $("#lblmessage1").css("display","block"); $("#lblmessage1").html("Please enter your email"); return false; } if(phone == "" || phone == "Your phone") { $("#lblmessage1").css("color","#FF0000"); $("#lblmessage1").css("display","block"); $("#lblmessage1").html("Please enter your phone"); return false; } if(message == "" || message == "Your message here") { $("#lblmessage1").css("color","#FF0000"); $("#lblmessage1").css("display","block"); $("#lblmessage1").html("Please enter your message"); return false; } $("#lblmessage1").css("display","none"); $("#lblmessage1").html(""); var names = name.split(" "); var first_name = ""; var last_name = ""; if(names.length > 1) { first_name = names[0]; for(var i=1;i 1) { first_name = names[0]; for(var i=1;i
"; popUpBubble(this.villaid); function showinfo(div,data,img,villaid,bmtitle,bmurl) { return function() { hideinfo("dvBiginfo"); div.style.zIndex = zIndex; zIndex = zIndex +1; data = data.replace("[break]","
"); data = data.replace("[break]","
"); bookmarklink = bmurl; bookmarktitle = bmtitle; $("#txtId").val(villaid); $('#img343210').attr("src",""); $('#lblInfo').html(""); $('#img343210').attr("src",img); $('#dvInfo').css('display','block'); $('#lblInfo').html(data); return false; }; } //google.maps.event.addDomListener(this.marker, 'click', showinfo(this.div_,this.label,this.image,this.villaid,this.bmtitle,this.bmurl)); /* var topDiv = document.createElement("div"); topDiv.style.textAlign = "right"; var closeImg = document.createElement("img"); closeImg.style.width = "32px"; closeImg.style.height = "32px"; closeImg.style.cursor = "pointer"; closeImg.src = "http://gmaps-samples.googlecode.com/svn/trunk/images/closebigger.gif"; topDiv.appendChild(closeImg); */ function removeInfoBox(ib) { return function() { popDownBubble(ib.villaid); ib.setMap(null); }; } google.maps.event.addDomListener(this.marker, 'mouseout', removeInfoBox(this)); //div.appendChild(topDiv); div.appendChild(contentDiv); div.style.display = 'none'; panes.floatPane.appendChild(div); this.panMap(); } else if (div.parentNode != panes.floatPane) { // The panes have changed. Move the div. div.parentNode.removeChild(div); panes.floatPane.appendChild(div); } else { // The panes have not changed, so no need to create or move the div. } } /* Pan the map to fit the InfoBox. */ InfoBox.prototype.panMap = function() { // if we go beyond map, pan map var map = this.map_; var bounds = map.getBounds(); if (!bounds) return; // The position of the infowindow var position = this.latlng_; // The dimension of the infowindow var iwWidth = this.width_; var iwHeight = this.height_; // The offset position of the infowindow var iwOffsetX = this.offsetHorizontal_; var iwOffsetY = this.offsetVertical_; // Padding on the infowindow var padX = 40; var padY = 40; // The degrees per pixel var mapDiv = map.getDiv(); var mapWidth = mapDiv.offsetWidth; var mapHeight = mapDiv.offsetHeight; var boundsSpan = bounds.toSpan(); var longSpan = boundsSpan.lng(); var latSpan = boundsSpan.lat(); var degPixelX = longSpan / mapWidth; var degPixelY = latSpan / mapHeight; // The bounds of the map var mapWestLng = bounds.getSouthWest().lng(); var mapEastLng = bounds.getNorthEast().lng(); var mapNorthLat = bounds.getNorthEast().lat(); var mapSouthLat = bounds.getSouthWest().lat(); // The bounds of the infowindow var iwWestLng = position.lng() + (iwOffsetX - padX) * degPixelX; var iwEastLng = position.lng() + (iwOffsetX + iwWidth + padX) * degPixelX; var iwNorthLat = position.lat() - (iwOffsetY - padY) * degPixelY; var iwSouthLat = position.lat() - (iwOffsetY + iwHeight + padY) * degPixelY; // calculate center shift var shiftLng = (iwWestLng < mapWestLng ? mapWestLng - iwWestLng : 0) + (iwEastLng > mapEastLng ? mapEastLng - iwEastLng : 0); var shiftLat = (iwNorthLat > mapNorthLat ? mapNorthLat - iwNorthLat : 0) + (iwSouthLat < mapSouthLat ? mapSouthLat - iwSouthLat : 0); // The center of the map var center = map.getCenter(); // The new map center var centerX = center.lng() - shiftLng; var centerY = center.lat() - shiftLat; // center the map to the new shifted center map.setCenter(new google.maps.LatLng(centerY, centerX)); // Remove the listener after panning is complete. if(this.boundsChangedListener_) { google.maps.event.removeListener(this.boundsChangedListener_); } this.boundsChangedListener_ = null; }; function CreateElement(tagName, properties) { var elem = document.createElement(tagName); for (var prop in properties) { if (prop == "style") elem.style.cssText = properties[prop]; else if (prop == "class") elem.className = properties[prop]; else elem.setAttribute(prop, properties[prop]); } return elem; } function setDropdowns(area,location) { //alert("I am in"); var country = area; //alert("area="+area+" location="+location); $.ajax({ type: "POST", url: "http://www.capprive.com/ajax.php", data: "vila=1&country="+country, success: function(msg){ //alert("ajax success"); $('#drpContinent').val(country); $('#drpContinent2').val(country); $('#drpContinent3').val(country); $('#drpCountry').html(msg); $('#drpCountry2').html(msg); $('#drpCountry3').html(msg); location = unescape(location); //alert("area="+area+" location="+location); $('#drpCountry').val(location); $('#drpCountry2').val(location); $('#drpCountry3').val(location); //directSearch(); } }); } function ZoomPanControl(map) { this.map = map; this.originalCenter = map.getCenter(); var t = this; var zoomPanContainer = CreateElement("div", { 'style': "position: relative; padding: 5px;" }); //Zoom Controls var zoomContainer = CreateElement("div", { 'style': "position: relative; width: 58px; height: 55px; -moz-user-select: none; overflow: hidden;" }); zoomPanContainer.appendChild(zoomContainer); div = CreateElement("div", { 'style': "position: absolute; left: 22px; top: 0px; width: 25px; height: 25px; overflow: hidden; background-image: url('http://www.capprive.com/images/zoomcontrol.png'); background-position: -17px -0px; background-repeat: no-repeat; cursor: pointer;", 'title': 'Zoom in' }); google.maps.event.addDomListener(div, "click", function() { t.zoom(ZoomDirection.IN); }); zoomContainer.appendChild(div); div = CreateElement("div", { 'style': "position: absolute; left: 22px; top: 27px; width: 25px; height: 25px; overflow: hidden; background-image: url('http://www.capprive.com/images/zoomcontrol.png'); background-position: -17px -30px; background-repeat: no-repeat; cursor: pointer;", 'title': 'Zoom out' }); google.maps.event.addDomListener(div, "click", function() { t.zoom(ZoomDirection.OUT); }); zoomContainer.appendChild(div); //Pan Controls var PanContainer = CreateElement("div", { 'style': "position: relative; left: 2px; top: 5px; width: 56px; height: 73px; padding: 5px; overflow: hidden;" }); zoomPanContainer.appendChild(PanContainer); var div = CreateElement("div", { 'style': "width: 56px; height: 56px; overflow: hidden;" }); div.appendChild(CreateElement("img", { 'alt': ' ', 'src': 'http://www.capprive.com/images/navcontrol.png', 'style': "position: absolute; left: 0px; top: -1px; -moz-user-select: none; border: 0px none; padding: 0px; margin: 0px; width: 67px; height: 73px;" })); PanContainer.appendChild(div); div = CreateElement("div", { 'style': "position: absolute; left: 2px; top: 25px;width: 25px; height: 23px; cursor: pointer; ", 'title': 'Pan left' }); div.innerHTML = "       "; google.maps.event.addDomListener(div, "click", function() { t.pan(PanDirection.LEFT); }); PanContainer.appendChild(div); div = CreateElement("div", { 'style': "position: absolute; left: 43px; top: 23px; width: 25px; height: 23px; cursor: pointer; line-height:25px;", 'title': 'Pan right' }); div.innerHTML = "       "; google.maps.event.addDomListener(div, "click", function() { t.pan(PanDirection.RIGHT); }); PanContainer.appendChild(div); div = CreateElement("div", { 'style': "position: absolute; left: 22px; top: 0px; width: 25px; height: 23px; cursor: pointer; line-height:25px;", 'title': 'Pan up' }); div.innerHTML = "       "; google.maps.event.addDomListener(div, "click", function() { t.pan(PanDirection.UP); }); PanContainer.appendChild(div); div = CreateElement("div", { 'style': "position: absolute; left: 22px; top: 45px; width: 25px; height: 23px; cursor: pointer; line-height:25px;", 'title': 'Pan down' }); div.innerHTML = "       "; google.maps.event.addDomListener(div, "click", function() { t.pan(PanDirection.DOWN); }); PanContainer.appendChild(div); /* div = CreateElement("div", { 'style': "position: absolute; left: 19px; top: 19px; width: 18.6667px; height: 18.6667px; cursor: pointer;", 'title': 'Reset center' }); google.maps.event.addDomListener(div, "click", function() { t.map.setCenter(t.originalCenter); }); PanContainer.appendChild(div); */ return zoomPanContainer; } /** @param {PanDirection} direction */ ZoomPanControl.prototype.pan = function(direction) { var panDistance = 50; if (direction == PanDirection.UP || direction == PanDirection.DOWN) { panDistance = Math.round(this.map.getDiv().offsetHeight / 2); this.map.panBy(0, direction == PanDirection.DOWN ? panDistance : -1 * panDistance); } else { panDistance = Math.round(this.map.getDiv().offsetWidth / 2); this.map.panBy(direction == PanDirection.RIGHT ? panDistance : -1 * panDistance, 0); } //$("#lblzoom").html("center:"+map.getCenter()+"|zoom:"+map.getZoom()); } /** @param {ZoomDirection} direction */ ZoomPanControl.prototype.zoom = function(direction) { var zoom = this.map.getZoom(); if (direction == ZoomDirection.IN && zoom < 19) this.map.setZoom(zoom + 1); else if (direction == ZoomDirection.OUT && zoom > 1) this.map.setZoom(zoom - 1); //$("#lblzoom").html("center:"+map.getCenter()+"|zoom:"+map.getZoom()); } /** @enum */ var PanDirection = { LEFT: 0, RIGHT: 1, UP: 3, DOWN: 4 } /** @enum */ var ZoomDirection = { IN: 0, OUT: 1 } window["missouristate"] = window["missouristate"] || {}; window["missouristate"]["web"] = window["missouristate"]["web"] || {}; window["missouristate"]["web"]["ZoomPanControl"] = ZoomPanControl; (function($) { var cache = []; // Arguments are image paths relative to the current page. $.preLoadImages = function() { var args_len = arguments.length; for (var i = args_len; i--;) { var cacheImage = document.createElement('img'); cacheImage.src = arguments[i]; cache.push(cacheImage); } } })(jQuery) /* SpryTabbedPanels.js - Revision: Spry Preview Release 1.4 */ // Copyright (c) 2006. Adobe Systems Incorporated. // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // * Neither the name of Adobe Systems Incorporated nor the names of its // contributors may be used to endorse or promote products derived from this // software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. var Spry; if (!Spry) Spry = {}; if (!Spry.Widget) Spry.Widget = {}; Spry.Widget.TabbedPanels = function(element, opts) { this.element = this.getElement(element); this.defaultTab = 0; // Show the first panel by default. this.bindings = []; this.tabSelectedClass = "TabbedPanelsTabSelected"; this.tabHoverClass = "TabbedPanelsTabHover"; this.tabFocusedClass = "TabbedPanelsTabFocused"; this.panelVisibleClass = "TabbedPanelsContentVisible"; this.focusElement = null; this.hasFocus = false; this.currentTabIndex = 0; this.enableKeyboardNavigation = true; Spry.Widget.TabbedPanels.setOptions(this, opts); // If the defaultTab is expressed as a number/index, convert // it to an element. if (typeof (this.defaultTab) == "number") { if (this.defaultTab < 0) this.defaultTab = 0; else { var count = this.getTabbedPanelCount(); if (this.defaultTab >= count) this.defaultTab = (count > 1) ? (count - 1) : 0; } this.defaultTab = this.getTabs()[this.defaultTab]; } // The defaultTab property is supposed to be the tab element for the tab content // to show by default. The caller is allowed to pass in the element itself or the // element's id, so we need to convert the current value to an element if necessary. if (this.defaultTab) this.defaultTab = this.getElement(this.defaultTab); this.attachBehaviors(); }; Spry.Widget.TabbedPanels.prototype.getElement = function(ele) { if (ele && typeof ele == "string") return document.getElementById(ele); return ele; } Spry.Widget.TabbedPanels.prototype.getElementChildren = function(element) { var children = []; var child = element.firstChild; while (child) { if (child.nodeType == 1 /* Node.ELEMENT_NODE */) children.push(child); child = child.nextSibling; } return children; }; Spry.Widget.TabbedPanels.prototype.addClassName = function(ele, className) { if (!ele || !className || (ele.className && ele.className.search(new RegExp("\\b" + className + "\\b")) != -1)) return; ele.className += (ele.className ? " " : "") + className; }; Spry.Widget.TabbedPanels.prototype.removeClassName = function(ele, className) { if (!ele || !className || (ele.className && ele.className.search(new RegExp("\\b" + className + "\\b")) == -1)) return; ele.className = ele.className.replace(new RegExp("\\s*\\b" + className + "\\b", "g"), ""); }; Spry.Widget.TabbedPanels.setOptions = function(obj, optionsObj, ignoreUndefinedProps) { if (!optionsObj) return; for (var optionName in optionsObj) { if (ignoreUndefinedProps && optionsObj[optionName] == undefined) continue; obj[optionName] = optionsObj[optionName]; } }; Spry.Widget.TabbedPanels.prototype.getTabGroup = function() { if (this.element) { var children = this.getElementChildren(this.element); if (children.length) return children[0]; } return null; }; Spry.Widget.TabbedPanels.prototype.getTabs = function() { var tabs = []; var tg = this.getTabGroup(); if (tg) tabs = this.getElementChildren(tg); return tabs; }; Spry.Widget.TabbedPanels.prototype.getContentPanelGroup = function() { if (this.element) { var children = this.getElementChildren(this.element); if (children.length > 1) return children[1]; } return null; }; Spry.Widget.TabbedPanels.prototype.getContentPanels = function() { var panels = []; var pg = this.getContentPanelGroup(); if (pg) panels = this.getElementChildren(pg); return panels; }; Spry.Widget.TabbedPanels.prototype.getIndex = function(ele, arr) { ele = this.getElement(ele); if (ele && arr && arr.length) { for (var i = 0; i < arr.length; i++) { if (ele == arr[i]) return i; } } return -1; }; Spry.Widget.TabbedPanels.prototype.getTabIndex = function(ele) { var i = this.getIndex(ele, this.getTabs()); if (i < 0) i = this.getIndex(ele, this.getContentPanels()); return i; }; Spry.Widget.TabbedPanels.prototype.getCurrentTabIndex = function() { return this.currentTabIndex; }; Spry.Widget.TabbedPanels.prototype.getTabbedPanelCount = function(ele) { return Math.min(this.getTabs().length, this.getContentPanels().length); }; Spry.Widget.TabbedPanels.addEventListener = function(element, eventType, handler, capture) { try { if (element.addEventListener) element.addEventListener(eventType, handler, capture); else if (element.attachEvent) element.attachEvent("on" + eventType, handler); } catch (e) {} }; Spry.Widget.TabbedPanels.prototype.onTabClick = function(e, tab) { this.showPanel(tab); }; Spry.Widget.TabbedPanels.prototype.onTabMouseOver = function(e, tab) { this.addClassName(tab, this.tabHoverClass); }; Spry.Widget.TabbedPanels.prototype.onTabMouseOut = function(e, tab) { this.removeClassName(tab, this.tabHoverClass); }; Spry.Widget.TabbedPanels.prototype.onTabFocus = function(e, tab) { this.hasFocus = true; this.addClassName(this.element, this.tabFocusedClass); }; Spry.Widget.TabbedPanels.prototype.onTabBlur = function(e, tab) { this.hasFocus = false; this.removeClassName(this.element, this.tabFocusedClass); }; Spry.Widget.TabbedPanels.ENTER_KEY = 13; Spry.Widget.TabbedPanels.SPACE_KEY = 32; Spry.Widget.TabbedPanels.prototype.onTabKeyDown = function(e, tab) { var key = e.keyCode; if (!this.hasFocus || (key != Spry.Widget.TabbedPanels.ENTER_KEY && key != Spry.Widget.TabbedPanels.SPACE_KEY)) return true; this.showPanel(tab); if (e.stopPropagation) e.stopPropagation(); if (e.preventDefault) e.preventDefault(); return false; }; Spry.Widget.TabbedPanels.prototype.preorderTraversal = function(root, func) { var stopTraversal = false; if (root) { stopTraversal = func(root); if (root.hasChildNodes()) { var child = root.firstChild; while (!stopTraversal && child) { stopTraversal = this.preorderTraversal(child, func); try { child = child.nextSibling; } catch (e) { child = null; } } } } return stopTraversal; }; Spry.Widget.TabbedPanels.prototype.addPanelEventListeners = function(tab, panel) { var self = this; Spry.Widget.TabbedPanels.addEventListener(tab, "click", function(e) { return self.onTabClick(e, tab); }, false); Spry.Widget.TabbedPanels.addEventListener(tab, "mouseover", function(e) { return self.onTabMouseOver(e, tab); }, false); Spry.Widget.TabbedPanels.addEventListener(tab, "mouseout", function(e) { return self.onTabMouseOut(e, tab); }, false); if (this.enableKeyboardNavigation) { // XXX: IE doesn't allow the setting of tabindex dynamically. This means we can't // rely on adding the tabindex attribute if it is missing to enable keyboard navigation // by default. // Find the first element within the tab container that has a tabindex or the first // anchor tag. var tabIndexEle = null; var tabAnchorEle = null; this.preorderTraversal(tab, function(node) { if (node.nodeType == 1 /* NODE.ELEMENT_NODE */) { var tabIndexAttr = tab.attributes.getNamedItem("tabindex"); if (tabIndexAttr) { tabIndexEle = node; return true; } if (!tabAnchorEle && node.nodeName.toLowerCase() == "a") tabAnchorEle = node; } return false; }); if (tabIndexEle) this.focusElement = tabIndexEle; else if (tabAnchorEle) this.focusElement = tabAnchorEle; if (this.focusElement) { Spry.Widget.TabbedPanels.addEventListener(this.focusElement, "focus", function(e) { return self.onTabFocus(e, tab); }, false); Spry.Widget.TabbedPanels.addEventListener(this.focusElement, "blur", function(e) { return self.onTabBlur(e, tab); }, false); Spry.Widget.TabbedPanels.addEventListener(this.focusElement, "keydown", function(e) { return self.onTabKeyDown(e, tab); }, false); } } }; Spry.Widget.TabbedPanels.prototype.showPanel = function(elementOrIndex) { var tpIndex = -1; if (typeof elementOrIndex == "number") tpIndex = elementOrIndex; else // Must be the element for the tab or content panel. tpIndex = this.getTabIndex(elementOrIndex); if (!tpIndex < 0 || tpIndex >= this.getTabbedPanelCount()) return; var tabs = this.getTabs(); var panels = this.getContentPanels(); var numTabbedPanels = Math.max(tabs.length, panels.length); for (var i = 0; i < numTabbedPanels; i++) { if (i != tpIndex) { if (tabs[i]) this.removeClassName(tabs[i], this.tabSelectedClass); if (panels[i]) { this.removeClassName(panels[i], this.panelVisibleClass); panels[i].style.display = "none"; } } } this.addClassName(tabs[tpIndex], this.tabSelectedClass); this.addClassName(panels[tpIndex], this.panelVisibleClass); panels[tpIndex].style.display = "block"; this.currentTabIndex = tpIndex; }; Spry.Widget.TabbedPanels.prototype.attachBehaviors = function(element) { var tabs = this.getTabs(); var panels = this.getContentPanels(); var panelCount = this.getTabbedPanelCount(); for (var i = 0; i < panelCount; i++) this.addPanelEventListeners(tabs[i], panels[i]); this.showPanel(this.defaultTab); }; /* Copyright (c) 2009 Kelvin Luck (kelvin AT kelvinluck DOT com || http://www.kelvinluck.com) * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. * * See http://kelvinluck.com/assets/jquery/jScrollPane/ * $Id: jScrollPane.js 93 2010-06-01 08:17:28Z kelvin.luck $ */ /** * Replace the vertical scroll bars on any matched elements with a fancy * styleable (via CSS) version. With JS disabled the elements will * gracefully degrade to the browsers own implementation of overflow:auto. * If the mousewheel plugin has been included on the page then the scrollable areas will also * respond to the mouse wheel. * * @example jQuery(".scroll-pane").jScrollPane(); * * @name jScrollPane * @type jQuery * @param Object settings hash with options, described below. * scrollbarWidth - The width of the generated scrollbar in pixels * scrollbarMargin - The amount of space to leave on the side of the scrollbar in pixels * wheelSpeed - The speed the pane will scroll in response to the mouse wheel in pixels * showArrows - Whether to display arrows for the user to scroll with * arrowSize - The height of the arrow buttons if showArrows=true * animateTo - Whether to animate when calling scrollTo and scrollBy * dragMinHeight - The minimum height to allow the drag bar to be * dragMaxHeight - The maximum height to allow the drag bar to be * animateInterval - The interval in milliseconds to update an animating scrollPane (default 100) * animateStep - The amount to divide the remaining scroll distance by when animating (default 3) * maintainPosition- Whether you want the contents of the scroll pane to maintain it's position when you re-initialise it - so it doesn't scroll as you add more content (default true) * tabIndex - The tabindex for this jScrollPane to control when it is tabbed to when navigating via keyboard (default 0) * enableKeyboardNavigation - Whether to allow keyboard scrolling of this jScrollPane when it is focused (default true) * animateToInternalLinks - Whether the move to an internal link (e.g. when it's focused by tabbing or by a hash change in the URL) should be animated or instant (default false) * scrollbarOnLeft - Display the scrollbar on the left side? (needs stylesheet changes, see examples.html) * reinitialiseOnImageLoad - Whether the jScrollPane should automatically re-initialise itself when any contained images are loaded (default false) * topCapHeight - The height of the "cap" area between the top of the jScrollPane and the top of the track/ buttons * bottomCapHeight - The height of the "cap" area between the bottom of the jScrollPane and the bottom of the track/ buttons * observeHash - Whether jScrollPane should attempt to automagically scroll to the correct place when an anchor inside the scrollpane is linked to (default true) * @return jQuery * @cat Plugins/jScrollPane * @author Kelvin Luck (kelvin AT kelvinluck DOT com || http://www.kelvinluck.com) */ (function($) { $.jScrollPane = { active : [] }; $.fn.jScrollPane = function(settings) { settings = $.extend({}, $.fn.jScrollPane.defaults, settings); var rf = function() { return false; }; return this.each( function() { var $this = $(this); var paneEle = this; var currentScrollPosition = 0; var paneWidth; var paneHeight; var trackHeight; var trackOffset = settings.topCapHeight; var $container; if ($(this).parent().is('.jScrollPaneContainer')) { $container = $(this).parent(); currentScrollPosition = settings.maintainPosition ? $this.position().top : 0; var $c = $(this).parent(); paneWidth = $c.innerWidth(); paneHeight = $c.outerHeight(); $('>.jScrollPaneTrack, >.jScrollArrowUp, >.jScrollArrowDown, >.jScrollCap', $c).remove(); $this.css({'top':0}); } else { $this.data('originalStyleTag', $this.attr('style')); // Switch the element's overflow to hidden to ensure we get the size of the element without the scrollbars [http://plugins.jquery.com/node/1208] $this.css('overflow', 'hidden'); this.originalPadding = $this.css('paddingTop') + ' ' + $this.css('paddingRight') + ' ' + $this.css('paddingBottom') + ' ' + $this.css('paddingLeft'); this.originalSidePaddingTotal = (parseInt($this.css('paddingLeft')) || 0) + (parseInt($this.css('paddingRight')) || 0); paneWidth = $this.innerWidth(); paneHeight = $this.innerHeight(); $container = $('
') .attr({'className':'jScrollPaneContainer'}) .css( { 'height':paneHeight+'px', 'width':paneWidth+'px' } ); if (settings.enableKeyboardNavigation) { $container.attr( 'tabindex', settings.tabIndex ); } $this.wrap($container); $container = $this.parent(); // deal with text size changes (if the jquery.em plugin is included) // and re-initialise the scrollPane so the track maintains the // correct size $(document).bind( 'emchange', function(e, cur, prev) { $this.jScrollPane(settings); } ); } trackHeight = paneHeight; if (settings.reinitialiseOnImageLoad) { // code inspired by jquery.onImagesLoad: http://plugins.jquery.com/project/onImagesLoad // except we re-initialise the scroll pane when each image loads so that the scroll pane is always up to size... // TODO: Do I even need to store it in $.data? Is a local variable here the same since I don't pass the reinitialiseOnImageLoad when I re-initialise? var $imagesToLoad = $.data(paneEle, 'jScrollPaneImagesToLoad') || $('img', $this); var loadedImages = []; if ($imagesToLoad.length) { $imagesToLoad.each(function(i, val) { $(this).bind('load readystatechange', function() { if($.inArray(i, loadedImages) == -1){ //don't double count images loadedImages.push(val); //keep a record of images we've seen $imagesToLoad = $.grep($imagesToLoad, function(n, i) { return n != val; }); $.data(paneEle, 'jScrollPaneImagesToLoad', $imagesToLoad); var s2 = $.extend(settings, {reinitialiseOnImageLoad:false}); $this.jScrollPane(s2); // re-initialise } }).each(function(i, val) { if(this.complete || this.complete===undefined) { //needed for potential cached images this.src = this.src; } }); }); }; } var p = this.originalSidePaddingTotal; var realPaneWidth = paneWidth - settings.scrollbarWidth - settings.scrollbarMargin - p; var cssToApply = { 'height':'auto', 'width': realPaneWidth + 'px' } if(settings.scrollbarOnLeft) { cssToApply.paddingLeft = settings.scrollbarMargin + settings.scrollbarWidth + 'px'; } else { cssToApply.paddingRight = settings.scrollbarMargin + 'px'; } $this.css(cssToApply); var contentHeight = $this.outerHeight(); var percentInView = paneHeight / contentHeight; var isScrollable = percentInView < .99; $container[isScrollable ? 'addClass' : 'removeClass']('jScrollPaneScrollable'); if (isScrollable) { $container.append( $('
').addClass('jScrollCap jScrollCapTop').css({height:settings.topCapHeight}), $('
').attr({'className':'jScrollPaneTrack'}).css({'width':settings.scrollbarWidth+'px'}).append( $('
').attr({'className':'jScrollPaneDrag'}).css({'width':settings.scrollbarWidth+'px'}).append( $('
').attr({'className':'jScrollPaneDragTop'}).css({'width':settings.scrollbarWidth+'px'}), $('
').attr({'className':'jScrollPaneDragBottom'}).css({'width':settings.scrollbarWidth+'px'}) ) ), $('
').addClass('jScrollCap jScrollCapBottom').css({height:settings.bottomCapHeight}) ); var $track = $('>.jScrollPaneTrack', $container); var $drag = $('>.jScrollPaneTrack .jScrollPaneDrag', $container); var currentArrowDirection; var currentArrowTimerArr = [];// Array is used to store timers since they can stack up when dealing with keyboard events. This ensures all timers are cleaned up in the end, preventing an acceleration bug. var currentArrowInc; var whileArrowButtonDown = function() { if (currentArrowInc > 4 || currentArrowInc % 4 == 0) { positionDrag(dragPosition + currentArrowDirection * mouseWheelMultiplier); } currentArrowInc++; }; if (settings.enableKeyboardNavigation) { $container.bind( 'keydown.jscrollpane', function(e) { switch (e.keyCode) { case 38: //up currentArrowDirection = -1; currentArrowInc = 0; whileArrowButtonDown(); currentArrowTimerArr[currentArrowTimerArr.length] = setInterval(whileArrowButtonDown, 100); return false; case 40: //down currentArrowDirection = 1; currentArrowInc = 0; whileArrowButtonDown(); currentArrowTimerArr[currentArrowTimerArr.length] = setInterval(whileArrowButtonDown, 100); return false; case 33: // page up case 34: // page down // TODO return false; default: } } ).bind( 'keyup.jscrollpane', function(e) { if (e.keyCode == 38 || e.keyCode == 40) { for (var i = 0; i < currentArrowTimerArr.length; i++) { clearInterval(currentArrowTimerArr[i]); } return false; } } ); } if (settings.showArrows) { var currentArrowButton; var currentArrowInterval; var onArrowMouseUp = function(event) { $('html').unbind('mouseup', onArrowMouseUp); currentArrowButton.removeClass('jScrollActiveArrowButton'); clearInterval(currentArrowInterval); }; var onArrowMouseDown = function() { $('html').bind('mouseup', onArrowMouseUp); currentArrowButton.addClass('jScrollActiveArrowButton'); currentArrowInc = 0; whileArrowButtonDown(); currentArrowInterval = setInterval(whileArrowButtonDown, 100); }; $container .append( $('') .attr( { 'href':'javascript:;', 'className':'jScrollArrowUp', 'tabindex':-1 } ) .css( { 'width':settings.scrollbarWidth+'px', 'top':settings.topCapHeight + 'px' } ) .html('Scroll up') .bind('mousedown', function() { currentArrowButton = $(this); currentArrowDirection = -1; onArrowMouseDown(); this.blur(); return false; }) .bind('click', rf), $('') .attr( { 'href':'javascript:;', 'className':'jScrollArrowDown', 'tabindex':-1 } ) .css( { 'width':settings.scrollbarWidth+'px', 'bottom':settings.bottomCapHeight + 'px' } ) .html('Scroll down') .bind('mousedown', function() { currentArrowButton = $(this); currentArrowDirection = 1; onArrowMouseDown(); this.blur(); return false; }) .bind('click', rf) ); var $upArrow = $('>.jScrollArrowUp', $container); var $downArrow = $('>.jScrollArrowDown', $container); } if (settings.arrowSize) { trackHeight = paneHeight - settings.arrowSize - settings.arrowSize; trackOffset += settings.arrowSize; } else if ($upArrow) { var topArrowHeight = $upArrow.height(); settings.arrowSize = topArrowHeight; trackHeight = paneHeight - topArrowHeight - $downArrow.height(); trackOffset += topArrowHeight; } trackHeight -= settings.topCapHeight + settings.bottomCapHeight; $track.css({'height': trackHeight+'px', top:trackOffset+'px'}) var $pane = $(this).css({'position':'absolute', 'overflow':'visible'}); var currentOffset; var maxY; var mouseWheelMultiplier; // store this in a seperate variable so we can keep track more accurately than just updating the css property.. var dragPosition = 0; var dragMiddle = percentInView*paneHeight/2; // pos function borrowed from tooltip plugin and adapted... var getPos = function (event, c) { var p = c == 'X' ? 'Left' : 'Top'; return event['page' + c] || (event['client' + c] + (document.documentElement['scroll' + p] || document.body['scroll' + p])) || 0; }; var ignoreNativeDrag = function() { return false; }; var initDrag = function() { ceaseAnimation(); currentOffset = $drag.offset(false); currentOffset.top -= dragPosition; maxY = trackHeight - $drag[0].offsetHeight; mouseWheelMultiplier = 2 * settings.wheelSpeed * maxY / contentHeight; }; var onStartDrag = function(event) { initDrag(); dragMiddle = getPos(event, 'Y') - dragPosition - currentOffset.top; $('html').bind('mouseup', onStopDrag).bind('mousemove', updateScroll).bind('mouseleave', onStopDrag) if ($.browser.msie) { $('html').bind('dragstart', ignoreNativeDrag).bind('selectstart', ignoreNativeDrag); } return false; }; var onStopDrag = function() { $('html').unbind('mouseup', onStopDrag).unbind('mousemove', updateScroll); dragMiddle = percentInView*paneHeight/2; if ($.browser.msie) { $('html').unbind('dragstart', ignoreNativeDrag).unbind('selectstart', ignoreNativeDrag); } }; var positionDrag = function(destY) { $container.scrollTop(0); destY = destY < 0 ? 0 : (destY > maxY ? maxY : destY); dragPosition = destY; $drag.css({'top':destY+'px'}); var p = destY / maxY; $this.data('jScrollPanePosition', (paneHeight-contentHeight)*-p); $pane.css({'top':((paneHeight-contentHeight)*p) + 'px'}); $this.trigger('scroll'); if (settings.showArrows) { $upArrow[destY == 0 ? 'addClass' : 'removeClass']('disabled'); $downArrow[destY == maxY ? 'addClass' : 'removeClass']('disabled'); } }; var updateScroll = function(e) { positionDrag(getPos(e, 'Y') - currentOffset.top - dragMiddle); }; var dragH = Math.max(Math.min(percentInView*(paneHeight-settings.arrowSize*2), settings.dragMaxHeight), settings.dragMinHeight); $drag.css( {'height':dragH+'px'} ).bind('mousedown', onStartDrag); var trackScrollInterval; var trackScrollInc; var trackScrollMousePos; var doTrackScroll = function() { if (trackScrollInc > 8 || trackScrollInc%4==0) { positionDrag((dragPosition - ((dragPosition - trackScrollMousePos) / 2))); } trackScrollInc ++; }; var onStopTrackClick = function() { clearInterval(trackScrollInterval); $('html').unbind('mouseup', onStopTrackClick).unbind('mousemove', onTrackMouseMove); }; var onTrackMouseMove = function(event) { trackScrollMousePos = getPos(event, 'Y') - currentOffset.top - dragMiddle; }; var onTrackClick = function(event) { initDrag(); onTrackMouseMove(event); trackScrollInc = 0; $('html').bind('mouseup', onStopTrackClick).bind('mousemove', onTrackMouseMove); trackScrollInterval = setInterval(doTrackScroll, 100); doTrackScroll(); return false; }; $track.bind('mousedown', onTrackClick); $container.bind( 'mousewheel', function (event, delta) { delta = delta || (event.wheelDelta ? event.wheelDelta / 120 : (event.detail) ? -event.detail/3 : 0); initDrag(); ceaseAnimation(); var d = dragPosition; positionDrag(dragPosition - delta * mouseWheelMultiplier); var dragOccured = d != dragPosition; return !dragOccured; } ); var _animateToPosition; var _animateToInterval; function animateToPosition() { var diff = (_animateToPosition - dragPosition) / settings.animateStep; if (diff > 1 || diff < -1) { positionDrag(dragPosition + diff); } else { positionDrag(_animateToPosition); ceaseAnimation(); } } var ceaseAnimation = function() { if (_animateToInterval) { clearInterval(_animateToInterval); delete _animateToPosition; } }; var scrollTo = function(pos, preventAni) { if (typeof pos == "string") { // Legal hash values aren't necessarily legal jQuery selectors so we need to catch any // errors from the lookup... try { $e = $(pos, $this); } catch (err) { return; } if (!$e.length) return; pos = $e.offset().top - $this.offset().top; } ceaseAnimation(); var maxScroll = contentHeight - paneHeight; pos = pos > maxScroll ? maxScroll : pos; $this.data('jScrollPaneMaxScroll', maxScroll); var destDragPosition = pos/maxScroll * maxY; if (preventAni || !settings.animateTo) { positionDrag(destDragPosition); } else { $container.scrollTop(0); _animateToPosition = destDragPosition; _animateToInterval = setInterval(animateToPosition, settings.animateInterval); } }; $this[0].scrollTo = scrollTo; $this[0].scrollBy = function(delta) { var currentPos = -parseInt($pane.css('top')) || 0; scrollTo(currentPos + delta); }; initDrag(); scrollTo(-currentScrollPosition, true); // Deal with it when the user tabs to a link or form element within this scrollpane $('*', this).bind( 'focus', function(event) { var $e = $(this); // loop through parents adding the offset top of any elements that are relatively positioned between // the focused element and the jScrollPaneContainer so we can get the true distance from the top // of the focused element to the top of the scrollpane... var eleTop = 0; var preventInfiniteLoop = 100; while ($e[0] != $this[0]) { eleTop += $e.position().top; $e = $e.offsetParent(); if (!preventInfiniteLoop--) { return; } } var viewportTop = -parseInt($pane.css('top')) || 0; var maxVisibleEleTop = viewportTop + paneHeight; var eleInView = eleTop > viewportTop && eleTop < maxVisibleEleTop; if (!eleInView) { var destPos = eleTop - settings.scrollbarMargin; if (eleTop > viewportTop) { // element is below viewport - scroll so it is at bottom. destPos += $(this).height() + 15 + settings.scrollbarMargin - paneHeight; } scrollTo(destPos); } } ) if (settings.observeHash) { if (location.hash && location.hash.length > 1) { setTimeout(function(){ scrollTo(location.hash); }, $.browser.safari ? 100 : 0); } // use event delegation to listen for all clicks on links and hijack them if they are links to // anchors within our content... $(document).bind('click', function(e){ $target = $(e.target); if ($target.is('a')) { var h = $target.attr('href'); if (h && h.substr(0, 1) == '#' && h.length > 1) { setTimeout(function(){ scrollTo(h, !settings.animateToInternalLinks); }, $.browser.safari ? 100 : 0); } } }); } // Deal with dragging and selecting text to make the scrollpane scroll... function onSelectScrollMouseDown(e) { $(document).bind('mousemove.jScrollPaneDragging', onTextSelectionScrollMouseMove); $(document).bind('mouseup.jScrollPaneDragging', onSelectScrollMouseUp); } var textDragDistanceAway; var textSelectionInterval; function onTextSelectionInterval() { direction = textDragDistanceAway < 0 ? -1 : 1; $this[0].scrollBy(textDragDistanceAway / 2); } function clearTextSelectionInterval() { if (textSelectionInterval) { clearInterval(textSelectionInterval); textSelectionInterval = undefined; } } function onTextSelectionScrollMouseMove(e) { var offset = $this.parent().offset().top; var maxOffset = offset + paneHeight; var mouseOffset = getPos(e, 'Y'); textDragDistanceAway = mouseOffset < offset ? mouseOffset - offset : (mouseOffset > maxOffset ? mouseOffset - maxOffset : 0); if (textDragDistanceAway == 0) { clearTextSelectionInterval(); } else { if (!textSelectionInterval) { textSelectionInterval = setInterval(onTextSelectionInterval, 100); } } } function onSelectScrollMouseUp(e) { $(document) .unbind('mousemove.jScrollPaneDragging') .unbind('mouseup.jScrollPaneDragging'); clearTextSelectionInterval(); } $container.bind('mousedown.jScrollPane', onSelectScrollMouseDown); $.jScrollPane.active.push($this[0]); } else { $this.css( { 'height':paneHeight+'px', 'width':paneWidth-this.originalSidePaddingTotal+'px', 'padding':this.originalPadding } ); $this[0].scrollTo = $this[0].scrollBy = function() {}; // clean up listeners $this.parent().unbind('mousewheel').unbind('mousedown.jScrollPane').unbind('keydown.jscrollpane').unbind('keyup.jscrollpane'); } } ) }; $.fn.jScrollPaneRemove = function() { $(this).each(function() { $this = $(this); var $c = $this.parent(); if ($c.is('.jScrollPaneContainer')) { $this.css( { 'top':'', 'height':'', 'width':'', 'padding':'', 'overflow':'', 'position':'' } ); $this.attr('style', $this.data('originalStyleTag')); $c.after($this).remove(); } }); } $.fn.jScrollPane.defaults = { scrollbarWidth : 10, scrollbarMargin : 5, wheelSpeed : 18, showArrows : false, arrowSize : 0, animateTo : false, dragMinHeight : 1, dragMaxHeight : 99999, animateInterval : 100, animateStep: 3, maintainPosition: true, scrollbarOnLeft: false, reinitialiseOnImageLoad: false, tabIndex : 0, enableKeyboardNavigation: true, animateToInternalLinks: false, topCapHeight: 0, bottomCapHeight: 0, observeHash: true }; // clean up the scrollTo expandos $(window) .bind('unload', function() { var els = $.jScrollPane.active; for (var i=0; i, My Object Oriented (JavaScript) Tools. Copyright (c) 2006-2009 Valerio Proietti, , MIT Style License. var MooTools={version:"1.2.4",build:"0d9113241a90b9cd5643b926795852a2026710d4"};var Native=function(k){k=k||{};var a=k.name;var i=k.legacy;var b=k.protect; var c=k.implement;var h=k.generics;var f=k.initialize;var g=k.afterImplement||function(){};var d=f||i;h=h!==false;d.constructor=Native;d.$family={name:"native"}; if(i&&f){d.prototype=i.prototype;}d.prototype.constructor=d;if(a){var e=a.toLowerCase();d.prototype.$family={name:e};Native.typize(d,e);}var j=function(n,l,o,m){if(!b||m||!n.prototype[l]){n.prototype[l]=o; }if(h){Native.genericize(n,l,b);}g.call(n,l,o);return n;};d.alias=function(n,l,p){if(typeof n=="string"){var o=this.prototype[n];if((n=o)){return j(this,l,n,p); }}for(var m in n){this.alias(m,n[m],l);}return this;};d.implement=function(m,l,o){if(typeof m=="string"){return j(this,m,l,o);}for(var n in m){j(this,n,m[n],l); }return this;};if(c){d.implement(c);}return d;};Native.genericize=function(b,c,a){if((!a||!b[c])&&typeof b.prototype[c]=="function"){b[c]=function(){var d=Array.prototype.slice.call(arguments); return b.prototype[c].apply(d.shift(),d);};}};Native.implement=function(d,c){for(var b=0,a=d.length;b-1:this.indexOf(a)>-1;},trim:function(){return this.replace(/^\s+|\s+$/g,"");},clean:function(){return this.replace(/\s+/g," ").trim(); },camelCase:function(){return this.replace(/-\D/g,function(a){return a.charAt(1).toUpperCase();});},hyphenate:function(){return this.replace(/[A-Z]/g,function(a){return("-"+a.charAt(0).toLowerCase()); });},capitalize:function(){return this.replace(/\b[a-z]/g,function(a){return a.toUpperCase();});},escapeRegExp:function(){return this.replace(/([-.*+?^${}()|[\]\/\\])/g,"\\$1"); },toInt:function(a){return parseInt(this,a||10);},toFloat:function(){return parseFloat(this);},hexToRgb:function(b){var a=this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/); return(a)?a.slice(1).hexToRgb(b):null;},rgbToHex:function(b){var a=this.match(/\d{1,3}/g);return(a)?a.rgbToHex(b):null;},stripScripts:function(b){var a=""; var c=this.replace(/]*>([\s\S]*?)<\/script>/gi,function(){a+=arguments[1]+"\n";return"";});if(b===true){$exec(a);}else{if($type(b)=="function"){b(a,c); }}return c;},substitute:function(a,b){return this.replace(b||(/\\?\{([^{}]+)\}/g),function(d,c){if(d.charAt(0)=="\\"){return d.slice(1);}return(a[c]!=undefined)?a[c]:""; });}});Hash.implement({has:Object.prototype.hasOwnProperty,keyOf:function(b){for(var a in this){if(this.hasOwnProperty(a)&&this[a]===b){return a;}}return null; },hasValue:function(a){return(Hash.keyOf(this,a)!==null);},extend:function(a){Hash.each(a||{},function(c,b){Hash.set(this,b,c);},this);return this;},combine:function(a){Hash.each(a||{},function(c,b){Hash.include(this,b,c); },this);return this;},erase:function(a){if(this.hasOwnProperty(a)){delete this[a];}return this;},get:function(a){return(this.hasOwnProperty(a))?this[a]:null; },set:function(a,b){if(!this[a]||this.hasOwnProperty(a)){this[a]=b;}return this;},empty:function(){Hash.each(this,function(b,a){delete this[a];},this); return this;},include:function(a,b){if(this[a]==undefined){this[a]=b;}return this;},map:function(b,c){var a=new Hash;Hash.each(this,function(e,d){a.set(d,b.call(c,e,d,this)); },this);return a;},filter:function(b,c){var a=new Hash;Hash.each(this,function(e,d){if(b.call(c,e,d,this)){a.set(d,e);}},this);return a;},every:function(b,c){for(var a in this){if(this.hasOwnProperty(a)&&!b.call(c,this[a],a)){return false; }}return true;},some:function(b,c){for(var a in this){if(this.hasOwnProperty(a)&&b.call(c,this[a],a)){return true;}}return false;},getKeys:function(){var a=[]; Hash.each(this,function(c,b){a.push(b);});return a;},getValues:function(){var a=[];Hash.each(this,function(b){a.push(b);});return a;},toQueryString:function(a){var b=[]; Hash.each(this,function(f,e){if(a){e=a+"["+e+"]";}var d;switch($type(f)){case"object":d=Hash.toQueryString(f,e);break;case"array":var c={};f.each(function(h,g){c[g]=h; });d=Hash.toQueryString(c,e);break;default:d=e+"="+encodeURIComponent(f);}if(f!=undefined){b.push(d);}});return b.join("&");}});Hash.alias({keyOf:"indexOf",hasValue:"contains"}); var Event=new Native({name:"Event",initialize:function(a,f){f=f||window;var k=f.document;a=a||f.event;if(a.$extended){return a;}this.$extended=true;var j=a.type; var g=a.target||a.srcElement;while(g&&g.nodeType==3){g=g.parentNode;}if(j.test(/key/)){var b=a.which||a.keyCode;var m=Event.Keys.keyOf(b);if(j=="keydown"){var d=b-111; if(d>0&&d<13){m="f"+d;}}m=m||String.fromCharCode(b).toLowerCase();}else{if(j.match(/(click|mouse|menu)/i)){k=(!k.compatMode||k.compatMode=="CSS1Compat")?k.html:k.body; var i={x:a.pageX||a.clientX+k.scrollLeft,y:a.pageY||a.clientY+k.scrollTop};var c={x:(a.pageX)?a.pageX-f.pageXOffset:a.clientX,y:(a.pageY)?a.pageY-f.pageYOffset:a.clientY}; if(j.match(/DOMMouseScroll|mousewheel/)){var h=(a.wheelDelta)?a.wheelDelta/120:-(a.detail||0)/3;}var e=(a.which==3)||(a.button==2);var l=null;if(j.match(/over|out/)){switch(j){case"mouseover":l=a.relatedTarget||a.fromElement; break;case"mouseout":l=a.relatedTarget||a.toElement;}if(!(function(){while(l&&l.nodeType==3){l=l.parentNode;}return true;}).create({attempt:Browser.Engine.gecko})()){l=false; }}}}return $extend(this,{event:a,type:j,page:i,client:c,rightClick:e,wheel:h,relatedTarget:l,target:g,code:b,key:m,shift:a.shiftKey,control:a.ctrlKey,alt:a.altKey,meta:a.metaKey}); }});Event.Keys=new Hash({enter:13,up:38,down:40,left:37,right:39,esc:27,space:32,backspace:8,tab:9,"delete":46});Event.implement({stop:function(){return this.stopPropagation().preventDefault(); },stopPropagation:function(){if(this.event.stopPropagation){this.event.stopPropagation();}else{this.event.cancelBubble=true;}return this;},preventDefault:function(){if(this.event.preventDefault){this.event.preventDefault(); }else{this.event.returnValue=false;}return this;}});function Class(b){if(b instanceof Function){b={initialize:b};}var a=function(){Object.reset(this);if(a._prototyping){return this; }this._current=$empty;var c=(this.initialize)?this.initialize.apply(this,arguments):this;delete this._current;delete this.caller;return c;}.extend(this); a.implement(b);a.constructor=Class;a.prototype.constructor=a;return a;}Function.prototype.protect=function(){this._protected=true;return this;};Object.reset=function(a,c){if(c==null){for(var e in a){Object.reset(a,e); }return a;}delete a[c];switch($type(a[c])){case"object":var d=function(){};d.prototype=a[c];var b=new d;a[c]=Object.reset(b);break;case"array":a[c]=$unlink(a[c]); break;}return a;};new Native({name:"Class",initialize:Class}).extend({instantiate:function(b){b._prototyping=true;var a=new b;delete b._prototyping;return a; },wrap:function(a,b,c){if(c._origin){c=c._origin;}return function(){if(c._protected&&this._current==null){throw new Error('The method "'+b+'" cannot be called.'); }var e=this.caller,f=this._current;this.caller=f;this._current=arguments.callee;var d=c.apply(this,arguments);this._current=f;this.caller=e;return d;}.extend({_owner:a,_origin:c,_name:b}); }});Class.implement({implement:function(a,d){if($type(a)=="object"){for(var e in a){this.implement(e,a[e]);}return this;}var f=Class.Mutators[a];if(f){d=f.call(this,d); if(d==null){return this;}}var c=this.prototype;switch($type(d)){case"function":if(d._hidden){return this;}c[a]=Class.wrap(this,a,d);break;case"object":var b=c[a]; if($type(b)=="object"){$mixin(b,d);}else{c[a]=$unlink(d);}break;case"array":c[a]=$unlink(d);break;default:c[a]=d;}return this;}});Class.Mutators={Extends:function(a){this.parent=a; this.prototype=Class.instantiate(a);this.implement("parent",function(){var b=this.caller._name,c=this.caller._owner.parent.prototype[b];if(!c){throw new Error('The method "'+b+'" has no parent.'); }return c.apply(this,arguments);}.protect());},Implements:function(a){$splat(a).each(function(b){if(b instanceof Function){b=Class.instantiate(b);}this.implement(b); },this);}};var Chain=new Class({$chain:[],chain:function(){this.$chain.extend(Array.flatten(arguments));return this;},callChain:function(){return(this.$chain.length)?this.$chain.shift().apply(this,arguments):false; },clearChain:function(){this.$chain.empty();return this;}});var Events=new Class({$events:{},addEvent:function(c,b,a){c=Events.removeOn(c);if(b!=$empty){this.$events[c]=this.$events[c]||[]; this.$events[c].include(b);if(a){b.internal=true;}}return this;},addEvents:function(a){for(var b in a){this.addEvent(b,a[b]);}return this;},fireEvent:function(c,b,a){c=Events.removeOn(c); if(!this.$events||!this.$events[c]){return this;}this.$events[c].each(function(d){d.create({bind:this,delay:a,"arguments":b})();},this);return this;},removeEvent:function(b,a){b=Events.removeOn(b); if(!this.$events[b]){return this;}if(!a.internal){this.$events[b].erase(a);}return this;},removeEvents:function(c){var d;if($type(c)=="object"){for(d in c){this.removeEvent(d,c[d]); }return this;}if(c){c=Events.removeOn(c);}for(d in this.$events){if(c&&c!=d){continue;}var b=this.$events[d];for(var a=b.length;a--;a){this.removeEvent(d,b[a]); }}return this;}});Events.removeOn=function(a){return a.replace(/^on([A-Z])/,function(b,c){return c.toLowerCase();});};var Options=new Class({setOptions:function(){this.options=$merge.run([this.options].extend(arguments)); if(!this.addEvent){return this;}for(var a in this.options){if($type(this.options[a])!="function"||!(/^on[A-Z]/).test(a)){continue;}this.addEvent(a,this.options[a]); delete this.options[a];}return this;}});var Element=new Native({name:"Element",legacy:window.Element,initialize:function(a,b){var c=Element.Constructors.get(a); if(c){return c(b);}if(typeof a=="string"){return document.newElement(a,b);}return document.id(a).set(b);},afterImplement:function(a,b){Element.Prototype[a]=b; if(Array[a]){return;}Elements.implement(a,function(){var c=[],g=true;for(var e=0,d=this.length;e";}return document.id(this.createElement(a)).set(b);},newTextNode:function(a){return this.createTextNode(a); },getDocument:function(){return this;},getWindow:function(){return this.window;},id:(function(){var a={string:function(d,c,b){d=b.getElementById(d);return(d)?a.element(d,c):null; },element:function(b,e){$uid(b);if(!e&&!b.$family&&!(/^object|embed$/i).test(b.tagName)){var c=Element.Prototype;for(var d in c){b[d]=c[d];}}return b;},object:function(c,d,b){if(c.toElement){return a.element(c.toElement(b),d); }return null;}};a.textnode=a.whitespace=a.window=a.document=$arguments(0);return function(c,e,d){if(c&&c.$family&&c.uid){return c;}var b=$type(c);return(a[b])?a[b](c,e,d||document):null; };})()});if(window.$==null){Window.implement({$:function(a,b){return document.id(a,b,this.document);}});}Window.implement({$$:function(a){if(arguments.length==1&&typeof a=="string"){return this.document.getElements(a); }var f=[];var c=Array.flatten(arguments);for(var d=0,b=c.length;d1);a.each(function(e){var f=this.getElementsByTagName(e.trim());(b)?c.extend(f):c=f; },this);return new Elements(c,{ddup:b,cash:!d});}});(function(){var h={},f={};var i={input:"checked",option:"selected",textarea:(Browser.Engine.webkit&&Browser.Engine.version<420)?"innerHTML":"value"}; var c=function(l){return(f[l]||(f[l]={}));};var g=function(n,l){if(!n){return;}var m=n.uid;if(Browser.Engine.trident){if(n.clearAttributes){var q=l&&n.cloneNode(false); n.clearAttributes();if(q){n.mergeAttributes(q);}}else{if(n.removeEvents){n.removeEvents();}}if((/object/i).test(n.tagName)){for(var o in n){if(typeof n[o]=="function"){n[o]=$empty; }}Element.dispose(n);}}if(!m){return;}h[m]=f[m]=null;};var d=function(){Hash.each(h,g);if(Browser.Engine.trident){$A(document.getElementsByTagName("object")).each(g); }if(window.CollectGarbage){CollectGarbage();}h=f=null;};var j=function(n,l,s,m,p,r){var o=n[s||l];var q=[];while(o){if(o.nodeType==1&&(!m||Element.match(o,m))){if(!p){return document.id(o,r); }q.push(o);}o=o[l];}return(p)?new Elements(q,{ddup:false,cash:!r}):null;};var e={html:"innerHTML","class":"className","for":"htmlFor",defaultValue:"defaultValue",text:(Browser.Engine.trident||(Browser.Engine.webkit&&Browser.Engine.version<420))?"innerText":"textContent"}; var b=["compact","nowrap","ismap","declare","noshade","checked","disabled","readonly","multiple","selected","noresize","defer"];var k=["value","type","defaultValue","accessKey","cellPadding","cellSpacing","colSpan","frameBorder","maxLength","readOnly","rowSpan","tabIndex","useMap"]; b=b.associate(b);Hash.extend(e,b);Hash.extend(e,k.associate(k.map(String.toLowerCase)));var a={before:function(m,l){if(l.parentNode){l.parentNode.insertBefore(m,l); }},after:function(m,l){if(!l.parentNode){return;}var n=l.nextSibling;(n)?l.parentNode.insertBefore(m,n):l.parentNode.appendChild(m);},bottom:function(m,l){l.appendChild(m); },top:function(m,l){var n=l.firstChild;(n)?l.insertBefore(m,n):l.appendChild(m);}};a.inside=a.bottom;Hash.each(a,function(l,m){m=m.capitalize();Element.implement("inject"+m,function(n){l(this,document.id(n,true)); return this;});Element.implement("grab"+m,function(n){l(document.id(n,true),this);return this;});});Element.implement({set:function(o,m){switch($type(o)){case"object":for(var n in o){this.set(n,o[n]); }break;case"string":var l=Element.Properties.get(o);(l&&l.set)?l.set.apply(this,Array.slice(arguments,1)):this.setProperty(o,m);}return this;},get:function(m){var l=Element.Properties.get(m); return(l&&l.get)?l.get.apply(this,Array.slice(arguments,1)):this.getProperty(m);},erase:function(m){var l=Element.Properties.get(m);(l&&l.erase)?l.erase.apply(this):this.removeProperty(m); return this;},setProperty:function(m,n){var l=e[m];if(n==undefined){return this.removeProperty(m);}if(l&&b[m]){n=!!n;}(l)?this[l]=n:this.setAttribute(m,""+n); return this;},setProperties:function(l){for(var m in l){this.setProperty(m,l[m]);}return this;},getProperty:function(m){var l=e[m];var n=(l)?this[l]:this.getAttribute(m,2); return(b[m])?!!n:(l)?n:n||null;},getProperties:function(){var l=$A(arguments);return l.map(this.getProperty,this).associate(l);},removeProperty:function(m){var l=e[m]; (l)?this[l]=(l&&b[m])?false:"":this.removeAttribute(m);return this;},removeProperties:function(){Array.each(arguments,this.removeProperty,this);return this; },hasClass:function(l){return this.className.contains(l," ");},addClass:function(l){if(!this.hasClass(l)){this.className=(this.className+" "+l).clean(); }return this;},removeClass:function(l){this.className=this.className.replace(new RegExp("(^|\\s)"+l+"(?:\\s|$)"),"$1");return this;},toggleClass:function(l){return this.hasClass(l)?this.removeClass(l):this.addClass(l); },adopt:function(){Array.flatten(arguments).each(function(l){l=document.id(l,true);if(l){this.appendChild(l);}},this);return this;},appendText:function(m,l){return this.grab(this.getDocument().newTextNode(m),l); },grab:function(m,l){a[l||"bottom"](document.id(m,true),this);return this;},inject:function(m,l){a[l||"bottom"](this,document.id(m,true));return this;},replaces:function(l){l=document.id(l,true); l.parentNode.replaceChild(this,l);return this;},wraps:function(m,l){m=document.id(m,true);return this.replaces(m).grab(m,l);},getPrevious:function(l,m){return j(this,"previousSibling",null,l,false,m); },getAllPrevious:function(l,m){return j(this,"previousSibling",null,l,true,m);},getNext:function(l,m){return j(this,"nextSibling",null,l,false,m);},getAllNext:function(l,m){return j(this,"nextSibling",null,l,true,m); },getFirst:function(l,m){return j(this,"nextSibling","firstChild",l,false,m);},getLast:function(l,m){return j(this,"previousSibling","lastChild",l,false,m); },getParent:function(l,m){return j(this,"parentNode",null,l,false,m);},getParents:function(l,m){return j(this,"parentNode",null,l,true,m);},getSiblings:function(l,m){return this.getParent().getChildren(l,m).erase(this); },getChildren:function(l,m){return j(this,"nextSibling","firstChild",l,true,m);},getWindow:function(){return this.ownerDocument.window;},getDocument:function(){return this.ownerDocument; },getElementById:function(o,n){var m=this.ownerDocument.getElementById(o);if(!m){return null;}for(var l=m.parentNode;l!=this;l=l.parentNode){if(!l){return null; }}return document.id(m,n);},getSelected:function(){return new Elements($A(this.options).filter(function(l){return l.selected;}));},getComputedStyle:function(m){if(this.currentStyle){return this.currentStyle[m.camelCase()]; }var l=this.getDocument().defaultView.getComputedStyle(this,null);return(l)?l.getPropertyValue([m.hyphenate()]):null;},toQueryString:function(){var l=[]; this.getElements("input, select, textarea",true).each(function(m){if(!m.name||m.disabled||m.type=="submit"||m.type=="reset"||m.type=="file"){return;}var n=(m.tagName.toLowerCase()=="select")?Element.getSelected(m).map(function(o){return o.value; }):((m.type=="radio"||m.type=="checkbox")&&!m.checked)?null:m.value;$splat(n).each(function(o){if(typeof o!="undefined"){l.push(m.name+"="+encodeURIComponent(o)); }});});return l.join("&");},clone:function(o,l){o=o!==false;var r=this.cloneNode(o);var n=function(v,u){if(!l){v.removeAttribute("id");}if(Browser.Engine.trident){v.clearAttributes(); v.mergeAttributes(u);v.removeAttribute("uid");if(v.options){var w=v.options,s=u.options;for(var t=w.length;t--;){w[t].selected=s[t].selected;}}}var x=i[u.tagName.toLowerCase()]; if(x&&u[x]){v[x]=u[x];}};if(o){var p=r.getElementsByTagName("*"),q=this.getElementsByTagName("*");for(var m=p.length;m--;){n(p[m],q[m]);}}n(r,this);return document.id(r); },destroy:function(){Element.empty(this);Element.dispose(this);g(this,true);return null;},empty:function(){$A(this.childNodes).each(function(l){Element.destroy(l); });return this;},dispose:function(){return(this.parentNode)?this.parentNode.removeChild(this):this;},hasChild:function(l){l=document.id(l,true);if(!l){return false; }if(Browser.Engine.webkit&&Browser.Engine.version<420){return $A(this.getElementsByTagName(l.tagName)).contains(l);}return(this.contains)?(this!=l&&this.contains(l)):!!(this.compareDocumentPosition(l)&16); },match:function(l){return(!l||(l==this)||(Element.get(this,"tag")==l));}});Native.implement([Element,Window,Document],{addListener:function(o,n){if(o=="unload"){var l=n,m=this; n=function(){m.removeListener("unload",n);l();};}else{h[this.uid]=this;}if(this.addEventListener){this.addEventListener(o,n,false);}else{this.attachEvent("on"+o,n); }return this;},removeListener:function(m,l){if(this.removeEventListener){this.removeEventListener(m,l,false);}else{this.detachEvent("on"+m,l);}return this; },retrieve:function(m,l){var o=c(this.uid),n=o[m];if(l!=undefined&&n==undefined){n=o[m]=l;}return $pick(n);},store:function(m,l){var n=c(this.uid);n[m]=l; return this;},eliminate:function(l){var m=c(this.uid);delete m[l];return this;}});window.addListener("unload",d);})();Element.Properties=new Hash;Element.Properties.style={set:function(a){this.style.cssText=a; },get:function(){return this.style.cssText;},erase:function(){this.style.cssText="";}};Element.Properties.tag={get:function(){return this.tagName.toLowerCase(); }};Element.Properties.html=(function(){var c=document.createElement("div");var a={table:[1,"","
"],select:[1,""],tbody:[2,"","
"],tr:[3,"","
"]}; a.thead=a.tfoot=a.tbody;var b={set:function(){var e=Array.flatten(arguments).join("");var f=Browser.Engine.trident&&a[this.get("tag")];if(f){var g=c;g.innerHTML=f[1]+e+f[2]; for(var d=f[0];d--;){g=g.firstChild;}this.empty().adopt(g.childNodes);}else{this.innerHTML=e;}}};b.erase=b.set;return b;})();if(Browser.Engine.webkit&&Browser.Engine.version<420){Element.Properties.text={get:function(){if(this.innerText){return this.innerText; }var a=this.ownerDocument.newElement("div",{html:this.innerHTML}).inject(this.ownerDocument.body);var b=a.innerText;a.destroy();return b;}};}Element.Properties.events={set:function(a){this.addEvents(a); }};Native.implement([Element,Window,Document],{addEvent:function(e,g){var h=this.retrieve("events",{});h[e]=h[e]||{keys:[],values:[]};if(h[e].keys.contains(g)){return this; }h[e].keys.push(g);var f=e,a=Element.Events.get(e),c=g,i=this;if(a){if(a.onAdd){a.onAdd.call(this,g);}if(a.condition){c=function(j){if(a.condition.call(this,j)){return g.call(this,j); }return true;};}f=a.base||f;}var d=function(){return g.call(i);};var b=Element.NativeEvents[f];if(b){if(b==2){d=function(j){j=new Event(j,i.getWindow()); if(c.call(i,j)===false){j.stop();}};}this.addListener(f,d);}h[e].values.push(d);return this;},removeEvent:function(c,b){var a=this.retrieve("events");if(!a||!a[c]){return this; }var f=a[c].keys.indexOf(b);if(f==-1){return this;}a[c].keys.splice(f,1);var e=a[c].values.splice(f,1)[0];var d=Element.Events.get(c);if(d){if(d.onRemove){d.onRemove.call(this,b); }c=d.base||c;}return(Element.NativeEvents[c])?this.removeListener(c,e):this;},addEvents:function(a){for(var b in a){this.addEvent(b,a[b]);}return this; },removeEvents:function(a){var c;if($type(a)=="object"){for(c in a){this.removeEvent(c,a[c]);}return this;}var b=this.retrieve("events");if(!b){return this; }if(!a){for(c in b){this.removeEvents(c);}this.eliminate("events");}else{if(b[a]){while(b[a].keys[0]){this.removeEvent(a,b[a].keys[0]);}b[a]=null;}}return this; },fireEvent:function(d,b,a){var c=this.retrieve("events");if(!c||!c[d]){return this;}c[d].keys.each(function(e){e.create({bind:this,delay:a,"arguments":b})(); },this);return this;},cloneEvents:function(d,a){d=document.id(d);var c=d.retrieve("events");if(!c){return this;}if(!a){for(var b in c){this.cloneEvents(d,b); }}else{if(c[a]){c[a].keys.each(function(e){this.addEvent(a,e);},this);}}return this;}});Element.NativeEvents={click:2,dblclick:2,mouseup:2,mousedown:2,contextmenu:2,mousewheel:2,DOMMouseScroll:2,mouseover:2,mouseout:2,mousemove:2,selectstart:2,selectend:2,keydown:2,keypress:2,keyup:2,focus:2,blur:2,change:2,reset:2,select:2,submit:2,load:1,unload:1,beforeunload:2,resize:1,move:1,DOMContentLoaded:1,readystatechange:1,error:1,abort:1,scroll:1}; (function(){var a=function(b){var c=b.relatedTarget;if(c==undefined){return true;}if(c===false){return false;}return($type(this)!="document"&&c!=this&&c.prefix!="xul"&&!this.hasChild(c)); };Element.Events=new Hash({mouseenter:{base:"mouseover",condition:a},mouseleave:{base:"mouseout",condition:a},mousewheel:{base:(Browser.Engine.gecko)?"DOMMouseScroll":"mousewheel"}}); })();Element.Properties.styles={set:function(a){this.setStyles(a);}};Element.Properties.opacity={set:function(a,b){if(!b){if(a==0){if(this.style.visibility!="hidden"){this.style.visibility="hidden"; }}else{if(this.style.visibility!="visible"){this.style.visibility="visible";}}}if(!this.currentStyle||!this.currentStyle.hasLayout){this.style.zoom=1;}if(Browser.Engine.trident){this.style.filter=(a==1)?"":"alpha(opacity="+a*100+")"; }this.style.opacity=a;this.store("opacity",a);},get:function(){return this.retrieve("opacity",1);}};Element.implement({setOpacity:function(a){return this.set("opacity",a,true); },getOpacity:function(){return this.get("opacity");},setStyle:function(b,a){switch(b){case"opacity":return this.set("opacity",parseFloat(a));case"float":b=(Browser.Engine.trident)?"styleFloat":"cssFloat"; }b=b.camelCase();if($type(a)!="string"){var c=(Element.Styles.get(b)||"@").split(" ");a=$splat(a).map(function(e,d){if(!c[d]){return"";}return($type(e)=="number")?c[d].replace("@",Math.round(e)):e; }).join(" ");}else{if(a==String(Number(a))){a=Math.round(a);}}this.style[b]=a;return this;},getStyle:function(g){switch(g){case"opacity":return this.get("opacity"); case"float":g=(Browser.Engine.trident)?"styleFloat":"cssFloat";}g=g.camelCase();var a=this.style[g];if(!$chk(a)){a=[];for(var f in Element.ShortStyles){if(g!=f){continue; }for(var e in Element.ShortStyles[f]){a.push(this.getStyle(e));}return a.join(" ");}a=this.getComputedStyle(g);}if(a){a=String(a);var c=a.match(/rgba?\([\d\s,]+\)/); if(c){a=a.replace(c[0],c[0].rgbToHex());}}if(Browser.Engine.presto||(Browser.Engine.trident&&!$chk(parseInt(a,10)))){if(g.test(/^(height|width)$/)){var b=(g=="width")?["left","right"]:["top","bottom"],d=0; b.each(function(h){d+=this.getStyle("border-"+h+"-width").toInt()+this.getStyle("padding-"+h).toInt();},this);return this["offset"+g.capitalize()]-d+"px"; }if((Browser.Engine.presto)&&String(a).test("px")){return a;}if(g.test(/(border(.+)Width|margin|padding)/)){return"0px";}}return a;},setStyles:function(b){for(var a in b){this.setStyle(a,b[a]); }return this;},getStyles:function(){var a={};Array.flatten(arguments).each(function(b){a[b]=this.getStyle(b);},this);return a;}});Element.Styles=new Hash({left:"@px",top:"@px",bottom:"@px",right:"@px",width:"@px",height:"@px",maxWidth:"@px",maxHeight:"@px",minWidth:"@px",minHeight:"@px",backgroundColor:"rgb(@, @, @)",backgroundPosition:"@px @px",color:"rgb(@, @, @)",fontSize:"@px",letterSpacing:"@px",lineHeight:"@px",clip:"rect(@px @px @px @px)",margin:"@px @px @px @px",padding:"@px @px @px @px",border:"@px @ rgb(@, @, @) @px @ rgb(@, @, @) @px @ rgb(@, @, @)",borderWidth:"@px @px @px @px",borderStyle:"@ @ @ @",borderColor:"rgb(@, @, @) rgb(@, @, @) rgb(@, @, @) rgb(@, @, @)",zIndex:"@",zoom:"@",fontWeight:"@",textIndent:"@px",opacity:"@"}); Element.ShortStyles={margin:{},padding:{},border:{},borderWidth:{},borderStyle:{},borderColor:{}};["Top","Right","Bottom","Left"].each(function(g){var f=Element.ShortStyles; var b=Element.Styles;["margin","padding"].each(function(h){var i=h+g;f[h][i]=b[i]="@px";});var e="border"+g;f.border[e]=b[e]="@px @ rgb(@, @, @)";var d=e+"Width",a=e+"Style",c=e+"Color"; f[e]={};f.borderWidth[d]=f[e][d]=b[d]="@px";f.borderStyle[a]=f[e][a]=b[a]="@";f.borderColor[c]=f[e][c]=b[c]="rgb(@, @, @)";});(function(){Element.implement({scrollTo:function(h,i){if(b(this)){this.getWindow().scrollTo(h,i); }else{this.scrollLeft=h;this.scrollTop=i;}return this;},getSize:function(){if(b(this)){return this.getWindow().getSize();}return{x:this.offsetWidth,y:this.offsetHeight}; },getScrollSize:function(){if(b(this)){return this.getWindow().getScrollSize();}return{x:this.scrollWidth,y:this.scrollHeight};},getScroll:function(){if(b(this)){return this.getWindow().getScroll(); }return{x:this.scrollLeft,y:this.scrollTop};},getScrolls:function(){var i=this,h={x:0,y:0};while(i&&!b(i)){h.x+=i.scrollLeft;h.y+=i.scrollTop;i=i.parentNode; }return h;},getOffsetParent:function(){var h=this;if(b(h)){return null;}if(!Browser.Engine.trident){return h.offsetParent;}while((h=h.parentNode)&&!b(h)){if(d(h,"position")!="static"){return h; }}return null;},getOffsets:function(){if(this.getBoundingClientRect){var j=this.getBoundingClientRect(),m=document.id(this.getDocument().documentElement),p=m.getScroll(),k=this.getScrolls(),i=this.getScroll(),h=(d(this,"position")=="fixed"); return{x:j.left.toInt()+k.x-i.x+((h)?0:p.x)-m.clientLeft,y:j.top.toInt()+k.y-i.y+((h)?0:p.y)-m.clientTop};}var l=this,n={x:0,y:0};if(b(this)){return n; }while(l&&!b(l)){n.x+=l.offsetLeft;n.y+=l.offsetTop;if(Browser.Engine.gecko){if(!f(l)){n.x+=c(l);n.y+=g(l);}var o=l.parentNode;if(o&&d(o,"overflow")!="visible"){n.x+=c(o); n.y+=g(o);}}else{if(l!=this&&Browser.Engine.webkit){n.x+=c(l);n.y+=g(l);}}l=l.offsetParent;}if(Browser.Engine.gecko&&!f(this)){n.x-=c(this);n.y-=g(this); }return n;},getPosition:function(k){if(b(this)){return{x:0,y:0};}var l=this.getOffsets(),i=this.getScrolls();var h={x:l.x-i.x,y:l.y-i.y};var j=(k&&(k=document.id(k)))?k.getPosition():{x:0,y:0}; return{x:h.x-j.x,y:h.y-j.y};},getCoordinates:function(j){if(b(this)){return this.getWindow().getCoordinates();}var h=this.getPosition(j),i=this.getSize(); var k={left:h.x,top:h.y,width:i.x,height:i.y};k.right=k.left+k.width;k.bottom=k.top+k.height;return k;},computePosition:function(h){return{left:h.x-e(this,"margin-left"),top:h.y-e(this,"margin-top")}; },setPosition:function(h){return this.setStyles(this.computePosition(h));}});Native.implement([Document,Window],{getSize:function(){if(Browser.Engine.presto||Browser.Engine.webkit){var i=this.getWindow(); return{x:i.innerWidth,y:i.innerHeight};}var h=a(this);return{x:h.clientWidth,y:h.clientHeight};},getScroll:function(){var i=this.getWindow(),h=a(this); return{x:i.pageXOffset||h.scrollLeft,y:i.pageYOffset||h.scrollTop};},getScrollSize:function(){var i=a(this),h=this.getSize();return{x:Math.max(i.scrollWidth,h.x),y:Math.max(i.scrollHeight,h.y)}; },getPosition:function(){return{x:0,y:0};},getCoordinates:function(){var h=this.getSize();return{top:0,left:0,bottom:h.y,right:h.x,height:h.y,width:h.x}; }});var d=Element.getComputedStyle;function e(h,i){return d(h,i).toInt()||0;}function f(h){return d(h,"-moz-box-sizing")=="border-box";}function g(h){return e(h,"border-top-width"); }function c(h){return e(h,"border-left-width");}function b(h){return(/^(?:body|html)$/i).test(h.tagName);}function a(h){var i=h.getDocument();return(!i.compatMode||i.compatMode=="CSS1Compat")?i.html:i.body; }})();Element.alias("setPosition","position");Native.implement([Window,Document,Element],{getHeight:function(){return this.getSize().y;},getWidth:function(){return this.getSize().x; },getScrollTop:function(){return this.getScroll().y;},getScrollLeft:function(){return this.getScroll().x;},getScrollHeight:function(){return this.getScrollSize().y; },getScrollWidth:function(){return this.getScrollSize().x;},getTop:function(){return this.getPosition().y;},getLeft:function(){return this.getPosition().x; }});Native.implement([Document,Element],{getElements:function(h,g){h=h.split(",");var c,e={};for(var d=0,b=h.length;d1),cash:!g});}});Element.implement({match:function(b){if(!b||(b==this)){return true; }var d=Selectors.Utils.parseTagAndID(b);var a=d[0],e=d[1];if(!Selectors.Filters.byID(this,e)||!Selectors.Filters.byTag(this,a)){return false;}var c=Selectors.Utils.parseSelector(b); return(c)?Selectors.Utils.filter(this,c,{}):true;}});var Selectors={Cache:{nth:{},parsed:{}}};Selectors.RegExps={id:(/#([\w-]+)/),tag:(/^(\w+|\*)/),quick:(/^(\w+|\*)$/),splitter:(/\s*([+>~\s])\s*([a-zA-Z#.*:\[])/g),combined:(/\.([\w-]+)|\[(\w+)(?:([!*^$~|]?=)(["']?)([^\4]*?)\4)?\]|:([\w-]+)(?:\(["']?(.*?)?["']?\)|$)/g)}; Selectors.Utils={chk:function(b,c){if(!c){return true;}var a=$uid(b);if(!c[a]){return c[a]=true;}return false;},parseNthArgument:function(h){if(Selectors.Cache.nth[h]){return Selectors.Cache.nth[h]; }var e=h.match(/^([+-]?\d*)?([a-z]+)?([+-]?\d*)?$/);if(!e){return false;}var g=parseInt(e[1],10);var d=(g||g===0)?g:1;var f=e[2]||false;var c=parseInt(e[3],10)||0; if(d!=0){c--;while(c<1){c+=d;}while(c>=d){c-=d;}}else{d=c;f="index";}switch(f){case"n":e={a:d,b:c,special:"n"};break;case"odd":e={a:2,b:0,special:"n"}; break;case"even":e={a:2,b:1,special:"n"};break;case"first":e={a:0,special:"index"};break;case"last":e={special:"last-child"};break;case"only":e={special:"only-child"}; break;default:e={a:(d-1),special:"index"};}return Selectors.Cache.nth[h]=e;},parseSelector:function(e){if(Selectors.Cache.parsed[e]){return Selectors.Cache.parsed[e]; }var d,h={classes:[],pseudos:[],attributes:[]};while((d=Selectors.RegExps.combined.exec(e))){var i=d[1],g=d[2],f=d[3],b=d[5],c=d[6],j=d[7];if(i){h.classes.push(i); }else{if(c){var a=Selectors.Pseudo.get(c);if(a){h.pseudos.push({parser:a,argument:j});}else{h.attributes.push({name:c,operator:"=",value:j});}}else{if(g){h.attributes.push({name:g,operator:f,value:b}); }}}}if(!h.classes.length){delete h.classes;}if(!h.attributes.length){delete h.attributes;}if(!h.pseudos.length){delete h.pseudos;}if(!h.classes&&!h.attributes&&!h.pseudos){h=null; }return Selectors.Cache.parsed[e]=h;},parseTagAndID:function(b){var a=b.match(Selectors.RegExps.tag);var c=b.match(Selectors.RegExps.id);return[(a)?a[1]:"*",(c)?c[1]:false]; },filter:function(f,c,e){var d;if(c.classes){for(d=c.classes.length;d--;d){var g=c.classes[d];if(!Selectors.Filters.byClass(f,g)){return false;}}}if(c.attributes){for(d=c.attributes.length; d--;d){var b=c.attributes[d];if(!Selectors.Filters.byAttribute(f,b.name,b.operator,b.value)){return false;}}}if(c.pseudos){for(d=c.pseudos.length;d--;d){var a=c.pseudos[d]; if(!Selectors.Filters.byPseudo(f,a.parser,a.argument,e)){return false;}}}return true;},getByTagAndID:function(b,a,d){if(d){var c=(b.getElementById)?b.getElementById(d,true):Element.getElementById(b,d,true); return(c&&Selectors.Filters.byTag(c,a))?[c]:[];}else{return b.getElementsByTagName(a);}},search:function(o,h,t){var b=[];var c=h.trim().replace(Selectors.RegExps.splitter,function(k,j,i){b.push(j); return":)"+i;}).split(":)");var p,e,A;for(var z=0,v=c.length;z":function(h,g,j,a,f){var c=Selectors.Utils.getByTagAndID(g,j,a);for(var e=0,d=c.length;ea){return false;}}return(c==a);},even:function(b,a){return Selectors.Pseudo["nth-child"].call(this,"2n+1",a); },odd:function(b,a){return Selectors.Pseudo["nth-child"].call(this,"2n",a);},selected:function(){return this.selected;},enabled:function(){return(this.disabled===false); }});Element.Events.domready={onAdd:function(a){if(Browser.loaded){a.call(this);}}};(function(){var b=function(){if(Browser.loaded){return;}Browser.loaded=true; window.fireEvent("domready");document.fireEvent("domready");};window.addEvent("load",b);if(Browser.Engine.trident){var a=document.createElement("div"); (function(){($try(function(){a.doScroll();return document.id(a).inject(document.body).set("html","temp").dispose();}))?b():arguments.callee.delay(50);})(); }else{if(Browser.Engine.webkit&&Browser.Engine.version<525){(function(){(["loaded","complete"].contains(document.readyState))?b():arguments.callee.delay(50); })();}else{document.addEvent("DOMContentLoaded",b);}}})();var JSON=new Hash(this.JSON&&{stringify:JSON.stringify,parse:JSON.parse}).extend({$specialChars:{"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},$replaceChars:function(a){return JSON.$specialChars[a]||"\\u00"+Math.floor(a.charCodeAt()/16).toString(16)+(a.charCodeAt()%16).toString(16); },encode:function(b){switch($type(b)){case"string":return'"'+b.replace(/[\x00-\x1f\\"]/g,JSON.$replaceChars)+'"';case"array":return"["+String(b.map(JSON.encode).clean())+"]"; case"object":case"hash":var a=[];Hash.each(b,function(e,d){var c=JSON.encode(e);if(c){a.push(JSON.encode(d)+":"+c);}});return"{"+a+"}";case"number":case"boolean":return String(b); case false:return"null";}return null;},decode:function(string,secure){if($type(string)!="string"||!string.length){return null;}if(secure&&!(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(string.replace(/\\./g,"@").replace(/"[^"\\\n\r]*"/g,""))){return null; }return eval("("+string+")");}});Native.implement([Hash,Array,String,Number],{toJSON:function(){return JSON.encode(this);}});var Cookie=new Class({Implements:Options,options:{path:false,domain:false,duration:false,secure:false,document:document},initialize:function(b,a){this.key=b; this.setOptions(a);},write:function(b){b=encodeURIComponent(b);if(this.options.domain){b+="; domain="+this.options.domain;}if(this.options.path){b+="; path="+this.options.path; }if(this.options.duration){var a=new Date();a.setTime(a.getTime()+this.options.duration*24*60*60*1000);b+="; expires="+a.toGMTString();}if(this.options.secure){b+="; secure"; }this.options.document.cookie=this.key+"="+b;return this;},read:function(){var a=this.options.document.cookie.match("(?:^|;)\\s*"+this.key.escapeRegExp()+"=([^;]*)"); return(a)?decodeURIComponent(a[1]):null;},dispose:function(){new Cookie(this.key,$merge(this.options,{duration:-1})).write("");return this;}});Cookie.write=function(b,c,a){return new Cookie(b,a).write(c); };Cookie.read=function(a){return new Cookie(a).read();};Cookie.dispose=function(b,a){return new Cookie(b,a).dispose();};var Swiff=new Class({Implements:[Options],options:{id:null,height:1,width:1,container:null,properties:{},params:{quality:"high",allowScriptAccess:"always",wMode:"transparent",swLiveConnect:true},callBacks:{},vars:{}},toElement:function(){return this.object; },initialize:function(l,m){this.instance="Swiff_"+$time();this.setOptions(m);m=this.options;var b=this.id=m.id||this.instance;var a=document.id(m.container); Swiff.CallBacks[this.instance]={};var e=m.params,g=m.vars,f=m.callBacks;var h=$extend({height:m.height,width:m.width},m.properties);var k=this;for(var d in f){Swiff.CallBacks[this.instance][d]=(function(n){return function(){return n.apply(k.object,arguments); };})(f[d]);g[d]="Swiff.CallBacks."+this.instance+"."+d;}e.flashVars=Hash.toQueryString(g);if(Browser.Engine.trident){h.classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"; e.movie=l;}else{h.type="application/x-shockwave-flash";h.data=l;}var j=''; }}j+="";this.object=((a)?a.empty():new Element("div")).set("html",j).firstChild;},replaces:function(a){a=document.id(a,true);a.parentNode.replaceChild(this.toElement(),a); return this;},inject:function(a){document.id(a,true).appendChild(this.toElement());return this;},remote:function(){return Swiff.remote.apply(Swiff,[this.toElement()].extend(arguments)); }});Swiff.CallBacks={};Swiff.remote=function(obj,fn){var rs=obj.CallFunction(''+__flash__argumentsToXML(arguments,2)+""); return eval(rs);};var Fx=new Class({Implements:[Chain,Events,Options],options:{fps:50,unit:false,duration:500,link:"ignore"},initialize:function(a){this.subject=this.subject||this; this.setOptions(a);this.options.duration=Fx.Durations[this.options.duration]||this.options.duration.toInt();var b=this.options.wait;if(b===false){this.options.link="cancel"; }},getTransition:function(){return function(a){return -(Math.cos(Math.PI*a)-1)/2;};},step:function(){var a=$time();if(a=(7-4*d)/11){e=c*c-Math.pow((11-6*d-11*f)/4,2); break;}}return e;},Elastic:function(b,a){return Math.pow(2,10*--b)*Math.cos(20*b*Math.PI*(a[0]||1)/3);}});["Quad","Cubic","Quart","Quint"].each(function(b,a){Fx.Transitions[b]=new Fx.Transition(function(c){return Math.pow(c,[a+2]); });});var Request=new Class({Implements:[Chain,Events,Options],options:{url:"",data:"",headers:{"X-Requested-With":"XMLHttpRequest",Accept:"text/javascript, text/html, application/xml, text/xml, */*"},async:true,format:false,method:"post",link:"ignore",isSuccess:null,emulation:true,urlEncoded:true,encoding:"utf-8",evalScripts:false,evalResponse:false,noCache:false},initialize:function(a){this.xhr=new Browser.Request(); this.setOptions(a);this.options.isSuccess=this.options.isSuccess||this.isSuccess;this.headers=new Hash(this.options.headers);},onStateChange:function(){if(this.xhr.readyState!=4||!this.running){return; }this.running=false;this.status=0;$try(function(){this.status=this.xhr.status;}.bind(this));this.xhr.onreadystatechange=$empty;if(this.options.isSuccess.call(this,this.status)){this.response={text:this.xhr.responseText,xml:this.xhr.responseXML}; this.success(this.response.text,this.response.xml);}else{this.response={text:null,xml:null};this.failure();}},isSuccess:function(){return((this.status>=200)&&(this.status<300)); },processScripts:function(a){if(this.options.evalResponse||(/(ecma|java)script/).test(this.getHeader("Content-type"))){return $exec(a);}return a.stripScripts(this.options.evalScripts); },success:function(b,a){this.onSuccess(this.processScripts(b),a);},onSuccess:function(){this.fireEvent("complete",arguments).fireEvent("success",arguments).callChain(); },failure:function(){this.onFailure();},onFailure:function(){this.fireEvent("complete").fireEvent("failure",this.xhr);},setHeader:function(a,b){this.headers.set(a,b); return this;},getHeader:function(a){return $try(function(){return this.xhr.getResponseHeader(a);}.bind(this));},check:function(){if(!this.running){return true; }switch(this.options.link){case"cancel":this.cancel();return true;case"chain":this.chain(this.caller.bind(this,arguments));return false;}return false;},send:function(k){if(!this.check(k)){return this; }this.running=true;var i=$type(k);if(i=="string"||i=="element"){k={data:k};}var d=this.options;k=$extend({data:d.data,url:d.url,method:d.method},k);var g=k.data,b=String(k.url),a=k.method.toLowerCase(); switch($type(g)){case"element":g=document.id(g).toQueryString();break;case"object":case"hash":g=Hash.toQueryString(g);}if(this.options.format){var j="format="+this.options.format; g=(g)?j+"&"+g:j;}if(this.options.emulation&&!["get","post"].contains(a)){var h="_method="+a;g=(g)?h+"&"+g:h;a="post";}if(this.options.urlEncoded&&a=="post"){var c=(this.options.encoding)?"; charset="+this.options.encoding:""; this.headers.set("Content-type","application/x-www-form-urlencoded"+c);}if(this.options.noCache){var f="noCache="+new Date().getTime();g=(g)?f+"&"+g:f; }var e=b.lastIndexOf("/");if(e>-1&&(e=b.indexOf("#"))>-1){b=b.substr(0,e);}if(g&&a=="get"){b=b+(b.contains("?")?"&":"?")+g;g=null;}this.xhr.open(a.toUpperCase(),b,this.options.async); this.xhr.onreadystatechange=this.onStateChange.bind(this);this.headers.each(function(m,l){try{this.xhr.setRequestHeader(l,m);}catch(n){this.fireEvent("exception",[l,m]); }},this);this.fireEvent("request");this.xhr.send(g);if(!this.options.async){this.onStateChange();}return this;},cancel:function(){if(!this.running){return this; }this.running=false;this.xhr.abort();this.xhr.onreadystatechange=$empty;this.xhr=new Browser.Request();this.fireEvent("cancel");return this;}});(function(){var a={}; ["get","post","put","delete","GET","POST","PUT","DELETE"].each(function(b){a[b]=function(){var c=Array.link(arguments,{url:String.type,data:$defined}); return this.send($extend(c,{method:b}));};});Request.implement(a);})();Element.Properties.send={set:function(a){var b=this.retrieve("send");if(b){b.cancel(); }return this.eliminate("send").store("send:options",$extend({data:this,link:"cancel",method:this.get("method")||"post",url:this.get("action")},a));},get:function(a){if(a||!this.retrieve("send")){if(a||!this.retrieve("send:options")){this.set("send",a); }this.store("send",new Request(this.retrieve("send:options")));}return this.retrieve("send");}};Element.implement({send:function(a){var b=this.get("send"); b.send({data:this,url:a||b.options.url});return this;}});Request.HTML=new Class({Extends:Request,options:{update:false,append:false,evalScripts:true,filter:false},processHTML:function(c){var b=c.match(/]*>([\s\S]*?)<\/body>/i); c=(b)?b[1]:c;var a=new Element("div");return $try(function(){var d=""+c+"",g;if(Browser.Engine.trident){g=new ActiveXObject("Microsoft.XMLDOM"); g.async=false;g.loadXML(d);}else{g=new DOMParser().parseFromString(d,"text/xml");}d=g.getElementsByTagName("root")[0];if(!d){return null;}for(var f=0,e=d.childNodes.length; f'); // loading image }, onSuccess: function(response) { el.set('html',response); /* $('the_months').getElements('.weekend').each(function(el) { // NOTE - CAN't change bg color as this will mess with states!!!!!! }); */ if(clickable_past=="off"){ document.id('the_months').getElements('.past').each(function(el) { el.set('opacity','0.6'); // NOTE - CAN't change bg color as this will mess with states!!!!!! }); } } }).send(); } // make the dates clickable function activate_dates(){ // add custom events here - eg to update booking form } // calendar navigation buttons function calendar_nav(){ $$('#cal_controls img').each(function(img) { // thanks to http://davidwalsh.name/mootools-image-mouseovers var src = img.getProperty('src'); img.setStyle('cursor','pointer'); var extension = src.substring(src.lastIndexOf('.'),src.length) img.addEvent('mouseenter', function() { img.setProperty('src',src.replace(extension,'_over' + extension)); }); img.addEvent('mouseleave', function() { img.setProperty('src',src); }); img.addEvent('click', function() { var type=img.getParent().get('id'); if(type=='cal_prev'){ // get each calendar and calculate new date $$('div.load_cal').each(function(el){ var this_date=el.getFirst().id; var data=this_date.split('_'); // convert to numeric cur_month = parseFloat(data[0]); new_year = parseFloat(data[1]); new_month=(cur_month-months_to_show); if(new_month<1){ // reset month and add 1 year new_month=(new_month+12); new_year=(new_year-1); } load_calendar(el,new_month,new_year); }); }else if(type=='cal_next'){ // get each calendar and calculate new date $$('div.load_cal').each(function(el){ var this_date=el.getFirst().id; var data=this_date.split('_'); // convert to numeric cur_month = parseFloat(data[0]); new_year = parseFloat(data[1]); new_month=(cur_month+months_to_show); if(new_month>12){ // reset month and add 1 year new_month=(new_month-12); new_year=(new_year+1); } load_calendar(el,new_month,new_year); }); } // once drawn, make calendars clickable activate_dates(); }); }); } window.addEvent('domready', function() { // load initial calendars if($$('.load_cal')){ $$('.load_cal').each(function(el){ var this_date=el.get('id'); var data=this_date.split('_'); load_calendar(el,data[0],data[1]); }); // once drawn, make calendars clickable activate_dates(); // calendar next and back buttons calendar_nav(); } });/*! * Galleria v 1.1.95 2010-08-06 * http://galleria.aino.se * * Copyright (c) 2010, Aino * Licensed under the MIT license. */ (function() { var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b__super\b/ : /.*/, Class = function(){}, window = this; Class.extend = function(prop) { var __super = this.prototype; initializing = true; var proto = new this(); initializing = false; for (var name in prop) { if (name) { proto[name] = typeof prop[name] == "function" && typeof __super[name] == "function" && fnTest.test(prop[name]) ? (function(name, fn) { return function() { var tmp = this.__super; this.__super = __super[name]; var ret = fn.apply(this, arguments); this.__super = tmp; return ret; }; })(name, prop[name]) : prop[name]; } } function Class() { if ( !initializing && this.__constructor ) { this.__constructor.apply(this, arguments); } } Class.prototype = proto; Class.constructor = Class; Class.extend = arguments.callee; return Class; }; var Base = Class.extend({ loop : function( elem, fn) { var scope = this; if (typeof elem == 'number') { elem = new Array(elem); } jQuery.each(elem, function() { fn.call(scope, arguments[1], arguments[0]); }); return elem; }, create : function( elem, className ) { elem = elem || 'div'; var el = document.createElement(elem); if (className) { el.className = className; } return el; }, getElements : function( selector ) { var elems = {}; this.loop( jQuery(selector), this.proxy(function( elem ) { this.push(elem, elems); })); return elems; }, setStyle : function( elem, css ) { jQuery(elem).css(css); return this; }, getStyle : function( elem, styleProp, parse ) { var val = jQuery(elem).css(styleProp); return parse ? this.parseValue( val ) : val; }, cssText : function( string ) { var style = document.createElement('style'); this.getElements('head')[0].appendChild(style); if (style.styleSheet) { // IE style.styleSheet.cssText = string; } else { var cssText = document.createTextNode(string); style.appendChild(cssText); } return this; }, touch : function(el) { var sibling = el.nextSibling; var parent = el.parentNode; parent.removeChild(el); if ( sibling ) { parent.insertBefore(el, sibling); } else { parent.appendChild(el); } if (el.styleSheet && el.styleSheet.imports.length) { this.loop(el.styleSheet.imports, function(i) { el.styleSheet.addImport(i.href); }); } }, loadCSS : function(href, callback) { var exists = this.getElements('link[href="'+href+'"]').length; if (exists) { callback.call(null); return exists[0]; } var link = this.create('link'); link.rel = 'stylesheet'; link.href = href; if (typeof callback == 'function') { // a new css check method, still experimental... this.wait(function() { return !!document.body; }, function() { var testElem = this.create('div', 'galleria-container galleria-stage'); this.moveOut(testElem); document.body.appendChild(testElem); var getStyles = this.proxy(function() { var str = ''; var props; if (document.defaultView && document.defaultView.getComputedStyle) { props = document.defaultView.getComputedStyle(testElem, ""); this.loop(props, function(prop) { str += prop + props.getPropertyValue(prop); }); } else if (testElem.currentStyle) { // IE props = testElem.currentStyle; this.loop(props, function(val, prop) { str += prop + val; }); } return str; }); var current = getStyles(); this.wait(function() { return getStyles() !== current; }, function() { document.body.removeChild(testElem); callback.call(link); }, function() { G.raise('Could not confirm theme CSS'); }, 2000); }); } window.setTimeout(this.proxy(function() { var styles = this.getElements('link[rel="stylesheet"],style'); if (styles.length) { styles[0].parentNode.insertBefore(link, styles[0]); } else { this.getElements('head')[0].appendChild(link); } // IE needs a manual touch to re-order the cascade if (G.IE) { this.loop(styles, function(el) { this.touch(el); }) } }), 2); return link; }, moveOut : function( elem ) { return this.setStyle(elem, { position: 'absolute', left: '-10000px', display: 'block' }); }, moveIn : function( elem ) { return this.setStyle(elem, { left: '0' }); }, reveal : function( elem ) { return jQuery( elem ).show(); }, hide : function( elem ) { return jQuery( elem ).hide(); }, mix : function() { return jQuery.extend.apply(jQuery, arguments); }, proxy : function( fn, scope ) { if ( typeof fn !== 'function' ) { return function() {}; } scope = scope || this; return function() { return fn.apply( scope, Array.prototype.slice.call(arguments) ); }; }, listen : function( elem, type, fn ) { jQuery(elem).bind( type, fn ); }, forget : function( elem, type, fn ) { jQuery(elem).unbind(type, fn); }, dispatch : function( elem, type ) { jQuery(elem).trigger(type); }, clone : function( elem, keepEvents ) { keepEvents = keepEvents || false; return jQuery(elem).clone(keepEvents)[0]; }, removeAttr : function( elem, attributes ) { this.loop( attributes.split(' '), function(attr) { jQuery(elem).removeAttr(attr); }); }, push : function( elem, obj ) { if (typeof obj.length == 'undefined') { obj.length = 0; } Array.prototype.push.call( obj, elem ); return elem; }, width : function( elem, outer ) { return this.meassure(elem, outer, 'Width'); }, height : function( elem, outer ) { return this.meassure(elem, outer, 'Height'); }, meassure : function(el, outer, meassure) { var elem = jQuery( el ); var ret = outer ? elem['outer'+meassure](true) : elem[meassure.toLowerCase()](); // fix quirks mode if (G.QUIRK) { var which = meassure == "Width" ? [ "left", "right" ] : [ "top", "bottom" ]; this.loop(which, function(s) { ret += elem.css('border-' + s + '-width').replace(/[^\d]/g,'') * 1; ret += elem.css('padding-' + s).replace(/[^\d]/g,'') * 1; }); } return ret; }, toggleClass : function( elem, className, arg ) { if (typeof arg !== 'undefined') { var fn = arg ? 'addClass' : 'removeClass'; jQuery(elem)[fn](className); return this; } jQuery(elem).toggleClass(className); return this; }, hideAll : function( el ) { jQuery(el).find('*').hide(); }, animate : function( el, options ) { options.complete = this.proxy(options.complete); var elem = jQuery(el); if (!elem.length) { return; } if (options.from) { elem.css(from); } elem.animate(options.to, { duration: options.duration || 400, complete: options.complete, easing: options.easing || 'swing' }); }, wait : function(fn, callback, err, max) { fn = this.proxy(fn); callback = this.proxy(callback); err = this.proxy(err); var ts = new Date().getTime() + (max || 3000); window.setTimeout(function() { if (fn()) { callback(); return false; } if (new Date().getTime() >= ts) { err(); callback(); return false; } window.setTimeout(arguments.callee, 2); }, 2); return this; }, loadScript: function(url, callback) { var script = document.createElement('script'); script.src = url; script.async = true; // HTML5 var done = false; var scope = this; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if ( !done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete") ) { done = true; if (typeof callback == 'function') { callback.call(scope, this); } // Handle memory leak in IE script.onload = script.onreadystatechange = null; } }; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(script, s); return this; }, parseValue: function(val) { if (typeof val == 'number') { return val; } else if (typeof val == 'string') { var arr = val.match(/\-?\d/g); return arr && arr.constructor == Array ? arr.join('')*1 : 0; } else { return 0; } } }); var Picture = Base.extend({ __constructor : function(order) { this.image = null; this.elem = this.create('div', 'galleria-image'); this.setStyle( this.elem, { overflow: 'hidden', position: 'relative' // for IE Standards mode } ); this.order = order; this.orig = { w:0, h:0, r:1 }; }, cache: {}, ready: false, add: function(src) { if (this.cache[src]) { return this.cache[src]; } var image = new Image(); image.src = src; this.setStyle(image, {display: 'block'}); if (image.complete && image.width) { this.cache[src] = image; return image; } image.onload = (function(scope) { return function() { scope.cache[src] = image; }; })(this); return image; }, isCached: function(src) { return this.cache[src] ? this.cache[src].complete : false; }, make: function(src) { var i = this.cache[src] || this.add(src); return this.clone(i); }, load: function(src, callback) { callback = this.proxy( callback ); this.elem.innerHTML = ''; this.image = this.make( src ); this.moveOut( this.image ); this.elem.appendChild( this.image ); this.wait(function() { return (this.image.complete && this.image.width); }, function() { this.orig = { h: this.h || this.image.height, w: this.w || this.image.width }; callback( {target: this.image, scope: this} ); }, function() { G.raise('image not loaded in 20 seconds: '+ src); }, 20000); return this; }, scale: function(options) { var o = this.mix({ width: 0, height: 0, min: undefined, max: undefined, margin: 0, complete: function(){}, position: 'center', crop: false }, options); if (!this.image) { return this; } var width,height; this.wait(function() { width = o.width || this.width(this.elem); height = o.height || this.height(this.elem); return width && height; }, function() { var nw = (width - o.margin*2) / this.orig.w; var nh = (height- o.margin*2) / this.orig.h; var rmap = { 'true': Math.max(nw,nh), 'width': nw, 'height': nh, 'false': Math.min(nw,nh) } var ratio = rmap[o.crop.toString()]; if (o.max) { ratio = Math.min(o.max, ratio); } if (o.min) { ratio = Math.max(o.min, ratio); } this.setStyle(this.elem, { width: width, height: height }); this.image.width = Math.ceil(this.orig.w * ratio); this.image.height = Math.ceil(this.orig.h * ratio); var getPosition = this.proxy(function(value, img, m) { var result = 0; if (/\%/.test(value)) { var pos = parseInt(value) / 100; result = Math.ceil(this.image[img] * -1 * pos + m * pos); } else { result = parseInt(value); } return result; }); var map = { 'top': { top: 0 }, 'left': { left: 0 }, 'right': { left: '100%' }, 'bottom': { top: '100%' } } var pos = {}; var mix = {}; this.loop(o.position.toLowerCase().split(' '), function(p, i) { if (p == 'center') { p = '50%'; } pos[i ? 'top' : 'left'] = p; }); this.loop(pos, function(val, key) { if (map.hasOwnProperty(val)) { mix = this.mix(mix, map[val]); } }); pos = pos.top ? this.mix(pos, mix) : mix; pos = this.mix({ top: '50%', left: '50%' }, pos); this.setStyle(this.image, { position : 'relative', top : getPosition(pos.top, 'height', height), left : getPosition(pos.left, 'width', width) }); this.ready = true; o.complete.call(this); }); return this; } }); var G = window.Galleria = Base.extend({ __constructor : function(options) { this.theme = undefined; this.options = options; this.playing = false; this.playtime = 5000; this.active = null; this.queue = {}; this.data = {}; this.dom = {}; var kb = this.keyboard = { keys : { UP: 38, DOWN: 40, LEFT: 37, RIGHT: 39, RETURN: 13, ESCAPE: 27, BACKSPACE: 8 }, map : {}, bound: false, press: this.proxy(function(e) { var key = e.keyCode || e.which; if (kb.map[key] && typeof kb.map[key] == 'function') { kb.map[key].call(this, e); } }), attach: this.proxy(function(map) { for( var i in map ) { var k = i.toUpperCase(); if ( kb.keys[k] ) { kb.map[kb.keys[k]] = map[i]; } } if (!kb.bound) { kb.bound = true; this.listen(document, 'keydown', kb.press); } }), detach: this.proxy(function() { kb.bound = false; this.forget(document, 'keydown', kb.press); }) }; this.timeouts = { trunk: {}, add: function(id, fn, delay, loop) { loop = loop || false; this.clear(id); if (loop) { var self = this; var old = fn; fn = function() { old(); self.add(id,fn,delay); } } this.trunk[id] = window.setTimeout(fn,delay); }, clear: function(id) { if (id && this.trunk[id]) { window.clearTimeout(this.trunk[id]); delete this.trunk[id]; } else if (typeof id == 'undefined') { for (var i in this.trunk) { window.clearTimeout(this.trunk[i]); delete this.trunk[i]; } } } }; this.controls = { 0 : null, 1 : null, active : 0, swap : function() { this.active = this.active ? 0 : 1; }, getActive : function() { return this[this.active]; }, getNext : function() { return this[Math.abs(this.active - 1)]; } }; var fs = this.fullscreen = { scrolled: 0, enter: this.proxy(function() { this.toggleClass( this.get('container'), 'fullscreen'); fs.scrolled = jQuery(window).scrollTop(); this.loop(fs.getElements(), function(el, i) { fs.styles[i] = el.getAttribute('style'); el.removeAttribute('style'); }); this.setStyle(fs.getElements(0), { position: 'fixed', top: 0, left: 0, width: '100%', height: '100%', zIndex: 10000 }); var bh = { height: '100%', overflow: 'hidden', margin:0, padding:0 }; this.setStyle( fs.getElements(1), bh ); this.setStyle( fs.getElements(2), bh ); this.attachKeyboard({ escape: this.exitFullscreen, right: this.next, left: this.prev }); this.rescale(this.proxy(function() { this.trigger(G.FULLSCREEN_ENTER); })); this.listen(window, 'resize', fs.scale); }), scale: this.proxy(function() { this.rescale(); }), exit: this.proxy(function() { this.toggleClass( this.get('container'), 'fullscreen', false); if (!fs.styles.length) { return; } this.loop(fs.getElements(), function(el, i) { el.removeAttribute('style'); el.setAttribute('style', fs.styles[i]); }); window.scrollTo(0, fs.scrolled); this.detachKeyboard(); this.rescale(this.proxy(function() { this.trigger(G.FULLSCREEN_EXIT); })); this.forget(window, 'resize', fs.scale); }), styles: [], getElements: this.proxy(function(i) { var elems = [ this.get('container'), document.body, this.getElements('html')[0] ]; return i ? elems[i] : elems; }) }; var idle = this.idle = { trunk: [], bound: false, add: this.proxy(function(elem, styles, fn) { if (!elem) { return; } if (!idle.bound) { idle.addEvent(); } elem = jQuery(elem); var orig = {}; for (var style in styles) { orig[style] = elem.css(style); } elem.data('idle', { from: orig, to: styles, complete: true, busy: false, fn: this.proxy(fn) }); idle.addTimer(); idle.trunk.push(elem); }), remove: this.proxy(function(elem) { elem = jQuery(elem); this.loop(idle.trunk, function(el, i) { if ( el && !el.not(elem).length ) { idle.show(elem); idle.trunk.splice(i,1); } }); if (!idle.trunk.length) { idle.removeEvent(); this.clearTimer('idle'); } }), addEvent: this.proxy(function() { idle.bound = true; this.listen( this.get('container'), 'mousemove click', idle.showAll ); }), removeEvent: this.proxy(function() { idle.bound = false; this.forget( this.get('container'), 'mousemove click', idle.showAll ); }), addTimer: this.proxy(function() { this.addTimer('idle', this.proxy(function() { idle.hide(); }),this.options.idle_time); }), hide: this.proxy(function() { this.trigger(G.IDLE_ENTER); this.loop(idle.trunk, function(elem) { var data = elem.data('idle'); data.complete = false; data.fn(); elem.animate(data.to, { duration: 600, queue: false, easing: 'swing' }); }); }), showAll: this.proxy(function() { this.clearTimer('idle'); this.loop(idle.trunk, function(elem) { idle.show(elem); }); }), show: this.proxy(function(elem) { var data = elem.data('idle'); if (!data.busy && !data.complete) { data.busy = true; this.trigger(G.IDLE_EXIT); elem.animate(data.from, { duration: 300, queue: false, easing: 'swing', complete: function() { $(this).data('idle').busy = false; $(this).data('idle').complete = true; } }); } idle.addTimer(); }) }; var lightbox = this.lightbox = { w: 0, h: 0, initialized: false, active: null, init: this.proxy(function() { if (lightbox.initialized) { return; } lightbox.initialized = true; var elems = 'lightbox-overlay lightbox-box lightbox-content lightbox-shadow lightbox-title ' + 'lightbox-info lightbox-close lightbox-prev lightbox-next lightbox-counter'; this.loop(elems.split(' '), function(el) { this.addElement(el); lightbox[el.split('-')[1]] = this.get(el); }); lightbox.image = new Galleria.Picture(); this.append({ 'lightbox-box': ['lightbox-shadow','lightbox-content', 'lightbox-close'], 'lightbox-info': ['lightbox-title','lightbox-counter','lightbox-next','lightbox-prev'], 'lightbox-content': ['lightbox-info'] }); document.body.appendChild( lightbox.overlay ); document.body.appendChild( lightbox.box ); lightbox.content.appendChild( lightbox.image.elem ); lightbox.close.innerHTML = '×'; lightbox.prev.innerHTML = '◄'; lightbox.next.innerHTML = '►'; this.listen( lightbox.close, 'click', lightbox.hide ); this.listen( lightbox.overlay, 'click', lightbox.hide ); this.listen( lightbox.next, 'click', lightbox.showNext ); this.listen( lightbox.prev, 'click', lightbox.showPrev ); if (this.options.lightbox_clicknext) { this.setStyle( lightbox.image.elem, {cursor:'pointer'} ); this.listen( lightbox.image.elem, 'click', lightbox.showNext); } this.setStyle( lightbox.overlay, { position: 'fixed', display: 'none', opacity: this.options.overlay_opacity, top: 0, left: 0, width: '100%', height: '100%', background: this.options.overlay_background, zIndex: 99990 }); this.setStyle( lightbox.box, { position: 'fixed', display: 'none', width: 400, height: 400, top: '50%', left: '50%', marginTop: -200, marginLeft: -200, zIndex: 99991 }); this.setStyle( lightbox.shadow, { background:'#000', opacity:.4, width: '100%', height: '100%', position: 'absolute' }); this.setStyle( lightbox.content, { backgroundColor:'#fff',position: 'absolute', top: 10, left: 10, right: 10, bottom: 10, overflow: 'hidden' }); this.setStyle( lightbox.info, { color: '#444', fontSize: '11px', fontFamily: 'arial,sans-serif', height: 13, lineHeight: '13px', position: 'absolute', bottom: 10, left: 10, right: 10, opacity: 0 }); this.setStyle( lightbox.close, { background: '#fff', height: 20, width: 20, position: 'absolute', textAlign: 'center', cursor: 'pointer', top: 10, right: 10, lineHeight: '22px', fontSize: '16px', fontFamily:'arial,sans-serif',color:'#444', zIndex: 99999 }); this.setStyle( lightbox.image.elem, { top: 10, left: 10, right: 10, bottom: 30, position: 'absolute' }); this.loop('title prev next counter'.split(' '), function(el) { var css = { display: 'inline', 'float':'left' }; if (el != 'title') { this.mix(css, { 'float': 'right'}); if (el != 'counter') { this.mix(css, { cursor: 'pointer'}); } else { this.mix(css, { marginLeft: 8 }); } } this.setStyle(lightbox[el], css); }); this.loop('prev next close'.split(' '), function(el) { this.listen(lightbox[el], 'mouseover', this.proxy(function() { this.setStyle(lightbox[el], { color:'#000' }); })); this.listen(lightbox[el], 'mouseout', this.proxy(function() { this.setStyle(lightbox[el], { color:'#444' }); })); }); this.trigger(G.LIGHTBOX_OPEN); }), rescale: this.proxy(function(e) { var w = Math.min( this.width(window), lightbox.w ); var h = Math.min( this.height(window), lightbox.h ); var r = Math.min( (w-60) / lightbox.w, (h-80) / lightbox.h ); var destW = (lightbox.w * r) + 40; var destH = (lightbox.h * r) + 60; var dest = { width: destW, height: destH, marginTop: Math.ceil(destH/2)*-1, marginLeft: Math.ceil(destW)/2*-1 } if (!e) { this.animate( lightbox.box, { to: dest, duration: this.options.lightbox_transition_speed, easing: 'galleria', complete: function() { this.trigger({ type: G.LIGHTBOX_IMAGE, imageTarget: lightbox.image.image }); this.moveIn( lightbox.image.image ); this.animate( lightbox.image.image, { to: { opacity:1 }, duration: this.options.lightbox_fade_speed } ); this.animate( lightbox.info, { to: { opacity:1 }, duration: this.options.lightbox_fade_speed } ); } }); } else { this.setStyle( lightbox.box, dest ); } }), hide: this.proxy(function() { lightbox.image.image = null; this.forget(window, 'resize', lightbox.rescale); this.hide( lightbox.box ); this.setStyle( lightbox.info, { opacity: 0 } ); this.animate( lightbox.overlay, { to: { opacity: 0 }, duration: 200, complete: function() { this.hide( lightbox.overlay ); this.setStyle( lightbox.overlay, { opacity: this.options.overlay_opacity}); this.trigger(G.LIGHTBOX_CLOSE); } }); }), showNext: this.proxy(function() { lightbox.show(this.getNext(lightbox.active)); }), showPrev: this.proxy(function() { lightbox.show(this.getPrev(lightbox.active)); }), show: this.proxy(function(index) { if (!lightbox.initialized) { lightbox.init(); } this.forget( window, 'resize', lightbox.rescale ); index = typeof index == 'number' ? index : this.getIndex(); lightbox.active = index; var data = this.getData(index); var total = this.data.length; this.setStyle( lightbox.info, {opacity:0} ); lightbox.image.load( data.image, function(o) { lightbox.w = o.scope.orig.w; lightbox.h = o.scope.orig.h; this.setStyle(o.target, { width: '100.5%', height: '100.5%', top:0, zIndex: 99998, opacity: 0 }); lightbox.title.innerHTML = data.title; lightbox.counter.innerHTML = (index+1) + ' / ' + total; this.listen( window, 'resize', lightbox.rescale ); lightbox.rescale(); }); this.reveal( lightbox.overlay ); this.reveal( lightbox.box ); }) }; this.thumbnails = { width: 0 }; this.stageWidth = 0; this.stageHeight = 0; var elems = 'container stage images image-nav image-nav-left image-nav-right ' + 'info info-text info-title info-description info-author ' + 'thumbnails thumbnails-list thumbnails-container thumb-nav-left thumb-nav-right ' + 'loader counter'; elems = elems.split(' '); this.loop(elems, function(blueprint) { this.dom[ blueprint ] = this.create('div', 'galleria-' + blueprint); }); this.target = this.dom.target = options.target.nodeName ? options.target : this.getElements(options.target)[0]; if (!this.target) { G.raise('Target not found.'); } }, init: function() { this.options = this.mix(G.theme.defaults, this.options); this.options = this.mix({ autoplay: false, carousel: true, carousel_follow: true, carousel_speed: 400, carousel_steps: 'auto', clicknext: false, data_config : function( elem ) { return {}; }, data_image_selector: 'img', data_source: this.target, data_type: 'auto', debug: false, extend: function(options) {}, height: 'auto', idle_time: 30, image_crop: true, image_margin: 0, image_pan: false, image_pan_smoothness: 12, image_position: '80%', keep_source: false, lightbox_clicknext: true, lightbox_fade_speed: 200, lightbox_transition_speed: 300, link_source_images: true, max_scale_ratio: undefined, min_scale_ratio: undefined, on_image: function(img,thumb) {}, overlay_opacity: .5, overlay_background: '#0b0b0b', popup_links: false, preload: 0, queue: true, show: 0, show_info: true, show_counter: false, show_imagenav: true, thumb_crop: true, thumb_fit: true, thumb_margin: 0, thumb_quality: 'auto', thumbnails: true, transition: G.transitions.fade, transition_speed: 100 }, this.options); var o = this.options; this.bind(G.DATA, function() { this.run(); }); if (o.clicknext) { this.loop(this.data, function(data) { delete data.link; }); this.setStyle(this.get('stage'), { cursor: 'pointer'} ); this.listen(this.get('stage'), 'click', this.proxy(function() { this.next(); })); } this.bind(G.IMAGE, function(e) { o.on_image.call(this, e.imageTarget, e.thumbTarget); }); this.bind(G.READY, function() { if (G.History) { G.History.change(this.proxy(function(e) { var val = parseInt(e.value.replace(/\//,'')); if (isNaN(val)) { window.history.go(-1); } else { this.show(val, undefined, true); } })); } G.theme.init.call(this, o); o.extend.call(this, o); if (/^[0-9]{1,4}$/.test(hash) && G.History) { this.show(hash, undefined, true); } else if (typeof o.show == 'number') { this.show(o.show); } if (o.autoplay) { if (typeof o.autoplay == 'number') { this.playtime = o.autoplay; } this.trigger( G.PLAY ); this.playing = true; } }); this.load(); return this; }, bind : function(type, fn) { this.listen( this.get('container'), type, this.proxy(fn) ); return this; }, unbind : function(type) { this.forget( this.get('container'), type ); }, trigger : function( type ) { type = typeof type == 'object' ? this.mix( type, { scope: this } ) : { type: type, scope: this }; this.dispatch( this.get('container'), type ); return this; }, addIdleState: function() { this.idle.add.apply(this, arguments); return this; }, removeIdleState: function() { this.idle.remove.apply(this, arguments); return this; }, enterIdleMode: function() { this.idle.hide(); return this; }, exitIdleMode: function() { this.idle.show(); return this; }, addTimer: function() { this.timeouts.add.apply(this.timeouts, arguments); return this; }, clearTimer: function() { this.timeouts.clear.apply(this.timeouts, arguments); return this; }, enterFullscreen: function() { this.fullscreen.enter.apply(this, arguments); return this; }, exitFullscreen: function() { this.fullscreen.exit.apply(this, arguments); return this; }, openLightbox: function() { this.lightbox.show.apply(this, arguments); }, closeLightbox: function() { this.lightbox.hide.apply(this, arguments); }, getActive: function() { return this.controls.getActive(); }, getActiveImage: function() { return this.getActive().image || null; }, run : function() { var o = this.options; if (!this.data.length) { G.raise('Data is empty.'); } if (!o.keep_source && !Galleria.IE) { this.target.innerHTML = ''; } this.loop(2, function() { var image = new Picture(); this.setStyle( image.elem, { position: 'absolute', top: 0, left: 0 }); this.setStyle(this.get( 'images' ), { position: 'relative', top: 0, left: 0, width: '100%', height: '100%' }); this.get( 'images' ).appendChild( image.elem ); this.push(image, this.controls); }, this); if (o.carousel) { // try the carousel on each thumb load this.bind(G.THUMBNAIL, this.parseCarousel); } this.build(); this.target.appendChild(this.get('container')); this.loop(['info','counter','image-nav'], function(el) { if ( o[ 'show_'+el.replace(/-/,'') ] === false ) { this.moveOut( this.get(el) ); } }); var w = 0; var h = 0; for( var i=0; this.data[i]; i++ ) { var thumb; if (o.thumbnails === true) { thumb = new Picture(i); var src = this.data[i].thumb || this.data[i].image; this.get( 'thumbnails' ).appendChild( thumb.elem ); w = this.getStyle(thumb.elem, 'width', true); h = this.getStyle(thumb.elem, 'height', true); // grab & reset size for smoother thumbnail loads if (o.thumb_fit && o.thum_crop !== true) { this.setStyle(thumb.elem, { width:0, height: 0}); } thumb.load(src, this.proxy(function(e) { var orig = e.target.width; e.scope.scale({ width: w, height: h, crop: o.thumb_crop, margin: o.thumb_margin, complete: this.proxy(function() { // shrink thumbnails to fit var top = ['left', 'top']; var arr = ['Height', 'Width']; this.loop(arr, function(m,i) { if ((!o.thumb_crop || o.thumb_crop == m.toLowerCase()) && o.thumb_fit) { var css = {}; var opp = arr[Math.abs(i-1)].toLowerCase(); css[opp] = e.target[opp]; this.setStyle(e.target.parentNode, css); var css = {}; css[top[i]] = 0; this.setStyle(e.target, css); } e.scope['outer'+m] = this[m.toLowerCase()](e.target.parentNode, true); }); // set high quality if downscale is moderate this.toggleQuality(e.target, o.thumb_quality === true || ( o.thumb_quality == 'auto' && orig < e.target.width * 3 )); this.trigger({ type: G.THUMBNAIL, thumbTarget: e.target, thumbOrder: e.scope.order }); }) }); })); if (o.preload == 'all') { thumb.add(this.data[i].image); } } else if (o.thumbnails == 'empty') { thumb = { elem: this.create('div','galleria-image'), image: this.create('span','img') }; thumb.elem.appendChild(thumb.image); this.get( 'thumbnails' ).appendChild( thumb.elem ); } else { thumb = { elem: false, image: false } } var activate = this.proxy(function(e) { this.pause(); e.preventDefault(); var ind = e.currentTarget.rel; if (this.active !== ind) { this.show( ind ); } }); if (o.thumbnails !== false) { thumb.elem.rel = i; this.listen(thumb.elem, 'click', activate); } if (o.link_source_images && o.keep_source && this.data[i].elem) { this.data[i].elem.rel = i; this.listen(this.data[i].elem, 'click', activate); } this.push(thumb, this.thumbnails ); } this.setStyle( this.get('thumbnails'), { opacity: 0 } ); if (o.height && o.height != 'auto') { this.setStyle( this.get('container'), { height: o.height }) } this.wait(function() { // the most sensitive piece of code in Galleria, we need to have all the meassurements right to continue var cssHeight = this.getStyle( this.get( 'container' ), 'height', true ); this.stageWidth = this.width(this.get( 'stage' )); this.stageHeight = this.height( this.get( 'stage' )); if (this.stageHeight < 50 && o.height == 'auto') { // no height detected for sure, set reasonable ratio (16/9) this.setStyle( this.get( 'container' ), { height: Math.round( this.stageWidth*9/16 ) } ); this.stageHeight = this.height( this.get( 'stage' )); } return this.stageHeight && this.stageWidth; }, function() { this.listen(this.get('image-nav-right'), 'click', this.proxy(function(e) { if (o.clicknext) { e.stopPropagation(); } this.pause(); this.next(); })); this.listen(this.get('image-nav-left'), 'click', this.proxy(function(e) { if (o.clicknext) { e.stopPropagation(); } this.pause(); this.prev(); })); this.setStyle( this.get('thumbnails'), { opacity: 1 } ); this.trigger( G.READY ); }, function() { G.raise('Galleria could not load properly. Make sure stage has a height and width.'); }, 5000); }, mousePosition : function(e) { return { x: e.pageX - this.$('stage').offset().left + jQuery(document).scrollLeft(), y: e.pageY - this.$('stage').offset().top + jQuery(document).scrollTop() }; }, addPan : function(img) { var c = this.options.image_crop; if ( c === false ) { return; } if (this.options.image_crop === false) { return; } img = img || this.controls.getActive().image; if (img.tagName.toUpperCase() != 'IMG') { G.raise('Could not add pan'); } var x = img.width/2; var y = img.height/2; var curX = destX = this.getStyle(img, 'left', true) || 0; var curY = destY = this.getStyle(img, 'top', true) || 0; var distX = 0; var distY = 0; var active = false; var ts = new Date().getTime(); var calc = this.proxy(function(e) { if (new Date().getTime() - ts < 50) { return; } active = true; x = this.mousePosition(e).x; y = this.mousePosition(e).y; }); var loop = this.proxy(function(e) { if (!active) { return; } distX = img.width - this.stageWidth; distY = img.height - this.stageHeight; destX = x / this.stageWidth * distX * -1; destY = y / this.stageHeight * distY * -1; curX += (destX - curX) / this.options.image_pan_smoothness; curY += (destY - curY) / this.options.image_pan_smoothness; if (distY > 0) { this.setStyle(img, { top: Math.max(distY*-1, Math.min(0, curY)) }); } if (distX > 0) { this.setStyle(img, { left: Math.max(distX*-1, Math.min(0, curX)) }); } }); this.forget(this.get('stage'), 'mousemove'); this.listen(this.get('stage'), 'mousemove', calc); this.addTimer('pan', loop, 30, true); }, removePan: function() { this.forget(this.get('stage'), 'mousemove'); this.clearTimer('pan'); }, parseCarousel : function(e) { var w = 0; var h = 0; var hooks = [0]; this.loop(this.thumbnails, function(thumb,i) { if (thumb.ready) { w += thumb.outerWidth || this.width(thumb.elem, true); hooks[i+1] = w; h = Math.max(h, this.height(thumb.elem)); } }); this.toggleClass(this.get('thumbnails-container'), 'galleria-carousel', w > this.stageWidth); this.setStyle(this.get('thumbnails-list'), { overflow:'hidden', position: 'relative' // for IE Standards mode }); this.setStyle(this.get('thumbnails'), { width: w, height: h, position: 'relative', overflow: 'hidden' }); if (!this.carousel) { this.initCarousel(); } this.carousel.max = w; this.carousel.hooks = hooks; this.carousel.width = this.width(this.get('thumbnails-list')); this.carousel.setClasses(); }, initCarousel : function() { var c = this.carousel = { right: this.get('thumb-nav-right'), left: this.get('thumb-nav-left'), update: this.proxy(function() { this.parseCarousel(); // todo: fix so the carousel moves to the left }), width: 0, current: 0, set: function(i) { i = Math.max(i,0); while (c.hooks[i-1] + c.width > c.max && i >= 0) { i--; } c.current = i; c.animate(); }, hooks: [], getLast: function(i) { i = i || c.current return i-1; }, follow: function(i) { if (i == 0 || i == c.hooks.length-2) { c.set(i); return; } var last = c.current; while(c.hooks[last] - c.hooks[c.current] < c.width && last<= c.hooks.length) { last++; } if (i-1 < c.current) { c.set(i-1) } else if (i+2 > last) { c.set(i - last + c.current + 2) } }, max: 0, setClasses: this.proxy(function() { this.toggleClass( c.left, 'disabled', !c.current ); this.toggleClass( c.right, 'disabled', c.hooks[c.current] + c.width > c.max ); }), animate: this.proxy(function(to) { c.setClasses(); this.animate( this.get('thumbnails'), { to: { left: c.hooks[c.current] * -1 }, duration: this.options.carousel_speed, easing: 'galleria', queue: false }); }) }; this.listen(c.right, 'click', this.proxy(function(e) { if (this.options.carousel_steps == 'auto') { for (var i = c.current; i c.width) { c.set(i-2); break; } } } else { c.set(c.current + this.options.carousel_steps); } })); this.listen(c.left, 'click', this.proxy(function(e) { if (this.options.carousel_steps == 'auto') { for (var i = c.current; i>=0; i--) { if (c.hooks[c.current] - c.hooks[i] > c.width) { c.set(i+2); break; } else if (i == 0) { c.set(0); break; } } } else { c.set(c.current - this.options.carousel_steps); } })); }, addElement : function() { this.loop(arguments, function(b) { this.dom[b] = this.create('div', 'galleria-' + b ); }); return this; }, getDimensions: function(i) { return { w: i.width, h: i.height, cw: this.stageWidth, ch: this.stageHeight, top: (this.stageHeight - i.height) / 2, left: (this.stageWidth - i.width) / 2 }; }, attachKeyboard : function(map) { this.keyboard.attach(map); return this; }, detachKeyboard : function() { this.keyboard.detach(); return this; }, build : function() { this.append({ 'info-text' : ['info-title', 'info-description', 'info-author'], 'info' : ['info-text'], 'image-nav' : ['image-nav-right', 'image-nav-left'], 'stage' : ['images', 'loader', 'counter', 'image-nav'], 'thumbnails-list' : ['thumbnails'], 'thumbnails-container' : ['thumb-nav-left', 'thumbnails-list', 'thumb-nav-right'], 'container' : ['stage', 'thumbnails-container', 'info'] }); this.current = this.create('span', 'current'); this.current.innerHTML = '-'; this.get('counter').innerHTML = ' / ' + this.data.length + ''; this.prependChild('counter', this.current); }, appendChild : function(parent, child) { try { this.get(parent).appendChild(this.get(child)); } catch(e) {} }, prependChild : function(parent, child) { var child = this.get(child) || child; try { this.get(parent).insertBefore(child, this.get(parent).firstChild); } catch(e) {} }, remove : function() { var a = Array.prototype.slice.call(arguments); this.jQuery(a.join(',')).remove(); }, append : function(data) { for( var i in data) { if (data[i].constructor == Array) { for(var j=0; data[i][j]; j++) { this.appendChild(i, data[i][j]); } } else { this.appendChild(i, data[i]); } } return this; }, rescale : function(width, height, callback) { var o = this.options; callback = this.proxy(callback); if (typeof width == 'function') { callback = this.proxy(width); width = undefined; } var scale = this.proxy(function() { this.stageWidth = width || this.width(this.get('stage')); this.stageHeight = height || this.height(this.get('stage')); this.controls.getActive().scale({ width: this.stageWidth, height: this.stageHeight, crop: o.image_crop, max: o.max_scale_ratio, min: o.min_scale_ratio, margin: o.image_margin, position: o.image_position }); if (this.carousel) { this.carousel.update(); } this.trigger(G.RESCALE) callback(); }); if ( G.WEBKIT && !width && !height ) { this.addTimer('scale', scale, 5);// webkit is too fast } else { scale.call(this); } }, show : function(index, rewind, history) { if (!this.options.queue && this.queue.stalled) { return; } rewind = typeof rewind != 'undefined' ? !!rewind : index < this.active; history = history || false; index = Math.max(0, Math.min(parseInt(index), this.data.length - 1)); if (!history && G.History) { G.History.value(index.toString()); return; } this.active = index; this.push([index,rewind], this.queue); if (!this.queue.stalled) { this.showImage(); } return this; }, showImage : function() { var o = this.options; var args = this.queue[0]; var index = args[0]; var rewind = !!args[1]; if (o.carousel && this.carousel && o.carousel_follow) { this.carousel.follow(index); } var src = this.getData(index).image; var active = this.controls.getActive(); var next = this.controls.getNext(); var cached = next.isCached(src); var complete = this.proxy(function() { this.queue.stalled = false; this.toggleQuality(next.image, o.image_quality); this.setStyle( active.elem, { zIndex : 0 } ); this.setStyle( next.elem, { zIndex : 1 } ); this.trigger({ type: G.IMAGE, index: index, imageTarget: next.image, thumbTarget: this.thumbnails[index].image }); if (o.image_pan) { this.addPan(next.image); } this.controls.swap(); this.moveOut( active.image ); if (this.getData( index ).link) { this.setStyle( next.image, { cursor: 'pointer' } ); this.listen( next.image, 'click', this.proxy(function() { if (o.popup_links) { var win = window.open(this.getData( index ).link, '_blank'); } else { window.location.href = this.getData( index ).link; } })); } Array.prototype.shift.call( this.queue ); if (this.queue.length) { this.showImage(); } this.playCheck(); }); if (typeof o.preload == 'number' && o.preload > 0) { var p,n = this.getNext(); try { for (var i = o.preload; i>0; i--) { p = new Picture(); p.add(this.getData(n).image); n = this.getNext(n); } } catch(e) {} } this.trigger( { type: G.LOADSTART, cached: cached, index: index, imageTarget: next.image, thumbTarget: this.thumbnails[index].image } ); jQuery(this.thumbnails[index].elem).addClass('active').siblings('.active').removeClass('active'); next.load( src, this.proxy(function(e) { next.scale({ width: this.stageWidth, height: this.stageHeight, crop: o.image_crop, max: o.max_scale_ratio, min: o.min_scale_ratio, margin: o.image_margin, position: o.image_position, complete: this.proxy(function() { if (active.image) { this.toggleQuality(active.image, false); } this.toggleQuality(next.image, false); this.trigger({ type: G.LOADFINISH, cached: cached, index: index, imageTarget: next.image, thumbTarget: this.thumbnails[index].image }); this.queue.stalled = true; var transition = G.transitions[o.transition] || o.transition; this.removePan(); this.setInfo(index); this.setCounter(index); if (typeof transition == 'function') { transition.call(this, { prev: active.image, next: next.image, rewind: rewind, speed: o.transition_speed || 400 }, complete ); } else { complete(); } }) }); })); }, getNext : function(base) { base = typeof base == 'number' ? base : this.active; return base == this.data.length - 1 ? 0 : base + 1; }, getPrev : function(base) { base = typeof base == 'number' ? base : this.active; return base === 0 ? this.data.length - 1 : base - 1; }, next : function() { if (this.data.length > 1) { this.show(this.getNext(), false); } return this; }, prev : function() { if (this.data.length > 1) { this.show(this.getPrev(), true); } return this; }, get : function( elem ) { return elem in this.dom ? this.dom[ elem ] : null; }, getData : function( index ) { return this.data[index] || this.data[this.active]; }, getIndex : function() { return typeof this.active === 'number' ? this.active : 0; }, play : function(delay) { this.trigger( G.PLAY ); this.playing = true; this.playtime = delay || this.playtime; this.playCheck(); return this; }, pause : function() { this.trigger( G.PAUSE ); this.playing = false; return this; }, playCheck : function() { var p = 0; var i = 20; // the interval var ts = function() { return new Date().getTime(); } var now = ts(); if (this.playing) { this.clearTimer('play'); var fn = this.proxy(function() { p = ts() - now; if ( p >= this.playtime && this.playing ) { this.clearTimer('play'); this.next(); return; } if ( this.playing ) { this.trigger({ type: G.PROGRESS, percent: Math.ceil(p / this.playtime * 100), seconds: Math.floor(p/1000), milliseconds: p }); this.addTimer('play', fn, i); } }); this.addTimer('play', fn, i); } }, setActive: function(val) { this.active = val; return this; }, setCounter: function(index) { index = index || this.active; this.current.innerHTML = index+1; return this; }, setInfo : function(index) { var data = this.getData(index || this.active); this.loop(['title','description','author'], function(type) { var elem = this.get('info-'+type); var fn = data[type] && data[type].length ? 'reveal' : 'hide'; this[fn](elem); if (data[type]) { elem.innerHTML = data[type]; } }); return this; }, hasInfo : function(index) { var d = this.getData(index); var check = 'title description author'.split(' '); for ( var i=0; check[i]; i++ ) { if ( d[ check[i] ] && d[ check[i] ].length ) { return true; } } return false; }, getDataObject : function(o) { var obj = { image: '', thumb: '', title: '', description: '', author: '', link: '' }; return o ? this.mix(obj,o) : obj; }, jQuery : function( str ) { var ret = []; this.loop(str.split(','), this.proxy(function(elem) { elem = elem.replace(/^\s\s*/, "").replace(/\s\s*$/, ""); if (this.get(elem)) { ret.push(elem); } })); var jQ = jQuery(this.get(ret.shift())); this.loop(ret, this.proxy(function(elem) { jQ = jQ.add(this.get(elem)); })); return jQ; }, $ : function( str ) { return this.jQuery( str ); }, toggleQuality : function(img, force) { if (!G.IE7 || typeof img == 'undefined' || !img) { return this; } if (typeof force === 'undefined') { force = img.style.msInterpolationMode == 'nearest-neighbor'; } img.style.msInterpolationMode = force ? 'bicubic' : 'nearest-neighbor'; return this; }, unload : function() { //TODO }, load : function() { var loaded = 0; var o = this.options; if ( (o.data_type == 'auto' && typeof o.data_source == 'object' && !(o.data_source instanceof jQuery) && !o.data_source.tagName ) || o.data_type == 'json' || o.data_source.constructor == Array ) { this.data = o.data_source; this.trigger( G.DATA ); } else { // assume selector var images = jQuery(o.data_source).find(o.data_image_selector); var getData = this.proxy(function( elem ) { var i,j,anchor = elem.parentNode; if (anchor && anchor.nodeName == 'A') { if (anchor.href.match(/\.(png|gif|jpg|jpeg)/i)) { i = anchor.href; } else { j = anchor.href; } } var obj = this.getDataObject({ title: elem.title, thumb: elem.src, image: i || elem.src, description: elem.alt, link: j || elem.getAttribute('longdesc'), elem: elem }); return this.mix(obj, o.data_config( elem ) ); }); this.loop(images, function( elem ) { loaded++; this.push( getData( elem ), this.data ); if (!o.keep_source && !Galleria.IE) { elem.parentNode.removeChild(elem); } if ( loaded == images.length ) { this.trigger( G.DATA ); } }); } } }); G.log = function() { try { console.log.apply( console, Array.prototype.slice.call(arguments) ); } catch(e) { try { opera.postError.apply( opera, arguments ); } catch(er) { alert( Array.prototype.join.call( arguments, " " ) ); } } }; var nav = navigator.userAgent.toLowerCase(); var hash = window.location.hash.replace(/#\//,''); G.DATA = 'data'; G.READY = 'ready'; G.THUMBNAIL = 'thumbnail'; G.LOADSTART = 'loadstart'; G.LOADFINISH = 'loadfinish'; G.IMAGE = 'image'; G.THEMELOAD = 'themeload'; G.PLAY = 'play'; G.PAUSE = 'pause'; G.PROGRESS = 'progress'; G.FULLSCREEN_ENTER = 'fullscreen_enter'; G.FULLSCREEN_EXIT = 'fullscreen_exit'; G.IDLE_ENTER = 'idle_enter'; G.IDLE_EXIT = 'idle_exit'; G.RESCALE = 'rescale'; G.LIGHTBOX_OPEN = 'lightbox_open'; G.LIGHTBOX_CLOSE = 'lightbox_cloe'; G.LIGHTBOX_IMAGE = 'lightbox_image'; G.IE8 = (typeof(XDomainRequest) !== 'undefined') G.IE7 = !!(window.XMLHttpRequest && document.expando); G.IE6 = (!window.XMLHttpRequest); G.IE = !!(G.IE6 || G.IE7); G.WEBKIT = /webkit/.test( nav ); G.SAFARI = /safari/.test( nav ); G.CHROME = /chrome/.test( nav ); G.QUIRK = (G.IE && document.compatMode && document.compatMode == "BackCompat"); G.MAC = /mac/.test(navigator.platform.toLowerCase()); G.OPERA = !!window.opera G.Picture = Picture; G.addTheme = function(obj) { var theme = {}; var orig = ['name','author','version','defaults','init']; var proto = G.prototype; proto.loop(orig, function(val) { if (!obj[ val ]) { G.raise(val+' not specified in theme.'); } if (val != 'name' && val != 'init') { theme[val] = obj[val]; } }); theme.init = obj.init; if (obj.css) { var css; proto.loop(proto.getElements('script'), function(el) { var reg = new RegExp('galleria.' + obj.name.toLowerCase() + '.js'); if(reg.test(el.src)) { css = el.src.replace(/[^\/]*$/, "") + obj.css; proto.loadCSS(css, function() { G.theme = theme; jQuery(document).trigger( G.THEMELOAD ); }); } }); if (!css) { G.raise('No theme CSS loaded'); } } return theme; }; G.raise = function(msg) { if ( G.debug ) { throw new Error( msg ); } }; G.loadTheme = function(src) { G.prototype.loadScript(src); }; G.galleries = []; G.get = function(index) { if (G.galleries[index]) { return G.galleries[index]; } else if (typeof index !== 'number') { return G.galleries; } else { G.raise('Gallery index not found'); } } jQuery.easing.galleria = function (x, t, b, c, d) { if ((t/=d/2) < 1) { return c/2*t*t*t*t + b; } return -c/2 * ((t-=2)*t*t*t - 2) + b; }; G.transitions = { add: function(name, fn) { if (name != arguments.callee.name ) { this[name] = fn; } }, fade: function(params, complete) { jQuery(params.next).show().css('opacity',0).animate({ opacity: 1 }, params.speed, complete); if (params.prev) { jQuery(params.prev).css('opacity',1).animate({ opacity: 0 }, params.speed); } }, flash: function(params, complete) { jQuery(params.next).css('opacity',0); if (params.prev) { jQuery(params.prev).animate({ opacity: 0 }, (params.speed/2), function() { jQuery(params.next).animate({ opacity: 1 }, params.speed, complete); }); } else { jQuery(params.next).animate({ opacity: 1 }, params.speed, complete); } }, pulse: function(params, complete) { if (params.prev) { jQuery(params.prev).css('opacity',0); } jQuery(params.next).css('opacity',0).animate({ opacity:1 }, params.speed, complete); }, slide: function(params, complete) { var image = jQuery(params.next).parent(); var images = this.$('images'); var width = this.stageWidth; image.css({ left: width * ( params.rewind ? -1 : 1 ) }); images.animate({ left: width * ( params.rewind ? 1 : -1 ) }, { duration: params.speed, queue: false, easing: 'galleria', complete: function() { images.css('left',0); image.css('left',0); complete(); } }); }, fadeslide: function(params, complete) { if (params.prev) { jQuery(params.prev).css({ opacity: 1, left: 0 }).animate({ opacity: 0, left: 50 * ( params.rewind ? 1 : -1 ) },{ duration: params.speed, queue: false, easing: 'swing' }); } jQuery(params.next).css({ left: 50 * ( params.rewind ? -1 : 1 ), opacity: 0 }).animate({ opacity: 1, left:0 }, { duration: params.speed, complete: complete, queue: false, easing: 'swing' }); } }; G.addTransition = function() { G.transitions.add.apply(this, arguments); } jQuery.fn.galleria = function(options) { options = options || {}; var selector = this.selector; return this.each(function() { if ( !options.keep_source ) { jQuery(this).children().hide(); } options = G.prototype.mix(options, {target: this} ); var height = G.prototype.height(this) || G.prototype.getStyle(this, 'height', true); if (!options.height && height) { options = G.prototype.mix( { height: height }, options ); } G.debug = !!options.debug; var gallery = new G(options); Galleria.galleries.push(gallery); if (G.theme) { gallery.init(); } else { jQuery(document).bind(G.THEMELOAD, function() { gallery.init(); }); } }) }; })();