/*
 *  Burnavon Javascript
 * -----------------------------
 *  Created: 29.6.2011
 *  Author:  David Lowry
 *
 */

/* MOO MORE */
MooTools.More={version:"1.2.4.4",build:"6f6057dc645fdb7547689183b2311063bd653ddf"};Fx.Scroll=new Class({Extends:Fx,options:{offset:{x:0,y:0},wheelStops:true},initialize:function(b,a){this.element=this.subject=document.id(b);
this.parent(a);var d=this.cancel.bind(this,false);if($type(this.element)!="element"){this.element=document.id(this.element.getDocument().body);}var c=this.element;
if(this.options.wheelStops){this.addEvent("start",function(){c.addEvent("mousewheel",d);},true);this.addEvent("complete",function(){c.removeEvent("mousewheel",d);
},true);}},set:function(){var a=Array.flatten(arguments);if(Browser.Engine.gecko){a=[Math.round(a[0]),Math.round(a[1])];}this.element.scrollTo(a[0],a[1]);
},compute:function(c,b,a){return[0,1].map(function(d){return Fx.compute(c[d],b[d],a);});},start:function(c,g){if(!this.check(c,g)){return this;}var e=this.element.getScrollSize(),b=this.element.getScroll(),d={x:c,y:g};
for(var f in d){var a=e[f];if($chk(d[f])){d[f]=($type(d[f])=="number")?d[f]:a;}else{d[f]=b[f];}d[f]+=this.options.offset[f];}return this.parent([b.x,b.y],[d.x,d.y]);
},toTop:function(){return this.start(false,0);},toLeft:function(){return this.start(0,false);},toRight:function(){return this.start("right",false);},toBottom:function(){return this.start(false,"bottom");
},toElement:function(b){var a=document.id(b).getPosition(this.element);return this.start(a.x,a.y);},scrollIntoView:function(c,e,d){e=e?$splat(e):["x","y"];
var h={};c=document.id(c);var f=c.getPosition(this.element);var i=c.getSize();var g=this.element.getScroll();var a=this.element.getSize();var b={x:f.x+i.x,y:f.y+i.y};
["x","y"].each(function(j){if(e.contains(j)){if(b[j]>g[j]+a[j]){h[j]=b[j]-a[j];}if(f[j]<g[j]){h[j]=f[j];}}if(h[j]==null){h[j]=g[j];}if(d&&d[j]){h[j]=h[j]+d[j];
}},this);if(h.x!=g.x||h.y!=g.y){this.start(h.x,h.y);}return this;},scrollToCenter:function(c,e,d){e=e?$splat(e):["x","y"];c=$(c);var h={},f=c.getPosition(this.element),i=c.getSize(),g=this.element.getScroll(),a=this.element.getSize(),b={x:f.x+i.x,y:f.y+i.y};
["x","y"].each(function(j){if(e.contains(j)){h[j]=f[j]-(a[j]-i[j])/2;}if(h[j]==null){h[j]=g[j];}if(d&&d[j]){h[j]=h[j]+d[j];}},this);if(h.x!=g.x||h.y!=g.y){this.start(h.x,h.y);
}return this;}});
Fx.Slide=new Class({Extends:Fx,options:{mode:"vertical"},initialize:function(B,A){this.addEvent("complete",function(){this.open=(this.wrapper["offset"+this.layout.capitalize()]!=0);
if(this.open&&Browser.Engine.webkit419){this.element.dispose().inject(this.wrapper);}},true);this.element=this.subject=$(B);this.parent(A);var C=this.element.retrieve("wrapper");
this.wrapper=C||new Element("div",{styles:$extend(this.element.getStyles("margin","position"),{overflow:"hidden"})}).wraps(this.element);this.element.store("wrapper",this.wrapper).setStyle("margin",0);
this.now=[];this.open=true;},vertical:function(){this.margin="margin-top";this.layout="height";this.offset=this.element.offsetHeight;},horizontal:function(){this.margin="margin-left";
this.layout="width";this.offset=this.element.offsetWidth;},set:function(A){this.element.setStyle(this.margin,A[0]);this.wrapper.setStyle(this.layout,A[1]);
return this;},compute:function(E,D,C){var B=[];var A=2;A.times(function(F){B[F]=Fx.compute(E[F],D[F],C);});return B;},start:function(B,E){if(!this.check(arguments.callee,B,E)){return this;
}this[E||this.options.mode]();var D=this.element.getStyle(this.margin).toInt();var C=this.wrapper.getStyle(this.layout).toInt();var A=[[D,C],[0,this.offset]];
var G=[[D,C],[-this.offset,0]];var F;switch(B){case"in":F=A;break;case"out":F=G;break;case"toggle":F=(this.wrapper["offset"+this.layout.capitalize()]==0)?A:G;
}return this.parent(F[0],F[1]);},slideIn:function(A){return this.start("in",A);},slideOut:function(A){return this.start("out",A);},hide:function(A){this[A||this.options.mode]();
this.open=false;return this.set([-this.offset,0]);},show:function(A){this[A||this.options.mode]();this.open=true;return this.set([0,this.offset]);},toggle:function(A){return this.start("toggle",A);
}});Element.Properties.slide={set:function(B){var A=this.retrieve("slide");if(A){A.cancel();}return this.eliminate("slide").store("slide:options",$extend({link:"cancel"},B));
},get:function(A){if(A||!this.retrieve("slide")){if(A||!this.retrieve("slide:options")){this.set("slide",A);}this.store("slide",new Fx.Slide(this,this.retrieve("slide:options")));
}return this.retrieve("slide");}};Element.implement({slide:function(D,E){D=D||"toggle";var B=this.get("slide"),A;switch(D){case"hide":B.hide(E);break;case"show":B.show(E);
break;case"toggle":var C=this.retrieve("slide:flag",B.open);B[(C)?"slideOut":"slideIn"](E);this.store("slide:flag",!C);A=true;break;default:B.start(D,E);
}if(!A){this.eliminate("slide:flag");}return this;}});

