Subversion Repositories Sites.tela-botanica.org

Rev

Rev 609 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
415 jpm 1
/**
2
 * jQuery lightBox plugin
3
 * This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/)
4
 * and adapted to me for use like a plugin from jQuery.
5
 * @name jquery-lightbox-0.4.js
6
 * @author Leandro Vieira Pinho - http://leandrovieira.com
7
 * @version 0.4
8
 * @date November 17, 2007
9
 * @category jQuery plugin
10
 * @copyright (c) 2007 Leandro Vieira Pinho (leandrovieira.com)
11
 * @license CC Attribution-No Derivative Works 2.5 Brazil - http://creativecommons.org/licenses/by-nd/2.5/br/deed.en_US
12
 * @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin
13
 */
14
 
15
// Offering a Custom Alias suport - More info: http://docs.jquery.com/Plugins/Authoring#Custom_Alias
16
(function($) {
17
	/**
18
	 */
19
	$.fn.lightBox = function(settings) {
20
		// Settings to configure the jQuery lightBox plugin how you like
21
		settings = jQuery.extend({
22
			// Configuration related to overlay
23
			overlayBgColor: 		'#000',		// (string) Background color to overlay; inform a hexadecimal value like: #RRGGBB. Where RR, GG, and BB are the hexadecimal values for the red, green, and blue values of the color.
24
			overlayOpacity:			0.8,		// (integer) Opacity value to overlay; inform: 0.X. Where X are number from 0 to 9
25
			// Configuration related to images
26
			imageLoading:			'actions/galerie/presentation/images/lightbox-ico-loading.gif',		// (string) Path and the name of the loading icon
27
			imageBtnPrev:			'actions/galerie/presentation/images/lightbox-btn-prev.gif',			// (string) Path and the name of the prev button image
28
			imageBtnNext:			'actions/galerie/presentation/images/lightbox-btn-next.gif',			// (string) Path and the name of the next button image
29
			imageBtnClose:			'actions/galerie/presentation/images/lightbox-btn-close.gif',		// (string) Path and the name of the close btn
30
			imageBlank:				'actions/galerie/presentation/images/lightbox-blank.gif',			// (string) Path and the name of a blank image (one pixel)
31
			// Configuration related to container image box
32
			containerBorderSize:	10,			// (integer) If you adjust the padding in the CSS for the container, #lightbox-container-image-box, you will need to update this value
33
			containerResizeSpeed:	400,		// (integer) Specify the resize duration of container image. These number are miliseconds. 400 is default.
34
			// Configuration related to texts in caption. For example: Image 2 of 8. You can alter either "Image" and "of" texts.
35
			txtImage:				'Image',	// (string) Specify text "Image"
36
			txtOf:					'of',		// (string) Specify text "of"
37
			// Configuration related to keyboard navigation
38
			keyToClose:				'c',		// (string) (c = close) Letter to close the jQuery lightBox interface. Beyond this letter, the letter X and the SCAPE key is used to.
39
			keyToPrev:				'p',		// (string) (p = previous) Letter to show the previous image
40
			keyToNext:				'n',		// (string) (n = next) Letter to show the next image.
41
			// Don´t alter these variables in any way
42
			imageArray:				[],
43
			activeImage:			0
44
		},settings);
45
		// Caching the jQuery object with all elements matched
46
		var jQueryMatchedObj = this; // This, in this context, refer to jQuery object
47
		/**
48
		 */
49
		function _initialize() {
50
			_start(this,jQueryMatchedObj); // This, in this context, refer to object (link) which the user have clicked
51
			return false; // Avoid the browser following the link
52
		}
53
		/**
54
		 */
55
		function _start(objClicked,jQueryMatchedObj) {
56
			// Hime some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
57
			$('embed, object, select').css({ 'visibility' : 'hidden' });
58
			// Call the function to create the markup structure; style some elements; assign events in some elements.
59
			_set_interface();
60
			// Unset total images in imageArray
61
			settings.imageArray.length = 0;
62
			// Unset image active information
63
			settings.activeImage = 0;
64
			// We have an image set? Or just an image? Let´s see it.
65
			if ( jQueryMatchedObj.length == 1 ) {
66
				settings.imageArray.push(new Array(objClicked.getAttribute('href'),objClicked.getAttribute('title')));
67
			} else {
68
				// Add an Array (as many as we have), with href and title atributes, inside the Array that storage the images references
69
				for ( var i = 0; i < jQueryMatchedObj.length; i++ ) {
70
					settings.imageArray.push(new Array(jQueryMatchedObj[i].getAttribute('href'),jQueryMatchedObj[i].getAttribute('title')));
71
				}
72
			}
73
			while ( settings.imageArray[settings.activeImage][0] != objClicked.getAttribute('href') ) {
74
				settings.activeImage++;
75
			}
76
			// Call the function that prepares image exibition
77
			_set_image_to_view();
78
		}
79
		/**
80
		 */
81
		function _set_interface() {
82
			// Apply the HTML markup into body tag
83
			$('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><div id="lightbox-container-image"><img id="lightbox-image"><div style="" id="lightbox-nav"><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="' + settings.imageLoading + '"></a></div></div></div><div id="lightbox-container-image-data-box"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span></div><div id="lightbox-secNav"><a href="#" id="lightbox-secNav-btnClose"><img src="' + settings.imageBtnClose + '"></a></div></div></div></div>');
84
			// Get page sizes
85
			var arrPageSizes = ___getPageSize();
86
			// Style overlay and show it
87
			$('#jquery-overlay').css({
88
				backgroundColor:	settings.overlayBgColor,
89
				opacity:			settings.overlayOpacity,
90
				width:				arrPageSizes[0],
91
				height:				arrPageSizes[1]
92
			}).fadeIn();
93
			// Get page scroll
94
			var arrPageScroll = ___getPageScroll();
95
			// Calculate top and left offset for the jquery-lightbox div object and show it
96
			$('#jquery-lightbox').css({
97
				top:	arrPageScroll[1] + (arrPageSizes[3] / 10),
98
				left:	arrPageScroll[0]
99
			}).show();
100
			// Assigning click events in elements to close overlay
101
			$('#jquery-overlay,#jquery-lightbox').click(function() {
102
				_finish();
103
			});
104
			// Assign the _finish function to lightbox-loading-link and lightbox-secNav-btnClose objects
105
			$('#lightbox-loading-link,#lightbox-secNav-btnClose').click(function() {
106
				_finish();
107
				return false;
108
			});
109
			// If window was resized, calculate the new overlay dimensions
110
			$(window).resize(function() {
111
				// Get page sizes
112
				var arrPageSizes = ___getPageSize();
113
				// Style overlay and show it
114
				$('#jquery-overlay').css({
115
					width:		arrPageSizes[0],
116
					height:		arrPageSizes[1]
117
				});
118
				// Get page scroll
119
				var arrPageScroll = ___getPageScroll();
120
				// Calculate top and left offset for the jquery-lightbox div object and show it
121
				$('#jquery-lightbox').css({
122
					top:	arrPageScroll[1] + (arrPageSizes[3] / 10),
123
					left:	arrPageScroll[0]
124
				});
125
			});
126
		}
127
		/**
128
		 */
129
		function _set_image_to_view() { // show the loading
130
			// Show the loading
131
			$('#lightbox-loading').show();
132
			// Hide some elements
133
			$('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();
134
			// Image preload process
135
			var objImagePreloader = new Image();
136
			objImagePreloader.onload = function() {
137
				$('#lightbox-image').attr('src',settings.imageArray[settings.activeImage][0]);
138
				// Perfomance an effect in the image container resizing it
139
				_resize_container_image_box(objImagePreloader.width,objImagePreloader.height);
140
				//	clear onLoad, IE behaves irratically with animated gifs otherwise
141
				objImagePreloader.onload=function(){};
142
			}
143
			objImagePreloader.src = settings.imageArray[settings.activeImage][0];
144
		};
145
		/**
146
		 */
147
		function _resize_container_image_box(intImageWidth,intImageHeight) {
148
			// Get current width and height
149
			var intCurrentWidth = $('#lightbox-container-image-box').width();
150
			var intCurrentHeight = $('#lightbox-container-image-box').height();
151
			// Get the width and height of the selected image plus the padding
152
			var intWidth = (intImageWidth + (settings.containerBorderSize * 2)); // Plus the image´s width and the left and right padding value
153
			var intHeight = (intImageHeight + (settings.containerBorderSize * 2)); // Plus the image´s height and the left and right padding value
154
			// Diferences
155
			var intDiffW = intCurrentWidth - intWidth;
156
			var intDiffH = intCurrentHeight - intHeight;
157
			// Perfomance the effect
158
			$('#lightbox-container-image-box').animate({ width: intWidth, height: intHeight },settings.containerResizeSpeed,function() { _show_image(); });
159
			if ( ( intDiffW == 0 ) && ( intDiffH == 0 ) ) {
160
				if ( $.browser.msie ) {
161
					___pause(250);
162
				} else {
163
					___pause(100);
164
				}
165
			}
166
			$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({ height: intImageHeight + (settings.containerBorderSize * 2) });
167
			$('#lightbox-container-image-data-box').css({ width: intImageWidth });
168
		};
169
		/**
170
		 */
171
		function _show_image() {
172
			$('#lightbox-loading').hide();
173
			$('#lightbox-image').fadeIn(function() {
174
				_show_image_data();
175
				_set_navigation();
176
			});
177
			_preload_neighbor_images();
178
		};
179
		/**
180
		 */
181
		function _show_image_data() {
182
			$('#lightbox-container-image-data-box').slideDown('fast');
183
			$('#lightbox-image-details-caption').hide();
184
			if ( settings.imageArray[settings.activeImage][1] ) {
185
				$('#lightbox-image-details-caption').html(settings.imageArray[settings.activeImage][1]).show();
186
			}
187
			// If we have a image set, display 'Image X of X'
188
			if ( settings.imageArray.length > 1 ) {
189
				$('#lightbox-image-details-currentNumber').html(settings.txtImage + ' ' + ( settings.activeImage + 1 ) + ' ' + settings.txtOf + ' ' + settings.imageArray.length).show();
190
			}
191
		}
192
		/**
193
		 */
194
		function _set_navigation() {
195
			$('#lightbox-nav').show();
196
 
197
			// Instead to define this configuration in CSS file, we define here. And it´s need to IE. Just.
198
			$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });
199
 
200
			// Show the prev button, if not the first image in set
201
			if ( settings.activeImage != 0 ) {
202
				// Show the images button for Next buttons
203
				$('#lightbox-nav-btnPrev').unbind().hover(function() {
204
					$(this).css({ 'background' : 'url(' + settings.imageBtnPrev + ') left 15% no-repeat' });
205
				},function() {
206
					$(this).css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });
207
				}).show().bind('click',function() {
208
					settings.activeImage = settings.activeImage - 1;
209
					_set_image_to_view();
210
					return false;
211
				});
212
			}
213
 
214
			// Show the next button, if not the last image in set
215
			if ( settings.activeImage != ( settings.imageArray.length -1 ) ) {
216
				// Show the images button for Next buttons
217
				$('#lightbox-nav-btnNext').unbind().hover(function() {
218
					$(this).css({ 'background' : 'url(' + settings.imageBtnNext + ') right 15% no-repeat' });
219
				},function() {
220
					$(this).css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });
221
				}).show().bind('click',function() {
222
					settings.activeImage = settings.activeImage + 1;
223
					_set_image_to_view();
224
					return false;
225
				});
