﻿

/**
* .disableTextSelect - Disable Text Select Plugin
*
* Version: 1.1
* Updated: 2007-11-28
*
* Used to stop users from selecting text
*
* Copyright (c) 2007 James Dempster (letssurf@gmail.com, http://www.jdempster.com/category/jquery/disabletextselect/)
*
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
**/

/**
* Requirements:
* - jQuery (John Resig, http://www.jquery.com/)
**/
(function($) {
	if ($.browser.mozilla) {
		$.fn.disableTextSelect = function() {
			return this.each(function() {
				$(this).css({
					'MozUserSelect': 'none'
				});
			});
		};
		$.fn.enableTextSelect = function() {
			return this.each(function() {
				$(this).css({
					'MozUserSelect': ''
				});
			});
		};
	} else if ($.browser.msie) {
		$.fn.disableTextSelect = function() {
			return this.each(function() {
				$(this).bind('selectstart.disableTextSelect', function() {
					return false;
				});
			});
		};
		$.fn.enableTextSelect = function() {
			return this.each(function() {
				$(this).unbind('selectstart.disableTextSelect');
			});
		};
	} else {
		$.fn.disableTextSelect = function() {
			return this.each(function() {
				$(this).bind('mousedown.disableTextSelect', function() {
					return false;
				});
			});
		};
		$.fn.enableTextSelect = function() {
			return this.each(function() {
				$(this).unbind('mousedown.disableTextSelect');
			});
		};
	}
})(jQuery);


/* Copyright (c) 2006 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.
*
* $LastChangedDate: 2007-06-19 20:23:36 -0500 (Tue, 19 Jun 2007) $
* $Rev: 2110 $
*
* Version 2.1
*/

(function($) {

	/**
	* The bgiframe is chainable and applies the iframe hack to get 
	* around zIndex issues in IE6. It will only apply itself in IE 
	* and adds a class to the iframe called 'bgiframe'. The iframe
	* is appeneded as the first child of the matched element(s) 
	* with a tabIndex and zIndex of -1.
	* 
	* By default the plugin will take borders, sized with pixel units,
	* into account. If a different unit is used for the border's width,
	* then you will need to use the top and left settings as explained below.
	*
	* NOTICE: This plugin has been reported to cause perfromance problems
	* when used on elements that change properties (like width, height and
	* opacity) a lot in IE6. Most of these problems have been caused by 
	* the expressions used to calculate the elements width, height and 
	* borders. Some have reported it is due to the opacity filter. All 
	* these settings can be changed if needed as explained below.
	*
	* @example $('div').bgiframe();
	* @before <div><p>Paragraph</p></div>
	* @result <div><iframe class="bgiframe".../><p>Paragraph</p></div>
	*
	* @param Map settings Optional settings to configure the iframe.
	* @option String|Number top The iframe must be offset to the top
	* 		by the width of the top border. This should be a negative 
	*      number representing the border-top-width. If a number is 
	* 		is used here, pixels will be assumed. Otherwise, be sure
	*		to specify a unit. An expression could also be used. 
	* 		By default the value is "auto" which will use an expression 
	* 		to get the border-top-width if it is in pixels.
	* @option String|Number left The iframe must be offset to the left
	* 		by the width of the left border. This should be a negative 
	*      number representing the border-left-width. If a number is 
	* 		is used here, pixels will be assumed. Otherwise, be sure
	*		to specify a unit. An expression could also be used. 
	* 		By default the value is "auto" which will use an expression 
	* 		to get the border-left-width if it is in pixels.
	* @option String|Number width This is the width of the iframe. If
	*		a number is used here, pixels will be assume. Otherwise, be sure
	* 		to specify a unit. An experssion could also be used.
	*		By default the value is "auto" which will use an experssion
	* 		to get the offsetWidth.
	* @option String|Number height This is the height of the iframe. If
	*		a number is used here, pixels will be assume. Otherwise, be sure
	* 		to specify a unit. An experssion could also be used.
	*		By default the value is "auto" which will use an experssion
	* 		to get the offsetHeight.
	* @option Boolean opacity This is a boolean representing whether or not
	* 		to use opacity. If set to true, the opacity of 0 is applied. If
	*		set to false, the opacity filter is not applied. Default: true.
	* @option String src This setting is provided so that one could change 
	*		the src of the iframe to whatever they need.
	*		Default: "javascript:false;"
	*
	* @name bgiframe
	* @type jQuery
	* @cat Plugins/bgiframe
	* @author Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
	*/
	$.fn.bgIframe = $.fn.bgiframe = function(s) {
		// This is only for IE6
		if ($.browser.msie && parseInt($.browser.version) <= 6) {
			s = $.extend({
				top: 'auto', // auto == .currentStyle.borderTopWidth
				left: 'auto', // auto == .currentStyle.borderLeftWidth
				width: 'auto', // auto == offsetWidth
				height: 'auto', // auto == offsetHeight
				opacity: true,
				src: 'javascript:false;'
			}, s || {});
			var prop = function(n) { return n && n.constructor == Number ? n + 'px' : n; },
		    html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="' + s.src + '"' +
		               'style="display:block;position:absolute;z-index:-1;' +
			               (s.opacity !== false ? 'filter:Alpha(Opacity=\'0\');' : '') +
					       'top:' + (s.top == 'auto' ? 'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')' : prop(s.top)) + ';' +
					       'left:' + (s.left == 'auto' ? 'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')' : prop(s.left)) + ';' +
					       'width:' + (s.width == 'auto' ? 'expression(this.parentNode.offsetWidth+\'px\')' : prop(s.width)) + ';' +
					       'height:' + (s.height == 'auto' ? 'expression(this.parentNode.offsetHeight+\'px\')' : prop(s.height)) + ';' +
					'"/>';
			return this.each(function() {
				if ($('> iframe.bgiframe', this).length == 0)
					this.insertBefore(document.createElement(html), this.firstChild);
			});
		}
		return this;
	};

	// Add browser.version if it doesn't exist
	if (!$.browser.version)
		$.browser.version = navigator.userAgent.toLowerCase().match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)[1];

})(jQuery);

