window.log=function(){log.history=log.history||[];log.history.push(arguments);if(this.console){arguments.callee=arguments.callee.caller;var a=[].slice.call(arguments);(typeof console.log==="object"?log.apply.call(console.log,console,a):console.log.apply(console,a))}};
(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,timeStamp,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();){b[a]=b[a]||c}})((function(){try
{console.log();return window.console;}catch(err){return window.console={};}})());


/*
 Copyright (c) 2009-2011 Petr Vostrel (http://petr.vostrel.cz/)
 Dual licensed under the MIT (MIT-LICENSE.txt)
 and GPL (GPL-LICENSE.txt) licenses.

 jQuery Reel
 http://jquery.vostrel.cz/reel
 Version: 1.1.3
 Updated: 2011-05-08

 Requires jQuery 1.4.2 or higher
*/
jQuery.reel||function(h,kb,ja,p){function A(j){return h.reel.instances.length?h.reel.instances.first().data(j):null}function lb(j){return h.reel.instances.push(j[0])&&j}function mb(j){return(h.reel.instances=h.reel.instances.not("#"+j.attr(M)))&&j}function ka(j){return nb&&"data:image/gif;base64,R0lGODlh"+j}function ob(j){return"<"+j+"/>"}function la(j){return"."+j}function ma(j){return"http://code.vostrel.cz/"+j}function na(j){return"url("+j+")"}function H(j){return+j.toFixed(4)}function V(j,a,u){return N(j,
Ma(a,u))}function pb(j){function a(){h.fn[this]||(h.fn[this]=function(){return this})}h.each(j,a)}function oa(j,a){return v(j)*(a?-1:1)}function W(j){return j.originalEvent.touches[0]}h.reel={version:"1.1.3",def:{footage:6,frame:1,frames:36,hint:"",horizontal:true,hotspot:p,indicator:0,klass:"",loops:true,reversed:p,spacing:0,stitched:0,suffix:"-reel",tooltip:"",area:p,brake:0.5,clickfree:false,cw:false,delay:-1,directional:false,draggable:true,entry:p,graph:p,image:p,images:[],inversed:false,laziness:6,
monitor:p,opening:0,orbital:0,path:"",preloader:4,rebound:0.5,revolution:p,row:1,rows:0,speed:0,step:p,steps:p,tempo:36,timeout:2,throwable:true,vertical:false,wheelable:true}};h.fn.reel=function(j){var a=h.extend({},h.reel.def,j);j=function(g){var r=[];g.filter(qb).each(function(){var c=h(this),d=a.images.length&&a.images||a.image||c.attr(Na),t=X(c.css(Oa)),m=X(c.css(Pa));!d||d==Qa||!t||!m||r.push(c)});g.filter(Ra+la(w)).each(function(){r.push(h(this))});return h(r)}(this);var u=[];a.reversed&&(a.cw=
true);a.tooltip&&(a.hint=a.tooltip);a.hotspot&&(a.area=a.hotspot);j.each(function(){var g=h(this),r=g.data(),c=function(f,b){r[f]=b;g.trigger("store",[f,b]);return b},d=function(f){var b=r[f];g.trigger("recall",[f,b]);return b},t={setup:function(f){if(g.hasClass(w))return m.call(f);var b=g.attr(Na),e=c(M,g.attr(M)||g.attr(M,w+"-"+ +new Date).attr(M)),i=g.attr("style"),k=a.images,l=a.stitched,n=a.loops,s={x:X(g.css(Oa)),y:X(g.css(Pa))},x=c(Sa,a.orbital&&a.footage||a.rows<=1&&k.length||a.frames),pa=
l?1:Ta(x/a.footage),O={display:"block",width:s.x,height:s.y};e="#"+e+a.suffix;var Ua=g.attr("class"),qa={position:"relative",width:s.x,height:s.y};qa=h(P,{id:e.substr(1),"class":Ua+ra+rb,css:qa});O=g.wrap(qa).attr({"class":w}).css(O).bind(t);u.push(lb(O)[0]);c(Va,k.length&&k.length||a.image||b.replace(/^(.*)\.(jpg|jpeg|png|gif)$/,"$1"+a.suffix+".$2"));c(Wa,Ua);c(y,a.frame);c(Xa,a.spacing);c(B,s);c(o,0);c(sa,a.steps||a.frames);c(Y,a.revolution||l/2||s.x*2);c(ta,pa);c(Z,1/(x-(n&&!l?0:1)));c(sb,1/N(x,
d(sa)));c(ua,l);c(Ya,l-(n?0:s.x));c($,e);c(E,c(va,a.speed)<0);c(I,0);c(J,a.vertical);c(z,(a.row-1)/(a.rows-1));c(aa,oa(1,!a.cw&&!l));c(Q,false);c(Za,a.brake);c(wa,!!a.orbital);c(C,a.tempo/(h.reel.lazy?a.laziness:1));c(ba,0);c($a,{src:b,style:i||Qa});D.bind(F,t.tick);m.call(f);g.trigger("start")},teardown:function(f){g.unbind(q).unbind(t);var b=g.data("events"),e=g.clone().attr(g.data($a)).css({background:"transparent"}).removeClass(w).addClass(d(Wa));for(var i in b)h.each(b[i],function(k,l){e.bind(i+
"."+l.namespace,l.handler,l.data)});h("img:"+xa,g.parent()).remove();mb(g);h(d($)).before(e).detach();ca();D.unbind(F,t.tick).unbind(F,t.opening_tick);da.unbind(ya).unbind(za);m.call(f)},start:function(){var f=d(B),b=d(Sa),e=N(b,d(sa));e=c(o,1/e*((a.step||a.frame)-1));c(y,e*b+1);g.attr("id");b=g.parent();e=h(P,{"class":tb,css:{position:ea,left:0,top:0,width:f.x,height:f.y,background:Aa,opacity:0}}).appendTo(b);e=c(ab,h(a.area||e));if(h.reel.touchy){g.css({WebkitUserSelect:"none",WebkitBackgroundSize:a.images.length?
"auto":d(ua)&&d(ua)+"px "+f.y+"px"||f.x*a.footage+"px "+f.y*d(ta)*(a.rows||1)*(a.directional?2:1)+"px"});e.bind(ub,function(i){g.trigger("down",[W(i).clientX,W(i).clientY,true])}).bind(vb,function(i){g.trigger("slide",[W(i).clientX,W(i).clientY,true]);return!(a.rows>1||a.orbital||d(Q))}).bind(wb,function(){g.trigger("up",[true]);return false}).bind(xb,function(){g.trigger("up",[true]);return false})}else e.css({cursor:"url("+bb+"), "+Ba}).bind(yb,function(i,k){g.trigger("wheel",[k]);return false}).bind(zb,
function(){g.trigger("play")}).bind(a.clickfree?Ab:Bb,function(i){g.trigger("down",[i.clientX,i.clientY]);return false}).bind(a.clickfree?Cb:"",function(){g.trigger("up");return false}).disableTextSelect();a.hint&&e.attr(Db,a.hint);a.monitor&&b.append(Ca=h(P,{"class":Eb,css:{position:ea,left:0,top:0}}))||(Ca=h());a.indicator&&b.append(cb("x"));a.rows>1&&a.indicator&&b.append(cb("y"));g.trigger("preload")},preload:function(f){var b=d(B),e=g.parent(),i=d(Va),k=a.images,l=!k.length?[i]:[].concat(k),
n=g[0];n.frames=l.length;n.preloaded=0;g.trigger("stop");for(e.append(Da=h(P,{"class":Fb,css:{position:ea,left:0,top:b.y-a.preloader,height:a.preloader,overflow:xa,backgroundColor:Aa}}));l.length;){var s=a.path+l.shift(),x=h(new Image).hide().bind("load"+q,function(){n.preloaded++;h(this).unbind(q);Da.css({width:1/n.frames*n.preloaded*b.x});if(n.frames==n.preloaded){Da.remove();k.length||g.css({backgroundImage:na(a.path+i)});g.attr({src:Gb}).trigger(a.rows>1&&!a.stitched?"rowChange":"frameChange").trigger("loaded").trigger("opening");
m.call(f)}});e.append(x);setTimeout(function(pa,O){return function(){pa.attr({src:O})}}(x,s),0)}},tick:function(f){var b=d(I);if(R){var e=H(b-d(Za)/A(C)*R);b=!(b*e<=0||b<v(e))&&c(I,b>v(d(va))?e:(R=G=0))}Ca.text(d(a.monitor));b&&R++;G&&G++;db(0);Ea=true;if(G&&!b)return m.call(f);if(d(fa))return m.call(f,K());e=d(aa)*oa(1,d(E));var i=(d(Fa)?b:v(d(va))+b)/A(C);b=d(o);e=c(o,b-i*e);m.call(f);e!=b&&g.trigger("fractionChange")},opening:function(){var f=a.entry||a.speed,b=d(o),e=a.opening;c(o,b-f*a.opening);
c(ba,e*A(C));D.bind(F,t.opening_tick)},opening_tick:function(f){var b=(a.entry||a.speed)/A(C)*(a.cw?-1:1),e=d(o);c(o,H(e+b));b=c(ba,d(ba)-1);g.trigger("fractionChange");m.call(f);if(!(b>1)){D.unbind(F,t.opening_tick);Hb()}},play:function(f){var b=c(Ga,true);c(Fa,!b);eb();m.call(f)},pause:function(f){c(Ga,false);K();m.call(f)},stop:function(f){var b=c(Fa,true);c(Ga,!b);m.call(f)},down:function(f,b,e,i){if(a.draggable){c(fa,d(y));c(I,0);ga=ha(b,e,d(o),d(Y),d(z));K();ca();if(!i){da.css({cursor:na(Ib)+
", "+Ba}).bind(za,function(k){g.trigger("slide",[k.clientX,k.clientY]);m.call(k);return false});a.clickfree||da.bind(ya,function(k){g.trigger("up");m.call(k)})}}m.call(f)},up:function(f,b){if(!a.draggable)return m.call(f);c(fa,false);c(Q,false);var e=c(I,!a.throwable?0:v(S[0]+S[1])/60);R=e?1:0;e?eb():K();ca();!b&&da.unbind(ya).unbind(za)&&d(ab).css({cursor:na(bb)+", "+Ba});m.call(f)},slide:function(f,b,e){if(a.draggable&&Ea){Ea=false;K();var i={x:b-ga.x,y:e-ga.y};if(v(i.x)>0||v(i.y)>0){ga={x:b,y:e};
var k=d(Y),l=d(fb),n=d(J),s=c(o,gb(n?e-l.y:b-l.x,d(Ha),k,d(Ia),d(Ja),d(aa)));c(Q,d(Q)||d(y)!=d(fa));(i=db(n?i.y:i.x||0))&&c(E,i<0);if(a.orbital&&d(wa)){c(J,v(e-l.y)>v(b-l.x));l=ha(b,e,s,k,d(z))}if(a.rows>1){i=d(B).y;n=d(hb);var x=-n*i;c(z,H(h.reel.math.envelope(e-l.y,n,i,x,x+i,-1)))}!(s%1)&&!a.loops&&ha(b,e,s,k,d(z));g.trigger("fractionChange")}}m.call(f)},wheel:function(f,b){if(!a.wheelable)return m.call(f);var e=Ta(Jb(v(b))/2);e=oa(e,b>0);b=0.2*d(Y);ha(p,p,d(o),b,d(z));c(o,gb(e,d(Ha),b,d(Ia),d(Ja),
d(aa)));e&&c(E,e<0);c(I,0);K();m.call(f);g.trigger("fractionChange");return false},fractionChange:function(f,b){b=!b?d(o):c(o,b);b=a.loops?b-T(b):V(0,1,b);b=c(o,H(b));var e=d(y),i=c(y,1+T(b/d(Z))),k=a.orbital;c(wa,!!k&&(i<=k||i>=a.footage-k+2));if(!a.loops&&a.rebound){!G&&!(b%1)?Ka++:(Ka=0);Ka>=a.rebound*1E3/A(C)&&c(E,!d(E))}k=d(B);var l=(d(J)?k.y:k.x)-a.indicator;b=V(0,l,U(h.reel.math.interpolate(b,-1,l+2)));b=!a.cw||a.stitched?b:l-b;h(la(La+".x"),d($)).css(d(J)?{left:0,top:b}:{left:b,top:k.y-a.indicator});
if(a.rows>1){b=d(B).y-a.indicator;b=V(0,b,U(h.reel.math.interpolate(d(z),-1,b+2)));h(la(La+".y"),d($)).css({top:b})}if(i==e&&i!=1)return m.call(f);g.trigger(a.rows>1?"rowChange":"frameChange");m.call(f)},rowChange:function(f,b){var e=T(d(o)/d(Z))+1;b=c(z,V(0,1,H(b!=p?(b-1)/(a.rows-1):d(z))));c(y,e+(a.rows<=1?0:U(b*(a.rows-1))*a.frames));m.call(f);g.trigger("frameChange")},frameChange:function(f,b){var e=!b?d(o):c(o,H(d(Z)*(b-1)));b=c(y,U(b?b:d(y)));var i=a.images,k=a.footage,l=d(B),n=a.horizontal;
if(d(J)){b=a.inversed?k+1-b:b;b+=k}if(i.length)g.attr({src:a.path+i[b-1]});else{if(a.stitched)i=[-U(e*d(Ya))+L,0+L];else{e=b%k-1;e=e<0?k-1:e;k=T((b-0.1)/k);k+=a.rows>1?0:d(E)?0:d(ta);b=d(Xa);k=k*((n?l.y:l.x)+b);l=e*((n?l.x:l.y)+b);i=i.length?[0,0]:n?[-l+L,-k+L]:[-k+L,-l+L]}g.css({backgroundPosition:i.join(ra)})}m.call(f)}},m=function(f){ib||delete this;return f},G,R=0,eb=function(){return G=0},K=function(){clearTimeout(jb);D.unbind(F,t.opening_tick);g.trigger("play");return G=-a.timeout*A(C)},jb,
Hb=function(){jb=setTimeout(function(){g.trigger("play")},a.delay*1E3||0)},Ca,Da,cb=function(f){return h(P,{"class":[La,f].join(ra),css:{width:a.indicator,height:a.indicator,overflow:xa,top:d(B).y-a.indicator,left:0,position:ea,backgroundColor:Aa}})},Ka=0,ga={x:0,y:0},db=function(f){return S.push(f)&&S.shift()&&f},ca=function(){return S=[0,0]},S=ca(),gb=a.graph||h.reel.math[a.loops?"hatch":"envelope"],ha=function(f,b,e,i,k){c(Ha,e);c(hb,k);c(Ia,a.loops?0:-e*i);c(Ja,a.loops?i:i-e*i);return f&&c(fb,
{x:f,y:b})||p},Ea=true,da=h.browser.opera?D:h.unique(D.add(kb.top.document));t.setup()});ia=ia||function g(){var r=+new Date,c=A(C);if(c){D.trigger(F);h.reel.cost=(+new Date+h.reel.cost-r)/2;return ia=setTimeout(g,N(4,1E3/c-h.reel.cost))}else return ia=p}();return h(u)};h.reel.math={envelope:function(j,a,u,g,r,c){return a+N(g,Ma(r,-j*c))/u},hatch:function(j,a,u,g,r,c){j=(j<g?r:0)+j%r;j=a+-j*c/u;return j-T(j)},interpolate:function(j,a,u){return a+j*(u-a)}};h.reel.touchy=/iphone|ipod|ipad|android/i.test(navigator.userAgent);
h.reel.lazy=/iphone|ipod|android/i.test(navigator.userAgent);h.reel.instances=h();h.reel.cost=0;h.reel.leader=A;pb("mousewheel disableTextSelect enableTextSelect".split(/ /));var D=h(ja);ja=+h.browser.version.split(".").slice(0,2).join(".");var ib=h.browser.msie,nb=!(ib&&ja<8),Ba="ew-resize",ia,w="jquery-reel",rb=w+"-overlay",La=w+"-indicator",Fb=w+"-preloader",Eb=w+"-monitor",tb=w+"-interface",Gb=ka("CAAIAIAAAAAAAAAAACH5BAEAAAAALAAAAAAIAAgAAAIHhI+py+1dAAA7")||ma("blank.gif"),bb=ka("EAAQAJECAAAAAP///////wAAACH5BAEAAAIALAAAAAAQABAAQAI3lC8AeBDvgosQxQtne7yvLWGStVBelXBKqDJpNzLKq3xWBlU2nUs4C/O8cCvU0EfZGUwt19FYAAA7")||
ma("jquery.reel.cursor-drag.gif"),Ib=ka("EAAQAJECAAAAAP///////wAAACH5BAEAAAIALAAAAAAQABAAQAIslI95EB3MHECxNjBVdE/5b2zcRV1QBabqhwltq41St4hj5konmVioZ6OtEgUAOw==")||ma("jquery.reel.cursor-drag-down.gif"),U=Math.round,T=Math.floor,Ta=Math.ceil,Ma=Math.min,N=Math.max,v=Math.abs,Jb=Math.sqrt,X=parseInt,ab="area",$a="backup",E="backwards",Z="bit",Za="brake",wa="center",Wa="classes",fa="clicked",fb="clicked_location",Ha="clicked_on",hb="clicked_row",aa="cwish",B="dimensions",o="fraction",y="frame",Sa="frames",
Ja="hi",xa="hidden",Va="image",ba="opening_ticks",Ia="lo",Ga="playing",Q="reeling",Y="revolution",z="row",ta="rows",Xa="spacing",va="speed",$="stage",sa="steps",ua="stitched",Ya="stitched_travel",Fa="stopped",C="tempo",I="velocity",J="vertical",sb="wheel_step",q=".reel",zb="dblclick"+q,Bb="mousedown"+q,Ab="mouseenter"+q,Cb="mouseleave"+q,za="mousemove"+q,ya="mouseup"+q,yb="mousewheel"+q,F="tick"+q,xb="touchcancel"+q,wb="touchend"+q,ub="touchstart"+q,vb="touchmove"+q,Qa="",ra=" ",ea="absolute",Ra=
"div",P=ob(Ra),Pa="height",Aa="#000",M="id",qb="img",L="px",Na="src",Db="title",Oa="width"}(jQuery,window,document);