226
			}
227
			// Enable keyboard navigation
228
			_enable_keyboard_navigation();
229
		}
230
		/**
231
		 */
232
		function _enable_keyboard_navigation() {
233
			$(document).keydown(function(objEvent) {
234
				_keyboard_action(objEvent);
235
			});
236
		}
237
		/**
238
		 */
239
		function _disable_keyboard_navigation() {
240
			$(document).unbind();
241
		}
242
		/**
243
		 */
244
		function _keyboard_action(objEvent) {
245
			// To ie
246
			if ( objEvent == null ) {
247
				keycode = event.keyCode;
248
				escapeKey = 27;
249
			// To Mozilla
250
			} else {
251
				keycode = objEvent.keyCode;
252
				escapeKey = objEvent.DOM_VK_ESCAPE;
253
			}
254
			// Get the key in lower case form
255
			key = String.fromCharCode(keycode).toLowerCase();
256
			// Verify the keys to close the ligthBox
257
			if ( ( key == settings.keyToClose ) || ( key == 'x' ) || ( keycode == escapeKey ) ) {
258
				_finish();
259
			}
260
			// Verify the key to show the previous image
261
			if ( ( key == settings.keyToPrev ) || ( keycode == 37 ) ) {
262
				// If we´re not showing the first image, call the previous
263
				if ( settings.activeImage != 0 ) {
264
					settings.activeImage = settings.activeImage - 1;
265
					_set_image_to_view();
266
					_disable_keyboard_navigation();
267
				}
268
			}
269
			// Verify the key to show the next image
270
			if ( ( key == settings.keyToNext ) || ( keycode == 39 ) ) {
271
				// If we´re not showing the last image, call the next
272
				if ( settings.activeImage != ( settings.imageArray.length - 1 ) ) {
273
					settings.activeImage = settings.activeImage + 1;
274
					_set_image_to_view();
275
					_disable_keyboard_navigation();
276
				}
277
			}
278
		}
279
		/**
280
		 */
281
		function _preload_neighbor_images() {
282
			if ( (settings.imageArray.length -1) > settings.activeImage ) {
283
				objNext = new Image();
284
				objNext.src = settings.imageArray[settings.activeImage + 1][0];
285
			}
286
			if ( settings.activeImage > 0 ) {
287
				objPrev = new Image();
288
				objPrev.src = settings.imageArray[settings.activeImage -1][0];
289
			}
290
		}
291
		/**
292
		 */
293
		function _finish() {
294
			$('#jquery-lightbox').remove();
295
			$('#jquery-overlay').fadeOut(function() { $('#jquery-overlay').remove(); });
296
			// Show some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
297
			$('embed, object, select').css({ 'visibility' : 'visible' });
298
		}
299
		/**
300
		 */
301
		function ___getPageSize() {
302
			var xScroll, yScroll;
303
			if (window.innerHeight && window.scrollMaxY) {
304
				xScroll = window.innerWidth + window.scrollMaxX;
305
				yScroll = window.innerHeight + window.scrollMaxY;
306
			} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
307
				xScroll = document.body.scrollWidth;
308
				yScroll = document.body.scrollHeight;
309
			} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