; (function($) { // secure $ jQuery alias
	/*******************************************************************************************/
	// jquery.event.hover.js - rev 5 
	// Copyright (c) 2008, Three Dub Media (http://threedubmedia.com)
	// Liscensed under the MIT License (MIT-LICENSE.txt)
	// http://www.opensource.org/licenses/mit-license.php
	// Created: 2008-06-02 | Updated: 2008-07-30
	/*******************************************************************************************/

	//	USE THESE PROPERTIES TO CUSTOMIZE SETTINGS...

	//	$.event.special.hover.delay = 100; 
	//	Defines the delay (msec) while mouse is inside the element before checking the speed

	//	$.event.special.hover.speed = 100; 
	//	Defines the maximum speed (px/sec) the mouse may be moving to trigger the hover event

	// save the old jquery "hover" method
	//$.fn._hover = $.fn.hover;

	// We (Magnus Ottosson) has renamed this function to specialhover so we still can use the normal hover function

	// jquery method 
	$.fn.specialhover = function(fn1, fn2, fn3) {
		if (fn3) this.bind('hoverstart', fn1); // 3 args
		if (fn2) this.bind('hoverend', fn3 ? fn3 : fn2); // 2+ args
		return !fn1 ? this.trigger('hover') // 0 args 
		: this.bind('hover', fn3 ? fn2 : fn1); // 1+ args
	};

	// special event configuration
	var hover = $.event.special.hover = {
		delay: 100, // milliseconds
		speed: 100, // pixels per second
		setup: function(data) {
			data = $.extend({ speed: hover.speed, delay: hover.delay, hovered: 0 }, data || {});
			$.event.add(this, "mouseenter mouseleave", hoverHandler, data);
		},
		teardown: function() {
			$.event.remove(this, "mouseenter mouseleave", hoverHandler);
		}
	};

	// shared event handler
	function hoverHandler(event) {
		var data = event.data || event;
		switch (event.type) {
			case 'mouseenter': // mouseover
				data.dist2 = 0; // init mouse distance²
				data.event = event; // store the event
				event.type = "hoverstart"; // hijack event
				if ($.event.handle.call(this, event) !== false) { // handle "hoverstart"
					data.elem = this; // ref to the current element
					$.event.add(this, "mousemove", hoverHandler, data); // track the mouse
					data.timer = setTimeout(compare, data.delay); // start async compare
				}
				break;
			case 'mousemove': // track the event, mouse distance² = x² + y²
				data.dist2 += Math.pow(event.pageX - data.event.pageX, 2)
				+ Math.pow(event.pageY - data.event.pageY, 2);
				data.event = event; // store current event
				break;
			case 'mouseleave': // mouseout
				clearTimeout(data.timer); // uncompare
				if (data.hovered) {
					event.type = "hoverend"; // hijack event
					$.event.handle.call(this, event); // handle "hoverend"
					data.hovered--; // reset flag
				}
				else $.event.remove(data.elem, "mousemove", hoverHandler); // untrack
				break;
			default: // timeout compare // distance² = x² + y²  = ( speed * time )²
				if (data.dist2 <= Math.pow(data.speed * (data.delay / 1e3), 2)) { // speed acceptable
					$.event.remove(data.elem, "mousemove", hoverHandler); // untrack
					data.event.type = "hover"; // hijack event
					if ($.event.handle.call(data.elem, data.event) !== false) // handle "hover"
						data.hovered++; // flag for "hoverend"
				}
				else data.timer = setTimeout(compare, data.delay); // async recurse
				data.dist2 = 0; // reset distance² for next compare
				break;
		}
		function compare() { hoverHandler(data); }; // timeout/recursive function
	};

	/*******************************************************************************************/
})(jQuery); // confine scope