/* Copyright (c) 2009 Brandon Aaron (http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
 * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
 *
 * Version: 3.0.2
 * 
 * Requires: 1.2.2+
 */
(function(c){var a=["DOMMouseScroll","mousewheel"];c.event.special.mousewheel={setup:function(){if(this.addEventListener){for(var d=a.length;d;){this.addEventListener(a[--d],b,false)}}else{this.onmousewheel=b}},teardown:function(){if(this.removeEventListener){for(var d=a.length;d;){this.removeEventListener(a[--d],b,false)}}else{this.onmousewheel=null}}};c.fn.extend({mousewheel:function(d){return d?this.bind("mousewheel",d):this.trigger("mousewheel")},unmousewheel:function(d){return this.unbind("mousewheel",d)}});function b(f){var d=[].slice.call(arguments,1),g=0,e=true;f=c.event.fix(f||window.event);f.type="mousewheel";if(f.wheelDelta){g=f.wheelDelta/120}if(f.detail){g=-f.detail/3}d.unshift(f,g);return c.event.handle.apply(this,d)}})(jQuery);


// $('img.photo',this).imagesLoaded(myFunction)
// execute a callback when all images have loaded.
// needed because .load() doesn't work on cached images

// mit license. paul irish. 2010.
// webkit fix from Oren Solomianik. thx!

