jQuery.fn.sameHeight = function() {
  var newHeight = -999999999999;

  this.each(function(i, el) {
    var h = jQuery(el).height();
    if (h > newHeight) {
      newHeight = h;
    }
  });

  return this.each(function(i, el) {
    jQuery(el).height(newHeight);
  });
};

//Url Params
$.urlParam = function(name){
    var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
    if (results != null) {
				return results[1] || 0;
		} else {
				return '';
		}
		
}

//header nav
$(function() {
	id = $('nav').attr('class');
	if ($('header-top-nav-link').hasClass('selected-top-nav')) {
		$(this).removeClass('selected-top-nav');
	}
	$('nav #' + id).addClass('selected-top-nav');

});



$('.header-top-nav-link').live('mouseover', function() {
	var tab = $(this).attr('id');
	$('nav').removeClass();
	$('nav').addClass(tab);
});

$('.header-top-nav-link').live('click', function() {
	var tab = $(this).attr('id');
	$('nav').removeClass();
	$('nav').addClass(tab);
});

$('.header-top-nav-link').live('mouseout', function() {
	$('nav').removeClass();
	var selectedNav = $('.selected-top-nav').attr('id');
	$('nav').addClass(selectedNav);
});



//home-main-block
var homeAnimFinished = true;
var fastAnim = (isIE6 || isIE7);
var idx = nxt = 0;
var currentIdx = 0;

$(function(){
    $('.home-main-block-nav-item a').click(function(){
        return false;
    });

    $('.home-main-block-nav-item a').mouseover(function(){
        idx = parseInt($(this).attr('rel'));
        if (currentIdx == idx) { return false; }
        currentIdx = idx;

        $('#home-main-block-nav-ul').removeClass();
        $('#home-main-block-nav-ul').addClass($(this).attr('id'));

        var href = $(this).attr('href');
        if (homeAnimFinished && !fastAnim) {
            $('#home-main-block .home-main-block-item').fadeOut();
            $(href).fadeIn(function(){ homeAnimFinished = true; });
            homeAnimFinished = false;
        } else {
            $('#home-main-block .home-main-block-item').hide();
            $(href).show();
            fastAnim = true;
        }
        return false;
    });

});

//pre-footer
var pfAnimFinished = true;
var pfFastAnim = (isIE6 || isIE7);
var pfIdx = nxt = 0;
var pfCurrentIdx = 0;

$(function(){
    $('.pre-footer-nav-link').click(function(){
        pfIdx = parseInt($(this).attr('rel'));
        if (pfCurrentIdx == pfIdx) { return false; }
        pfCurrentIdx = pfIdx;

        $('.pre-footer-nav-item .pre-footer-nav-link').each(function(index) {
						$(this).removeClass('selected');
				});
				$(this).addClass('selected');
				$('#pre-footer-nav').removeClass();
				$('#pre-footer-nav').addClass($(this).attr('id'));

        var href = $(this).attr('href');
        if (pfAnimFinished && !fastAnim) {
            $('#pre-footer-wrapper .pre-footer-item').fadeOut();
            $(href).fadeIn(function(){ pfAnimFinished = true; });
            pfAnimFinished = false;
        } else {
            $('#pre-footer-wrapper .pre-footer-item').hide();
            $(href).show();
            pfFastAnim = true;
        }
        return false;
    });

});


//inputs
$(function(){
	if ($('#header-sign-in .input-box input').val() == '') {
		$(this).css('background-color', 'transparent');
	} else {
		$(this).css('background-color', '#ffffff');
	}
	$('#header-sign-in .input-box input').focus(function() {
		$(this).css('background-color', '#ffffff');
	});
	$('#header-sign-in .input-box input').blur(function() {
		if ($(this).val() == '') {
			$(this).css('background-color', 'transparent');
		} else {
			$(this).css('background-color', '#ffffff');
		}
	});

	if ($('#footer-newsletter-form .input-box input').val() == '') {
		$(this).css('background-color', 'transparent');
	} else {
		$(this).css('background-color', '#ffffff');
	}
	$('#footer-newsletter-form .input-box input').focus(function() {
		$(this).css('background-color', '#ffffff');
	});
	$('#footer-newsletter-form .input-box input').blur(function() {
		if ($(this).val() == '') {
			$(this).css('background-color', 'transparent');
		} else {
			$(this).css('background-color', '#ffffff');
		}
	});
});


