var settings = {
scroll_el: window, scrolling: false, scrollX: 1550, realX: 0, scrollY: 3800, realY: 0, interval: 10,decel: 8,IEspeed: 100,
loader: '<div class="center"><img src="images/aggregate-loader.gif" alt="Loader" /></div>',
loadersm: '<div class="center"><img src="images/aggregate-loader-sm.gif" alt="Loader" /></div>',
goodbrowser: false, ie: false, mobile: false, myScroll: null, loop: null, lost: false, slider: null, curLost: 0,
lostTrail: [ "#lost-anchor", "#lost1-anchor", "#lost2-anchor", "#lost3-anchor", "#home-anchor" ]
}
$(document).ready( function() { start(); });
function ismobile() { return ( navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod' ) ? true : false; }
function isIE(){ return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent); }
function isGoodBrowser() {
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)) { var version=new Number(RegExp.$1); if (version>=4) return true; }
	if ( navigator.userAgent.toLowerCase().indexOf('chrome') > -1 ) return true;
	if (/Safari[\/\s](\d+\.\d+)/.test(navigator.userAgent)) { var version = new Number(RegExp.$1); if (version>=5) return true; }
	return false;
}
function setup() {
	settings.goodbrowser = true;
	if ( !ismobile() ) {
		if ( isIE() ) { settings.decel /= 3; settings.ie = true; }
		$( "#header" ).css( "position", "fixed" );
		//openMap();
	}
	var scrolltolocation = window.location.toString().split("/");
	scrolltolocation = scrolltolocation[(parseInt(scrolltolocation.length)-1)].toLowerCase();
	scrolltolocation = (scrolltolocation=='9b') ? 'b9' : scrolltolocation;
	scrolltolocation = scrolltolocation + "-anchor";
	if ( $( "#" + scrolltolocation).length!=0 ) { scrollToSection( "#" + scrolltolocation ); }
}
var main = function() {
	if ( settings.scrolling ) {
		//if ( !settings.goodbrowser && !settings.mobile || settings.lost )
		if ( !settings.goodbrowser && !settings.mobile || settings.lost ) {
			if ( Math.abs(settings.scrollX-settings.realX)>settings.IEspeed )
				settings.realX = ( settings.realX<settings.scrollX ) ? settings.realX + settings.IEspeed : settings.realX - settings.IEspeed;
			else 
				settings.realX = settings.scrollX;
			
			if ( settings.realX!=settings.scrollX ) {
				$(settings.scroll_el).scrollLeft( settings.realX );
				settings.oldX = $(settings.scroll_el).scrollLeft();
			} else {
				if ( Math.abs(settings.scrollY-settings.realY)>settings.IEspeed )
					settings.realY = ( settings.realY<settings.scrollY ) ? settings.realY + settings.IEspeed : settings.realY - settings.IEspeed;
				else
					settings.realY = settings.scrollY;
				
				$(settings.scroll_el).scrollLeft( settings.scrollX );
				if ( settings.realY!=settings.scrollY ) {
					$(settings.scroll_el).scrollTop( settings.realY );
					//settings.oldY = $(settings.scroll_el).scrollTop();
				} else {
					$(settings.scroll_el).scrollTop( settings.scrollY );
					stopScroll();
				}
			}
		}
		else if ( !settings.mobile ) {
			var moveX = ( settings.scrollX - settings.realX ) / settings.decel; settings.realX += moveX;
			var moveY = ( settings.scrollY - settings.realY ) / settings.decel; settings.realY += moveY;
			
			if ( Math.abs( moveX )>=(1/settings.decel) || Math.abs( moveY )>=(1/settings.decel) ) {
				$(settings.scroll_el).scrollLeft( settings.realX );
				$(settings.scroll_el).scrollTop( settings.realY );
			} else {
				$(settings.scroll_el).scrollLeft( settings.scrollX );
				$(settings.scroll_el).scrollTop( settings.scrollY );
				stopScroll();
			}
		} else {
			var moveX = ( settings.scrollX - settings.realX ) / settings.decel;
			settings.realX += moveX;
			
			var moveY = ( settings.scrollY - settings.realY ) / settings.decel;
			settings.realY += moveY;
			
			myScroll.setPosition( (settings.realX * -1), (settings.realY * -1), true );
			
			if ( Math.abs(moveX)<=(1/settings.decel) && Math.abs(moveY)<=(1/settings.decel) ) {
				stopScroll();
				if ( !settings.mobile ) {
					$( settings.scroll_el ).scrollLeft( settings.scrollX );
					$( settings.scroll_el ).scrollTop( settings.scrollY );
				} else {
					myScroll.setPosition( (settings.realX * -1), (settings.realY * -1), true );
				}
			}
		}
	}
	else
	{
		stopScroll();
	}
}
function start() { setTimeout( function(){setup();}, settings.interval ); }
function startScroll() { if ( !settings.scrolling ) { settings.scrolling = true; settings.loop = setInterval( function(){main();}, settings.interval ); } }

