/*bgiframe*/
/* 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:25:28 -0500 (Tue, 19 Jun 2007) $
 * $Rev: 2111 $
 *
 * Version 2.1
 */
(function($){$.fn.bgIframe=$.fn.bgiframe=function(s){if($.browser.msie&&parseInt($.browser.version)<=6){s=$.extend({top:'auto',left:'auto',width:'auto',height:'auto',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;};if(!$.browser.version)$.browser.version=navigator.userAgent.toLowerCase().match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)[1];})(jQuery);





// JQUERY JSON PLUGIN - INPUT AN OBJECT, OUTPUT JSON //
(function ($) {
    var m = {
            '\b': '\\b',
            '\t': '\\t',
            '\n': '\\n',
            '\f': '\\f',
            '\r': '\\r',
            '"' : '\\"',
            '\\': '\\\\'
        },
        s = {
            'array': function (x) {
                var a = ['['], b, f, i, l = x.length, v;
                for (i = 0; i < l; i += 1) {
                    v = x[i];
                    f = s[typeof v];
                    if (f) {
                        v = f(v);
                        if (typeof v == 'string') {
                            if (b) {
                                a[a.length] = ',';
                            }
                            a[a.length] = v;
                            b = true;
                        }
                    }
                }
                a[a.length] = ']';
                return a.join('');
            },
            'boolean': function (x) {
                return String(x);
            },
            'null': function (x) {
                return "null";
            },
            'number': function (x) {
                return isFinite(x) ? String(x) : 'null';
            },
            'object': function (x) {
                if (x) {
                    if (x instanceof Array) {
                        return s.array(x);
                    }
                    var a = ['{'], b, f, i, v;
                    for (i in x) {
                        v = x[i];
                        f = s[typeof v];
                        if (f) {
                            v = f(v);
                            if (typeof v == 'string') {
                                if (b) {
                                    a[a.length] = ',';
                                }
                                a.push(s.string(i), ':', v);
                                b = true;
                            }
                        }
                    }
                    a[a.length] = '}';
                    return a.join('');
                }
                return 'null';
            },
            'string': function (x) {
                if (/["\\\x00-\x1f]/.test(x)) {
                    x = x.replace(/([\x00-\x1f\\"])/g, function(a, b) {
                        var c = m[b];
                        if (c) {
                            return c;
                        }
                        c = b.charCodeAt();
                        return '\\u00' +
                            Math.floor(c / 16).toString(16) +
                            (c % 16).toString(16);
                    });
                }
                return '"' + x + '"';
            }
        };

	$.toJSON = function(v) {
		var f = isNaN(v) ? s[typeof v] : s['number'];
		if (f) return f(v);
	};

	$.parseJSON = function(v, safe) {
		if (safe === undefined) safe = $.parseJSON.safe;
		if (safe && !/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(v))
			return undefined;
		return eval('('+v+')');
	};

	$.parseJSON.safe = false;

})(jQuery);


// END JSON OBJECT



/* easing */
jQuery.easing['jswing']=jQuery.easing['swing'];jQuery.extend(jQuery.easing,{def:'easeOutQuad',swing:function(x,t,b,c,d){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;}});

/*

 * jQuery ifixpng plugin

 * (previously known as pngfix)

 * Version 3.1.2  (2008/09/01)

 * @requires jQuery v1.2.6 or above, or a lower version with the dimensions plugin

 *

 * Based on the plugin by Kush M., http://jquery.khurshid.com

 *

 * Background position Fixed

 * Also fixes non-visible images

 * (c) Copyright Yereth Jansen (yereth@yereth.nl)

 * personal website: http://www.yereth.nl

 * Company website: http://www.wharf.nl

 *

 * Dual licensed under the MIT and GPL licenses:

 * http://www.opensource.org/licenses/mit-license.php

 * http://www.gnu.org/licenses/gpl.html

 *

 * For a demonstration of the background-position being fixed:

 * http://www.yereth.nl/bgpos.html

 *

 * Plugin page:

 * http://plugins.jquery.com/project/iFixPng2

 *

 */



/**

 *

 * @example

 *

 * optional if location of pixel.gif if different to default which is images/pixel.gif

 * $.ifixpng('media/pixel.gif');

 *

 * $('img[@src$=.png], #panel').ifixpng();

 *

 * @apply hack to all png images and #panel which icluded png img in its css

 *

 * @name ifixpng

 * @type jQuery

 * @cat Plugins/Image

 * @return jQuery

 * @author jQuery Community

 */

(function($) {



	/**

	 * helper variables and function

	 */

	$.ifixpng = function(customPixel) {

		$.ifixpng.pixel = customPixel;

	};



	$.ifixpng.regexp = {

		bg: /^url\(["']?(.*\.png([?].*)?)["']?\)$/i,

		img: /.*\.png([?].*)?$/i

	},



	$.ifixpng.getPixel = function() {

		return $.ifixpng.pixel || 'images/pixel.gif';

	};



	var hack = {

		base	: $('base').attr('href'),

		ltie7	: $.browser.msie && $.browser.version <= 9,

		filter	: function(src) {

			return "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop,src='"+src+"')";

		}

	};



	/**

	 * Applies ie png hack to selected dom elements

	 *

	 * $('img[@src$=.png]').ifixpng();

	 * @desc apply hack to all images with png extensions

	 *

	 * $('#panel, img[@src$=.png]').ifixpng();

	 * @desc apply hack to element #panel and all images with png extensions

	 *

	 * @name ifixpng

	 */



	$.fn.ifixpng = hack.ltie7 ? function() {

		function fixImage(image, source, width, height, hidden) {

			image.css({filter:hack.filter(source), width: width, height: height})

			  .attr({src:$.ifixpng.getPixel()})

			  .positionFix();

		}



    	return this.each(function() {

			var $$ = $(this);

			if ($$.is('img') || $$.is('input')) { // hack image tags present in dom

				var source, img;

				if (this.src && this.src.match($.ifixpng.regexp.img)) { // make sure it is png image

					// use source tag value if set

					source = (hack.base && this.src.substring(0,1)!='/' && this.src.indexOf(hack.base) === -1) ? hack.base + this.src : this.src;

					// If the width is not set, we have a problem; the image is not probably visible or not loaded

					// and we need a work around.

					if (!this.width || !this.height) {

						$(new Image()).one('load', function() {

							fixImage($$, source, this.width, this.height);

							$(this).remove();

						}).attr('src', source);

					// If the image already has dimensions (it's loaded and visible) we can fix it straight away.

					} else fixImage($$, source, this.width, this.height);

				}

			} else if (this.style) { // hack png css properties present inside css

				var imageSrc = $$.css('backgroundImage');

				// Background repeated images we cannot fix unfortunately

				if (imageSrc && imageSrc.match($.ifixpng.regexp.bg) && this.currentStyle.backgroundRepeat == 'no-repeat') {

					imageSrc = RegExp.$1;

					var x = this.currentStyle.backgroundPositionX || 0, y = this.currentStyle.backgroundPositionY || 0;

					if (x || y) {

						var css = {}, img;

						if (typeof x != 'undefined') {

							if (x == 'left') css.left = 0;

							// if right is 0, we have to check if the parent has an odd width, because of an IE bug

							else if (x == 'right') css.right = $$.width() % 2 === 1 ? -1 : 0;

							else css.left = x;

						}

						if (typeof y != 'undefined') {

							// if bottom is 0, we have to check if the parent has an odd height, because of an IE bug

							if (y == 'bottom') css.bottom = $$.height() % 2 === 1 ? -1 : 0;

							else if (y == 'top') css.top = 0;

							else css.top = y;

						}

						img = new Image();

						$(img).one('load', function() {

							var x,y, expr = {}, prop;

							// Now the image is loaded for sure, we can see if the background position needs fixing with an expression (in case of percentages)

							if (/center|%/.test(css.top)) {

								expr.top = "(this.parentNode.offsetHeight - this.offsetHeight) * " + (css.top == 'center' ? 0.5 : (parseInt(css.top) / 100));

								delete css.top;

							}

							if (/center|%/.test(css.left)) {

								expr.left = "(this.parentNode.offsetWidth - this.offsetWidth) * " + (css.left == 'center' ? 0.5 : (parseInt(css.left) / 100));

								delete css.left;

							}

							// Let's add the helper DIV which will simulate the background image

							$$.positionFix().css({backgroundImage: 'none'}).prepend(

								$('<div></div>').css(css).css({

									width: this.width,

									height: this.height,

									position: 'absolute',

									filter: hack.filter(imageSrc)

								})

							);

							if (expr.top || expr.left) {

								var elem = $$.children(':first')[0];

								if($.browser.msie && $.browser.version <= 7) for (prop in expr) elem.style.setExpression(prop, expr[prop], 'JavaScript');

							}

							$(this).remove();

						});

						img.src = imageSrc;

					} else {

						$$.css({backgroundImage: 'none', filter:hack.filter(imageSrc)});

					}

				}

			}

		});

	} : function() { return this; };



	/**

	 * positions selected item relatively

	 */

	$.fn.positionFix = function() {

		return this.each(function() {

			var $$ = $(this);

			if ($$.css('position') != 'absolute') $$.css({position:'relative'});

		});

	};



})(jQuery);


/**
 * jQuery (PNG Fix)
 * Microsoft Internet Explorer 24bit PNG Fix
 *
 * The MIT License
 *
 * Copyright (c) 2007 Paul Campbell (pauljamescampbell.co.uk)
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * @param		Object
 * @return		Array
 */
(function($) {

	$.fn.pngfix = function(options) {

		// ECMA scope fix
		var elements 	= this;
		// Plug-in values
		var settings 	= $.extend({
			imageFixSrc: 	false
		}, options);

		if(!$.browser.msie || ($.browser.msie &&  $.browser.version >= 7)) {
			return(elements); // Kill
		}

		function setFilter(el, path, mode) {
			// Apply filter to element, setting the MSDN properties:
			//		:src
			//		:enabled
			//		:sizingMethod
			var fs 			= el.attr("filters");
			var alpha 		= "DXImageTransform.Microsoft.AlphaImageLoader";
			if (fs[alpha]) {
				with (fs[alpha]) {
					enabled = true;
					src = path;
					sizingMethod = mode;
			 	}
			} else {
				el.css("filter", 'progid:' + alpha + '(enabled="true", sizingMethod="' + mode + '", src="' + path + '")');
			}
		}

		function forceWidth(el) {
			if(el.css("width") == "auto" & el.css("height") == "auto") {
				// Only force width of element if it's set to auto
				el.css("width", el.attr("offsetWidth") + "px");
			}
		}

		// __APPLY__

		return(
			elements.each(function() {

				var el = $(this);

				if(el.attr("tagName").toUpperCase() == "IMG" && (/.png"?$/).test(el.attr("src"))) {

					if(!settings.imageFixSrc) {
						// Wrap the <img> in a <span> then apply style/filters,
						// removing the <img> tag from the final render
						el.wrap("<span></span>");
						var par = el.parent();
						par.css({
							height: 	el.height(),
							width: 		el.width(),
							display: 	"inline-block"
						});
						setFilter(par, el.attr("src"), "scale");
						el.remove();
					} else if((/.gif$/).test(settings.imageFixSrc)) {
						// Replace the current image with a transparent GIF
						// and apply the filter to the background of the
						// <img> tag (not the preferred route)
						forceWidth(el);
						setFilter(el, el.attr("src"), "image");
						el.attr("src", settings.imageFixSrc);
					}

				} else {
					var bg = el.css("backgroundImage");
					var matches = bg.match(/^url\("(.*)"\)$/);
					if(matches) {
						// Elements with a PNG as a backgroundImage have the
						// filter applied with a sizing method relevant to the
						// background repeat type
						forceWidth(el);
						el.css("backgroundImage", "none");

						// Restrict scaling methods to valid MSDN defintions (or one custom)
						if(el.css("backgroundRepeat").indexOf("repeat") > -1) {
							var sc = settings.repeatMethod == "repeat" ? "repeat" : "scale";
						} else {
							var sc = "crop";
						}
						setFilter(el, matches[1], sc);

						// IE peek-a-boo for internal links
						el.find("a").each(function() {
							$(this).css("position", "relative");
						});
					}
				}


			}) // __END__
		);
	}

})(jQuery);




/** JQUERY CREATE AN OVERLAY **/

(function($) {
	$.qOver = function(options) {
        $.qOver.obj = this;
        var $this = $.qOver.obj;


        this.opt = $.extend({}, $.qOver.defaults, options);
        this.winH = $(window).height() + $(window).scrollTop();
        this.winW = $(window).width();

        var overlayHTML = '<div id="jqueryOverlayDiv" style="display:none"><div id="jqueryOverlayDivInner"></div></div>';
        $("body").append(overlayHTML);
        this.overlay = $("#jqueryOverlayDiv");
        this.overlay.css({
            position:'absolute',
            zIndex:$this.opt.zIndex,
            'opacity': $this.opt.opacity,
            top:0,
            left:0,
            width:$this.winW,
            height:$this.winH
        });

        this.overlayColor = $("#jqueryOverlayDivInner");
        this.overlayColor.css({
            'position':'absolute',
            'top':0,
            'left':0,
            'width':$this.winW,
            'height':$this.winH,
            'background-color' : $this.opt.bgColor
        });

        if ($.browser.msie&&parseInt($.browser.version)<=6) //IE MUST DIE!
        {
			var frameheight = $this.winH;
			var framewidth = $this.winW;
			this.overlay.append('<iframe id="jqueryOverlayDiv_iframe" border="0" frameborder="0" allowtransparency="true" src="'+$this.opt.iframeBlankFile+'" style="position:absolute;top:0;left:0;z-index:-1;width:'+framewidth+';height:'+frameheight+'"></iframe>')
		}

	};


    $.qOver.action = function(){

            var $this = $.qOver.obj;
            if($this.overlay.is(':hidden'))
            {
                if($this.opt.animationType == 'fade')
                {
                    $this.overlay.css({opacity:0,display:'block'}).animate({opacity: $this.opt.opacity},$this.opt.animationSpeed,$this.opt.inFunction);
                }
            }
            else
            {
                if($this.opt.animationType == 'fade')
                {
                    $this.overlay.css({opacity:1,display:'block'}).animate({opacity: 0,display:'none'},$this.opt.animationSpeed,$this.opt.outFunction);
                }
            }

        return false;
        };





    $.qOver.defaults = {
            inFunction:null, //callback function for in action
            outFunction:null, //callback function for out action
            animationSpeed: 500, //speed of animation
            animationType: 'fade', //type of animation
            opacity: '.8', //level of opacity of overlay
			bgColor: '#000', //background color of overlay
            bgImage: null, //background image if any
            iframeBlankFile: '/blank.html', //blank iframe source file to create transparent iframe for IE6
            zIndex: 2 //adjust z-index in case you have other layers you want to cover
		};

})(jQuery);



/*
 * jQuery FlyOut
 * author: Jolyon Terwilliger - Nixbox Web Designs
 * website: http://nixboxdesigns.com/jquery.flyout.php
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * version 0.21 (July 21, 2008)
 * version 0.22 (July 22, 2008)
 	notes: minor reordering to loadingSrc logic.
 * version 0.23 (August 15, 2008)
 	added: config options for loadingText and closeTip to facilitate locale.
			Thanks Tony for the nudge.
 * version 0.24 (Oct 2, 2008)
 	added: customize start location and size of flyout, if different
			from thumb link. Thanks to Jake Kronika for this patch.
 * version 1.0 (Oct 11, 2008)
 	added: support for final flyout location via destElement and destPadding:
			define a fixed container anywhere in the document and the pic will
			fly to that location, regardless of viewport position.
 	fixed: clicking on open source link no longer reopens same image.
	added: 4 callbacks for start and finish of flyOut and putAway animations.
	fixed: putAway function to put back to correct location, in case
			thumb has moved (page or div scroll, etc)
 * version 1.1 (Nov 16, 2008)
 	fixed: Opera 9.5+ doesn't report window.height() correctly - patched with code
			from jquery Bug 3117:  http://dev.jquery.com/ticket/3117
			note: once this is patched in jQuery core, or fixed in Opera
			this may eventually be removed.
	added: when flyOut image is completed, a customizable class
			(default to 'shown') is appended to the thumb image container
			so an external event can trigger the click to close any open
			elements. See demo page for example.
 */

/**
 * The flyout() method provides an alternate means of loading and display sub-content
 * with a nifty flyout animation technique.
 * Currently, flyout only supports img sub-content.
 *
 * flyout() takes a single object argument:  $().flyout({param:setting, etc..})
 *
 * Settings:
 *
 *			outSpeed:	speed in milliseconds for the flyout animation - default: 1000
 *
 *			inSpeed:	speed in milliseconds for the flyback animation - default: 500
 *
 *			outEase:	the easing method to use for the flyout animation - default: swing
 *
 *			inEase:		the easing method to use for the flyback animation - default: swing
 *
 *			loadingSrc: the image file to use while an image is being loaded prior to flyout
 *						default: none
 *
 *			loader: 	the ID for the created flyout div that contains the sub-content
 *						this is currently only useful for multiple skinnings via CSS
 *						default: 'loader'
 *
 *			loaderZIndex: the CSS z-index for the flyout
 *						default: 500
 *
 *			widthMargin: the left and right margin space for the final flyout
 *						this value is effectively divided between the left and right margin
 *						default: 40
 *
 *			heightMargin: the top and bottom margin space for the final flyout
 *						this value is effectively divided between the top and bottom margin
 *						default: 40
 *
 *			loadingText: text shown when image is loading
 *
 *			closeTip: tip text for image alt/title tags
 *
 *			destElement: the destination container - overrides height and widthMargins
 *						specified in CSS notation - e.g. "#picContainer"
 *						default: none
 *
 *			destPadding: number of pixels to pad when flying out to destElement
 *						default: 10
 *
 *			startOffsetX: horizontal offset added to thumb left value for start of flyout animation
 *						Hint: can be negative.
 *						default: 0
 *
 *			startOffsetY: vertical offset added to thumb top value for start of flyout animation.
 *						default: 0
 *
 *			startHeight: overrides starting height of flyout animation
 *						default: 0  (uses thumb image height by default)
 *
 *			startWidth: overrides starting width of flyout animation
 *						default: 0  (uses thumb image width by default)
 *
 *			flyOutStart: function to run at start of flyout animation
 *						default: none
 *
 *			flyOutFinish: function to run at finish of flyout animation
 *						default: none
 *
 *			putAwayStart: function to run at start of putaway animation
 *						default: none
 *
 *			putAwayFinish: function to run at finish of putaway animation
 *						default: none
 *
 * For more details see: http://nixbox.com/demos/jquery.flyout.php
 *
 * @example $('.thumb').flyout();
 * @desc standard flyouts applied to all elements with the 'thumbs' class.
 *
 * @example $('.thumb').flyout({loadingSrc:'images/thumb-loading.gif',
 *								outEase:'easeOutCirc',
 *								inEase:'easeOutBounce'});
 * @desc flyouts created with different ease in and ease out and a loading animation image is specified
 *
 * @name flyout
 * @type jQuery
 * @param Object options Options which control the flyout animation and content
 * @cat Plugins/Flyout
 * @return jQuery
 * @author Jolyon Terwilliger (jolyon@nixbox.com)
 */
/*
$.fn.extend({flyout : function(options) {

		var shown=false;
		var animating=false;
		var $holder;
		var $thumb;
		var tloc;
		var th;
		var tw;
		var bigimg = new Image();
		var subType = 'img';
		var offset;

		this.click(function() {
			if (animating == true) { return false; }

			if (shown) { putAway(this); }
			else { flyOut(this); }

			return false;
		});

		var o = jQuery.extend({
			outSpeed : 1000,
			inSpeed : 500,
			outEase : 'swing',
			inEase : 'swing',
			loadingSrc: null,
			loader: 'loader',
			loaderZIndex: 500,
			widthMargin: 40,
			heightMargin: 40,
			loadingText : "Loading...",
			closeTip : " - Click here to close",
			destPadding: 20,
			startOffsetX: 0,
			startOffsetY: 0,
			startHeight: 0,
			startWidth: 0,
			flyOutStart: function() {},
			flyOutFinish: function() {},
			putAwayStart: function() {},
			putAwayFinish: function() {},
			shownClass: 'shown'
		}, options);

		function flyOut(it) {
			animating = true;

			$holder = $(it);
			$thumb = $('img',it);
			bigimg = new Image();
			sL = $(window).scrollLeft();
			sT = $(window).scrollTop();
			tloc = $thumb.offset();
			tloc.left += o.startOffsetX;
			tloc.top += o.startOffsetY;
			th = (o.startHeight > 0 ? o.startHeight : $thumb.height());
			tw = (o.startWidth > 0 ? o.startWidth : $thumb.width());

			$('<div></div>').attr('id',o.loader)
							.appendTo('body')
							.css({'position':'absolute',
								'top':tloc.top,
								'left':tloc.left,
								'height':th,
								'width':tw,
								'opacity':.5,
								'display':'block',
								'z-index':o.loaderZIndex});

			if (o.loadingSrc) {
				$('#'+o.loader).append($('<img/>')
								.load(function() {
										$(this)
											.css({'position':'relative',
												 'top':th/2-(this.height/2),
												 'left':tw/2-(this.width/2)})
											.attr('alt',o.loadingText);
										})
									.attr('src',o.loadingSrc)
								);
                	}
			else {
				$('#'+o.loader).css('background-color','#000')
								.append($('<span></span>')
										  	.text(o.loadingText)
											.css({'position':'relative',
												 'top':'2px',
												 'left':'2px',
												 'color':'#FFF',
												 'font-size':'9px'})
									 	);
			}



			$(bigimg).load(function() {
				imgtag = $('<img/>').attr('src',$holder.attr('href')).attr('title',$thumb.attr('title')+o.closeTip).attr('alt',$thumb.attr('alt')+o.closeTip).height(th).width(tw);

				o.flyOutStart.call(it);

				if (o.destElement) {
					var $dest = $(o.destElement);
					max_x = $dest.innerWidth() - (o.destPadding*2);
					max_y = $dest.innerHeight() - (o.destPadding*2);
				}
				else {
					max_x = $(window).width()-o.widthMargin;
					if ($.browser.opera)
						wh = document.getElementsByTagName('html')[0].clientHeight;
					else
						wh = $(window).height();
					max_y = wh-o.heightMargin;
				}

				width = bigimg.width;
				height = bigimg.height;

				x_dim = max_x / width;
				y_dim = max_y / height;

				if (x_dim <=y_dim) {
					y_dim = x_dim;
				} else {
					x_dim = y_dim;
				}

				dw = Math.round(width  * x_dim);
				dh = Math.round(height * y_dim);
				if (dw>width) {dw = width}
				if (dh>height) {dh = height}

				if (o.destElement) {
					dPos = $dest.offset();
					dl = Math.round(($dest.outerWidth()/2)-(dw/2)+dPos.left);
					dt = Math.round(($dest.outerHeight()/2)-(dh/2)+dPos.top);
				}
				else {
					dl = Math.round(($(window).width()/2)-(dw/2)+sL);
					if ($.browser.opera)
						wh = document.getElementsByTagName('html')[0].clientHeight;
					else
						wh = $(window).height();
					dt = Math.round((wh/2)-(dh/2)+sT);
				}

				$('#'+o.loader).empty().css('opacity',1).append(imgtag).width('auto').height('auto').animate({top:dt, left:dl},{duration:o.outSpeed, queue:false, easing:o.outEase});
				$('#'+o.loader+' '+subType).animate({height:dh, width:dw}, o.outSpeed, o.outEase,
				function() {
                       $('#loader').append('<div class="flyout_image"></div>');
                       $("div.flyout_image").click(function(){putAway(null)});
					o.flyOutFinish.call(it);
					shown = it;
					$holder.addClass(o.shownClass);
					animating=false;
                 //   console.log($('#'+o.loader+' '+subType).html())

					$('#'+o.loader+' '+subType).click(function(){putAway(null)})
				});
			});
			bigimg.src = $holder.attr('href');
		}


		function putAway(next) {
			// for future development:
			if (animating == true || shown == false) {return false;}
			o.putAwayStart.call(shown);

			animating = true;

			// check $thumb loc again, in case it moved...
			tloc = $thumb.offset();
			tloc.left += o.startOffsetX;
			tloc.top += o.startOffsetY;

			$('#'+o.loader).animate({top:tloc.top, left:tloc.left},{duration:o.inSpeed, queue:false, easing:o.inEase});
			$('#'+o.loader+' '+subType).animate({height:th, width:tw},
				o.inSpeed, o.inEase,
				function() {
					$('#'+o.loader).css('display','none').remove();
					o.putAwayFinish.call(shown);
					animating=false;
					bigimg=null;
					if (next && next != shown) {
						shown = false;
						flyOut(next);
					}
					shown = false;
					$holder.removeClass(o.shownClass);
				});
		}

		return this;	// never break the chain

	}
});



*/
/*
(c) Copyrights 2007 - 2008

Original idea by by Binny V A, http://www.openjs.com/scripts/events/keyboard_shortcuts/

jQuery Plugin by Tzury Bar Yochay
tzury.by@gmail.com
http://evalinux.wordpress.com
http://facebook.com/profile.php?id=513676303

Project's sites:
http://code.google.com/p/js-hotkeys/
http://github.com/tzuryby/hotkeys/tree/master

License: same as jQuery license.

USAGE:
    // simple usage
    $(document).bind('keydown', 'Ctrl+c', function(){ alert('copy anyone?');});

    // special options such as disableInIput
    $(document).bind('keydown', {combi:'Ctrl+x', disableInInput: true} , function() {});

Note:
    This plugin wraps the following jQuery methods: $.fn.find, $.fn.bind and $.fn.unbind

*/


(function (jQuery){
    // keep reference to the original $.fn.bind and $.fn.unbind
    jQuery.fn.__bind__ = jQuery.fn.bind;
    jQuery.fn.__unbind__ = jQuery.fn.unbind;
    jQuery.fn.__find__ = jQuery.fn.find;

    var hotkeys = {
        version: '0.7.8',
        override: /keydown|keypress|keyup/g,
        triggersMap: {},

        specialKeys: { 27: 'esc', 9: 'tab', 32:'space', 13: 'return', 8:'backspace', 145: 'scroll',
            20: 'capslock', 144: 'numlock', 19:'pause', 45:'insert', 36:'home', 46:'del',
            35:'end', 33: 'pageup', 34:'pagedown', 37:'left', 38:'up', 39:'right',40:'down',
            112:'f1',113:'f2', 114:'f3', 115:'f4', 116:'f5', 117:'f6', 118:'f7', 119:'f8',
            120:'f9', 121:'f10', 122:'f11', 123:'f12' },

        shiftNums: { "`":"~", "1":"!", "2":"@", "3":"#", "4":"$", "5":"%", "6":"^", "7":"&",
            "8":"*", "9":"(", "0":")", "-":"_", "=":"+", ";":":", "'":"\"", ",":"<",
            ".":">",  "/":"?",  "\\":"|" },

        newTrigger: function (type, combi, callback) {
            // i.e. {'keyup': {'ctrl': {cb: callback, disableInInput: false}}}
            var result = {};
            result[type] = {};
            result[type][combi] = {cb: callback, disableInInput: false};
            return result;
        }
    };
    // add firefox num pad char codes
    if (jQuery.browser.mozilla){
        hotkeys.specialKeys = jQuery.extend(hotkeys.specialKeys, { 96: '0', 97:'1', 98: '2', 99:
            '3', 100: '4', 101: '5', 102: '6', 103: '7', 104: '8', 105: '9' });
    }

    // a wrapper around of $.fn.find
    // see more at: http://groups.google.com/group/jquery-en/browse_thread/thread/18f9825e8d22f18d
    jQuery.fn.find = function( selector ) {
        this.query=selector;
        return jQuery.fn.__find__.apply(this, arguments);
	};

    jQuery.fn.unbind = function (type, combi, fn){
        if (jQuery.isFunction(combi)){
            fn = combi;
            combi = null;
        }
        if (combi && typeof combi === 'string'){
            var selectorId = ((this.prevObject && this.prevObject.query) || (this[0].id && this[0].id) || this[0]).toString();
            var hkTypes = type.split(' ');
            for (var x=0; x<hkTypes.length; x++){
                delete hotkeys.triggersMap[selectorId][hkTypes[x]][combi];
            }
        }
        // call jQuery original unbind
        return  this.__unbind__(type, fn);
    };

    jQuery.fn.bind = function(type, data, fn){
        // grab keyup,keydown,keypress
        var handle = type.match(hotkeys.override);

        if (jQuery.isFunction(data) || !handle){
            // call jQuery.bind only
            return this.__bind__(type, data, fn);
        }
        else{
            // split the job
            var result = null,
            // pass the rest to the original $.fn.bind
            pass2jq = jQuery.trim(type.replace(hotkeys.override, ''));

            // see if there are other types, pass them to the original $.fn.bind
            if (pass2jq){
                // call original jQuery.bind()
                result = this.__bind__(pass2jq, data, fn);
            }

            if (typeof data === "string"){
                data = {'combi': data};
            }
            if(data.combi){
                for (var x=0; x < handle.length; x++){
                    var eventType = handle[x];
                    var combi = data.combi.toLowerCase(),
                        trigger = hotkeys.newTrigger(eventType, combi, fn),
                        selectorId = ((this.prevObject && this.prevObject.query) || (this[0].id && this[0].id) || this[0]).toString();

                    //trigger[eventType][combi].propagate = data.propagate;
                    trigger[eventType][combi].disableInInput = data.disableInInput;

                    // first time selector is bounded
                    if (!hotkeys.triggersMap[selectorId]) {
                        hotkeys.triggersMap[selectorId] = trigger;
                    }
                    // first time selector is bounded with this type
                    else if (!hotkeys.triggersMap[selectorId][eventType]) {
                        hotkeys.triggersMap[selectorId][eventType] = trigger[eventType];
                    }
                    // make trigger point as array so more than one handler can be bound
                    var mapPoint = hotkeys.triggersMap[selectorId][eventType][combi];
                    if (!mapPoint){
                        hotkeys.triggersMap[selectorId][eventType][combi] = [trigger[eventType][combi]];
                    }
                    else if (mapPoint.constructor !== Array){
                        hotkeys.triggersMap[selectorId][eventType][combi] = [mapPoint];
                    }
                    else {
                        hotkeys.triggersMap[selectorId][eventType][combi][mapPoint.length] = trigger[eventType][combi];
                    }

                    // add attribute and call $.event.add per matched element
                    this.each(function(){
                        // jQuery wrapper for the current element
                        var jqElem = jQuery(this);

                        // element already associated with another collection
                        if (jqElem.attr('hkId') && jqElem.attr('hkId') !== selectorId){
                            selectorId = jqElem.attr('hkId') + ";" + selectorId;
                        }
                        jqElem.attr('hkId', selectorId);
                    });
                    result = this.__bind__(handle.join(' '), data, hotkeys.handler)
                }
            }
            return result;
        }
    };
    // work-around for opera and safari where (sometimes) the target is the element which was last
    // clicked with the mouse and not the document event it would make sense to get the document
    hotkeys.findElement = function (elem){
        if (!jQuery(elem).attr('hkId')){
            if (jQuery.browser.opera || jQuery.browser.safari){
                while (!jQuery(elem).attr('hkId') && elem.parentNode){
                    elem = elem.parentNode;
                }
            }
        }
        return elem;
    };
    // the event handler
    hotkeys.handler = function(event) {
        var target = hotkeys.findElement(event.currentTarget),
            jTarget = jQuery(target),
            ids = jTarget.attr('hkId');

        if(ids){
            ids = ids.split(';');
            var code = event.which,
                type = event.type,
                special = hotkeys.specialKeys[code],
                // prevent f5 overlapping with 't' (or f4 with 's', etc.)
                character = !special && String.fromCharCode(code).toLowerCase(),
                shift = event.shiftKey,
                ctrl = event.ctrlKey,
                // patch for jquery 1.2.5 && 1.2.6 see more at:
                // http://groups.google.com/group/jquery-en/browse_thread/thread/83e10b3bb1f1c32b
                alt = event.altKey || event.originalEvent.altKey,
                mapPoint = null;

            for (var x=0; x < ids.length; x++){
                if (hotkeys.triggersMap[ids[x]][type]){
                    mapPoint = hotkeys.triggersMap[ids[x]][type];
                    break;
                }
            }

            //find by: id.type.combi.options
            if (mapPoint){
                var trigger;
                // event type is associated with the hkId
                if(!shift && !ctrl && !alt) { // No Modifiers
                    trigger = mapPoint[special] ||  (character && mapPoint[character]);
                }
                else{
                    // check combinations (alt|ctrl|shift+anything)
                    var modif = '';
                    if(alt) modif +='alt+';
                    if(ctrl) modif+= 'ctrl+';
                    if(shift) modif += 'shift+';

                    // modifiers + special keys or modifiers + character or modifiers + shift character or just shift character
                    trigger = mapPoint[modif+special];
                    if (!trigger){
                        if (character){
                            trigger = mapPoint[modif+character]
                                || mapPoint[modif+hotkeys.shiftNums[character]]
                                // '$' can be triggered as 'Shift+4' or 'Shift+$' or just '$'
                                || (modif === 'shift+' && mapPoint[hotkeys.shiftNums[character]]);
                        }
                    }
                }
                if (trigger){
                    var result = false;
                    for (var x=0; x < trigger.length; x++){
                        if(trigger[x].disableInInput){
                            // double check event.currentTarget and event.target
                            var elem = jQuery(event.target);
                            if (jTarget.is("input") || jTarget.is("textarea")
                                || elem.is("input") || elem.is("textarea")) {
                                return true;
                            }
                        }
                        // call the registered callback function
                        result = result || trigger[x].cb.apply(this, [event]);
                    }
                    return result;
                }
            }
        }
    };
    // place it under window so it can be extended and overridden by others
    window.hotkeys = hotkeys;
    return jQuery;
})(jQuery);


/** SMART MODAL **/

(function($) {
	//base function to call and setup everything
	$.fn.modal=function(options){
		return this.each(function(){
			if(this._modal) return; //if already a modal return
			if(typeof(options) != "undefined")	var params = $.extend({}, $.fn.modal.defaults, options); //if some options are passed in merge them
			else var params = $.fn.modal.defaults;
			if(typeof(modal_count) == "undefined") modal_count=0; //set the counter to 0
			modal_count++;
			this._modal=modal_count; //set what modal number this is
			H[modal_count] = {config:params,target_modal:this}; //add to hash var
			$(this).modal_add_show(this); //add show & hide triggers
		});
	}
	$.fn.modal_add_show=function(ele){ return $.modal.show(ele); }
	//extra function so show & hide can be called
	$.fn.modal_show=function(){
		return this.each(function(){
			$.modal.open(this);
		});
	}
	$.fn.modal_hide=function(){
		return this.each(function(){
			$.modal.hide(this);
		});
	}
	//the default config vars
	$.fn.modal.defaults = {show:false, hide:false, modal_styles:{display:"block", zIndex:1001}, resize:true, hide_on_overlay_click:true,onOpen:'',onClose:'' };
	//the over riden stuff
	$.modal = {
		hash:{}, //the hash used to store all the configs & targets
		show:function(ele){
                   // console.log(ele)
			var pos = ele._modal, h = H[pos];
			jQ(h.target_modal).click(function(){
				$.modal.open(ele);
				return false;
			});
			return false;
		},

		hide:function(ele){
			var pos = ele._modal, h = H[pos];
			if(h.config.hide_on_overlay_click) var idstr = "#modal_overlay, .modal_close";
			else var idstr = ".modal_close";
			jQ(idstr).click(function(){
        jQ("#modal_content").remove();
				jQ("#modal_overlay").remove();
				if(h.config.hide)	h.config.hide();
                if($.isFunction(h.config.onClose)) h.config.onClose(ele);
				return false;
      });
		},
		open:function(ele){
			var pos = ele._modal;
			var h = H[pos];
			$.modal.insert_overlay();
			$.modal.insert_content_container();
			var content = $.modal.get_content($(h.target_modal));
			jQ("#modal_content").html(content);
			if(h.config.modal_styles) jQ("#modal_content").css(h.config.modal_styles);
			if(h.config.resize) $.modal.resize_container();
      $.modal.for_ie(jQ("#modal_overlay"));
			if(h.config.show) h.config.show();
			$.modal.hide(ele); //add hiding
            if($.isFunction(h.config.onOpen)) h.config.onOpen(ele);
		},
		resize_container: function(){
			var max_width = 0, max_height=0;
			jQ('#modal_content *').load(function(){
				jQ('#modal_content *').each(function(){
					var tw = jQ(this).outerWidth(), th = jQ(this).outerHeight();
					if(tw > max_width) max_width = tw;
					max_height += th;
				});
				if(max_width >0 && max_height>0) jQ('#modal_content').css('width', (max_width+jQ('#modal_content .modal_close:first').outerWidth())+'px').css('height', (max_height)+'px').css('margin-left', '-'+(max_width/2)+'px');
			});

		},
		insert_overlay:function(){
            if( window.innerHeight && window.scrollMaxY ) {
            pageWidth = window.innerWidth + window.scrollMaxX;
            pageHeight = window.innerHeight + window.scrollMaxY;
            }
            else if( document.body.scrollHeight > document.body.offsetHeight ) // all but Explorer Mac
            {
            pageWidth = document.body.scrollWidth;
            pageHeight = document.body.scrollHeight;
            }
            else // works in Explorer 6 Strict, Mozilla (not FF) and Safari
            { pageWidth = document.body.offsetWidth + document.body.offsetLeft; pageHeight = document.body.offsetHeight + document.body.offsetTop; }
			if(!jQ('#modal_overlay').length) jQ("body").append('<div id="modal_overlay"></div>');
      jQ("#modal_overlay").css({height:pageHeight,width:'100%',position:'absolute',left:0,top:0,'z-index':499,opacity:50/100});
		},
		insert_content_container:function(){
			if(!jQ('#modal_content').length) jQ("body").append('<div id="modal_content"></div>');
		},
		get_content:function(trig){
			c = "<div class='modal_close'><p>x</p></div>";
			if(trig.attr("rel")){ //if rel exists
				div_id = jQ('#'+trig.attr('rel'));
				div_class = jQ('.'+trig.attr('rel'));
				if(div_id.length){ c += div_id.html(); }
				else if(div_class.length){ c += div_class.html();	}
			}else if(trig.attr('href')){ //if it has a href but no rel then insert the href as image src
				if(trig.attr('title')){ c +="<h3 class='modal_title'>"+trig.attr('title')+"</h3><img src='"+trig.attr('href')+"' alt='"+trig.attr('title')+"' />"; 	}
				else{ c += "<img src='"+trig.attr('href')+"' alt='modal' />";	}
			}else{ c = c + trig.html(); }
			return c;
		},
		for_ie:function(o){
			if(ie6&&$('html,body').css({height:'100%',width:'100%'})&&o){
				$('html,body').css({height:'100%',width:'100%'});
        i=$('<iframe src="javascript:false;document.write(\'\');" class="overlay"></iframe>').css({opacity:0});
        o.html('<p style="width:100%;height:100%"/>').prepend(i)
        o = o.css({position:'absolute'})[0];
        for(var y in {Top:1,Left:1}) o.style.setExpression(y.toLowerCase(),"(_=(document.documentElement.scroll"+y+" || document.body.scroll"+y+"))+px");
			}
		}
	}
	var H=$.modal.hash,	jQ = jQuery;
			ie6=$.browser.msie&&($.browser.version == "6.0");
})(jQuery);


(function($){  //this function aligns an elements in relation to another.

    $.fn.alignElements = function(alignTo, options){
        var options = $.extend({}, $.fn.alignElements.defaults, options);
        var _this = null;
        var _that = null;
        var thisD = null;
        var thatD = null;
        var fn = this;

        return this.each(function(){
            fn._this = $(this);
            fn._that = $(alignTo);

            fn.thisD = $.fn.alignElements.getMeasurements(fn._this);
            fn.thatD = $.fn.alignElements.getMeasurements(fn._that);

            var obj = new $.fn.alignElements.align(fn,options);


        });

    };


    $.fn.alignElements.align = function(fn,options)
    {
        this.fn = fn;
        this.options = options;
        this.p =  $.fn.alignElements.alignByParents(fn._this);



        this.horizontal = function()
        {
            var fn = this.fn;
            var align = this;
            var a = this.options.alignHorizontal;


            if(a == 'top')
                {
                    var t = fn.thatD.top - fn.thisD.height;
                }
            else if(a=='bottom')
                {
                     var t = fn.thatD.top + fn.thatD.height;
                }
            else if(a=='center')
                {
                    var t = fn.thatD.top + (fn.thatD.height/2) - (fn.thisD.height/2);
                }


           return parseInt(t + align.p.top + this.options.modifyHorizontal);
        }


        this.vertical = function()
        {
            var fn = this.fn;
            var align = this;
            var a = this.options.alignVertical;

            if(a == 'left')
                {
                    var l = fn.thatD.left - fn.thisD.width;
                }
            else if(a=='right')
                {
                     var l = fn.thatD.left + fn.thatD.width;
                }
            else if(a=='center')
                {
                    var l = fn.thatD.left + fn.thatD.width - (fn.thisD.width/2);
                }


           return parseInt(l + align.p.left + this.options.modifyVertical);
        }



        this.cssTop = this.horizontal();
        this.cssLeft = this.vertical();

//        console.log(this.cssTop + ":" + this.cssLeft+":"+this.fn._this.attr('class'));

        this.fn._this.css({top:this.cssTop,left:this.cssLeft});

    }



    $.fn.alignElements.alignByParents = function(el) { //if any of the aligning elements parents are relatively positioned, when the element is moved it will be WRONG
           var parentDimensions = {};
           parentDimensions.top = 0;
           parentDimensions.left = 0;
           el.parents().each(function(){
               if($(this).css('position') == 'relative' || $(this).css('position') == 'absolute')
                   {
                       var thisD = $.fn.alignElements.getMeasurements($(this));
                       parentDimensions.top -= thisD.top;
                       parentDimensions.left -= thisD.left;
                   }
            });

            return parentDimensions;

    };


    $.fn.alignElements.getMeasurements = function(el)
    {
        var d = {};
        var o = el.offset();
        d.top = o.top - parseInt(el.css('paddingTop'));
        d.left = o.left - parseInt(el.css('paddingLeft'));
        d.height = el.height()+ parseInt(el.css('paddingBottom')) + parseInt(el.css('paddingTop'));
        d.width = el.width() + parseInt(el.css('paddingLeft')) + parseInt(el.css('paddingRight'));
        return d;
    }


    $.fn.alignElements.defaults = {
            alignHorizontal: 'center',
            modifyHorizontal: 0, //if you want to offset the horizontal alignment
            alignVertical:'center',
            modifyVertical: 0, //if you want to offset the vertical alignment
            leaveViewport:'true' //allows the aligned item to go off the screen - otherwise will adjust position to remain visible
        };




     function debug($obj) {
          if (window.console && window.console.log)
            window.console.log($obj);
        };

})(jQuery);



function getDimensions(el)
   {
       var o = el.offset();
       var dimensions = {};
       dimensions['top'] = o.top;
       dimensions['left'] = o.left;
       dimensions['height'] = el.height();
       dimensions['width'] = el.width();
       return dimensions;
   }

/** NON JQUERY FUNCTIONS **/

/*
function vIE(){return (navigator.appName=='Microsoft Internet Explorer')?parseFloat((new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})")).exec(navigator.userAgent)[1]):-1;}

	String.prototype.capitalize = function(){ //v1.0
        return this.replace(/\w+/g, function(a){
            return a.charAt(0).toUpperCase() + a.substr(1).toLowerCase();
        });
    };
*/