//header
$('#header-top-nav-personal, #header-top-nav-personal-overlay').live('mouseenter', function() {
  $('#header-top-nav-personal-overlay').show();
	$('nav').removeClass();
	$('nav').addClass('header-top-nav-personal');
});

$('#header-top-nav-personal, #header-top-nav-personal-overlay').live('mouseleave', function() {
	$('#header-top-nav-personal-overlay').hide();
	$('nav').removeClass();
	var selectedNav = $('.selected-top-nav').attr('id');
	$('nav').addClass(selectedNav);
});

$('#header-top-nav-business, #header-top-nav-business-overlay').live('mouseenter', function() {
  $('#header-top-nav-business-overlay').show();
	$('nav').removeClass();
	$('nav').addClass('header-top-nav-business');
});

$('#header-top-nav-business, #header-top-nav-business-overlay').live('mouseleave', function() {
	$('#header-top-nav-business-overlay').hide();
	$('nav').removeClass();
	var selectedNav = $('.selected-top-nav').attr('id');
	$('nav').addClass(selectedNav);
});

// button navs
function updateBtnBg() {
	$('.button-nav').each(function(index) {
		if ($(this).hasClass('selected') == false) {
			$(this).find('div').css('background-image', 'none');
		}
	});
}
$(function(){
	updateBtnBg();
					
	$('.button-nav').click(function() {
		$('.button-nav').each(function(index) {
			$(this).removeClass('selected');
		});
		$(this).addClass('selected');
		
		updateBtnBg();
	});

});

//Disclosures
$('#insurance-disclosures').live('click', function() {
	var width = 600;
	var height = 250;
	var url = $('#insurance-disclosures').attr('href');
	
	insurance = window.open(url, 'insurance_disclosures', 'height='+height+', width='+width+', resizable=yes');
	if (window.focus) {insurance.focus()}
	return false;
});			

$('#fdic-disclosures').live('click', function() {
	var width = 600;
	var height = 300;
	var url = $(this).attr('href');

	fdic = window.open(url, 'fdic_disclosures', 'height='+height+', width='+width+', resizable=yes');
	if (window.focus) {fdic.focus()}
	return false;
});

//calculators

/**
 * bar: the id or class of the black bar
 * left: the leff value of the button
 * pixels: the number of pixels to add
 */
function setBlackBar(bar, left, pixels) {
	var w = left + pixels;
	$(bar).width(w);
}

/**
 * slider: the slider to update
 * value: the new input value
 * max: the slider max
 */

function updateSlider(slider, value, max) {
		var button = slider + '-button';
		var black = slider + '-black';
		
		var r = Math.round(value * 179 / max);
		if (value > max) {
				r = 179;
				value = max;
		}
		$(button).css('left', r);
		setBlackBar(black, r, 14);
}

$('.price-format').live('blur', function() {
	var el = $(this);
	el.val(formatCurrency(el.val()));
});


//format currency
function formatCurrency(nStr) {
		nStr += '';
		var x = nStr.split('.');
		var x1 = x[0];
		var x2 = x.length > 1 ? '.' + x[1] : '';
		var rgx = /(\d+)(\d{3})/;
		while (rgx.test(x1)) {
				x1 = x1.replace(rgx, '$1' + ',' + '$2');
		}
		return x1 + x2;
}

function formatFloat(f) {
	if (isNaN(f)) { f = 0; }
		
	if (f >= 10) {
		if ((f + '').length == 2) { f += '.00'; }
		else if ((f + '').length == 4) { f += '0'; }
	} else {
		if ((f + '').length == 1) { f += '.00'; }
		else if ((f + '').length == 3) { f += '0'; }
	}
	return f;
}


function getCleanAmount(a) {
	a = a.replace(/,/g, '');
	var cleanAmount = parseInt(a);
	return cleanAmount;
}


/**
 * slider: the slider id (ex: #calculator-invested-amout-slider), 
 * 		=> button: #calculator-invested-amout-slider-button, => black bar: #calculator-invested-amout-slider-black
 * input: the related input id or other (ex: input[name="calculator-invested-amout-value"])
 * amount: the max amount of the slider
 * step: the slider step
 */