function stopScroll()
{
	if ( !settings.lost ) { clearInterval( settings.loop ); settings.scrolling = false; }
	else {
		if ( settings.curLost<settings.lostTrail.length ) {
			setDest( $( settings.lostTrail[ settings.curLost ] ) );
			settings.curLost++;
		} else {
			settings.lost = false;
		}
	}
}

function scrollToSection( dest ) { if ( !settings.lost ) { setDest( dest ); } }

function setDest( dest ) {
	if ( !settings.mobile ) {
		viewport_width = $(window).width();
		anchor_width = $( dest ).width();
		scrollX = ( viewport_width - anchor_width ) / 2 ;
		settings.scrollX = $( dest ).offset().left - scrollX;
		settings.scrollY = $( dest ).offset().top;
		settings.realX = $( settings.scroll_el ).scrollLeft();
		settings.realY = $( settings.scroll_el ).scrollTop();
	} else {
		settings.scrollX = $( dest ).position().left - $( settings.scroll_el ).position().left;
		settings.scrollY = $( dest ).position().top - $( settings.scroll_el ).position().top;
		settings.realX = $( settings.scroll_el ).position().left * -1;
		settings.realY = $( settings.scroll_el ).position().top * -1;
		myScroll.setTransitionTime('0');
	}
	startScroll();
}

if ( ismobile() ) {
	settings.scroll_el = "div#scroller";
	$( "#wrapper" ).css( "width", $( window ).width() );
	$( "#wrapper" ).css( "height", $( window ).height() );
	$( window ).resize( 
		function() { $( "#wrapper" ).css( "width", $( window ).width() ); $( "#wrapper" ).css( "height", $( window ).height() ); }
	);
	
	settings.decel /= 2;
	settings.mobile = true;
	$( "#scroller" ).bind( "touchstart", function(e){ stopScroll(); } );
	var myScroll = '';
	function loaded() {
		document.addEventListener('touchmove', function(e){ e.preventDefault(); });
		myScroll = new iScroll( 'scroller', { checkDOMChanges: false, bounce: false, momentum: false });
	}
	document.addEventListener('DOMContentLoaded', loaded);
	setTimeout(function () { myScroll.refresh(); }, 0);
}