// callback function is passed the last image to load
//   as an argument, and the collection as `this`


$.fn.imagesLoaded = function(callback){
  var elems = this.filter('img'),
      len   = elems.length,
      blank = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
      
  elems.bind('load.imgloaded',function(){
      if (--len <= 0 && this.src !== blank){ 
        elems.unbind('load.imgloaded');
        callback.call(elems,this); 
      }
  }).each(function(){
     // cached images don't fire load sometimes, so we reset src.
     if (this.complete || this.complete === undefined){
        var src = this.src;
        // webkit hack from http://groups.google.com/group/jquery-dev/browse_thread/thread/eee6ab7b2da50e1f
        // data uri bypasses webkit log warning (thx doug jones)
        this.src = blank;
        this.src = src;
     }  
  }); 

  return this;
};


/*!
 * jQuery UI Touch Punch 0.1.0
 *
 * Copyright 2010, Dave Furfero
 * Dual licensed under the MIT or GPL Version 2 licenses.
 *
 * Depends:
 *  jquery.ui.widget.js
 *  jquery.ui.mouse.js
 */

/*
(function(c){c.support.touch=typeof Touch==="object";if(!c.support.touch){return;}var f=c.ui.mouse.prototype,g=f._mouseInit,a=f._mouseDown,e=f._mouseUp,b={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup"};function d(h){var i=h.originalEvent.changedTouches[0];return c.extend(h,{type:b[h.type],which:1,pageX:i.pageX,pageY:i.pageY,screenX:i.screenX,screenY:i.screenY,clientX:i.clientX,clientY:i.clientY});}f._mouseInit=function(){var h=this;h.element.bind("touchstart."+h.widgetName,function(i){return h._mouseDown(d(i));});g.call(h);};f._mouseDown=function(j){var h=this,i=a.call(h,j);h._touchMoveDelegate=function(k){return h._mouseMove(d(k));};h._touchEndDelegate=function(k){return h._mouseUp(d(k));};c(document).bind("touchmove."+h.widgetName,h._touchMoveDelegate).bind("touchend."+h.widgetName,h._touchEndDelegate);return i;};f._mouseUp=function(i){var h=this;c(document).unbind("touchmove."+h.widgetName,h._touchMoveDelegate).unbind("touchend."+h.widgetName,h._touchEndDelegate);return e.call(h,i);};})(jQuery);
*/