/*
---
description: Provides a fallback for the placeholder property on input elements for older browsers.

license:
  - MIT-style license

authors:
  - Matthias Schmidt (http://www.m-schmidt.eu)

requires:
  core/1.2.5: '*'

provides:
  - Form.Placeholder

...
*/
(function(){if(!this.Form){this.Form={}}var a=("placeholder" in document.createElement("input"));if(!("supportsPlaceholder" in this)&&this.supportsPlaceholder!==false&&a){this.Form.Placeholder=new Class({});return}this.Form.Placeholder=new Class({Implements:Options,options:{color:"#A9A9A9",clearOnSubmit:true},initialize:function(c,b){this.setOptions(b);this.element=$(c);this.placeholder=this.element.get("placeholder");this.original_color=this.element.getStyle("color");if(this.element.get("value")==""){this.element.setStyle("color",this.options.color);this.element.set("value",this.placeholder)}this.element.addEvents({focus:function(){if(this.element.get("value")==this.placeholder){this.element.set("value","");this.element.setStyle("color",this.original_color)}}.bind(this),blur:function(){if(this.element.get("value")==""){this.element.setStyle("color",this.options.color);this.element.set("value",this.placeholder)}}.bind(this)});if(this.element.getParent("form")&&this.options.clearOnSubmit){this.element.getParent("form").addEvent("submit",function(d){if(this.element.get("value")==this.placeholder){this.element.set("value","")}}.bind(this))}}})})();





window.addEvent("domready", function() {

    // onDomready nominate base references
    main = document.getElement('#container');


		if (main.getElement('.quickpeeks')) {

		    doQuickpeeks = function() {
		       
		        // has thumbnails
		        // make the replace on click
		        // make them scroll
		        
		        var
		            wrapper = main.getElement('.scrolling.horizontal'),
		            thumbs = main.getElements('.scrolling li'),
		            navs = main.getElements('.additional a'),
		            start_pos = 0,
		            pos = 0,
		            next = false,
		            len = thumbs.length,
		            
		            // set up the thumbnail horizontal scroller (instantiated below)
		            
		            // this could be easily adapted to offer vertical scrolling with some css changes and 'left' being changed.
		            
		            scroller = function() {
		                navs.each(function(n) {

		                    n
		                    .addEvent('click',
		                        function(ev) {
		                            
		                            if (ev) ev.stop();
		                            
		                            // determine direction and current position/destination direction
		                            
		                            direction = (n.hasClass('prev')) ? -1 : 1;
                                // pos = (next) ? next : start_pos; // default
                                

		                            // check if the position is "first" (aka. last+1)
                                if (direction==1) {
                                		
                                		if (pos+1==len-3) {

	                                		return false;
	                                		
                                		} else {
                                			next = (pos + 1);
	                                		pos = next-1;
                                		}
                                		
                                } else {
                                
                                		next = ((pos - 1)>1) ? pos-1 : 0;
                                		pos = (next > 0) ? pos+1 : 1;
                                		
                                }


		                            // determine the width of the next thumbnail (how far to move the left bound along)
		                            
		                            width = thumbs[pos].getStyle('width') + thumbs[pos].getStyle('margin-right');
		                            width = ((-1*direction) * (width.substr(0, width.indexOf('px'))))-(direction*17);   // 4 pixels margin of error
		                            
		                            // determine the distance from the left side of the bounding box
				                        if (next==0) {

				                        		left = 0;

				                        } else {

				                            left = wrapper.getStyle('margin-left');
				                            left = left.substr(0,left.indexOf('px'));
				                            left = (parseInt(left)+parseInt(width))
				                        }

		                            
		                            // re-set the left bound offset
		                            
		                            pos = next;
		                            
		                            wrapper.setStyle('margin-left', left);
		                            
		                            return false;

		                        }
		                    )
		                });
		            };
		
		        // start the method.
		        scroller();
		        
		    } //doQuickpeeks()

				doQuickpeeks();
				
		}

    if (Form.Placeholder){

        Array.each( $('container').getElements('input, textarea'), function(x){
            if(x.getProperty('placeholder')){
                new Form.Placeholder(x);
            }
        });
    }

});