310
				xScroll = document.body.offsetWidth;
311
				yScroll = document.body.offsetHeight;
312
			}
313
			var windowWidth, windowHeight;
314
			if (self.innerHeight) {	// all except Explorer
315
				if(document.documentElement.clientWidth){
316
					windowWidth = document.documentElement.clientWidth;
317
				} else {
318
					windowWidth = self.innerWidth;
319
				}
320
				windowHeight = self.innerHeight;
321
			} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
322
				windowWidth = document.documentElement.clientWidth;
323
				windowHeight = document.documentElement.clientHeight;
324
			} else if (document.body) { // other Explorers
325
				windowWidth = document.body.clientWidth;
326
				windowHeight = document.body.clientHeight;
327
			}
328
			// for small pages with total height less then height of the viewport
329
			if(yScroll < windowHeight){
330
				pageHeight = windowHeight;
331
			} else {
332
				pageHeight = yScroll;
333
			}
334
			// for small pages with total width less then width of the viewport
335
			if(xScroll < windowWidth){
336
				pageWidth = xScroll;
337
			} else {
338
				pageWidth = windowWidth;
339
			}
340
			arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
341
			return arrayPageSize;
342
		};
343
		/**
344
		 */
345
		function ___getPageScroll() {
346
			var xScroll, yScroll;
347
			if (self.pageYOffset) {
348
				yScroll = self.pageYOffset;
349
				xScroll = self.pageXOffset;
350
			} else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
351
				yScroll = document.documentElement.scrollTop;
352
				xScroll = document.documentElement.scrollLeft;
353
			} else if (document.body) {// all other Explorers
354
				yScroll = document.body.scrollTop;
355
				xScroll = document.body.scrollLeft;
356
			}
357
			arrayPageScroll = new Array(xScroll,yScroll)
358
			return arrayPageScroll;
359
		};
360
		 /**
361
		  */
362
		 function ___pause(ms) {
363
			var date = new Date();
364
			curDate = null;
365
			do { var curDate = new Date(); }
366
			while ( curDate - date < ms);
367
		 };
368
		// Return the jQuery object for chaining. The unbind method is used to avoid click conflict when the plugin is called more than once
369
		return this.unbind('click').click(_initialize);
370
	};
371
})(jQuery); // Call and execute the function immediately passing the jQuery object
372
 
373
/**
374
 * jQuery SliderViewer Plugin
375
 * @name jquery.slideviewer.1.1.js
376
 * @author Gian Carlo Mingati - http://www.gcmingati.net/wordpress/wp-content/lab/jquery/imagestrip/imageslide-plugin.html
377
 * @version 1.1
378
 * @date October 6, 2007
379
 * @category jQuery plugin
380
 * @copyright (c) 2007 Gian Carlo Mingati (gcmingati.net)
381
 * @license ?
382
 * @example Visit http://www.gcmingati.net/wordpress/wp-content/lab/jquery/imagestrip/imageslide-plugin.html for more informations about this jQuery plugin
383
 */
384
 
385
jQuery(function(){
386
	jQuery("div.svw").prepend("<img src='http://www.gcmingati.net/wordpress/wp-content/uploads/svwloader.gif' class='ldrgif' alt='loading...'/ >");
387
});
388
var j = 0;
389
jQuery.fn.slideView = function(settings) {
390
	  settings = jQuery.extend({
391
     easeFunc: "easeInOutExpo", /* <-- easing function names changed in jquery.easing.1.2.js */
392
     easeTime: 750,
393
     toolTip: false
394
  }, settings);
395
	return this.each(function(){
396
		var container = jQuery(this);
397
		container.find("img.ldrgif").remove(); // removes the preloader gif
398
		container.removeClass("svw").addClass("stripViewer");
399
		var pictWidth = container.find("li").find("img").width();
400
		var pictHeight = container.find("li").find("img").height();
401
		var pictEls = container.find("li").size();
402
		var stripViewerWidth = pictWidth*pictEls;
434 jpm 403
		container.find("ul").css("width" , stripViewerWidth); //assegnamo la larghezza alla lista UL
404
		//container.find("li").css("width" , pictWidth);
415 jpm 405
		container.css("width" , pictWidth);
406
		container.css("height" , pictHeight);
407
		container.each(function(i) {
408
			jQuery(this).after("<div class='stripTransmitter' id='stripTransmitter" + j + "'><ul><\/ul><\/div>");
409
			jQuery(this).find("li").each(function(n) {
410
						jQuery("div#stripTransmitter" + j + " ul").append("<li><a title='" + jQuery(this).find("img").attr("alt") + "' href='#'>"+(n+1)+"<\/a><\/li>");
411
				});
412
			jQuery("div#stripTransmitter" + j + " a").each(function(z) {
413
				jQuery(this).bind("click", function(){
414
				jQuery(this).addClass("current").parent().parent().find("a").not(jQuery(this)).removeClass("current"); // wow!
415
				var cnt = - (pictWidth*z);
416
				jQuery(this).parent().parent().parent().prev().find("ul").animate({ left: cnt}, settings.easeTime, settings.easeFunc);
417
				return false;
418
				   });
419
				});
420
			jQuery("div#stripTransmitter" + j).css("width" , pictWidth + 20);
421
			jQuery("div#stripTransmitter" + j + " a:eq(0)").addClass("current");
422
			if(settings.toolTip){
423
			container.next(".stripTransmitter ul").find("a").Tooltip({
424
				track: true,
425
				delay: 0,
426
				showURL: false,
427
				showBody: false
428
				});
429
			}
430
			});
431
		j++;
432
  });
433
};
434
 
435
/**
436
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
437
 *
438
 * Uses the built In easIng capabilities added In jQuery 1.1
439
 * to offer multiple easIng options
440
 *
441
 * @copyright (c) 2007 George Smith
442
 * @license Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
443
 */
444
 
445
// t: current time, b: begInnIng value, c: change In value, d: duration
446
jQuery.easing['jswing'] = jQuery.easing['swing'];
447
 