/* Simply disable selection plugin */

(function($){

$.fn.disableSelection = function() {
    return this.each(function() {           
        $(this).attr('unselectable', 'on')
               .css({
                   '-moz-user-select':'none',
                   '-webkit-user-select':'none',
                   'user-select':'none'
               })
               .each(function() {
                   this.onselectstart = function() { return false; };
               });
    });
};

})(jQuery);

/**
* jQuery.UI.iPad plugin
* Copyright (c) 2010 Stephen von Takach
* licensed under MIT.
* Date: 27/8/2010
*
* Project Home: 
* http://code.google.com/p/jquery-ui-for-ipad-and-iphone/
*/


$(function() {
	//
	// Extend jQuery feature detection
	//
	$.extend($.support, {
		touch: "ontouchend" in document
	});
	
	//
	// Hook up touch events
	//
	if ($.support.touch) {
		document.addEventListener("touchstart", iPadTouchHandler, false);
		document.addEventListener("touchmove", iPadTouchHandler, false);
		document.addEventListener("touchend", iPadTouchHandler, false);
		document.addEventListener("touchcancel", iPadTouchHandler, false);
	}
});


var lastTap = null;			// Holds last tapped element (so we can compare for double tap)
var tapValid = false;			// Are we still in the .6 second window where a double tap can occur
var tapTimeout = null;			// The timeout reference