(function(){
function iScroll (el, options) {
	var that = this;
	that.element = typeof el == 'object' ? el : document.getElementById(el);
	that.wrapper = that.element.parentNode;

	that.element.style.webkitTransitionProperty = '-webkit-transform';
	that.element.style.webkitTransitionTimingFunction = 'cubic-bezier(0,0,0.25,1)';
	that.element.style.webkitTransitionDuration = '0';
	that.element.style.webkitTransform = translateOpen + '0,0' + translateClose;

	// Default options
	that.options = {
		bounce: has3d,
		momentum: has3d,
		checkDOMChanges: true,
		topOnDOMChanges: false,
		hScrollbar: has3d,
		vScrollbar: has3d,
		fadeScrollbar: isIphone || isIpad || !isTouch,
		shrinkScrollbar: isIphone || isIpad,
		desktopCompatibility: false,
		overflow: 'auto'
	};
	
	// User defined options
	if (typeof options == 'object') {
		for (var i in options) { that.options[i] = options[i]; }
	}

	if (that.options.desktopCompatibility) { that.options.overflow = 'hidden'; }
	
	that.wrapper.style.overflow = that.options.overflow;
	that.refresh();
	window.addEventListener('onorientationchange' in window ? 'orientationchange' : 'resize', that, false);
	if (isTouch || that.options.desktopCompatibility) { that.element.addEventListener(START_EVENT, that, false); that.element.addEventListener(MOVE_EVENT, that, false); that.element.addEventListener(END_EVENT, that, false); }
	if (that.options.checkDOMChanges) { that.element.addEventListener('DOMSubtreeModified', that, false); }
	if (!isTouch) { that.element.addEventListener('click', that, true); }
}

iScroll.prototype = {
	x: 0, y: 0, dist: 0,
	handleEvent: function (e) {
		var that = this;
		switch (e.type) {
			case 'click': if (!e._fake) { e.stopPropagation(); } break;
			case START_EVENT: that.touchStart(e); break;
			case MOVE_EVENT: that.touchMove(e); break;
			case END_EVENT: that.touchEnd(e); break;
			case 'webkitTransitionEnd': that.transitionEnd(e); break;
			case 'orientationchange': case 'resize': that.refresh(); break;
			case 'DOMSubtreeModified': that.onDOMModified(e); break;
		}
	},
	
	onDOMModified: function (e) {
		this.refresh();
		if (this.options.topOnDOMChanges && (this.x!=0 || this.y!=0)) { this.scrollTo(0,0,'0'); }
	},

	refresh: function () {
		var that = this,
			resetX = this.x, resetY = this.y;
		
		that.scrollWidth = that.wrapper.clientWidth;
		that.scrollHeight = that.wrapper.clientHeight;
		that.scrollerWidth = that.element.offsetWidth;
		that.scrollerHeight = that.element.offsetHeight;
		that.maxScrollX = that.scrollWidth - that.scrollerWidth;
		that.maxScrollY = that.scrollHeight - that.scrollerHeight;

		if (that.scrollX) {
			if (that.maxScrollX >= 0) { resetX = 0; } else if (that.x < that.maxScrollX) { resetX = that.maxScrollX; }
		}
		if (that.scrollY) {
			if (that.maxScrollY >= 0) { resetY = 0; } else if (that.y < that.maxScrollY) { resetY = that.maxScrollY; }
		}
		if (resetX!=that.x || resetY!=that.y) {
			that.setTransitionTime('0'); that.setPosition(resetX, resetY, true);
		}

		that.scrollX = that.scrollerWidth > that.scrollWidth;
		that.scrollY = !that.scrollX || that.scrollerHeight > that.scrollHeight;

		// Update horizontal scrollbar
		if (that.options.hScrollbar && that.scrollX) {
			that.scrollBarX = (that.scrollBarX instanceof scrollbar) ? that.scrollBarX : new scrollbar('horizontal', that.wrapper, that.options.fadeScrollbar, that.options.shrinkScrollbar);
			that.scrollBarX.init(that.scrollWidth, that.scrollerWidth);
		} else if (that.scrollBarX) {
			that.scrollBarX = that.scrollBarX.remove();
		}

		// Update vertical scrollbar
		if (that.options.vScrollbar && that.scrollY && that.scrollerHeight > that.scrollHeight) {
			that.scrollBarY = (that.scrollBarY instanceof scrollbar) ? that.scrollBarY : new scrollbar('vertical', that.wrapper, that.options.fadeScrollbar, that.options.shrinkScrollbar);
			that.scrollBarY.init(that.scrollHeight, that.scrollerHeight);
		} else if (that.scrollBarY) {
			that.scrollBarY = that.scrollBarY.remove();
		}
	},

	setPosition: function (x, y, hideScrollBars) {
		var that = this;
		this.x = x;
		this.y = y;
		that.element.style.webkitTransform = translateOpen + that.x + 'px,' + that.y + 'px' + translateClose;
		// Move the scrollbars
		if (!hideScrollBars) {
			if (that.scrollBarX) { that.scrollBarX.setPosition(that.x); }
			if (that.scrollBarY) { that.scrollBarY.setPosition(that.y); }
		}
	},
	
	setTransitionTime: function(time) {
		var that = this; time = time || '0'; that.element.style.webkitTransitionDuration = time;
		if (that.scrollBarX) { that.scrollBarX.bar.style.webkitTransitionDuration = time; that.scrollBarX.wrapper.style.webkitTransitionDuration = has3d && that.options.fadeScrollbar ? '300ms' : '0'; }
		if (that.scrollBarY) { that.scrollBarY.bar.style.webkitTransitionDuration = time; that.scrollBarY.wrapper.style.webkitTransitionDuration = has3d && that.options.fadeScrollbar ? '300ms' : '0'; }
	},
		
	touchStart: function(e) {
		var that = this,matrix;
		that.scrolling = true;		// This is probably not needed, but may be useful if iScroll is used in conjuction with other frameworks
		e.preventDefault();
		e.stopPropagation();
		that.moved = false;
		that.dist = 0;
		that.setTransitionTime('0');
		// Check if the scroller is really where it should be
		if (that.options.momentum) {
			matrix = new WebKitCSSMatrix(window.getComputedStyle(that.element).webkitTransform);
			if (matrix.e != that.x || matrix.f != that.y) { that.element.removeEventListener('webkitTransitionEnd', that, false); that.setPosition(matrix.e, matrix.f); that.moved = true; }
		}
		that.touchStartX = isTouch ? e.changedTouches[0].pageX : e.pageX;
		that.scrollStartX = that.x;
		that.touchStartY = isTouch ? e.changedTouches[0].pageY : e.pageY;
		that.scrollStartY = that.y;
		that.scrollStartTime = e.timeStamp;
	},
	
	touchMove: function(e) {
		var that = this, pageX = isTouch ? e.changedTouches[0].pageX : e.pageX, pageY = isTouch ? e.changedTouches[0].pageY : e.pageY, leftDelta = that.scrollX ? pageX - that.touchStartX : 0, topDelta = that.scrollY ? pageY - that.touchStartY : 0,newX = that.x + leftDelta,newY = that.y + topDelta;

		if (!that.scrolling) { return; }
		that.dist+= Math.abs(that.touchStartX - pageX) + Math.abs(that.touchStartY - pageY);
		that.touchStartX = pageX;
		that.touchStartY = pageY;
		// Slow down if outside of the boundaries
		if (newX > 0 || newX < that.maxScrollX) { newX = that.options.bounce ? Math.round(that.x + leftDelta / 3) : newX >= 0 ? 0 : that.maxScrollX; }
		if (newY > 0 || newY < that.maxScrollY) { newY = that.options.bounce ? Math.round(that.y + topDelta / 3) : newY >= 0 ? 0 : that.maxScrollY; }
		if (that.dist > 5) { /*5 pixels threshold is needed on Android, but also on iPhone looks more natural*/ that.setPosition(newX, newY); that.moved = true; }
	},
	
	touchEnd: function(e) {
		var that = this, time = e.timeStamp - that.scrollStartTime, target, ev, momentumX, momentumY, newDuration, newPositionX, newPositionY;
		if (!that.scrolling) { return; }
		that.scrolling = false;
		
		if (!that.moved) {
			that.resetPosition();
			// Find the last touched element
			target = isTouch ? e.changedTouches[0].target : e.target;
			while (target.nodeType != 1) {
				target = target.parentNode;
			}
			// Create the fake event
			ev = document.createEvent('Event');
			ev.initEvent('focus', true, true);
			target.dispatchEvent(ev);
			ev = document.createEvent('MouseEvents');
			ev.initMouseEvent("click", true, true, e.view, 1, target.screenX, target.screenY, target.clientX, target.clientY, e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, 0, null);
			ev._fake = true;
			target.dispatchEvent(ev);
			return;
		}

		if (!that.options.momentum || time > 250) { /*Prevent slingshot effetct*/ that.resetPosition(); return; }
		momentumX = that.scrollX === true ? that.momentum(that.x - that.scrollStartX, time, that.options.bounce ? -that.x + that.scrollWidth/5 : -that.x, that.options.bounce ? that.x + that.scrollerWidth - that.scrollWidth + that.scrollWidth/5 : that.x + that.scrollerWidth - that.scrollWidth) : { dist: 0, time: 0 };
		momentumY = that.scrollY === true ? that.momentum(that.y - that.scrollStartY, time, that.options.bounce ? -that.y + that.scrollHeight/5 : -that.y, that.options.bounce ? (that.maxScrollY < 0 ? that.y + that.scrollerHeight - that.scrollHeight : 0) + that.scrollHeight/5 : that.y + that.scrollerHeight - that.scrollHeight) : { dist: 0, time: 0 };
		if (!momentumX.dist && !momentumY.dist) { that.resetPosition(); return false; }
		newDuration = Math.max(Math.max(momentumX.time, momentumY.time), 1);		// The minimum animation length must be 1ms
		newPositionX = that.x + momentumX.dist;
		newPositionY = that.y + momentumY.dist;
		that.scrollTo(newPositionX, newPositionY, newDuration + 'ms');
	},
	
	transitionEnd: function () { this.element.removeEventListener('webkitTransitionEnd', this, false); this.resetPosition(); },

	resetPosition: function (time) {
		var that = this, resetX = that.x, resetY = that.y, that = that, time = time || '500ms';
		if (that.x >= 0) { resetX = 0; } else if (that.x < that.maxScrollX) { resetX = that.maxScrollX; }
		if (that.y >= 0 || that.maxScrollY > 0) { resetY = 0; } else if (that.y < that.maxScrollY) { resetY = that.maxScrollY; }
		if (resetX != that.x || resetY != that.y) { that.scrollTo(resetX, resetY, time); } else if (that.scrollBarX || that.scrollBarY) {
			// Hide the scrollbars
			if (that.scrollBarX) { that.scrollBarX.hide(); }
			if (that.scrollBarY) { that.scrollBarY.hide(); }
		}
	},

	scrollTo: function (destX, destY, runtime) {
		var that = this;
		that.setTransitionTime(runtime || '450ms');
		that.setPosition(destX, destY);
		if (runtime==='0' || runtime=='0s' || runtime=='0ms') { that.resetPosition(); } 
		else { that.element.addEventListener('webkitTransitionEnd', that, false); /*At the end of the transition check if we are still inside of the boundaries*/ }
	},
	scrollToElement: function (el, runtime) {
		el = typeof el == 'object' ? el : this.element.querySelector(el);
		if (!el) { return; }
		var that = this, x = that.scrollX ? -el.offsetLeft : 0, y = that.scrollY ? -el.offsetTop : 0;
		if (x >= 0) { x = 0; } else if (x < that.maxScrollX) { x = that.maxScrollX; }
		if (y >= 0) { y = 0; } else if (y < that.maxScrollY) { y = that.maxScrollY; }
		that.scrollTo(x, y, runtime);
	},
	momentum: function (dist, time, maxDistUpper, maxDistLower) {
		var friction = 3, deceleration = 1.3, speed = Math.abs(dist) / time * 1000, newDist = speed * speed / friction / 1000, newTime = 0;
		// Proportinally reduce speed if we are outside of the boundaries 
		if (dist > 0 && newDist > maxDistUpper) { speed = speed * maxDistUpper / newDist / friction; newDist = maxDistUpper; } 
		else if (dist < 0 && newDist > maxDistLower) { speed = speed * maxDistLower / newDist / friction; newDist = maxDistLower; }
		newDist = newDist * (dist < 0 ? -1 : 1);
		newTime = speed / deceleration;
		return { dist: Math.round(newDist), time: Math.round(newTime) };
	},
	destroy: function (full) {
		var that = this;
		window.removeEventListener('resize', that, false);
		that.element.removeEventListener(START_EVENT, that, false);
		that.element.removeEventListener(MOVE_EVENT, that, false);
		that.element.removeEventListener(END_EVENT, that, false);
		that.element.removeEventListener('DOMSubtreeModified', that, false);
		that.element.removeEventListener('click', that, true);
		that.element.removeEventListener('webkitTransitionEnd', that, false);
		if (that.scrollBarX) { that.scrollBarX = that.scrollBarX.remove(); }
		if (that.scrollBarY) { that.scrollBarY = that.scrollBarY.remove(); }
		if (full) { that.wrapper.parentNode.removeChild(that.wrapper); }
		return null;
	}
};

var scrollbar = function (dir, wrapper, fade, shrink) {
	var that = this;
	that.dir = dir;
	that.fade = fade;
	that.shrink = shrink;
	that.uid = ++uid;
	// Create main scrollbar
	that.bar = document.createElement('div');
	var style = 'position:absolute;top:0;left:0;-webkit-transition-timing-function:cubic-bezier(0,0,0.25,1);pointer-events:none;-webkit-transition-duration:0;-webkit-transition-delay:0;-webkit-transition-property:-webkit-transform;z-index:10;background:rgba(0,0,0,0.5);' +
		'-webkit-transform:' + translateOpen + '0,0' + translateClose + ';' +
		(dir == 'horizontal' ? '-webkit-border-radius:3px 2px;min-width:6px;min-height:5px' : '-webkit-border-radius:2px 3px;min-width:5px;min-height:6px'),
		size, ctx;
	that.bar.setAttribute('style', style);
	// Create scrollbar wrapper
	that.wrapper = document.createElement('div');
	style = '-webkit-mask:-webkit-canvas(scrollbar' + that.uid + that.dir + ');position:absolute;z-index:10;pointer-events:none;overflow:hidden;opacity:0;-webkit-transition-duration:' + (fade ? '300ms' : '0') + ';-webkit-transition-delay:0;-webkit-transition-property:opacity;' +
		(that.dir == 'horizontal' ? 'bottom:2px;left:1px;right:7px;height:5px' : 'top:1px;right:2px;bottom:7px;width:5px;');
	that.wrapper.setAttribute('style', style);
	// Add scrollbar to the DOM
	that.wrapper.appendChild(that.bar);
	wrapper.appendChild(that.wrapper);
}
scrollbar.prototype = {
	init: function (scroll, size) {
		var that = this, ctx, sbSize;
		// Create scrollbar mask
		if (that.dir == 'horizontal') {
			sbSize = that.wrapper.offsetWidth;
			ctx = document.getCSSCanvasContext("2d", "scrollbar" + that.uid + that.dir, sbSize, 5);
			ctx.fillStyle = "rgb(0,0,0)";
			ctx.beginPath();
			ctx.arc(2.5, 2.5, 2.5, Math.PI/2, -Math.PI/2, false);
			ctx.lineTo(sbSize-2.5, 0);
			ctx.arc(sbSize-2.5, 2.5, 2.5, -Math.PI/2, Math.PI/2, false);
			ctx.closePath();
			ctx.fill();
		} else {
			sbSize = that.wrapper.offsetHeight;
			ctx = document.getCSSCanvasContext("2d", "scrollbar" + that.uid + that.dir, 5, sbSize);
			ctx.fillStyle = "rgb(0,0,0)";
			ctx.beginPath();
			ctx.arc(2.5, 2.5, 2.5, Math.PI, 0, false);
			ctx.lineTo(5, sbSize-2.5);
			ctx.arc(2.5, sbSize-2.5, 2.5, 0, Math.PI, false);
			ctx.closePath();
			ctx.fill();
		}
		that.maxSize = that.dir == 'horizontal' ? that.wrapper.clientWidth : that.wrapper.clientHeight;
		that.size = Math.round(that.maxSize * that.maxSize / size);
		that.maxScroll = that.maxSize - that.size;
		that.toWrapperProp = that.maxScroll / (scroll - size);
		that.bar.style[that.dir == 'horizontal' ? 'width' : 'height'] = that.size + 'px';
	},
	setPosition: function (pos, hidden) {
		var that = this;
		if (!hidden && that.wrapper.style.opacity != '1') { that.show(); }
		pos = that.toWrapperProp * pos;
		if (pos < 0) {
			pos = that.shrink ? pos + pos*3 : 0;
			if (that.size + pos < 5) { pos = -that.size+5; }
		} else if (pos > that.maxScroll) {
			pos = that.shrink ? pos + (pos-that.maxScroll)*3 : that.maxScroll;
			if (that.size + that.maxScroll - pos < 5) { pos = that.size + that.maxScroll - 5; }
		}
		pos = that.dir == 'horizontal' ? translateOpen + Math.round(pos) + 'px,0' + translateClose : translateOpen + '0,' + Math.round(pos) + 'px' + translateClose;
		that.bar.style.webkitTransform = pos;
	},

	show: function () { if (has3d) { this.wrapper.style.webkitTransitionDelay = '0'; } this.wrapper.style.opacity = '1'; },
	hide: function () { if (has3d) { this.wrapper.style.webkitTransitionDelay = '200ms'; } this.wrapper.style.opacity = '0'; },
	remove: function () { this.wrapper.parentNode.removeChild(this.wrapper); return null; }
};
// Is translate3d compatible?
var has3d = ('WebKitCSSMatrix' in window && 'm11' in new WebKitCSSMatrix()),
	// Device sniffing
	isIphone = navigator.appVersion.match(/iphone/gi) ? true : false,
	isIpad = navigator.appVersion.match(/ipad/gi) ? true : false,
	isAndroid = navigator.appVersion.match(/android/gi) ? true : false,
	isTouch = isIphone || isIpad || isAndroid,
	// Event sniffing
	START_EVENT = isTouch ? 'touchstart' : 'mousedown',
	MOVE_EVENT = isTouch ? 'touchmove' : 'mousemove',
	END_EVENT = isTouch ? 'touchend' : 'mouseup',
	// Translate3d helper
	translateOpen = 'translate' + (has3d ? '3d(' : '(');
	translateClose = has3d ? ',0)' : ')';
	// Unique ID
	uid = 0;
// Expose iScroll to the world
window.iScroll = iScroll;
})();