448
jQuery.extend( jQuery.easing,
449
{
450
	def: 'easeOutQuad',
451
	swing: function (x, t, b, c, d) {
452
		//alert(jQuery.easing.default);
453
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
454
	},
455
	easeInQuad: function (x, t, b, c, d) {
456
		return c*(t/=d)*t + b;
457
	},
458
	easeOutQuad: function (x, t, b, c, d) {
459
		return -c *(t/=d)*(t-2) + b;
460
	},
461
	easeInOutQuad: function (x, t, b, c, d) {
462
		if ((t/=d/2) < 1) return c/2*t*t + b;
463
		return -c/2 * ((--t)*(t-2) - 1) + b;
464
	},
465
	easeInCubic: function (x, t, b, c, d) {
466
		return c*(t/=d)*t*t + b;
467
	},
468
	easeOutCubic: function (x, t, b, c, d) {
469
		return c*((t=t/d-1)*t*t + 1) + b;
470
	},
471
	easeInOutCubic: function (x, t, b, c, d) {
472
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
473
		return c/2*((t-=2)*t*t + 2) + b;
474
	},
475
	easeInQuart: function (x, t, b, c, d) {
476
		return c*(t/=d)*t*t*t + b;
477
	},
478
	easeOutQuart: function (x, t, b, c, d) {
479
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
480
	},
481
	easeInOutQuart: function (x, t, b, c, d) {
482
		if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
483
		return -c/2 * ((t-=2)*t*t*t - 2) + b;
484
	},
485
	easeInQuint: function (x, t, b, c, d) {
486
		return c*(t/=d)*t*t*t*t + b;
487
	},
488
	easeOutQuint: function (x, t, b, c, d) {
489
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
490
	},
491
	easeInOutQuint: function (x, t, b, c, d) {
492
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
493
		return c/2*((t-=2)*t*t*t*t + 2) + b;
494
	},
495
	easeInSine: function (x, t, b, c, d) {
496
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
497
	},
498
	easeOutSine: function (x, t, b, c, d) {
499
		return c * Math.sin(t/d * (Math.PI/2)) + b;
500
	},
501
	easeInOutSine: function (x, t, b, c, d) {
502
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
503
	},
504
	easeInExpo: function (x, t, b, c, d) {
505
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
506
	},
507
	easeOutExpo: function (x, t, b, c, d) {
508
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
509
	},
510
	easeInOutExpo: function (x, t, b, c, d) {
511
		if (t==0) return b;
512
		if (t==d) return b+c;
513
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
514
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
515
	},
516
	easeInCirc: function (x, t, b, c, d) {
517
		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
518
	},
519
	easeOutCirc: function (x, t, b, c, d) {
520
		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
521
	},
522
	easeInOutCirc: function (x, t, b, c, d) {
523
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
524
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
525
	},
526
	easeInElastic: function (x, t, b, c, d) {
527
		var s=1.70158;var p=0;var a=c;
528
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
529
		if (a < Math.abs(c)) { a=c; var s=p/4; }
530
		else var s = p/(2*Math.PI) * Math.asin (c/a);
531
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
532
	},
533
	easeOutElastic: function (x, t, b, c, d) {
534
		var s=1.70158;var p=0;var a=c;
535
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
536
		if (a < Math.abs(c)) { a=c; var s=p/4; }
537
		else var s = p/(2*Math.PI) * Math.asin (c/a);
538
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
539
	},
540
	easeInOutElastic: function (x, t, b, c, d) {
541
		var s=1.70158;var p=0;var a=c;
542
		if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
543
		if (a < Math.abs(c)) { a=c; var s=p/4; }
544
		else var s = p/(2*Math.PI) * Math.asin (c/a);
545
		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
546
		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
547
	},
548
	easeInBack: function (x, t, b, c, d, s) {
549
		if (s == undefined) s = 1.70158;
550
		return c*(t/=d)*t*((s+1)*t - s) + b;
551
	},
552
	easeOutBack: function (x, t, b, c, d, s) {
553
		if (s == undefined) s = 1.70158;
554
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
555
	},
556
	easeInOutBack: function (x, t, b, c, d, s) {
557
		if (s == undefined) s = 1.70158;
558
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
559
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
560
	},
561
	easeInBounce: function (x, t, b, c, d) {
562
		return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
563
	},
564
	easeOutBounce: function (x, t, b, c, d) {
565
		if ((t/=d) < (1/2.75)) {
566
			return c*(7.5625*t*t) + b;
567
		} else if (t < (2/2.75)) {
568
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
569
		} else if (t < (2.5/2.75)) {
570
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
571
		} else {
572
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
573
		}
574
	},
575
	easeInOutBounce: function (x, t, b, c, d) {
576
		if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
577
		return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
578
	}
579
});
580
/*
581
 * jQuery Tooltip plugin 1.1
582
 *
583
 * http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/
584
 *
585
 * Copyright (c) 2006 Jörn Zaefferer, Stefan Petre
586
 *
587
 * Dual licensed under the MIT and GPL licenses:
588
 *   http://www.opensource.org/licenses/mit-license.php
589
 *   http://www.gnu.org/licenses/gpl.html
590
 *
591
 * Revision: $Id: jquery.tooltip.js 2237 2007-07-04 19:11:15Z joern.zaefferer $
592
 *
593
 */
594
 
595
/**
596
 * Display a customized tooltip instead of the default one
597
 * for every selected element. The tooltip behaviour mimics
598
 * the default one, but lets you style the tooltip and
599
 * specify the delay before displaying it. In addition, it displays the
600
 * href value, if it is available.
601
 *
602
 * Requires dimensions plugin.
603
 *
604
 * When used on a page with select elements, include the bgiframe plugin. It is used if present.
605
 *
606
 * To style the tooltip, use these selectors in your stylesheet:
607
 *
608
 * #tooltip - The tooltip container
609
 *
610
 * #tooltip h3 - The tooltip title
611
 *
612
 * #tooltip div.body - The tooltip body, shown when using showBody
613
 *
614
 * #tooltip div.url - The tooltip url, shown when using showURL
615
 *
616
 *
617
 * @example $('a, input, img').Tooltip();
618
 * @desc Shows tooltips for anchors, inputs and images, if they have a title
619
 *
620
 * @example $('label').Tooltip({
621
 *   delay: 0,
622
 *   track: true,
623
 *   event: "click"
624
 * });
625
 * @desc Shows tooltips for labels with no delay, tracking mousemovement, displaying the tooltip when the label is clicked.
626
 *
627
 * @example // modify global settings
628
 * $.extend($.fn.Tooltip.defaults, {
629
 * 	track: true,
630
 * 	delay: 0,
631
 * 	showURL: false,
632
 * 	showBody: " - ",
633
 *  fixPNG: true
634
 * });
635
 * // setup fancy tooltips
636
 * $('a.pretty').Tooltip({
637
 * 	 extraClass: "fancy"
638
 * });
639
 $('img.pretty').Tooltip({
640
 * 	 extraClass: "fancy-img",
641
 * });
642
 * @desc This example starts with modifying the global settings, applying them to all following Tooltips; Afterwards, Tooltips for anchors with class pretty are created with an extra class for the Tooltip: "fancy" for anchors, "fancy-img" for images
643
 *
644
 * @param Object settings (optional) Customize your Tooltips
645
 * @option Number delay The number of milliseconds before a tooltip is display. Default: 250
646
 * @option Boolean track If true, let the tooltip track the mousemovement. Default: false
647
 * @option Boolean showURL If true, shows the href or src attribute within p.url. Defaul: true
648
 * @option String showBody If specified, uses the String to split the title, displaying the first part in the h3 tag, all following in the p.body tag, separated with <br/>s. Default: null
649
 * @option String extraClass If specified, adds the class to the tooltip helper. Default: null
650
 * @option Boolean fixPNG If true, fixes transparent PNGs in IE. Default: false
651
 * @option Function bodyHandler If specified its called to format the tooltip-body, hiding the title-part. Default: none
652
 * @option Number top The top-offset for the tooltip position. Default: 15
653
 * @option Number left The left-offset for the tooltip position. Default: 15
654
 *
655
 * @name Tooltip
656
 * @type jQuery
657
 * @cat Plugins/Tooltip
658
 * @author Jörn Zaefferer (http://bassistance.de)
659
 */
660
 
661
/**
662
 * A global flag to disable all tooltips.
663
 *
664
 * @example $("button.openModal").click(function() {
665
 *   $.Tooltip.blocked = true;
666
 *   // do some other stuff, eg. showing a modal dialog
667
 *   $.Tooltip.blocked = false;
668
 * });
669
 *
670
 * @property
671
 * @name $.Tooltip.blocked
672
 * @type Boolean
673
 * @cat Plugins/Tooltip
674
 */