function cancelTap() {
	tapValid = false;
}


var rightClickPending = false;	// Is a right click still feasible
var rightClickEvent = null;		// the original event
var holdTimeout = null;			// timeout reference
var cancelMouseUp = false;		// prevents a click from occuring as we want the context menu


function cancelHold() {
	if (rightClickPending) {
		window.clearTimeout(holdTimeout);
		rightClickPending = false;
		rightClickEvent = null;
	}
}

function startHold(event) {
	if (rightClickPending)
		return;

	rightClickPending = true; // We could be performing a right click
	rightClickEvent = (event.changedTouches)[0];
	holdTimeout = window.setTimeout("doRightClick();", 800);
}


function doRightClick() {
	rightClickPending = false;

	//
	// We need to mouse up (as we were down)
	//
	var first = rightClickEvent,
		simulatedEvent = document.createEvent("MouseEvent");
	simulatedEvent.initMouseEvent("mouseup", true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
			false, false, false, false, 0, null);
	first.target.dispatchEvent(simulatedEvent);

	//
	// emulate a right click
	//
	simulatedEvent = document.createEvent("MouseEvent");
	simulatedEvent.initMouseEvent("mousedown", true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
			false, false, false, false, 2, null);
	first.target.dispatchEvent(simulatedEvent);

	//
	// Show a context menu
	//
	simulatedEvent = document.createEvent("MouseEvent");
	simulatedEvent.initMouseEvent("contextmenu", true, true, window, 1, first.screenX + 50, first.screenY + 5, first.clientX + 50, first.clientY + 5,
                                  false, false, false, false, 2, null);
	first.target.dispatchEvent(simulatedEvent);


	//
	// Note:: I don't mouse up the right click here however feel free to add if required
	//


	cancelMouseUp = true;
	rightClickEvent = null; // Release memory
}