function setAmountSlider(slider, input, max, step) {
		var button = slider + '-button';
		var black = slider + '-black';

		$(slider + " " + button).draggable({axis:'x', containment:  slider});
		$(slider + " " + button).bind('drag', function (e){
				var r = parseInt($(this).css('left'));
				setBlackBar(black, r, 14);
	
				var amount = Math.round(r / 179 * max);
				if (isNaN(amount)) { amount = 0; }
				amount = Math.round(amount / step) * step;
				$(input).val(formatCurrency(amount));
		});
		$(input).change(function() {
				var amount = getCleanAmount($(this).val());
				var r = Math.round(amount * 179 / max);
				if (amount > max) {
						r = 179;
						amount = max;
				}
				$(this).val(formatCurrency(amount));
				$(button).css('left', r);
				setBlackBar(black, r, 14);
		});
}


function setRateSlider(slider, input, max, step) {
		var button = slider + '-button';
		var black = slider + '-black';

		$(slider + " " + button).draggable({axis:'x', containment: slider});
		$(slider + " " + button).bind('drag', function (e){
				var r = parseInt($(this).css('left'));
				setBlackBar(black, r, 14);
				var rate = r/179 * max;	
				if (isNaN(rate)) { rate = 0; }
				rate = Math.round(rate * step) / step;
				$(input).val(formatFloat(rate));
		});
		$(input).change(function() {
				var rate = $(this).val();
				var r = Math.round(rate * 179 / max);
				if (rate > max) {
						r = 179;
						rate = max;
				}
				$(this).val(formatFloat(rate));
				$(button).css('left', r);
				setBlackBar(black, r, 14);
		});
}

// Works for the months and years
function setTimeSlider(slider, input, max) {
		var button = slider + '-button';
		var black = slider + '-black';

		$(slider + " " + button).draggable({axis:'x', containment: slider});
		$(slider + " " + button).bind('drag', function (e){
				var r = parseInt($(this).css('left'));
				setBlackBar(black, r, 14);
				var years = Math.round(r / 179 * max);
				if (isNaN(years)) { years = 0; }
				$(input).val(years);
		});
		$(input).change(function() {
				var years = $(this).val();
				var r = Math.round(years * 179 / max);
				if (years > max) {
						r = 179;
						years = max;
				}
				$(this).val(years);
				$(button).css('left', r);
				setBlackBar(black, r, 14);
		});
}

// jQuery Plugins

/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 5/25/2009
 * @author Ariel Flesler
 * @version 1.4.2
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);

/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * Uses the built in easing capabilities added In jQuery 1.1
 * to offer multiple easing options
 *
 * TERMS OF USE - jQuery Easing
 * 
 * Open source under the BSD License. 
 * 
 * Copyright Â© 2008 George McGinley Smith
 * 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 the author nor the names of 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. 
 *
*/

// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	},
	easeInOutQuad: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	},
	easeInCubic: function (x, t, b, c, d) {
		return c*(t/=d)*t*t + b;
	},
	easeOutCubic: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	},
	easeInOutCubic: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	},
	easeInQuart: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t + b;
	},
	easeOutQuart: function (x, t, b, c, d) {
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
	},
	easeInOutQuart: 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;
	},
	easeInQuint: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t*t + b;
	},
	easeOutQuint: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
	},
	easeInOutQuint: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
		return c/2*((t-=2)*t*t*t*t + 2) + b;
	},
	easeInSine: function (x, t, b, c, d) {
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
	},
	easeOutSine: function (x, t, b, c, d) {
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	},
	easeInOutSine: function (x, t, b, c, d) {
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	},
	easeInExpo: function (x, t, b, c, d) {
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
	},
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	},
	easeInOutExpo: function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	},
	easeInCirc: function (x, t, b, c, d) {
		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
	},
	easeOutCirc: function (x, t, b, c, d) {
		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
	},
	easeInOutCirc: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
	},
	easeInElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	},
	easeOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	},
	easeInOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
	},
	easeInBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*(t/=d)*t*((s+1)*t - s) + b;
	},
	easeOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	},
	easeInOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158; 
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	},
	easeInBounce: function (x, t, b, c, d) {
		return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
	},
	easeOutBounce: function (x, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	},
	easeInOutBounce: function (x, t, b, c, d) {
		if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
		return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
	}
});

/*
 *
 * TERMS OF USE - EASING EQUATIONS
 * 
 * Open source under the BSD License. 
 * 
 * Copyright Â© 2001 Robert Penner
 * 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 the author nor the names of 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. 
 *
 */


/*!
 * 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);