675
 
676
/**
677
 * Global defaults for tooltips. Apply to all calls to the Tooltip plugin after modifying  the defaults.
678
 *
679
 * @example $.extend($.Tooltip.defaults, {
680
 *   track: true,
681
 *   delay: 0
682
 * });
683
 *
684
 * @property
685
 * @name $.Tooltip.defaults
686
 * @type Map
687
 * @cat Plugins/Tooltip
688
 */
689
(function($) {
690
 
691
	// the tooltip element
692
	var helper = {},
693
		// the current tooltipped element
694
		current,
695
		// the title of the current element, used for restoring
696
		title,
697
		// timeout id for delayed tooltips
698
		tID,
699
		// IE 5.5 or 6
700
		IE = $.browser.msie && /MSIE\s(5\.5|6\.)/.test(navigator.userAgent),
701
		// flag for mouse tracking
702
		track = false;
703
 
704
	$.Tooltip = {
705
		blocked: false,
706
		defaults: {
707
			delay: 200,
708
			showURL: true,
709
			extraClass: "",
710
			top: 15,
711
			left: 15
712
		},
713
		block: function() {
714
			$.Tooltip.blocked = !$.Tooltip.blocked;
715
		}
716
	};
717
 
718
	$.fn.extend({
719
		Tooltip: function(settings) {
720
			settings = $.extend({}, $.Tooltip.defaults, settings);
721
			createHelper();
722
			return this.each(function() {
723
					this.tSettings = settings;
724
					// copy tooltip into its own expando and remove the title
725
					this.tooltipText = this.title;
726
					$(this).removeAttr("title");
727
					// also remove alt attribute to prevent default tooltip in IE
728
					this.alt = "";
729
				})
730
				.hover(save, hide)
731
				.click(hide);
732
		},
733
		fixPNG: IE ? function() {
734
			return this.each(function () {
735
				var image = $(this).css('backgroundImage');
736
				if (image.match(/^url\(["']?(.*\.png)["']?\)$/i)) {
737
					image = RegExp.$1;
738
					$(this).css({
739
						'backgroundImage': 'none',
740
						'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image + "')"
741
					}).each(function () {
742
						var position = $(this).css('position');
743
						if (position != 'absolute' && position != 'relative')
744
							$(this).css('position', 'relative');
745
					});
746
				}
747
			});
748
		} : function() { return this; },
749
		unfixPNG: IE ? function() {
750
			return this.each(function () {
751
				$(this).css({'filter': '', backgroundImage: ''});
752
			});
753
		} : function() { return this; },
754
		hideWhenEmpty: function() {
755
			return this.each(function() {
756
				$(this)[ $(this).html() ? "show" : "hide" ]();
757
			});
758
		},
759
		url: function() {
760
			return this.attr('href') || this.attr('src');
761
		}
762
	});
763
 
764
	function createHelper() {
765
		// there can be only one tooltip helper
766
		if( helper.parent )
767
			return;
768
		// create the helper, h3 for title, div for url
769
		helper.parent = $('<div id="tooltip"><h3></h3><div class="body"></div><div class="url"></div></div>')
770
			// hide it at first
771
			.hide()
772
			// add to document
773
			.appendTo('body');
774
 
775
		// apply bgiframe if available
776
		if ( $.fn.bgiframe )
777
			helper.parent.bgiframe();
778
 
779
		// save references to title and url elements
780
		helper.title = $('h3', helper.parent);
781
		helper.body = $('div.body', helper.parent);
782
		helper.url = $('div.url', helper.parent);
783
	}
784
 
785
	// main event handler to start showing tooltips
786
	function handle(event) {
787
		// show helper, either with timeout or on instant
788
		if( this.tSettings.delay )
789
			tID = setTimeout(show, this.tSettings.delay);
790
		else
791
			show();
792
 
793
		// if selected, update the helper position when the mouse moves
794
		track = !!this.tSettings.track;
795
		$('body').bind('mousemove', update);
796
 
797
		// update at least once
798
		update(event);
799
	}
800
 
801
	// save elements title before the tooltip is displayed
802
	function save() {
803
		// if this is the current source, or it has no title (occurs with click event), stop
804
		if ( $.Tooltip.blocked || this == current || !this.tooltipText )
805
			return;
806
 
807
		// save current
808
		current = this;
809
		title = this.tooltipText;
810
 
811
		if ( this.tSettings.bodyHandler ) {
812
			helper.title.hide();
813
			helper.body.html( this.tSettings.bodyHandler.call(this) ).show();
814
		} else if ( this.tSettings.showBody ) {
815
			var parts = title.split(this.tSettings.showBody);
816
			helper.title.html(parts.shift()).show();
817
			helper.body.empty();
818
			for(var i = 0, part; part = parts[i]; i++) {
819
				if(i > 0)
820
					helper.body.append("<br/>");
821
				helper.body.append(part);
822
			}
823
			helper.body.hideWhenEmpty();
824
		} else {
825
			helper.title.html(title).show();
826
			helper.body.hide();
827
		}
828
 
829
		// if element has href or src, add and show it, otherwise hide it
830
		if( this.tSettings.showURL && $(this).url() )
831
			helper.url.html( $(this).url().replace('http://', '') ).show();
832
		else
833
			helper.url.hide();
834
 
835
		// add an optional class for this tip
836
		helper.parent.addClass(this.tSettings.extraClass);
837
 
838
		// fix PNG background for IE
839
		if (this.tSettings.fixPNG )
840
			helper.parent.fixPNG();
841
 
842
		handle.apply(this, arguments);
843
	}
844
 
845
	// delete timeout and show helper
846
	function show() {
847
		tID = null;
848
		helper.parent.show();
849
		update();
850
	}
851
 
852
	/**
853
	 * callback for mousemove
854
	 * updates the helper position
855
	 * removes itself when no current element
856
	 */
857
	function update(event)	{
858
		if($.Tooltip.blocked)
859
			return;
860
 
861
		// stop updating when tracking is disabled and the tooltip is visible
862
		if ( !track && helper.parent.is(":visible")) {
863
			$('body').unbind('mousemove', update)
864
		}
865
 
866
		// if no current element is available, remove this listener
867
		if( current == null ) {
868
			$('body').unbind('mousemove', update);
869
			return;
870
		}
871
		var left = helper.parent[0].offsetLeft;
872
		var top = helper.parent[0].offsetTop;
873
		if(event) {
874
			// position the helper 15 pixel to bottom right, starting from mouse position
875
			left = event.pageX + current.tSettings.left;
876
			top = event.pageY + current.tSettings.top;
877
			helper.parent.css({
878
				left: left + 'px',
879
				top: top + 'px'
880
			});
881
		}
882
		var v = viewport(),
883
			h = helper.parent[0];
884
		// check horizontal position
885
		if(v.x + v.cx < h.offsetLeft + h.offsetWidth) {
886
			left -= h.offsetWidth + 20 + current.tSettings.left;
887
			helper.parent.css({left: left + 'px'});
888
		}
889
		// check vertical position
890
		if(v.y + v.cy < h.offsetTop + h.offsetHeight) {
891
			top -= h.offsetHeight + 20 + current.tSettings.top;
892
			helper.parent.css({top: top + 'px'});
893
		}
894
	}
895
 
896
	function viewport() {
897
		return {
898
			x: $(window).scrollLeft(),
899
			y: $(window).scrollTop(),
900
			cx: $(window).width(),
901
			cy: $(window).height()
902
		};
903
	}
904
 
905
	// hide helper and restore added classes and the title
906
	function hide(event) {
907
		if($.Tooltip.blocked)
908
			return;
909
		// clear timeout if possible
910
		if(tID)
911
			clearTimeout(tID);
912
		// no more current element
913
		current = null;
914
 
915
		helper.parent.hide().removeClass( this.tSettings.extraClass );
916
 
917
		if( this.tSettings.fixPNG )
918
			helper.parent.unfixPNG();
919
	}
920
 
921
})(jQuery);
922
 
923
/* Copyright (c) 2007 Paul Bakaus (paul.bakaus@googlemail.com) and Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
924
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
925
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
926
 *
927
 * $LastChangedDate: 2007-06-22 04:38:37 +0200 (Fr, 22 Jun 2007) $
928
 * $Rev: 2141 $
929
 *
930
 * Version: 1.0b2
931
 */
932
 
933
(function($){
934
 
935
// store a copy of the core height and width methods
936
var height = $.fn.height,
937
    width  = $.fn.width;
938
 
939
$.fn.extend({
940
	/**
941
	 * If used on document, returns the document's height (innerHeight)
942
	 * If used on window, returns the viewport's (window) height
943
	 * See core docs on height() to see what happens when used on an element.
944
	 *
945
	 * @example $("#testdiv").height()
946
	 * @result 200
947
	 *
948
	 * @example $(document).height()
949
	 * @result 800
950
	 *
951
	 * @example $(window).height()
952
	 * @result 400
953
	 *
954
	 * @name height
955
	 * @type Object
956
	 * @cat Plugins/Dimensions
957
	 */
958
	height: function() {
959
		if ( this[0] == window )
960
			return self.innerHeight ||
961
				$.boxModel && document.documentElement.clientHeight ||
962
				document.body.clientHeight;
963
 
964
		if ( this[0] == document )
965
			return Math.max( document.body.scrollHeight, document.body.offsetHeight );
966
 
967
		return height.apply(this, arguments);
968
	},
969
 
970
	/**
971
	 * If used on document, returns the document's width (innerWidth)
972
	 * If used on window, returns the viewport's (window) width
973
	 * See core docs on height() to see what happens when used on an element.
974
	 *
975
	 * @example $("#testdiv").width()
976
	 * @result 200
977
	 *
978
	 * @example $(document).width()
979
	 * @result 800
980
	 *
981
	 * @example $(window).width()
982
	 * @result 400
983
	 *
984
	 * @name width
985
	 * @type Object
986
	 * @cat Plugins/Dimensions
987
	 */
988
	width: function() {
989
		if ( this[0] == window )
990
			return self.innerWidth ||
991
				$.boxModel && document.documentElement.clientWidth ||
992
				document.body.clientWidth;
993
 
994
		if ( this[0] == document )
995
			return Math.max( document.body.scrollWidth, document.body.offsetWidth );
996
 
997
		return width.apply(this, arguments);
998
	},
999
 
1000
	/**
1001
	 * Returns the inner height value (without border) for the first matched element.
1002
	 * If used on document, returns the document's height (innerHeight)
1003
	 * If used on window, returns the viewport's (window) height
1004
	 *
1005
	 * @example $("#testdiv").innerHeight()
1006
	 * @result 800
1007
	 *
1008
	 * @name innerHeight
1009
	 * @type Number
1010
	 * @cat Plugins/Dimensions
1011
	 */
1012
	innerHeight: function() {
1013
		return this[0] == window || this[0] == document ?
1014
			this.height() :
1015
			this.is(':visible') ?
1016
				this[0].offsetHeight - num(this, 'borderTopWidth') - num(this, 'borderBottomWidth') :
1017
				this.height() + num(this, 'paddingTop') + num(this, 'paddingBottom');
1018
	},
1019
 
1020
	/**
1021
	 * Returns the inner width value (without border) for the first matched element.
1022
	 * If used on document, returns the document's Width (innerWidth)
1023
	 * If used on window, returns the viewport's (window) width
1024
	 *
1025
	 * @example $("#testdiv").innerWidth()
1026
	 * @result 1000
1027
	 *
1028
	 * @name innerWidth
1029
	 * @type Number
1030
	 * @cat Plugins/Dimensions
1031
	 */
1032
	innerWidth: function() {
1033
		return this[0] == window || this[0] == document ?
1034
			this.width() :
1035
			this.is(':visible') ?
1036
				this[0].offsetWidth - num(this, 'borderLeftWidth') - num(this, 'borderRightWidth') :
1037
				this.width() + num(this, 'paddingLeft') + num(this, 'paddingRight');
1038
	},
1039
 
1040
	/**
1041
	 * Returns the outer height value (including border) for the first matched element.
1042
	 * Cannot be used on document or window.
1043
	 *
1044
	 * @example $("#testdiv").outerHeight()
1045
	 * @result 1000
1046
	 *
1047
	 * @name outerHeight
1048
	 * @type Number
1049
	 * @cat Plugins/Dimensions
1050
	 */
1051
	outerHeight: function() {
1052
		return this[0] == window || this[0] == document ?
1053
			this.height() :
1054
			this.is(':visible') ?
1055
				this[0].offsetHeight :
1056
				this.height() + num(this,'borderTopWidth') + num(this, 'borderBottomWidth') + num(this, 'paddingTop') + num(this, 'paddingBottom');
1057
	},
1058
 
1059
	/**
1060
	 * Returns the outer width value (including border) for the first matched element.
1061
	 * Cannot be used on document or window.
1062
	 *
1063
	 * @example $("#testdiv").outerHeight()
1064
	 * @result 1000
1065
	 *
1066
	 * @name outerHeight
1067
	 * @type Number
1068
	 * @cat Plugins/Dimensions
1069
	 */
1070
	outerWidth: function() {
1071
		return this[0] == window || this[0] == document ?
1072
			this.width() :
1073
			this.is(':visible') ?
1074
				this[0].offsetWidth :
1075
				this.width() + num(this, 'borderLeftWidth') + num(this, 'borderRightWidth') + num(this, 'paddingLeft') + num(this, 'paddingRight');
1076
	},
1077
 
1078
	/**
1079
	 * Returns how many pixels the user has scrolled to the right (scrollLeft).
1080
	 * Works on containers with overflow: auto and window/document.
1081
	 *
1082
	 * @example $("#testdiv").scrollLeft()
1083
	 * @result 100
1084
	 *
1085
	 * @name scrollLeft
1086
	 * @type Number
1087
	 * @cat Plugins/Dimensions
1088
	 */
1089
	/**
1090
	 * Sets the scrollLeft property and continues the chain.
1091
	 * Works on containers with overflow: auto and window/document.
1092
	 *
1093
	 * @example $("#testdiv").scrollLeft(10).scrollLeft()
1094
	 * @result 10
1095
	 *
1096
	 * @name scrollLeft
1097
	 * @param Number value A positive number representing the desired scrollLeft.
1098
	 * @type jQuery
1099
	 * @cat Plugins/Dimensions
1100
	 */
1101
	scrollLeft: function(val) {
1102
		if ( val != undefined )
1103
			// set the scroll left
1104
			return this.each(function() {
1105
				if (this == window || this == document)
1106
					window.scrollTo( val, $(window).scrollTop() );
1107
				else
1108
					this.scrollLeft = val;
1109
			});
1110
 
1111
		// return the scroll left offest in pixels
1112
		if ( this[0] == window || this[0] == document )
1113
			return self.pageXOffset ||
1114
				$.boxModel && document.documentElement.scrollLeft ||
1115
				document.body.scrollLeft;
1116
 
1117
		return this[0].scrollLeft;
1118
	},
1119
 
1120
	/**
1121
	 * Returns how many pixels the user has scrolled to the bottom (scrollTop).
1122
	 * Works on containers with overflow: auto and window/document.
1123
	 *
1124
	 * @example $("#testdiv").scrollTop()
1125
	 * @result 100
1126
	 *
1127
	 * @name scrollTop
1128
	 * @type Number
1129
	 * @cat Plugins/Dimensions
1130
	 */
1131
	/**
1132
	 * Sets the scrollTop property and continues the chain.
1133
	 * Works on containers with overflow: auto and window/document.
1134
	 *
1135
	 * @example $("#testdiv").scrollTop(10).scrollTop()
1136
	 * @result 10
1137
	 *
1138
	 * @name scrollTop
1139
	 * @param Number value A positive number representing the desired scrollTop.
1140
	 * @type jQuery
1141
	 * @cat Plugins/Dimensions
1142
	 */
1143
	scrollTop: function(val) {
1144
		if ( val != undefined )
1145
			// set the scroll top
1146
			return this.each(function() {
1147
				if (this == window || this == document)
1148
					window.scrollTo( $(window).scrollLeft(), val );
1149
				else
1150
					this.scrollTop = val;
1151
			});
1152
 
1153
		// return the scroll top offset in pixels
1154
		if ( this[0] == window || this[0] == document )
1155
			return self.pageYOffset ||
1156
				$.boxModel && document.documentElement.scrollTop ||
1157
				document.body.scrollTop;
1158
 
1159
		return this[0].scrollTop;
1160
	},
1161
 
1162
	/**
1163
	 * Returns the top and left positioned offset in pixels.
1164
	 * The positioned offset is the offset between a positioned
1165
	 * parent and the element itself.
1166
	 *
1167
	 * @example $("#testdiv").position()
1168
	 * @result { top: 100, left: 100 }
1169
	 *
1170
	 * @name position
1171
	 * @param Map options Optional settings to configure the way the offset is calculated.
1172
	 * @option Boolean margin Should the margin of the element be included in the calculations? False by default.
1173
	 * @option Boolean border Should the border of the element be included in the calculations? False by default.
1174
	 * @option Boolean padding Should the padding of the element be included in the calculations? False by default.
1175
	 * @param Object returnObject An object to store the return value in, so as not to break the chain. If passed in the
1176
	 *                            chain will not be broken and the result will be assigned to this object.
1177
	 * @type Object
1178
	 * @cat Plugins/Dimensions
1179
	 */
1180
	position: function(options, returnObject) {
1181
		var elem = this[0], parent = elem.parentNode, op = elem.offsetParent,
1182
		    options = $.extend({ margin: false, border: false, padding: false, scroll: false }, options || {}),
1183
			x = elem.offsetLeft,
1184
			y = elem.offsetTop,
1185
			sl = elem.scrollLeft,
1186
			st = elem.scrollTop;
1187
 
1188
		// Mozilla and IE do not add the border
1189
		if ($.browser.mozilla || $.browser.msie) {
1190
			// add borders to offset
1191
			x += num(elem, 'borderLeftWidth');
1192
			y += num(elem, 'borderTopWidth');
1193
		}
1194
 
1195
		if ($.browser.mozilla) {
1196
			do {
1197
				// Mozilla does not add the border for a parent that has overflow set to anything but visible
1198
				if ($.browser.mozilla && parent != elem && $.css(parent, 'overflow') != 'visible') {
1199
					x += num(parent, 'borderLeftWidth');
1200
					y += num(parent, 'borderTopWidth');
1201
				}
1202
 
1203
				if (parent == op) break; // break if we are already at the offestParent
1204
			} while ((parent = parent.parentNode) && (parent.tagName.toLowerCase() != 'body' || parent.tagName.toLowerCase() != 'html'));
1205
		}
1206
 
1207
		var returnValue = handleOffsetReturn(elem, options, x, y, sl, st);
1208
 
1209
		if (returnObject) { $.extend(returnObject, returnValue); return this; }
1210
		else              { return returnValue; }
1211
	},
1212
 
1213
	/**
1214
	 * Returns the location of the element in pixels from the top left corner of the viewport.
1215
	 *
1216
	 * For accurate readings make sure to use pixel values for margins, borders and padding.
1217
	 *
1218
	 * Known issues:
1219
	 *  - Issue: A div positioned relative or static without any content before it and its parent will report an offsetTop of 0 in Safari
1220
	 *    Workaround: Place content before the relative div ... and set height and width to 0 and overflow to hidden
1221
	 *
1222
	 * @example $("#testdiv").offset()
1223
	 * @result { top: 100, left: 100, scrollTop: 10, scrollLeft: 10 }
1224
	 *
1225
	 * @example $("#testdiv").offset({ scroll: false })
1226
	 * @result { top: 90, left: 90 }
1227
	 *
1228
	 * @example var offset = {}
1229
	 * $("#testdiv").offset({ scroll: false }, offset)
1230
	 * @result offset = { top: 90, left: 90 }
1231
	 *
1232
	 * @name offset
1233
	 * @param Map options Optional settings to configure the way the offset is calculated.
1234
	 * @option Boolean margin Should the margin of the element be included in the calculations? True by default.
1235
	 * @option Boolean border Should the border of the element be included in the calculations? False by default.
1236
	 * @option Boolean padding Should the padding of the element be included in the calculations? False by default.
1237
	 * @option Boolean scroll Should the scroll offsets of the parent elements be included in the calculations? True by default.
1238
	 *                        When true it adds the totla scroll offets of all parents to the total offset and also adds two properties
1239
	 *                        to the returned object, scrollTop and scrollLeft.
1240
	 * @options Boolean lite Will use offsetLite instead of offset when set to true. False by default.
1241
	 * @param Object returnObject An object to store the return value in, so as not to break the chain. If passed in the
1242
	 *                            chain will not be broken and the result will be assigned to this object.
1243
	 * @type Object
1244
	 * @cat Plugins/Dimensions
1245
	 */
1246
	offset: function(options, returnObject) {
1247
		var x = 0, y = 0, sl = 0, st = 0,
1248
		    elem = this[0], parent = this[0], op, parPos, elemPos = $.css(elem, 'position'),
1249
		    mo = $.browser.mozilla, ie = $.browser.msie, sf = $.browser.safari, oa = $.browser.opera,
1250
		    absparent = false, relparent = false,
1251
		    options = $.extend({ margin: true, border: false, padding: false, scroll: true, lite: false }, options || {});
1252
 
1253
		// Use offsetLite if lite option is true
1254
		if (options.lite) return this.offsetLite(options, returnObject);
1255
 
1256
		if (elem.tagName.toLowerCase() == 'body') {
1257
			// Safari is the only one to get offsetLeft and offsetTop properties of the body "correct"
1258
			// Except they all mess up when the body is positioned absolute or relative
1259
			x = elem.offsetLeft;
1260
			y = elem.offsetTop;
1261
			// Mozilla ignores margin and subtracts border from body element
1262
			if (mo) {
1263
				x += num(elem, 'marginLeft') + (num(elem, 'borderLeftWidth')*2);
1264
				y += num(elem, 'marginTop')  + (num(elem, 'borderTopWidth') *2);
1265
			} else
1266
			// Opera ignores margin
1267
			if (oa) {
1268
				x += num(elem, 'marginLeft');
1269
				y += num(elem, 'marginTop');
1270
			} else
1271
			// IE does not add the border in Standards Mode
1272
			if (ie && jQuery.boxModel) {
1273
				x += num(elem, 'borderLeftWidth');
1274
				y += num(elem, 'borderTopWidth');
1275
			}
1276
		} else {
1277
			do {
1278
				parPos = $.css(parent, 'position');
1279
 
1280
				x += parent.offsetLeft;
1281
				y += parent.offsetTop;
1282
 
1283
				// Mozilla and IE do not add the border
1284
				if (mo || ie) {
1285
					// add borders to offset
1286
					x += num(parent, 'borderLeftWidth');
1287
					y += num(parent, 'borderTopWidth');
1288
 
1289
					// Mozilla does not include the border on body if an element isn't positioned absolute and is without an absolute parent
1290
					if (mo && parPos == 'absolute') absparent = true;
1291
					// IE does not include the border on the body if an element is position static and without an absolute or relative parent
1292
					if (ie && parPos == 'relative') relparent = true;
1293
				}
1294
 
1295
				op = parent.offsetParent;
1296
				if (options.scroll || mo) {
1297
					do {
1298
						if (options.scroll) {
1299
							// get scroll offsets
1300
							sl += parent.scrollLeft;
1301
							st += parent.scrollTop;
1302
						}
1303
 
1304
						// Mozilla does not add the border for a parent that has overflow set to anything but visible
1305
						if (mo && parent != elem && $.css(parent, 'overflow') != 'visible') {
1306
							x += num(parent, 'borderLeftWidth');
1307
							y += num(parent, 'borderTopWidth');
1308
						}
1309
 
1310
						parent = parent.parentNode;
1311
					} while (parent != op);
1312
				}
1313
				parent = op;
1314
 
1315
				if (parent.tagName.toLowerCase() == 'body' || parent.tagName.toLowerCase() == 'html') {
1316
					// Safari and IE Standards Mode doesn't add the body margin for elments positioned with static or relative
1317
					if ((sf || (ie && $.boxModel)) && elemPos != 'absolute' && elemPos != 'fixed') {
1318
						x += num(parent, 'marginLeft');
1319
						y += num(parent, 'marginTop');
1320
					}
1321
					// Mozilla does not include the border on body if an element isn't positioned absolute and is without an absolute parent
1322
					// IE does not include the border on the body if an element is positioned static and without an absolute or relative parent
1323
					if ( (mo && !absparent && elemPos != 'fixed') ||
1324
					     (ie && elemPos == 'static' && !relparent) ) {
1325
						x += num(parent, 'borderLeftWidth');
1326
						y += num(parent, 'borderTopWidth');
1327
					}
1328
					break; // Exit the loop
1329
				}
1330
			} while (parent);
1331
		}
1332
 
1333
		var returnValue = handleOffsetReturn(elem, options, x, y, sl, st);
1334
 
1335
		if (returnObject) { $.extend(returnObject, returnValue); return this; }
1336
		else              { return returnValue; }
1337
	},
1338
 
1339
	/**
1340
	 * Returns the location of the element in pixels from the top left corner of the viewport.
1341
	 * This method is much faster than offset but not as accurate. This method can be invoked
1342
	 * by setting the lite option to true in the offset method.
1343
	 *
1344
	 * @name offsetLite
1345
	 * @param Map options Optional settings to configure the way the offset is calculated.
1346
	 * @option Boolean margin Should the margin of the element be included in the calculations? True by default.
1347
	 * @option Boolean border Should the border of the element be included in the calculations? False by default.
1348
	 * @option Boolean padding Should the padding of the element be included in the calculations? False by default.
1349
	 * @option Boolean scroll Should the scroll offsets of the parent elements be included in the calculations? True by default.
1350
	 *                        When true it adds the totla scroll offets of all parents to the total offset and also adds two properties
1351
	 *                        to the returned object, scrollTop and scrollLeft.
1352
	 * @param Object returnObject An object to store the return value in, so as not to break the chain. If passed in the
1353
	 *                            chain will not be broken and the result will be assigned to this object.
1354
	 * @type Object
1355
	 * @cat Plugins/Dimensions
1356
	 */
1357
	offsetLite: function(options, returnObject) {
1358
		var x = 0, y = 0, sl = 0, st = 0, parent = this[0], op,
1359
		    options = $.extend({ margin: true, border: false, padding: false, scroll: true }, options || {});
1360
 
1361
		do {
1362
			x += parent.offsetLeft;
1363
			y += parent.offsetTop;
1364
 
1365
			op = parent.offsetParent;
1366
			if (options.scroll) {
1367
				// get scroll offsets
1368
				do {
1369
					sl += parent.scrollLeft;
1370
					st += parent.scrollTop;
1371
					parent = parent.parentNode;
1372
				} while(parent != op);
1373
			}
1374
			parent = op;
1375
		} while (parent && parent.tagName.toLowerCase() != 'body' && parent.tagName.toLowerCase() != 'html');
1376
 
1377
		var returnValue = handleOffsetReturn(this[0], options, x, y, sl, st);
1378
 
1379
		if (returnObject) { $.extend(returnObject, returnValue); return this; }
1380
		else              { return returnValue; }
1381
	}
1382
});
1383
 
1384
/**
1385
 * Handles converting a CSS Style into an Integer.
1386
 * @private
1387
 */
1388
var num = function(el, prop) {
1389
	return parseInt($.css(el.jquery?el[0]:el,prop))||0;
1390
};
1391
 
1392
/**
1393
 * Handles the return value of the offset and offsetLite methods.
1394
 * @private
1395
 */
1396
var handleOffsetReturn = function(elem, options, x, y, sl, st) {
1397
	if ( !options.margin ) {
1398
		x -= num(elem, 'marginLeft');
1399
		y -= num(elem, 'marginTop');
1400
	}
1401
 
1402
	// Safari and Opera do not add the border for the element
1403
	if ( options.border && ($.browser.safari || $.browser.opera) ) {
1404
		x += num(elem, 'borderLeftWidth');
1405
		y += num(elem, 'borderTopWidth');
1406
	} else if ( !options.border && !($.browser.safari || $.browser.opera) ) {
1407
		x -= num(elem, 'borderLeftWidth');
1408
		y -= num(elem, 'borderTopWidth');
1409
	}
1410
 
1411
	if ( options.padding ) {
1412
		x += num(elem, 'paddingLeft');
1413
		y += num(elem, 'paddingTop');
1414
	}
1415
 
1416
	// do not include scroll offset on the element
1417
	if ( options.scroll ) {
1418
		sl -= elem.scrollLeft;
1419
		st -= elem.scrollTop;
1420
	}
1421
 
1422
	return options.scroll ? { top: y - st, left: x - sl, scrollTop:  st, scrollLeft: sl }
1423
	                      : { top: y, left: x };
1424
};
1425
 
1426
})(jQuery);