//
// mouse over event then mouse down
//
function iPadTouchStart(event) {
	var touches = event.changedTouches,
		first = touches[0],
		type = "mouseover",
		simulatedEvent = document.createEvent("MouseEvent");
	//
	// Mouse over first - I have live events attached on mouse over
	//
	simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
                            false, false, false, false, 0, null);
	first.target.dispatchEvent(simulatedEvent);

	type = "mousedown";
	simulatedEvent = document.createEvent("MouseEvent");

	simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
                            false, false, false, false, 0, null);
	first.target.dispatchEvent(simulatedEvent);


	if (!tapValid) {
		lastTap = first.target;
		tapValid = true;
		tapTimeout = window.setTimeout("cancelTap();", 600);
		startHold(event);
	}
	else {
		window.clearTimeout(tapTimeout);

		//
		// If a double tap is still a possibility and the elements are the same
		//	Then perform a double click
		//
		if (first.target == lastTap) {
			lastTap = null;
			tapValid = false;

			type = "click";
			simulatedEvent = document.createEvent("MouseEvent");

			simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
                         	false, false, false, false, 0/*left*/, null);
			first.target.dispatchEvent(simulatedEvent);

			type = "dblclick";
			simulatedEvent = document.createEvent("MouseEvent");

			simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
                         	false, false, false, false, 0/*left*/, null);
			first.target.dispatchEvent(simulatedEvent);
		}
		else {
			lastTap = first.target;
			tapValid = true;
			tapTimeout = window.setTimeout("cancelTap();", 600);
			startHold(event);
		}
	}
}

function iPadTouchHandler(event) {
	var type = "",
		button = 0; /*left*/

	if (event.touches.length > 1)
		return;

	switch (event.type) {
		case "touchstart":
			if ($(event.changedTouches[0].target).is("select")) {
				return;
			}
			iPadTouchStart(event); /*We need to trigger two events here to support one touch drag and drop*/
			event.preventDefault();
			return false;
			break;

		case "touchmove":
			cancelHold();
			type = "mousemove";
			event.preventDefault();
			break;

		case "touchend":
			if (cancelMouseUp) {
				cancelMouseUp = false;
				event.preventDefault();
				return false;
			}
			cancelHold();
			type = "mouseup";
			break;

		default:
			return;
	}

	var touches = event.changedTouches,
		first = touches[0],
		simulatedEvent = document.createEvent("MouseEvent");

	simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
                            false, false, false, false, button, null);

	first.target.dispatchEvent(simulatedEvent);

	if (type == "mouseup" && tapValid && first.target == lastTap) {	// This actually emulates the ipads default behaviour (which we prevented)
		simulatedEvent = document.createEvent("MouseEvent");		// This check avoids click being emulated on a double tap

		simulatedEvent.initMouseEvent("click", true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
                            false, false, false, false, button, null);

		first.target.dispatchEvent(simulatedEvent);
	}
}
