/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
*
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);

/**
 * jquery.scrollable 1.0.2. Put your HTML scroll.
 *
 * Copyright (c) 2009 Tero Piirainen
 * http://flowplayer.org/tools/scrollable.html
 *
 * Dual licensed under MIT and GPL 2+ licenses
 * http://www.opensource.org/licenses
 *
 * Launch  : March 2008
 * Version : 1.0.2 - Tue Feb 24 2009 10:52:08 GMT-0000 (GMT+00:00)
 */
(function($) {

	function fireEvent(opts, name, self, arg) {
		var fn = opts[name];

		if ($.isFunction(fn)) {
			try {
				return fn.call(self, arg);

			} catch (error) {
				if (opts.alert) {
					alert("Error calling scrollable." + name + ": " + error);
				} else {
					throw error;
				}
				return false;
			}
		}
		return true;
	}

	var current = null;


	// constructor
	function Scrollable(root, conf) {

		// current instance
		var self = this;
		if (!current) { current = self; }

		// horizontal flag
		var horizontal = !conf.vertical;


		// wrap (root elements for items)
		var wrap = $(conf.items, root);
		// current index
		var index = 0;


		// get handle to navigational elements
		var navi = root.siblings(conf.navi).eq(0);
		//var prev = root.siblings(conf.prev).eq(0);
		var prev = $(conf.prev);
		//var prev = root.siblings(conf.next).eq(0);
		var next = $(conf.next);

		//var prevPage = root.siblings(conf.prevPage).eq(0);
		var prevPage = $(conf.prevPage);
		//var nextPage = root.siblings(conf.nextPage).eq(0);
		var nextPage = $(conf.nextPage);


		// methods
		$.extend(self, {

			getVersion: function() {
				return [1, 0, 1];
			},

			getIndex: function() {
				return index;
			},

			getConf: function() {
				return conf;
			},

			getSize: function() {
				return self.getItems().size();
			},

			getPageAmount: function() {
				return Math.ceil(this.getSize() / conf.size);
			},

			getPageIndex: function() {
				return Math.ceil(index / conf.size);
			},

			getRoot: function() {
				return root;
			},

			getItemWrap: function() {
				return wrap;
			},

			getItems: function() {
				return wrap.children();
			},

			/* all seeking functions depend on this */
			seekTo: function(i, time, fn) {

				// default speed
				time = time || conf.speed;

				// function given as second argument
				if ($.isFunction(time)) {
					fn = time;
					time = conf.speed;
				}

				if (i < 0) { i = 0; }
				if (i > self.getSize() - conf.size) {
					//console.log(i+'---'+self.getSize()+'++++'+conf.size);
					this.end();
				 return self; }

				var item = self.getItems().eq(i);
				if (!item.length) { return self; }

				// onBeforeSeek
				if (fireEvent(conf, "onBeforeSeek", self, i) === false) {
					return self;
				}

				if (horizontal) {
					var left = -(item.outerWidth(true) * i);
					wrap.animate({left: left}, time, conf.easing, fn ? function() { fn.call(self); } : null);

				} else {
					var top = -(item.outerHeight(true) * i); // wrap.offset().top - item.offset().top;
					wrap.animate({top: top}, time, conf.easing, fn ? function() { fn.call(self); } : null);
				}


				// navi status update
				if (navi.length) {
					var klass = conf.activeClass;
					var page = Math.ceil(i / conf.size);
					page = Math.min(page, navi.children().length - 1);
					navi.children().removeClass(klass).eq(page).addClass(klass);
				}

				// prev buttons disabled flag
				if (i === 0) {
					prev.add(prevPage).addClass(conf.disabledClass);
				} else {
					prev.add(prevPage).removeClass(conf.disabledClass);
				}

				// next buttons disabled flag
				if (i >= self.getSize() - conf.size) {
					next.add(nextPage).addClass(conf.disabledClass);
				} else {
					next.add(nextPage).removeClass(conf.disabledClass);
				}

				current = self;
				index = i;

				// onSeek after index being updated
				fireEvent(conf, "onSeek", self, i);
				return self;

			},

			move: function(offset, time, fn) {
				var to = index + offset;
				if (conf.loop && to > (self.getSize() - conf.size)) {
					to = 0;
				}
				return this.seekTo(to, time, fn);
			},

			next: function(time, fn) {
			//alert (fn);
			//alert (time);

				return this.move(1, time, fn);
			},

			prev: function(time, fn) {
				return this.move(-1, time, fn);
			},

			movePage: function(offset, time, fn) {
				return this.move(conf.size * offset, time, fn);
			},

			setPage: function(page, time, fn) {
				var size = conf.size;
				var index = size * page;
				var lastPage = index + size >= this.getSize();
				if (lastPage) {
					index = this.getSize() - conf.size;
				}
				return this.seekTo(index, time, fn);
			},

			prevPage: function(time, fn) {
				return this.setPage(this.getPageIndex() - 1, time, fn);
			},

			nextPage: function(time, fn) {
				return this.setPage(this.getPageIndex() + 1, time, fn);
			},

			begin: function(time, fn) {
				return this.seekTo(0, time, fn);
			},

			end: function(time, fn) {
				return this.seekTo(this.getSize() - conf.size, time, fn);
			},

			reload: function() {
				return load();
			},

			click: function(index, time, fn) {

				var item = self.getItems().eq(index);
				var klass = conf.activeClass;

				if (!item.hasClass(klass) && (index >= 0 || index < this.getSize())) {
					self.getItems().removeClass(klass);
					item.addClass(klass);
					var delta = Math.floor(conf.size / 2);
					var to = index - delta;

					// next to last item must work
					if (to > self.getSize() - conf.size) { to--;	}

					if (to !== index) {
						return this.seekTo(to, time, fn);
					}
				}

				return self;
			}

		});


		// mousewheel
		if ($.isFunction($.fn.mousewheel)) {
			root.bind("mousewheel.scrollable", function(e, delta)  {
				// opera goes to opposite direction
				var step = $.browser.opera ? 1 : -1;

				self.move(delta > 0 ? step : -step, 50);
				return false;
			});
		}

		// prev button
		prev.addClass(conf.disabledClass).click(function() {
			self.prev();
		});


		// next button
		next.click(function() {
			self.next();
		});

		// prev page button
		nextPage.click(function() {
			self.nextPage();
		});


		// next page button
		prevPage.addClass(conf.disabledClass).click(function() {
			self.prevPage();
		});


		// keyboard
		if (conf.keyboard) {

			// unfortunately window.keypress does not work on IE.
			$(window).unbind("keypress.scrollable").bind("keypress.scrollable", function(evt) {

				var el = current;
				if (!el) { return; }

				if (horizontal && (evt.keyCode == 37 || evt.keyCode == 39)) {
					el.move(evt.keyCode == 37 ? -1 : 1);
					return evt.preventDefault();
				}

				if (!horizontal && (evt.keyCode == 38 || evt.keyCode == 40)) {
					el.move(evt.keyCode == 38 ? -1 : 1);
					return evt.preventDefault();
				}

				return true;

			});
		}

		// navi
		function load() {

			navi.each(function() {

				var nav = $(this);

				// generate new entries
				if (nav.is(":empty") || nav.data("me") == self) {

					nav.empty();
					nav.data("me", self);

					for (var i = 0; i < self.getPageAmount(); i++) {

						var item = $("<" + conf.naviItem + "/>").attr("href", i).click(function(e) {
							var el = $(this);
							el.parent().children().removeClass(conf.activeClass);
							el.addClass(conf.activeClass);
							self.setPage(el.attr("href"));
							return e.preventDefault();
						});

						if (i === 0) { item.addClass(conf.activeClass); }
						nav.append(item);
					}

				// assign onClick events to existing entries
				} else {

					// find a entries first -> syntaxically correct
					var els = nav.children();
					els.each(function(i)  {
						var item = $(this);
						item.attr("href", i);
						if (i === 0) { item.addClass(conf.activeClass); }

						item.click(function() {
							nav.find("." + conf.activeClass).removeClass(conf.activeClass);
							item.addClass(conf.activeClass);
							self.setPage(item.attr("href"));
						});

					});
				}

			});


			// item.click()
			if (conf.clickable) {
				self.getItems().each(function(index, arg) {
					var el = $(this);
					if (!el.data("set")) {
						el.bind("click.scrollable", function() {
							self.click(index);
						});
						el.data("set", true);
					}
				});
			}


			// hover
			if (conf.hoverClass) {
				self.getItems().hover(function()  {
					$(this).addClass(conf.hoverClass);
				}, function() {
					$(this).removeClass(conf.hoverClass);
				});
			}

			return self;
		}

		load();


		// interval stuff
		var timer = null;

		function setTimer() {
			timer = setInterval(function()  {
				self.next();

			}, conf.interval);
		}

		if (conf.interval > 0) {

			root.hover(function() {
				clearInterval(timer);
			}, function() {
				setTimer();
			});

			setTimer();
		}

	}


	// jQuery plugin implementation
	jQuery.prototype.scrollable = function(conf) {

		// already constructed --> return API
		var api = this.eq(typeof conf == 'number' ? conf : 0).data("scrollable");
		if (api) { return api; }


		var opts = {

			// basics
			size: 5,
			vertical:false,
			clickable: true,
			loop: false,
			interval: 0,
			speed: 400,
			keyboard: true,

			// other
			activeClass:'act',
			disabledClass: 'disabled',
			hoverClass: null,
			easing: 'swing',

			// navigational elements
			items: '.items',
			prev: '.prev',
			next: '.next',
			prevPage: '.prevPage',
			nextPage: '.nextPage',
			navi: '.navi',
			naviItem: 'a',


			// callbacks
			onBeforeSeek: null,
			onSeek: null,
			alert: true
		};


		$.extend(opts, conf);

		this.each(function() {
			var el = new Scrollable($(this), opts);
			$(this).data("scrollable", el);
		});

		return this;

	};


})(jQuery);



/*
 * jNice
 * version: 1.0 (11.26.08)
 * by Sean Mooney (sean@whitespace-creative.com)
 * Examples at: http://www.whitespace-creative.com/jquery/jnice/
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * To Use: place in the head
 *  <link href="inc/style/jNice.css" rel="stylesheet" type="text/css" />
 *  <script type="text/javascript" src="inc/js/jquery.jNice.js"></script>
 *
 * And apply the jNice class to the form you want to style
 *
 * To Do: Add textareas, Add File upload
 *
 ******************************************** */
(function($){
	$.fn.jNice = function(options){
		var self = this;
		var safari = $.browser.safari; /* We need to check for safari to fix the input:text problem */
		/* Apply document listener */
		$(document).mousedown(checkExternalClick);
		/* each form */
		return this.each(function(){
			$('input:submit, input:reset, input:button', this).each(ButtonAdd);
			/// HDNET: no buttons
			//$('button').focus(function(){ $(this).addClass('jNiceFocus')}).blur(function(){ $(this).removeClass('jNiceFocus')});
			$('input:text, input:password', this).each(TextAdd);

			// HDNET: get textarea fields
			$('textarea', this).each(TextareaAdd);
			/* If this is safari we need to add an extra class */
			//if (safari){$('.jNiceInputWrapper').each(function(){$(this).addClass('jNiceSafari').find('input').css('width', $(this).width()+11);});}
			if (safari){$('.jNiceInputWrapper').each(function(){$(this).addClass('jNiceSafari').find('input').css('width', $(this).width()-20);});}
			//$('input:checkbox', this).each(CheckAdd);
			//$('input:radio', this).each(RadioAdd);

			// HDNET: remove select fields - will replaced by another script
			//$('select', this).each(function(index){ SelectAdd(this, index); });

			/* Add a new handler for the reset action */
			$(this).bind('reset',function(){var action = function(){ Reset(this); }; window.setTimeout(action, 0); });
			$('.jNiceHidden').css({opacity:0});
		});
	};/* End the Plugin */

	var Reset = function(form){
		var sel;
		$('.jNiceSelectWrapper select', form).each(function(){sel = (this.selectedIndex<0) ? 0 : this.selectedIndex; $('ul', $(this).parent()).each(function(){$('a:eq('+ sel +')', this).click();});});
		$('a.jNiceCheckbox, a.jNiceRadio', form).removeClass('jNiceChecked');
		$('input:checkbox, input:radio', form).each(function(){if(this.checked){$('a', $(this).parent()).addClass('jNiceChecked');}});
	};

	var RadioAdd = function(){
		var $input = $(this).addClass('jNiceHidden').wrap('<span class="jRadioWrapper jNiceWrapper"></span>');
		var $wrapper = $input.parent();
		var $a = $('<span class="jNiceRadio"></span>');
		$wrapper.prepend($a);
		/* Click Handler */
		$a.click(function(){
				var $input = $(this).addClass('jNiceChecked').siblings('input').attr('checked',true);
				/* uncheck all others of same name */
				$('input:radio[name="'+ $input.attr('name') +'"]').not($input).each(function(){
					$(this).attr('checked',false).siblings('.jNiceRadio').removeClass('jNiceChecked');
				});
				return false;
		});
		$input.click(function(){
			if(this.checked){
				var $input = $(this).siblings('.jNiceRadio').addClass('jNiceChecked').end();
				/* uncheck all others of same name */
				$('input:radio[name="'+ $input.attr('name') +'"]').not($input).each(function(){
					$(this).attr('checked',false).siblings('.jNiceRadio').removeClass('jNiceChecked');
				});
			}
		}).focus(function(){ $a.addClass('jNiceFocus'); }).blur(function(){ $a.removeClass('jNiceFocus'); });

		/* set the default state */
		if (this.checked){ $a.addClass('jNiceChecked'); }
	};

	var CheckAdd = function(){
		var $input = $(this).addClass('jNiceHidden').wrap('<span class="jNiceWrapper"></span>');
		var $wrapper = $input.parent().append('<span class="jNiceCheckbox"></span>');
		/* Click Handler */
		var $a = $wrapper.find('.jNiceCheckbox').click(function(){
				var $a = $(this);
				var input = $a.siblings('input')[0];
				if (input.checked===true){
					input.checked = false;
					$a.removeClass('jNiceChecked');
				}
				else {
					input.checked = true;
					$a.addClass('jNiceChecked');
				}
				return false;
		});
		$input.click(function(){
			if(this.checked){ $a.addClass('jNiceChecked'); 	}
			else { $a.removeClass('jNiceChecked'); }
		//}).focus(function(){ $a.addClass('jNiceFocus'); }).blur(function(){ $a.removeClass('jNiceFocus'); });
		});

		/* set the default state */
		if (this.checked){$('.jNiceCheckbox', $wrapper).addClass('jNiceChecked');}
	};


	var TextAdd = function(){
		// HDNET: get id of the original element and add this to the new wrapper element as class name
		var inputID = $(this).get(0).id;
                /*
                var value = $(this).attr('value');
		var blurEvent = $(this).attr('onblur');
		var focusEvent = $(this).attr('onfocus');

                if(blurEvent) {
			var blurEvent = 'onblur="if(this.value == \'\')this.value=\''+value+'\';"';
		} else {
			var blurEvent = '';
		}

		if(focusEvent) {
			var focusEvent = 'onfocus="if(this.value == \''+value+'\')this.value = \'\';"';
		} else {
			var focusEvent = '';
		}*/


		var $input = $(this).addClass('jNiceInput').wrap('<div class="jNiceInputWrapper '+ inputID +' clearfix"><div class="jNiceInputInner"></div><div class="end"></div></div>');
		// Vorlaeufiger Fix von sk@hdnet.de "clearfix" raus
		//var $input = $(this).addClass('jNiceInput').wrap('<div class="jNiceInputWrapper '+ inputID +'"><div class="jNiceInputInner"></div><div class="end"></div></div>');

		var $wrapper = $input.parents('.jNiceInputWrapper');
		$input.focus(function(){
			$wrapper.addClass('jNiceInputWrapper_hover');
		}).blur(function(){
			$wrapper.removeClass('jNiceInputWrapper_hover');
		});


	};




	// HDNET: use that for submits
	var ButtonAdd = function(){
		var value = $(this).attr('value');
		$(this).replaceWith('<div class="jNiceSubmitWrapper '+ this.id +' '+ this.className +'"><input id="'+ this.id +'" name="'+ this.name +'" type="'+ this.type +'" class="'+ this.className +'" value="'+ value +'" /><span class="end"></span></div>');
	};

	// HDNET: add this for textareas
	var TextareaAdd = function(){

		var value = $(this).attr('value');
		var blurEvent = $(this).attr('onblur');
		var focusEvent = $(this).attr('onfocus');

		if(blurEvent) {
			var blurEvent = 'onblur="if(this.value == \'\')this.value=\''+value+'\';"';
		} else {
			var blurEvent = '';
		}

		if(focusEvent) {
			var focusEvent = 'onfocus="if(this.value == \''+value+'\')this.value = \'\';"';
		} else {
			var focusEvent = '';
		}


		$(this).replaceWith('<div class="jNiceTextareaWrapper '+ this.id +' '+ this.className +'"><span class="tl"></span><span class="tr"></span><div class="outerBottom"><div class="outerTop"><div class="innerEnd"><div class="innerBegin"><textarea id="'+ this.id +'" name="'+ this.name +'" class="'+ this.className +'" cols="'+ this.cols +'" rows="'+ this.rows +'" '+ blurEvent +' '+ focusEvent +'>'+ value +'</textarea></span></div></div></div></div><span class="bl"></span><span class="br"></span></div>');

	};

	/* Hide all open selects */
	var SelectHide = function(){
			$('.jNiceSelectWrapper ul:visible').hide();
	};

	/* Check for an external click */
	var checkExternalClick = function(event) {
		if ($(event.target).parents('.jNiceSelectWrapper').length === 0) { SelectHide(); }
	};

	var SelectAdd = function(element, index){
		var $select = $(element);
		index = index || $select.css('zIndex')*1;
		index = (index) ? index : 0;
		/* First thing we do is Wrap it */
		// HDNET: get id of the original element and add this to the new wrapper element as class name
		var elementID = element.id
		$select.wrap($('<div class="jNiceWrapper '+ elementID +'"></div>').css({zIndex:100-index}));
		//$select.wrap($('<div class="jNiceWrapper '+ elementID +'"></div>'));

		var width = $select.width();
		// HDNET; width without padding */
		var widthNoPadding = width - 20;
		$select.addClass('jNiceHidden').after('<div class="jNiceSelectWrapper"><div><span class="jNiceSelectText"></span><span class="jNiceSelectOpen"></span></div><ul></ul></div>');
		var $wrapper = $(element).siblings('.jNiceSelectWrapper').css({width: width +'px'});
		// HDNET; width without padding
		$('.jNiceSelectText, .jNiceSelectWrapper ul', $wrapper).width( widthNoPadding - $('.jNiceSelectOpen', $wrapper).width());
		/* IF IE 6 */
		if ($.browser.msie && jQuery.browser.version < 7) {
			$select.after($('<iframe src="javascript:\'\';" marginwidth="0" marginheight="0" align="bottom" scrolling="no" tabIndex="-1" frameborder="0"></iframe>').css({ height: $select.height()+4 +'px' }));
		}
		/* Now we add the options */
		SelectUpdate(element);
		/* Apply the click handler to the Open */
		$('div', $wrapper).click(function(){
			var $ul = $(this).siblings('ul');
			if ($ul.css('display')=='none'){ SelectHide(); } /* Check if box is already open to still allow toggle, but close all other selects */
			$ul.slideToggle({duration:50});
			var offSet = ($('a.selected', $ul).offset().top - $ul.offset().top);
			//$ul.animate({scrollTop: offSet, duration:0});
			return false;
		});
		/* Add the key listener */
		$select.keydown(function(e){
			var selectedIndex = this.selectedIndex;
			switch(e.keyCode){
				case 40: /* Down */
					if (selectedIndex < this.options.length - 1){ selectedIndex+=1; }
					break;
				case 38: /* Up */
					if (selectedIndex > 0){ selectedIndex-=1; }
					break;
				default:
					return;
					break;
			}

			$('ul a', $wrapper).removeClass('selected').eq(selectedIndex).addClass('selected');
			$('span:eq(0)', $wrapper).html($('option:eq('+ selectedIndex +')', $select).attr('selected', 'selected').text());
			return false;
		}).focus(function(){ $wrapper.addClass('jNiceFocus'); }).blur(function(){ $wrapper.removeClass('jNiceFocus'); });

	};

	var SelectUpdate = function(element){
		var $select = $(element);
		var $wrapper = $select.siblings('.jNiceSelectWrapper');
		var $ul = $wrapper.find('ul').find('li').remove().end().hide();
		$('option', $select).each(function(i){
			$ul.append('<li><a href="#" index="'+ i +'">'+ this.text +'</a></li>');
		});
		/* Add click handler to the a */
		$ul.find('a').click(function(){
			$('a.selected', $wrapper).removeClass('selected');
			$(this).addClass('selected');
			/* Fire the onchange event */
			if ($select[0].selectedIndex != $(this).attr('index') && $select[0].onchange) { $select[0].selectedIndex = $(this).attr('index'); $select[0].onchange(); }
			$select[0].selectedIndex = $(this).attr('index');
			$('span:eq(0)', $wrapper).html($(this).html());
			$ul.hide();
			return false;
		});
		/* Set the defalut */
		$('a:eq('+ $select[0].selectedIndex +')', $ul).click();
	};

	var SelectRemove = function(element){
		var zIndex = $(element).siblings('.jNiceSelectWrapper').css('zIndex');
		$(element).css({zIndex: zIndex}).removeClass('jNiceHidden');
		$(element).siblings('.jNiceSelectWrapper').remove();
	};

	/* Utilities */
	$.jNice = {
			SelectAdd : function(element, index){ 	SelectAdd(element, index); },
			SelectRemove : function(element){ SelectRemove(element); },
			SelectUpdate : function(element){ SelectUpdate(element); }
	};/* End Utilities */

	/* Automatically apply to any forms with class jNice */
	/*
	if ($.browser.msie && jQuery.browser.version < 7) {
		return false;
	} else {
		var $j = jQuery.noConflict();
		$j(document).ready(function() {
		//$j(function(){$('form.jNice').jNice();	});
			$j('form.jNice').jNice();
		});
	}*/
})(jQuery);



/*
 * Thickbox 3.1 - One Box To Rule Them All.
 * By Cody Lindley (http://www.codylindley.com)
 * Copyright (c) 2007 cody lindley
 * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
 */

var tb_pathToImage = WWWROOT+"skin/frontend/shop20/shop20/images/loadingAnimation.gif";

/*
 * !!!!!!!!!!!!!!!!! edit below this line at your own risk
 * !!!!!!!!!!!!!!!!!!!!!!!
 */

// on page load call tb_init
jQuery(document).ready(function(){
	tb_init('a.thickbox, area.thickbox, input.thickbox');// pass where to
															// apply thickbox
		imgLoader = new Image();// preload image
		imgLoader.src = tb_pathToImage;
	});

// add thickbox to href & area elements that have a class of .thickbox
function tb_init(domChunk){
	jQuery(domChunk).click(function(){
		var t = this.title || this.name || null;
		var a = this.href || this.alt;
		var g = this.rel || false;
		tb_show(t, a, g);
		this.blur();
		return false;
	});
}

function tb_show(caption, url, imageGroup){// function called when the user
											// clicks on a thickbox link

	try {
		if (typeof document.body.style.maxHeight === "undefined") {// if IE 6
			jQuery("body", "html").css( {
				height : "100%",
				width : "100%"
			});
			jQuery("html").css("overflow", "hidden");
			if (document.getElementById("TB_HideSelect") === null) {// iframe to
																	// hide
																	// select
																	// elements
																	// in ie6
				jQuery("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");
				jQuery("#TB_overlay").click(tb_remove);
			}
		}
		else {// all others
			if (document.getElementById("TB_overlay") === null) {
				jQuery("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
				jQuery("#TB_overlay").click(tb_remove);
			}
		}

		if (tb_detectMacXFF()) {
			jQuery("#TB_overlay").addClass("TB_overlayMacFFBGHack");// use png
																	// overlay
																	// so hide
																	// flash
		}
		else {
			jQuery("#TB_overlay").addClass("TB_overlayBG");// use background
															// and opacity
		}

		if (caption === null) {
			caption = "";
		}
		jQuery("body").append("<div id='TB_load'><img src='" + imgLoader.src + "' /></div>");// add
																								// loader
																								// to
																								// the
																								// page
		jQuery('#TB_load').show();// show loader

		var baseURL;
		if (url.indexOf("?") !== -1) { // ff there is a query string involved
			baseURL = url.substr(0, url.indexOf("?"));
		}
		else {
			baseURL = url;
		}

		var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/;
		var urlType = baseURL.toLowerCase().match(urlString);

		if (urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif' || urlType == '.bmp') {// code
																														// to
																														// show
																														// images

			TB_PrevCaption = "";
			TB_PrevURL = "";
			TB_PrevHTML = "";
			TB_NextCaption = "";
			TB_NextURL = "";
			TB_NextHTML = "";
			TB_imageCount = "";
			TB_FoundURL = false;
			if (imageGroup) {
				TB_TempArray = jQuery("a[@rel=" + imageGroup + "]").get();
				for (TB_Counter = 0; ((TB_Counter < TB_TempArray.length) && (TB_NextHTML === "")); TB_Counter++) {
					var urlTypeTemp = TB_TempArray[TB_Counter].href.toLowerCase().match(urlString);
					if (!(TB_TempArray[TB_Counter].href == url)) {
						if (TB_FoundURL) {
							TB_NextCaption = TB_TempArray[TB_Counter].title;
							TB_NextURL = TB_TempArray[TB_Counter].href;
							TB_NextHTML = "<span id='TB_next'>&nbsp;&nbsp;<a href='#'>Next &gt;</a></span>";
						}
						else {
							TB_PrevCaption = TB_TempArray[TB_Counter].title;
							TB_PrevURL = TB_TempArray[TB_Counter].href;
							TB_PrevHTML = "<span id='TB_prev'>&nbsp;&nbsp;<a href='#'>&lt; Prev</a></span>";
						}
					}
					else {
						TB_FoundURL = true;
						TB_imageCount = "Image " + (TB_Counter + 1) + " of " + (TB_TempArray.length);
					}
				}
			}

			imgPreloader = new Image();
			imgPreloader.onload = function(){
				imgPreloader.onload = null;

				// Resizing large images - orginal by Christian Montoya edited
				// by me.
				var pagesize = tb_getPageSize();
				var x = pagesize[0] - 150;
				var y = pagesize[1] - 150;
				var imageWidth = imgPreloader.width;
				var imageHeight = imgPreloader.height;
				if (imageWidth > x) {
					imageHeight = imageHeight * (x / imageWidth);
					imageWidth = x;
					if (imageHeight > y) {
						imageWidth = imageWidth * (y / imageHeight);
						imageHeight = y;
					}
				}
				else if (imageHeight > y) {
					imageWidth = imageWidth * (y / imageHeight);
					imageHeight = y;
					if (imageWidth > x) {
						imageHeight = imageHeight * (x / imageWidth);
						imageWidth = x;
					}
				}
				// End Resizing

				TB_WIDTH = imageWidth + 30;
				TB_HEIGHT = imageHeight + 60;
				jQuery("#TB_window").append("<a href='' id='TB_ImageOff' title='Close'><img id='TB_Image' src='" + url + "' width='" + imageWidth + "' height='" + imageHeight + "' alt='" + caption + "'/></a>" + "<div id='TB_caption'>" + caption + "<div id='TB_secondLine'>" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "</div></div><div id='TB_closeWindow'><a href='#' id='TB_closeWindowButton' title='Schliessen'>Schliessen</a></div>");

				jQuery("#TB_closeWindowButton").click(tb_remove);

				if (!(TB_PrevHTML === "")) {
					function goPrev(){
						if (jQuery(document).unbind("click", goPrev)) {
							jQuery(document).unbind("click", goPrev);
						}
						jQuery("#TB_window").remove();
						jQuery("body").append("<div id='TB_window'></div>");
						tb_show(TB_PrevCaption, TB_PrevURL, imageGroup);
						return false;
					}
					jQuery("#TB_prev").click(goPrev);
				}

				if (!(TB_NextHTML === "")) {
					function goNext(){
						jQuery("#TB_window").remove();
						jQuery("body").append("<div id='TB_window'></div>");
						tb_show(TB_NextCaption, TB_NextURL, imageGroup);
						return false;
					}
					jQuery("#TB_next").click(goNext);

				}

				document.onkeydown = function(e){
					if (e == null) { // ie
						keycode = event.keyCode;
					}
					else { // mozilla
						keycode = e.which;
					}
					if (keycode == 27) { // close
						tb_remove();
					}
					else if (keycode == 190) { // display previous image
						if (!(TB_NextHTML == "")) {
							document.onkeydown = "";
							goNext();
						}
					}
					else if (keycode == 188) { // display next image
						if (!(TB_PrevHTML == "")) {
							document.onkeydown = "";
							goPrev();
						}
					}
				};

				tb_position();
				jQuery("#TB_load").remove();
				jQuery("#TB_ImageOff").click(tb_remove);
				jQuery("#TB_window").css( {
					display : "block"
				}); // for safari using css instead of show
			};

			imgPreloader.src = url;
		}
		else {// code to show html

			var queryString = url.replace(/^[^\?]+\??/, '');
			var params = tb_parseQuery(queryString);

			TB_WIDTH = (params['width'] * 1) + 30 || 630; // defaults to 630
															// if no paramaters
															// were added to URL
			TB_HEIGHT = (params['height'] * 1) + 40 || 440; // defaults to 440
															// if no paramaters
															// were added to URL
			ajaxContentW = TB_WIDTH - 30;
			ajaxContentH = TB_HEIGHT - 45;

			if (url.indexOf('TB_iframe') != -1) {// either iframe or ajax
													// window
				urlNoQuery = url.split('TB_');
				jQuery("#TB_iframeContent").remove();
				if (params['modal'] != "true") {// iframe no modal
					jQuery("#TB_window").append("<div class='cart'><table class='empty' width='100%'><thead><tr><th class='first'>"+caption+"</th><th class='last' style='text-align:right;'><a href='#' id='TB_closeWindowButton' title='Schliessen' style='color:#fff'>Schliessen</a></th></tr></thead></table></div><iframe frameborder='0' hspace='0' src='" + urlNoQuery[0] + "' id='TB_iframeContent' name='TB_iframeContent" + Math.round(Math.random() * 1000) + "' onload='tb_showIframe()' style='width:" + (ajaxContentW + 29) + "px;height:" + (ajaxContentH + 17) + "px;' > </iframe>");
				}
				else {// iframe modal
					jQuery("#TB_overlay").unbind();
					jQuery("#TB_window").append("<iframe frameborder='0' hspace='0' src='" + urlNoQuery[0] + "' id='TB_iframeContent' name='TB_iframeContent" + Math.round(Math.random() * 1000) + "' onload='tb_showIframe()' style='width:" + (ajaxContentW + 29) + "px;height:" + (ajaxContentH + 17) + "px;'> </iframe>");
				}
			}
			else {// not an iframe, ajax
				if (jQuery("#TB_window").css("display") != "block") {
					if (params['modal'] != "true") {// ajax no modal
						jQuery("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>" + caption + "</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='Schliessen'>Schliessen</a></div></div><div id='TB_ajaxContent' style='width:" + ajaxContentW + "px;height:" + ajaxContentH + "px'></div>");
					}
					else {// ajax modal
						jQuery("#TB_overlay").unbind();
						jQuery("#TB_window").append("<div id='TB_ajaxContent' class='TB_modal' style='width:" + ajaxContentW + "px;height:" + ajaxContentH + "px;'></div>");
					}
				}
				else {// this means the window is already up, we are just
						// loading new content via ajax
					jQuery("#TB_ajaxContent")[0].style.width = ajaxContentW + "px";
					jQuery("#TB_ajaxContent")[0].style.height = ajaxContentH + "px";
					jQuery("#TB_ajaxContent")[0].scrollTop = 0;
					jQuery("#TB_ajaxWindowTitle").html(caption);
				}
			}

			jQuery("#TB_closeWindowButton").click(tb_remove);

			if (url.indexOf('TB_inline') != -1) {
				jQuery("#TB_ajaxContent").append(jQuery('#' + params['inlineId']).children());
				jQuery("#TB_window").unload(function(){
					jQuery('#' + params['inlineId']).append(jQuery("#TB_ajaxContent").children()); // move
																									// elements
																									// back
																									// when
																									// you're
																									// finished
					});
				tb_position();
				jQuery("#TB_load").remove();
				jQuery("#TB_window").css( {
					display : "block"
				});
			}
			else if (url.indexOf('TB_iframe') != -1) {
				tb_position();
				if ($.browser.safari) {// safari needs help because it will not
										// fire iframe onload
					jQuery("#TB_load").remove();
					jQuery("#TB_window").css( {
						display : "block"
					});
				}
			}
			else {
				jQuery("#TB_ajaxContent").load(url += "&random=" + (new Date().getTime()), function(){// to
																										// do a
																										// post
																										// change
																										// this
																										// load
																										// method
							tb_position();
							jQuery("#TB_load").remove();
							tb_init("#TB_ajaxContent a.thickbox");
							jQuery("#TB_window").css( {
								display : "block"
							});
						});
			}

		}

		if (!params['modal']) {
			document.onkeyup = function(e){
				if (e == null) { // ie
					keycode = event.keyCode;
				}
				else { // mozilla
					keycode = e.which;
				}
				if (keycode == 27) { // close
					tb_remove();
				}
			};
		}

	} catch (e) {
		// nothing here
	}
}

// helper functions below
function tb_showIframe(){
	jQuery("#TB_load").remove();
	jQuery("#TB_window").css( {
		display : "block"
	});
}

function tb_remove(){
	jQuery("#TB_imageOff").unbind("click");
	jQuery("#TB_closeWindowButton").unbind("click");
	jQuery("#TB_window").fadeOut("fast", function(){
		jQuery('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();
	});
	jQuery("#TB_load").remove();
	if (typeof document.body.style.maxHeight == "undefined") {// if IE 6
		jQuery("body", "html").css( {
			height : "auto",
			width : "auto"
		});
		jQuery("html").css("overflow", "");
	}
	document.onkeydown = "";
	document.onkeyup = "";
	return false;
}

function tb_position(){
	jQuery("#TB_window").css( {
		marginLeft : '-' + parseInt((TB_WIDTH / 2), 10) + 'px',
		width : TB_WIDTH + 'px'
	});
	if (!(jQuery.browser.msie && jQuery.browser.version < 7)) { // take away IE6
		jQuery("#TB_window").css( {
			marginTop : '-' + parseInt((TB_HEIGHT / 2), 10) + 'px'
		});
	}
}

function tb_parseQuery(query){
	var Params = {};
	if (!query) {
		return Params;
	}// return empty object
	var Pairs = query.split(/[;&]/);
	for ( var i = 0; i < Pairs.length; i++) {
		var KeyVal = Pairs[i].split('=');
		if (!KeyVal || KeyVal.length != 2) {
			continue;
		}
		var key = unescape(KeyVal[0]);
		var val = unescape(KeyVal[1]);
		val = val.replace(/\+/g, ' ');
		Params[key] = val;
	}
	return Params;
}

function tb_getPageSize(){
	var de = document.documentElement;
	var w = window.innerWidth || self.innerWidth || (de && de.clientWidth) || document.body.clientWidth;
	var h = window.innerHeight || self.innerHeight || (de && de.clientHeight) || document.body.clientHeight;
	arrayPageSize = [ w, h ];
	return arrayPageSize;
}

function tb_detectMacXFF(){
	var userAgent = navigator.userAgent.toLowerCase();
	if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox') != -1) {
		return true;
	}
}



/*
 * JQZoom Evolution 1.0.1 - Javascript Image magnifier
 *
 * Copyright (c) Engineer Renzi Marco(www.mind-projects.it)
 *
 * $Date: 12-12-2008
 *
 *	ChangeLog:
 *
 * $License : GPL,so any change to the code you should copy and paste this section,and would be nice to report this to me(renzi.mrc@gmail.com).
 */
(function($)
{
    $.fn.jqzoom = function(options)
    {
        var settings = {
            zoomType: 'standard', //standard/reverse/innerzoom
            zoomWidth: 200,		//zoomed width default width
            zoomHeight: 200,		//zoomed div default width
            xOffset: 10,		//zoomed div default offset
            yOffset: 0,
            position: "right" ,//zoomed div default position,offset position is to the right of the image
            lens:true, //zooming lens over the image,by default is 1;
			lensReset : false,
			imageOpacity: 0.2,
			title : true,
			alwaysOn: false,
			showEffect: 'show',
			hideEffect: 'hide',
			fadeinSpeed: 'fast',
			fadeoutSpeed: 'slow',
			preloadImages :true,
			showPreload: true,
			preloadText : 'Loading zoom',
			preloadPosition : 'center'   //bycss
        };

			//extending options
			options = options || {};
        	$.extend(settings, options);


		return this.each(function()
		{
			var a = $(this);
			var aTitle = a.attr('title'); //variabile per memorizzare il titolo href
			$(a).removeAttr('title');
			$(a).css('outline-style','none');


			var img = $("img", this);
			var imageTitle = img.attr('title');
			img.removeAttr('title');	//variabile per memorizzare il titolo immagine


			var smallimage = new Smallimage( img );
			var smallimagedata = {};
			//imageborder
			var btop = 0;
			var bleft = 0;

			var loader = null;     //variabile per memorizzare oggetto loader
			loader = new Loader();

			var ZoomTitle = (trim(aTitle).length > 0) ? aTitle :
			(trim(imageTitle).length > 0) ? imageTitle : null;  //setting zoomtitle
			var ZoomTitleObj = new zoomTitle();

			var largeimage = new Largeimage( a[0].href );

			var lens = new Lens();
			var lensdata = {};
			//lensborder



			var largeimageloaded = false;
			var scale = {}; //rapporto tra immagine grande e piccola scale.x/scale.y
			var stage = null; // quadrato che mostra l'immagine ingrandita
			var running = false; // running = true quando si verifica l'evento che mostra lo zoom(adesso mouseover).
			var mousepos = {};
			var firstime = 0;
			var preloadshow = false;
			var isMouseDown = false;
			var dragstatus = false
			//loading smallimagedata
			smallimage.loadimage();

			//ritorna false al click dell href
			$(this).click(function(){return false;});

			//se settato alwaysOn attivo lo Zoom e lo mostro.

			//attivo al mouseover
			$(this).hover(function(e)
			{
				mousepos.x = e.pageX;
				mousepos.y	= e.pageY;
				activate();
			},function()
			{
				deactivate();
			});


			//ALWAYS ON
			if(settings.alwaysOn)
			{
				setTimeout(function(){activate();},150);
			}


			function activate()
			{

				if ( !running ) {

					//finding border
					smallimage.findborder();

					running = true;

					//rimuovo il titolo al mouseover
					imageTitle = img.attr('title');
					img.removeAttr('title');
					aTitle = a.attr('title');
					$(a).removeAttr('title');

					//se non cË creo l'oggetto largeimage
					if (!largeimage || $.browser.safari) {
						largeimage = new Largeimage( a[0].href );
					}

					//se l'immagine grande non Ë stata caricata la carico
					if(!largeimageloaded || $.browser.safari)
					{
						largeimage.loadimage();
					}else
					{
					//after preload
						if(settings.zoomType != 'innerzoom')
						{
							stage = new Stage();
							stage.activate();
						}
						lens = new Lens;
						lens.activate();
					}

					//hack per MAC
				/*	if($.browser.safari)
					{
						if(settings.zoomType != 'innerzoom') //se innerzoom non mostro la finestra dello zoom
						{
							stage = new Stage();
							stage.activate();
						}
						if($('div.jqZoomPup').length <= 0)
						{
						lens = new Lens();
						}
						//if(settings.zoomType == 'innerzoom'){lens = new Lens()};
						lens.activate();
						(settings.alwaysOn) ? lens.center() : lens.setposition(null);
					}
					*/
					a[0].blur();
					//alert($('div.jqZoomPup').length);
					return false;
				}




			}

			function deactivate()
			{
				if(settings.zoomType == 'reverse' &&  !settings.alwaysOn)
				{
					img.css({'opacity' : 1});
				}

				if(!settings.alwaysOn)
				{
					//resetting parameters
					running = false;
					largeimageloaded = false;
					$(lens.node).unbind('mousemove');
					lens.remove();
					if($('div.jqZoomWindow').length >0)
					{
						stage.remove();
					}
					if($('div.jqZoomTitle').length > 0)
					{
						ZoomTitleObj.remove();
					}
					//resetting title
					img.attr('title',imageTitle);
					a.attr('title',aTitle);
					$().unbind();

					a.unbind('mousemove');
					//resetto il parametro che mi dice che Ë la prima volta che mostor lo zoom
					firstime = 0;
					//remove ieiframe
					if(jQuery('.zoom_ieframe').length > 0)
					{
						jQuery('.zoom_ieframe').remove();
					}
				}else
				{
					if(settings.lensReset)
					{
						switch(settings.zoomType)
						{
							case 'innerzoom':
							largeimage.setcenter();
							break;
							default:
							lens.center();
							break;
						}
					}
				}

				//non so se serve da provare
				if(settings.alwaysOn)
				{
					activate();
				}
			};





		//smallimage
		function Smallimage( image )
		{
			this.node = image[0];

			this.loadimage = function() {
				this.node.src = image[0].src;
			};
			this.findborder = function()
			{
				var bordertop = '';
				bordertop = $(img).css('border-top-width');
				btop = '';
				var borderleft = '';
				borderleft = $(img).css('border-left-width');
				bleft = '';
				/*if($.browser.msie)
				{
					var temp = bordertop.split(' ');

					bordertop = temp[1];
					var temp = borderleft.split(' ');
					borderleft = temp[1];
				}*/

				if(bordertop)
				{
					for(i=0;i<3;i++)
					{
						var x = [];
						x = bordertop.substr(i,1);

						if(isNaN(x) == false)
						{
							btop = btop +''+ bordertop.substr(i,1);
						}else
						{
							break;
						}
					}
				}

				if(borderleft)
				{
					for(i=0;i<3;i++)
					{
						if(!isNaN(borderleft.substr(i,1)))
						{
							bleft = bleft + borderleft.substr(i,1)
						}else
						{
							break;
						}
					}
				}
				btop = (btop.length > 0) ? eval(btop) : 0;
				bleft = (bleft.length > 0) ? eval(bleft) : 0;


			}
			this.node.onload = function()
			{
				//setto il cursor e la posizione dell'href


				a.css({'cursor':'url(../images/magnify.cur)','display':'block'});

				if(a.css('position')!= 'absolute' && a.parent().css('position'))
				{
					a.css({'cursor':'url(../images/magnify.cur)','position':'relative','display':'block'});
				}
				if(a.parent().css('position') != 'absolute')
				{
					a.parent().css('position','relative');
					//a.css('position','relative');
				}
				else{
				//a.css('position','relative');
				}
				if($.browser.safari || $.browser.opera)
				{
					$(img).css({position:'absolute',top:'0px',left:'0px'});
				}
				/*if(a.css('position')!= 'absolute' && a.parent().css('position'))
				{
					a.css({'cursor':'crosshair','position':'relative','display':'block'});
				}
				if(a.parent().css('position') != 'absolute')
				{
					alert('in');
					a.parent().css('position','relative');
					//a.css('position','relative');
				}
				else{
				//a.css('position','relative');
				}*/



				/*
				if(a.parent().css('position') != 'relative' && a.css('position') != 'absolute')
				{
				a.css({'cursor':'crosshair','position':'relative','display':'block'});
				}*/

				//al docuemnt ready viene caricato l'src quindi viene azionato l'onload e carico tutti i dati
				smallimagedata.w = $( this ).width();
				smallimagedata.h = $( this ).height();


				//non viene fatta assegnazione alla variabile globale
				smallimagedata.h = $( this ).height();
				smallimagedata.pos = $( this ).offset();
				smallimagedata.pos.l = $( this ).offset().left;
				smallimagedata.pos.t = $( this ).offset().top;
				smallimagedata.pos.r = smallimagedata.w + smallimagedata.pos.l;
				smallimagedata.pos.b = smallimagedata.h + smallimagedata.pos.t;

				//per sicurezza setto l'altezza e la width dell'href
				a.height(smallimagedata.h);
				a.width(smallimagedata.w);


				//PRELOAD IMAGES
				if(settings.preloadImages)
				{
					largeimage.loadimage();
				}



			};



			return this;
		};



		//Lens
		function Lens()
		{


			//creating element and adding class
			this.node = document.createElement("div");
			$(this.node).addClass('jqZoomPup');

			this.node.onerror = function() {
				$( lens.node ).remove();
				lens = new Lens();
				lens.activate() ;
			};




			//funzione privata per il caricamento dello zoom
			this.loadlens = function()
			{


				switch(settings.zoomType)
				{
					case 'reverse':
						this.image = new Image();
						this.image.src = smallimage.node.src; // fires off async
						this.node.appendChild( this.image );
						$( this.node ).css({'opacity' : 1});
					break;
					case 'innerzoom':

						this.image = new Image();
						this.image.src = largeimage.node.src; // fires off async
						this.node.appendChild( this.image );
						$( this.node ).css({'opacity' : 1});
					break
					default:
					break;
				}



				switch(settings.zoomType)
				{
					case 'innerzoom':
						lensdata.w = smallimagedata.w;
						lensdata.h = smallimagedata.h;
					break;
					default:
						lensdata.w = (settings.zoomWidth)/scale.x;
						lensdata.h = (settings.zoomHeight)/scale.y;
					break;
				}

			$( this.node ).css({
					width: lensdata.w + 'px',
					height: lensdata.h + 'px',
					position: 'absolute',
					/*cursor: 'crosshair',*/
					display: 'none',
					//border: '1px solid blue'
					borderWidth: 1+'px'
				});
			a.append(this.node);
			}
			return this;
		};

		Lens.prototype.activate = function()
		{
			//carico la lente
			this.loadlens();

			switch(settings.zoomType)
			{
				case 'reverse':
					img.css({'opacity' : settings.imageOpacity});

					(settings.alwaysOn) ? lens.center() : lens.setposition(null);
					//lens.center();
					//bindo ad a il mousemove della lente
					a.bind( 'mousemove', function(e)
					{
						mousepos.x = e.pageX;
						mousepos.y = e.pageY;
						lens.setposition( e );
					});
				break;
				case 'innerzoom':

					//	lens = new Lens();
					//	lens.activate();

					$( this.node ).css({top : 0 ,left: 0});
				   	if(settings.title)
					{
						ZoomTitleObj.loadtitle();
					}

					largeimage.setcenter();

				   	a.bind( 'mousemove', function(e)
				   	{
						mousepos.x = e.pageX;
						mousepos.y = e.pageY;
						largeimage.setinner( e );

					/*if(settings.zoomType == 'innerzoom' && running)
					{
						$(a).mousemove(function(){
							if($('div.jqZoomPup').length <= 0)
							{
								lens = new Lens();
								lens.activate();
							}
						});
					}*/

						/*if($('div.jqZoomPup').length <= 0)
							{
								lens = new Lens();
								lens.activate();
							}*/

					});
				break;
				default:
					/*$(document).mousemove(function(e){
					if(isMouseDown && dragstatus != false){
					lens.setposition( e );
					}
					});
					lens.center()


					dragstatus = 'on'
					$(document).mouseup(function(e){
					if(isMouseDown && dragstatus != false){
						isMouseDown = false;
						dragstatus = false;

					}
					});

					$(this.node).mousedown(function(e){
					$('div.jqZoomPup').css("cursor", "move");
					$(this.node).css("position", "absolute");

				// set z-index
					$(this.node).css("z-index", parseInt( new Date().getTime()/1000 ));
					if($.browser.safari)
					{
						$(a).css("cursor", "move");
					}
					isMouseDown    = true;
					dragstatus = 'on';
					lens.setposition( e );
					});
					*/


					(settings.alwaysOn) ? lens.center() : lens.setposition(null);

					//bindo ad a il mousemove della lente
					$(a).bind( 'mousemove', function(e)
					{

						mousepos.x = e.pageX;
						mousepos.y = e.pageY;
						lens.setposition( e );
					});

				break;
			}


			return this;
		};

		Lens.prototype.setposition = function( e)
		{


			if(e)
			{
				mousepos.x = e.pageX;
				mousepos.y	= e.pageY;
			}

			if(firstime == 0)
			{
			 	var lensleft = (smallimagedata.w)/2 - (lensdata.w)/2 ;
			 	var lenstop = (smallimagedata.h)/2 - (lensdata.h)/2 ;
				//ADDED

				$('div.jqZoomPup').show()
				if(settings.lens)
				{
					this.node.style.visibility = 'visible';
				}
				else
				{
					this.node.style.visibility = 'hidden';
					$('div.jqZoomPup').hide();
				}
				//ADDED
				firstime = 1;

			}else
			{
				var lensleft = mousepos.x - smallimagedata.pos.l - (lensdata.w)/2 ;
				var lenstop = mousepos.y - smallimagedata.pos.t -(lensdata.h)/2 ;
			}


				//a sinistra
				if(overleft())
				{
					lensleft = 0  + bleft;
				}else
				//a destra
				if(overright())
				{
					if($.browser.msie)
					{
					lensleft = smallimagedata.w - lensdata.w  + bleft + 1  ;
					}else
					{
					lensleft = smallimagedata.w - lensdata.w  + bleft - 1  ;
					}


				}

				//in alto
				if(overtop())
				{
					lenstop = 0 + btop ;
				}else
				//sotto
				if(overbottom())
				{

					if($.browser.msie)
					{
					lenstop = smallimagedata.h - lensdata.h  + btop + 1 ;
					}else
					{
					lenstop = smallimagedata.h - lensdata.h - 1 + btop  ;
					}

				}
				lensleft = parseInt(lensleft);
				lenstop = parseInt(lenstop);

				//setto lo zoom ed un eventuale immagine al centro
				$('div.jqZoomPup',a).css({top: lenstop,left: lensleft });

				if(settings.zoomType == 'reverse')
				{
					$('div.jqZoomPup img',a).css({'position': 'absolute','top': -( lenstop - btop +1) ,'left': -(lensleft - bleft +1)  });
				}

				this.node.style.left = lensleft + 'px';
				this.node.style.top = lenstop + 'px';

				//setto l'immagine grande
				largeimage.setposition();

				function overleft() {
					return mousepos.x - (lensdata.w +2*1)/2  - bleft < smallimagedata.pos.l;
				}

				function overright() {

					return mousepos.x + (lensdata.w + 2* 1)/2  > smallimagedata.pos.r + bleft ;
				}

				function overtop() {
					return mousepos.y - (lensdata.h + 2* 1)/2  - btop < smallimagedata.pos.t;
				}

				function overbottom() {
					return mousepos.y + (lensdata.h + 2* 1)/2    > smallimagedata.pos.b + btop;
				}

			return this;
		};


		//mostra la lente al centro dell'immagine
		Lens.prototype.center = function()
		{
			$('div.jqZoomPup',a).css('display','none');
			var lensleft = (smallimagedata.w)/2 - (lensdata.w)/2 ;
			var lenstop = (smallimagedata.h)/2 - (lensdata.h)/2;
			this.node.style.left = lensleft + 'px';
			this.node.style.top = lenstop + 'px';
			$('div.jqZoomPup',a).css({top: lenstop,left: lensleft });

			if(settings.zoomType == 'reverse')
			{
				/*if($.browser.safari){
					alert('safari');
					alert(2*bleft);
					$('div.jqZoomPup img',a).css({'position': 'absolute','top': -( lenstop - btop +1) ,'left': -(lensleft - 2*bleft)  });
				}else
				{*/
					$('div.jqZoomPup img',a).css({'position': 'absolute','top': -(lenstop - btop + 1) ,'left': -( lensleft  - bleft +1)   });
				//}
			}

			largeimage.setposition();
			if($.browser.msie)
			{
				$('div.jqZoomPup',a).show();
			}else
			{
				setTimeout(function(){$('div.jqZoomPup').fadeIn('fast');},10);
			}
		};


		//ritorna l'offset
		Lens.prototype.getoffset = function() {
			var o = {};
			o.left = parseInt(this.node.style.left) ;
			o.top =  parseInt(this.node.style.top) ;
			return o;
		};

		//rimuove la lente
		Lens.prototype.remove = function()
		{

			if(settings.zoomType == 'innerzoom')
			{
				$('div.jqZoomPup',a).fadeOut('fast',function(){/*$('div.jqZoomPup img').remove();*/$(this).remove();});
			}else
			{
				//$('div.jqZoomPup img').remove();
				$('div.jqZoomPup',a).remove();
			}
		};

		Lens.prototype.findborder = function()
		{
			var bordertop = '';
			bordertop = $('div.jqZoomPup').css('borderTop');
			//alert(bordertop);
			lensbtop = '';
			var borderleft = '';
			borderleft = $('div.jqZoomPup').css('borderLeft');
			lensbleft = '';
			if($.browser.msie)
			{
				var temp = bordertop.split(' ');

				bordertop = temp[1];
				var temp = borderleft.split(' ');
				borderleft = temp[1];
			}

			if(bordertop)
			{
				for(i=0;i<3;i++)
				{
					var x = [];
					x = bordertop.substr(i,1);

					if(isNaN(x) == false)
					{
						lensbtop = lensbtop +''+ bordertop.substr(i,1);
					}else
					{
						break;
					}
				}
			}

			if(borderleft)
			{
				for(i=0;i<3;i++)
				{
					if(!isNaN(borderleft.substr(i,1)))
					{
						lensbleft = lensbleft + borderleft.substr(i,1)
					}else
					{
						break;
					}
				}
			}


			lensbtop = (lensbtop.length > 0) ? eval(lensbtop) : 0;
			lensbleft = (lensbleft.length > 0) ? eval(lensbleft) : 0;
		}

		//LARGEIMAGE
		function Largeimage( url )
		{
			this.url = url;
			this.node = new Image();

			/*if(settings.preloadImages)
			{
			 	preload.push(new Image());
				preload.slice(-1).src = url ;
			}*/

			this.loadimage = function()
			{


				if(!this.node)
				this.node = new Image();

				this.node.style.position = 'absolute';
				this.node.style.display = 'none';
				this.node.style.left = '-5000px';
				this.node.style.top = '10px';
				loader = new Loader();

				if(settings.showPreload && !preloadshow)
				{
					loader.show();
					preloadshow = true;
				}

				document.body.appendChild( this.node );
				this.node.src = this.url; // fires off async
			}

			this.node.onload = function()
			{
				this.style.display = 'block';
				var w = Math.round($(this).width());
				var	h = Math.round($(this).height());

				this.style.display = 'none';

				//setting scale
				scale.x = (w / smallimagedata.w);
				scale.y = (h / smallimagedata.h);





				if($('div.preload').length > 0)
				{
					$('div.preload').remove();
				}

				largeimageloaded = true;

				if(settings.zoomType != 'innerzoom' && running){
					stage = new Stage();
					stage.activate();
				}

				if(running)
				{
				//alert('in');
				lens = new Lens();

				lens.activate() ;

				}
				//la attivo

				if($('div.preload').length > 0)
				{
					$('div.preload').remove();
				}
			}
			return this;
		}


		Largeimage.prototype.setposition = function()
		{
          	this.node.style.left = Math.ceil( - scale.x * parseInt(lens.getoffset().left) + bleft) + 'px';
			this.node.style.top = Math.ceil( - scale.y * parseInt(lens.getoffset().top) +btop) + 'px';
		};

		//setto la posizione dell'immagine grande nel caso di innerzoom
		Largeimage.prototype.setinner = function(e) {
          	this.node.style.left = Math.ceil( - scale.x * Math.abs(e.pageX - smallimagedata.pos.l)) + 'px';
			this.node.style.top = Math.ceil( - scale.y * Math.abs(e.pageY - smallimagedata.pos.t)) + 'px';
			$('div.jqZoomPup img',a).css({'position': 'absolute','top': this.node.style.top,'left': this.node.style.left  });
		};


		Largeimage.prototype.setcenter = function() {
          	this.node.style.left = Math.ceil(- scale.x * Math.abs((smallimagedata.w)/2)) + 'px';
			this.node.style.top = Math.ceil( - scale.y * Math.abs((smallimagedata.h)/2)) + 'px';


			$('div.jqZoomPup img',a).css({'position': 'absolute','top': this.node.style.top,'left': this.node.style.left  });
		};


		//STAGE
		function Stage()
		{

			var leftpos = smallimagedata.pos.l;
			var toppos = smallimagedata.pos.t;
			//creating element and class
			this.node = document.createElement("div");
			$(this.node).addClass('jqZoomWindow');

			$( this.node )
				.css({
					position: 'absolute',
					width: Math.round(settings.zoomWidth) + 'px',
					height: Math.round(settings.zoomHeight) + 'px',
					display: 'none',
					zIndex: 10000,
					overflow: 'hidden'
				});

			//fa il positionamento
		    switch(settings.position)
		    {
		    	case "right":

				leftpos = (smallimagedata.pos.r + Math.abs(settings.xOffset) + settings.zoomWidth < screen.width)
				? (smallimagedata.pos.l + smallimagedata.w + Math.abs(settings.xOffset))
				: (smallimagedata.pos.l - settings.zoomWidth - Math.abs(settings.xOffset));

				topwindow = smallimagedata.pos.t + settings.yOffset + settings.zoomHeight;
				toppos = (topwindow < screen.height && topwindow > 0)
				?  smallimagedata.pos.t + settings.yOffset
				:  smallimagedata.pos.t;

		    	break;
		    	case "left":

				leftpos = (smallimagedata.pos.l - Math.abs(settings.xOffset) - settings.zoomWidth > 0)
				? (smallimagedata.pos.l - Math.abs(settings.xOffset) - settings.zoomWidth)
				: (smallimagedata.pos.l + smallimagedata.w + Math.abs(settings.xOffset));

				topwindow = smallimagedata.pos.t + settings.yOffset + settings.zoomHeight;
				toppos = (topwindow < screen.height && topwindow > 0)
				?  smallimagedata.pos.t + settings.yOffset
				:  smallimagedata.pos.t;

		    	break;
		    	case "top":

				toppos = (smallimagedata.pos.t - Math.abs(settings.yOffset) - settings.zoomHeight > 0)
				? (smallimagedata.pos.t - Math.abs(settings.yOffset) - settings.zoomHeight)
				: (smallimagedata.pos.t + smallimagedata.h + Math.abs(settings.yOffset));


				leftwindow = smallimagedata.pos.l + settings.xOffset + settings.zoomWidth;
				leftpos = (leftwindow < screen.width && leftwindow > 0)
				? smallimagedata.pos.l + settings.xOffset
				: smallimagedata.pos.l;

		    	break;
		    	case "bottom":


				toppos = (smallimagedata.pos.b + Math.abs(settings.yOffset) + settings.zoomHeight < $('body').height())
				? (smallimagedata.pos.b + Math.abs(settings.yOffset))
				: (smallimagedata.pos.t - settings.zoomHeight - Math.abs(settings.yOffset));


				leftwindow = smallimagedata.pos.l + settings.xOffset + settings.zoomWidth;
				leftpos = (leftwindow < screen.width && leftwindow > 0)
				? smallimagedata.pos.l + settings.xOffset
				: smallimagedata.pos.l;

		    	break;
		    	default:

				leftpos = (smallimagedata.pos.l + smallimagedata.w + settings.xOffset + settings.zoomWidth < screen.width)
				? (smallimagedata.pos.l + smallimagedata.w + Math.abs(settings.xOffset))
				: (smallimagedata.pos.l - settings.zoomWidth - Math.abs(settings.xOffset));

				toppos = (smallimagedata.pos.b + Math.abs(settings.yOffset) + settings.zoomHeight < screen.height)
				? (smallimagedata.pos.b + Math.abs(settings.yOffset))
				: (smallimagedata.pos.t - settings.zoomHeight - Math.abs(settings.yOffset));

		    	break;
		    }

			this.node.style.left = leftpos + 'px';
			this.node.style.top = toppos + 'px';
			return this;
		}


		Stage.prototype.activate = function()
		{

			if ( !this.node.firstChild )
					this.node.appendChild( largeimage.node );


			if(settings.title)
			{
				ZoomTitleObj.loadtitle();
			}



			document.body.appendChild( this.node );


			switch(settings.showEffect)
			{
				case 'show':
					$(this.node).show();
				break;
				case 'fadein':
					$(this.node).fadeIn(settings.fadeinSpeed);
				break;
				default:
					$(this.node).show();
				break;
			}

			$(this.node).show();

            if ($.browser.msie && $.browser.version < 7) {
	        this.ieframe = $('<iframe class="zoom_ieframe" frameborder="0" src="#"></iframe>')
	          .css({ position: "absolute", left:this.node.style.left,top:this.node.style.top,zIndex: 99,width:settings.zoomWidth,height:settings.zoomHeight })
	          .insertBefore(this.node);
	     	 };


			largeimage.node.style.display = 'block';
		}

		Stage.prototype.remove = function() {
			switch(settings.hideEffect)
			{
				case 'hide':
					$('.jqZoomWindow').remove();
				break;
				case 'fadeout':
					$('.jqZoomWindow').fadeOut(settings.fadeoutSpeed);
				break;
				default:
					$('.jqZoomWindow').remove();
				break;
			}
		}

		function zoomTitle()
		{

			this.node =  jQuery('<div />')
				.addClass('jqZoomTitle')
				.html('' + ZoomTitle +'');

			this.loadtitle = function()
			{
				if(settings.zoomType == 'innerzoom')
				{
					$(this.node)
					.css({position: 'absolute',
						  top: smallimagedata.pos.b +3,
						  left: (smallimagedata.pos.l+1),
						  width:smallimagedata.w
						  })
					.appendTo('body');
				}else
				{
					$(this.node).appendTo(stage.node);
				}
			};
		}

		zoomTitle.prototype.remove = function() {
			$('.jqZoomTitle').remove();
		}


		function Loader()
		{

			this.node = document.createElement("div");
			$(this.node).addClass('preload');
			$(this.node).html(settings.preloadText);//appendo il testo

			$(this.node )
				.appendTo("body")
				.css('visibility','hidden');



			this.show = function()
			{
				switch(settings.preloadPosition)
				{
					case 'center':
						loadertop =  smallimagedata.pos.t + (smallimagedata.h - $(this.node ).height())/2;
						loaderleft = smallimagedata.pos.l + (smallimagedata.w - $(this.node ).width())/2;
					break;
					default:
					var loaderoffset = this.getoffset();
					loadertop = !isNaN(loaderoffset.top) ? smallimagedata.pos.t + loaderoffset.top : smallimagedata.pos.t + 0;
					loaderleft = !isNaN(loaderoffset.left) ? smallimagedata.pos.l + loaderoffset.left : smallimagedata.pos.l + 0;
					break;
				}

				//setting position
				$(this.node).css({
							top: loadertop  ,
							left: loaderleft ,
							position: 'absolute',
							visibility:'visible'
					    	});
			}
			return this;
		}

		Loader.prototype.getoffset = function()
		{
			var o = null;
			o = $('div.preload').offset();
			return o;
		}

		});
	}
})(jQuery);

	function trim(stringa)
	{
	    while (stringa.substring(0,1) == ' '){
	        stringa = stringa.substring(1, stringa.length);
	    }
	    while (stringa.substring(stringa.length-1, stringa.length) == ' '){
	        stringa = stringa.substring(0,stringa.length-1);
	    }
	    return stringa;
	}


	(function(a){a.widget("ui.selectmenu",{_init:function(){var r=this,f=this.options;var m=Math.round(Math.random()*1000);this.ids=[this.element.attr("id")+"_button_"+m,this.element.attr("id")+"_menu_"+m];this.classes=" "+this.element.attr("id");this._safemouseup=true;this.newelement=a('<a class="'+this.widgetBaseClass+' ui-widget ui-state-default ui-corner-all" id="'+this.ids[0]+'" role="button" href="#" aria-haspopup="true" aria-owns="'+this.ids[1]+'" aria-expanded="false"></a>').insertAfter(this.element);var k=this.element.attr("tabindex")||"0";this.newelement.attr("tabindex",k);this.newelement.data("selectelement",this.element);this.selectmenuIcon=a('<span class="'+this.widgetBaseClass+'-icon ui-icon"></span>').prependTo(this.newelement).addClass((f.style=="popup")?"ui-icon-triangle-2-n-s":"ui-icon-triangle-1-s");a("label[for="+this.element.attr("id")+"]").attr("for",this.ids[0]).bind("click",function(){r.newelement.focus();return false});this.newelement.bind("mousedown",function(i){r._toggle(i);if(f.style=="popup"){r._safemouseup=false;setTimeout(function(){r._safemouseup=true},300)}return false}).bind("click",function(){return false}).keydown(function(j){var i=true;switch(j.keyCode){case a.ui.keyCode.ENTER:i=true;break;case a.ui.keyCode.SPACE:i=false;r._toggle(j);break;case a.ui.keyCode.UP:case a.ui.keyCode.LEFT:i=false;r._moveSelection(-1);break;case a.ui.keyCode.DOWN:case a.ui.keyCode.RIGHT:i=false;r._moveSelection(1);break;case a.ui.keyCode.TAB:i=true;break;default:i=false;r._typeAhead(j.keyCode,"mouseup");break}return i}).bind("mouseover focus",function(){a(this).addClass(r.widgetBaseClass+"-focus ui-state-hover")}).bind("mouseout blur",function(){a(this).removeClass(r.widgetBaseClass+"-focus ui-state-hover")});a(document).mousedown(function(i){r.close(i)});this.element.click(function(){this._refreshValue()}).focus(function(){this.newelement.focus()});var d=(f.style=="dropdown")?" ui-corner-bottom":" ui-corner-all";this.list=a('<ul class="'+r.widgetBaseClass+"-menu ui-widget ui-widget-content"+d+this.classes+'" aria-hidden="true" role="listbox" aria-multiselectable="false" aria-labelledby="'+this.ids[0]+'" id="'+this.ids[1]+'"></ul>').appendTo("body");var b=[];this.element.find("option").each(function(){b.push({value:a(this).attr("value"),text:r._formatText(jQuery(this).text()),selected:a(this).attr("selected"),classes:a(this).attr("class"),parentOptGroup:a(this).parent("optgroup").attr("label")})});var p=(r.options.style=="popup")?" ui-state-active":"";for(var l in b){var e=a('<li><a href="#" tabindex="-1" role="option" aria-selected="false">'+b[l].text+"</a></li>").data("index",l).addClass(b[l].classes).data("optionClasses",b[l].classes).mouseup(function(i){if(r._safemouseup){var j=a(this).data("index")!=r._selectedIndex();r.value(a(this).data("index"));r.select(i);if(j){r.change(i)}r.close(i,true)}return false}).click(function(){return false}).bind("mouseover focus",function(){r._selectedOptionLi().addClass(p);r._focusedOptionLi().removeClass(r.widgetBaseClass+"-item-focus ui-state-hover");a(this).removeClass("ui-state-active").addClass(r.widgetBaseClass+"-item-focus ui-state-hover")}).bind("mouseout blur",function(){if(a(this).is(r._selectedOptionLi())){a(this).addClass(p)}a(this).removeClass(r.widgetBaseClass+"-item-focus ui-state-hover")});if(b[l].parentOptGroup){var n=r.widgetBaseClass+"-group-"+b[l].parentOptGroup;if(this.list.find("li."+n).size()){this.list.find("li."+n+":last ul").append(e)}else{a('<li class="'+r.widgetBaseClass+"-group "+n+'"><span class="'+r.widgetBaseClass+'-group-label">'+b[l].parentOptGroup+"</span><ul></ul></li>").appendTo(this.list).find("ul").append(e)}}else{e.appendTo(this.list)}this.list.bind("mousedown mouseup",function(){return false});if(f.icons){for(var h in f.icons){if(e.is(f.icons[h].find)){e.data("optionClasses",b[l].classes+" "+r.widgetBaseClass+"-hasIcon").addClass(r.widgetBaseClass+"-hasIcon");var q=f.icons[h].icon||"";e.find("a:eq(0)").prepend('<span class="'+r.widgetBaseClass+"-item-icon ui-icon "+q+'"></span>')}}}}this.list.find("li:last").addClass("ui-corner-bottom");if(f.style=="popup"){this.list.find("li:first").addClass("ui-corner-top")}if(f.transferClasses){var s=this.element.attr("class")||"";this.newelement.add(this.list).addClass(s)}var g=this.element.width();this.newelement.width((f.width)?f.width:g);if(f.style=="dropdown"){this.list.width((f.menuWidth)?f.menuWidth:((f.width)?f.width:g))}else{this.list.width((f.menuWidth)?f.menuWidth:((f.width)?f.width-f.handleWidth:g-f.handleWidth))}if(f.maxHeight&&f.maxHeight<this.list.height()){this.list.height(f.maxHeight)}this._optionLis=this.list.find("li:not(."+r.widgetBaseClass+"-group)");this.list.keydown(function(j){var i=true;switch(j.keyCode){case a.ui.keyCode.UP:case a.ui.keyCode.LEFT:i=false;r._moveFocus(-1);break;case a.ui.keyCode.DOWN:case a.ui.keyCode.RIGHT:i=false;r._moveFocus(1);break;case a.ui.keyCode.HOME:i=false;r._moveFocus(":first");break;case a.ui.keyCode.PAGE_UP:i=false;r._scrollPage("up");break;case a.ui.keyCode.PAGE_DOWN:i=false;r._scrollPage("down");break;case a.ui.keyCode.END:i=false;r._moveFocus(":last");break;case a.ui.keyCode.ENTER:case a.ui.keyCode.SPACE:i=false;r.close(j,true);a(j.target).parents("li:eq(0)").trigger("mouseup");break;case a.ui.keyCode.TAB:i=true;r.close(j);break;case a.ui.keyCode.ESCAPE:i=false;r.close(j,true);break;default:i=false;r._typeAhead(j.keyCode,"focus");break}return i});if(f.style=="dropdown"){this.newelement.addClass(r.widgetBaseClass+"-dropdown");this.list.addClass(r.widgetBaseClass+"-menu-dropdown")}else{this.newelement.addClass(r.widgetBaseClass+"-popup");this.list.addClass(r.widgetBaseClass+"-menu-popup")}this.newelement.prepend('<span class="'+r.widgetBaseClass+'-status">'+b[this._selectedIndex()].text+"</span>");this.element.hide();if(this.element.attr("disabled")==true){this.disable()}this.value(this._selectedIndex())},destroy:function(){this.element.removeData(this.widgetName).removeClass(this.widgetBaseClass+"-disabled "+this.namespace+"-state-disabled").removeAttr("aria-disabled");a("label[for="+this.newelement.attr("id")+"]").attr("for",this.element.attr("id")).unbind("click");this.newelement.remove();this.list.remove();this.element.show()},_typeAhead:function(f,e){var b=this;if(!b._prevChar){b._prevChar=["",0]}var h=String.fromCharCode(f);c=h.toLowerCase();var d=false;function g(i,j){d=true;a(i).trigger(e);b._prevChar[1]=j}this.list.find("li a").each(function(j){if(!d){var k=a(this).text();if(k.indexOf(h)==0||k.indexOf(c)==0){if(b._prevChar[0]==h){if(b._prevChar[1]<j){g(this,j)}}else{g(this,j)}}}});this._prevChar[0]=h},_uiHash:function(){return{value:this.value()}},open:function(d){var b=this;this._refreshPosition();this._closeOthers(d);this.newelement.attr("aria-expanded",true).addClass("ui-state-active");this.list.appendTo("body").addClass(b.widgetBaseClass+"-open").attr("aria-hidden",false).find("li:not(."+b.widgetBaseClass+"-group):eq("+this._selectedIndex()+") a").focus();if(this.options.style=="dropdown"){this.newelement.removeClass("ui-corner-all").addClass("ui-corner-top")}this._refreshPosition();this._trigger("open",d,this._uiHash())},close:function(d,b){if(this.newelement.is(".ui-state-active")){this.newelement.attr("aria-expanded",false).removeClass("ui-state-active");this.list.attr("aria-hidden",true).removeClass(this.widgetBaseClass+"-open");if(this.options.style=="dropdown"){this.newelement.removeClass("ui-corner-top").addClass("ui-corner-all")}if(b){this.newelement.focus()}this._trigger("close",d,this._uiHash())}},change:function(b){this.element.trigger("change");this._trigger("change",b,this._uiHash())},select:function(b){this._trigger("select",b,this._uiHash())},_closeOthers:function(b){a("."+this.widgetBaseClass+".ui-state-active").not(this.newelement).each(function(){a(this).data("selectelement").selectmenu("close",b)});a("."+this.widgetBaseClass+".ui-state-hover").trigger("mouseout")},_toggle:function(d,b){if(this.list.is("."+this.widgetBaseClass+"-open")){this.close(d,b)}else{this.open(d)}},_formatText:function(b){return this.options.format?this.options.format(b):b},_selectedIndex:function(){return this.element[0].selectedIndex},_selectedOptionLi:function(){return this._optionLis.eq(this._selectedIndex())},_focusedOptionLi:function(){return this.list.find("."+this.widgetBaseClass+"-item-focus")},_moveSelection:function(e){var d=parseInt(this._selectedOptionLi().data("index"),10);var b=d+e;return this._optionLis.eq(b).trigger("mouseup")},_moveFocus:function(e){if(!isNaN(e)){var d=parseInt(this._focusedOptionLi().data("index"),10);var b=d+e}else{var b=parseInt(this._optionLis.filter(e).data("index"),10)}if(b<0){b=0}if(b>this._optionLis.size()-1){b=this._optionLis.size()-1}this._focusedOptionLi().find("a:eq(0)").blur();this._optionLis.eq(b).find("a:eq(0)").focus()},_scrollPage:function(d){var b=Math.floor(this.list.outerHeight()/this.list.find("li:first").outerHeight());b=(d=="up")?-b:b;this._moveFocus(b)},_setData:function(b,d){this.options[b]=d;if(b=="disabled"){this.element.add(this.newelement).add(this.list)[d?"addClass":"removeClass"](this.widgetBaseClass+"-disabled "+this.namespace+"-state-disabled").attr("aria-disabled",d)}},value:function(b){if(arguments.length){this.element[0].selectedIndex=b;this._refreshValue();this._refreshPosition()}return this.element[0].selectedIndex},_refreshValue:function(){var d=(this.options.style=="popup")?" ui-state-active":"";this.list.find("."+this.widgetBaseClass+"-item-selected").removeClass(this.widgetBaseClass+"-item-selected"+d).find("a").attr("aria-selected","false");this._selectedOptionLi().addClass(this.widgetBaseClass+"-item-selected"+d).find("a").attr("aria-selected","true");var b=this.newelement.data("optionClasses")?this.newelement.data("optionClasses"):"";var e=this._selectedOptionLi().data("optionClasses")?this._selectedOptionLi().data("optionClasses"):"";this.newelement.removeClass(b).data("optionClasses",e).addClass(e).find("."+this.widgetBaseClass+"-status").html(this._selectedOptionLi().find("a:eq(0)").html())},_refreshPosition:function(){this.list.css("left",this.newelement.offset().left);var b=this.newelement.offset().top;var d=this.list[0].scrollTop;this.list.find("li:lt("+this._selectedIndex()+")").each(function(){d-=a(this).outerHeight()});if(this.newelement.is("."+this.widgetBaseClass+"-popup")){b+=d;this.list.css("top",b)}else{b+=this.newelement.height();this.list.css("top",b)}}});a.extend(a.ui.selectmenu,{getter:"value",version:"@VERSION",eventPrefix:"selectmenu",defaults:{transferClasses:true,style:"popup",width:null,menuWidth:null,handleWidth:26,maxHeight:null,icons:null,format:null}})})(jQuery);


	/**
	 * --------------------------------------------------------------------
	 * jQuery-Plugin "pngFix"
	 * Version: 1.1, 11.09.2007
	 * by Andreas Eberhard, andreas.eberhard@gmail.com
	 *                      http://jquery.andreaseberhard.de/
	 *
	 * Copyright (c) 2007 Andreas Eberhard
	 * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
	 */
	eval(function(p,a,c,k,e,r){e=function(c){return(c<62?'':e(parseInt(c/62)))+((c=c%62)>35?String.fromCharCode(c+29):c.toString(36))};if('0'.replace(0,e)==0){while(c--)r[e(c)]=k[c];k=[function(e){return r[e]||e}];e=function(){return'([237-9n-zA-Z]|1\\w)'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(s(m){3.fn.pngFix=s(c){c=3.extend({P:\'blank.gif\'},c);8 e=(o.Q=="t R S"&&T(o.u)==4&&o.u.A("U 5.5")!=-1);8 f=(o.Q=="t R S"&&T(o.u)==4&&o.u.A("U 6.0")!=-1);p(3.browser.msie&&(e||f)){3(2).B("img[n$=.C]").D(s(){3(2).7(\'q\',3(2).q());3(2).7(\'r\',3(2).r());8 a=\'\';8 b=\'\';8 g=(3(2).7(\'E\'))?\'E="\'+3(2).7(\'E\')+\'" \':\'\';8 h=(3(2).7(\'F\'))?\'F="\'+3(2).7(\'F\')+\'" \':\'\';8 i=(3(2).7(\'G\'))?\'G="\'+3(2).7(\'G\')+\'" \':\'\';8 j=(3(2).7(\'H\'))?\'H="\'+3(2).7(\'H\')+\'" \':\'\';8 k=(3(2).7(\'V\'))?\'float:\'+3(2).7(\'V\')+\';\':\'\';8 d=(3(2).parent().7(\'href\'))?\'cursor:hand;\':\'\';p(2.9.v){a+=\'v:\'+2.9.v+\';\';2.9.v=\'\'}p(2.9.w){a+=\'w:\'+2.9.w+\';\';2.9.w=\'\'}p(2.9.x){a+=\'x:\'+2.9.x+\';\';2.9.x=\'\'}8 l=(2.9.cssText);b+=\'<y \'+g+h+i+j;b+=\'9="W:X;white-space:pre-line;Y:Z-10;I:transparent;\'+k+d;b+=\'q:\'+3(2).q()+\'z;r:\'+3(2).r()+\'z;\';b+=\'J:K:L.t.M(n=\\\'\'+3(2).7(\'n\')+\'\\\', N=\\\'O\\\');\';b+=l+\'"></y>\';p(a!=\'\'){b=\'<y 9="W:X;Y:Z-10;\'+a+d+\'q:\'+3(2).q()+\'z;r:\'+3(2).r()+\'z;">\'+b+\'</y>\'}3(2).hide();3(2).after(b)});3(2).B("*").D(s(){8 a=3(2).11(\'I-12\');p(a.A(".C")!=-1){8 b=a.13(\'url("\')[1].13(\'")\')[0];3(2).11(\'I-12\',\'none\');3(2).14(0).15.J="K:L.t.M(n=\'"+b+"\',N=\'O\')"}});3(2).B("input[n$=.C]").D(s(){8 a=3(2).7(\'n\');3(2).14(0).15.J=\'K:L.t.M(n=\\\'\'+a+\'\\\', N=\\\'O\\\');\';3(2).7(\'n\',c.P)})}return 3}})(3);',[],68,'||this|jQuery||||attr|var|style||||||||||||||src|navigator|if|width|height|function|Microsoft|appVersion|border|padding|margin|span|px|indexOf|find|png|each|id|class|title|alt|background|filter|progid|DXImageTransform|AlphaImageLoader|sizingMethod|scale|blankgif|appName|Internet|Explorer|parseInt|MSIE|align|position|relative|display|inline|block|css|image|split|get|runtimeStyle'.split('|'),0,{}))



	/**
 **************************************************
 * Javascript USERFUNCTIONS
 * userfunctions.js
 *
 * @author: HDNET GmbH & Co. KG
 * @version: 2.0
 * @updated: 2009-10-07 (AH)
 **************************************************
**/
function wait(msecs) {
	var start = new Date().getTime();
	var cur = start
	while(cur - start < msecs) {
		cur = new Date().getTime();
	}
}

/**
 **************************************************
 WEITERLEITUNG
 *
 * @description redirect to given URL
 **************************************************
**/
function goToUrl(aUrl){
	document.location.href = aUrl;
}



/**
 **************************************************
 GLOBAL DEFINITIONS
 *
 * @description: global domready function for all functions
 * run jQuery in noConflict mode
 **************************************************
**/
/* no conflict mode - it works besides prototype */
//var $j = jQuery.noConflict();
jQuery.noConflict();

/* *** GLOBAL domReady begin *** */
jQuery(document).ready(function() {




/**
 **************************************************
 SUCKERFISH SCRIPT
 *
 * @description: pseudo classes for ie6
 **************************************************
**/
jQuery('ul#navMain li').each(function() {
	jQuery(this).children('div.lvl2').children('ul:last').addClass('last');
});

jQuery('ul#navMain li').mouseenter(function(event) {
	var subObject = jQuery(this).children('div.lvl2').children('ul');
	var cS = jQuery(subObject).size();

	jQuery(subObject).each(function() {
		var breite = jQuery(this).css('width');
		var name = jQuery(this).get(0).tagName;
		var singleBreite = breite.replace('px','');

		/*var addWidth = 42;

		if(jQuery.browser.msie && jQuery.browser.version*1 < 7 && cS != 1) {
			var addWidth = 500;
		}

		if(cS == 1) {
			var addWidth = 0;
		} */

		var ulBreite = singleBreite*cS;

		jQuery(this).parent().parent().find('div.lvl2').css({'width':ulBreite});
	});
});


jQuery.fn.suckerfish = function() {
//	if (jQuery.browser.msie && jQuery.browser.version*1 < 7) {
		//this.find('li').hover(function() {
		jQuery(this).find('li.normal').mouseenter(function(event) {
			wait(MENU_DELAY);
			//alert($(this));
			jQuery(this).addClass('over');


		/*
			setTimeout(function() {
				//jQuery(this).find('li').find().('div.divider').fadeIn(500);
				jQuery(this).children('ul').fadeIn(500);
            },2000);


			jQuery(this).addClass('over').wait(1000, function(){
				jQuery(this).find('ul.subList').css({'height':'70px'});
			});*/

			//jQuery(this).fadeOut(1000, function() {
			//	alert(jQuery(this));
			//	jQuery(this).addClass('over');
			//}).addClass('normal');
    	});

    	jQuery(this).find('li.normal').mouseleave(function(event) {
			jQuery(this).removeClass('over');
		});


//		$('#image1') . animate( { 'width' : 0 }, function() {
//    $('#image1').removeClass( 'animating' );
//}) . addClass('animating');

//	}
}


jQuery('ul#navMain').suckerfish();
jQuery('ul#navMain div.lvl2').mouseenter(function(event) {
		wait(0);
    	jQuery(this).parent().find('a').addClass('over');
    	jQuery(this).parent().find('a').triggerHandler('mouseover');
    	return false;
});

jQuery('ul#navMain div.lvl2').mouseleave(function(event) {
    	jQuery(this).parent().find('a').removeClass('over');
    	jQuery(this).parent().find('a').triggerHandler('mouseout');
    	// AH: To make sure even IE6 understands it...
    	jQuery(this).parent().removeClass('over');
    	return false;
});


/*
var hiConfig = {
     sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)
     interval: 200, // number = milliseconds for onMouseOver polling interval
     over: makeTall, // function = onMouseOver callback (REQUIRED)
     timeout: 500, // number = milliseconds delay before onMouseOut
     out: makeShort // function = onMouseOut callback (REQUIRED)
};


jQuery('ul#navMain li').hoverIntent({
	sensitivity: 3,
	interval: 200,
	over: makeTall,
	timeout: 500,
	out: makeShort
});
*/



/**
 **************************************************
 DETAIL SLIDE - SLIDE EVENT / SLIDER SIDBAR
 *
 * @description: enable the sliding event and toggle
 * hover and act classes
 **************************************************
**/
/* detail slider */
// initialize scrollable
jQuery("div.detailSlider div.nav").scrollable({
    size:6,
    items:'.items',
    hoverClass:'hover'
});

/* detail slider thumbails*/
//initialize scrollable
jQuery("div.detailMedia div.thumbnailNav").scrollable({
	size:5,
	items:'.items',
    hoverClass:'hover'
});

/* slider sidebar */
// initialize scrollable
jQuery("div.slider div.nav").scrollable({
    size:2,
    items:'.items',
    hoverClass:'',
    vertical:true
});




/**
 **************************************************
 DETAIL SLIDE - TOGGLE PRODUCT DETAIL
 *
 * @description: toggles the detail views of the
 * slider
 **************************************************
**/
/*
jQuery('.detailSlider .items li').click(function() {

    // get id from trigger element
    id = jQuery(this).attr('id');

    // set id from event element with the trigger id
    idDetail = id+'detail';

    // toggle the event elements
    jQuery('.detailSlider .item').css('display','none');
    jQuery('#'+idDetail).fadeIn('fast');
});
*/



/**
 **************************************************
 TAB CONTENT
 *
 * @description: toggles the content of the
 * box via tab links; toggles act classes
 **************************************************
**/
jQuery(".tabContent .content").tabs();

jQuery.fn.getTabContent = function(tab) {
	var tabs = jQuery('.tabContent .content').tabs();

   	tabs.tabs('select',tab);
   	//tabs.tabs('option', 'spinner', 'Retrieving data...');

}




/**
 **************************************************
 DIALOG WINDOW
 *
 * @description: opens a dialog window with jQuery UI
 * trigger is the link in the memo box
 **************************************************
**/
//	$(function() {
/*
jQuery('#navAccount .memo').click(function() {
    var dialog = jQuery("<div id='dialog'></div>").insertAfter('#page');
    jQuery(dialog).load("preisvergleich.html", function() {

    	jQuery(dialog).dialog({
    		resizable:true,
    		//autoOpen:false,
    		width:1100,
    		height:400,
        	maxHeight:800,
    		maxWidth:1400,
    		minHeight:400,
    		minWidth:1100,
        	modal:true
    	});

    	jQuery('#dialog .close').click(function() {
    		//$('#page').remove(dialog);
    		window.close();
    		//$('#page').remove(this);
    		return false;
    	});

    });
    return false;
});
*/

/* *** ONLY CLOSE the POPUP *** */
jQuery('#dialog .close').click(function() {
	window.close();
    return false;
});




/**
 **************************************************
 FORM FIELDS FOCUS CLASSES
 *
 * @description: set focus classes in text and area
 * fields to change the background; no niceforms!
 **************************************************
**/
/*
jQuery('form input').focus( function() {
    $p = this.parentNode;
    jQuery($p).addClass('focus');
}).blur( function() {
    $p = this.parentNode;
    jQuery($p).removeClass('focus');
});
jQuery('form textarea').focus( function() {
    $p = this.parentNode;
    jQuery($p).addClass('focus');
}).blur( function() {
    $p = this.parentNode;
    jQuery($p).removeClass('focus');
});

*/

jQuery('form textarea#frage').click( function(event) {
	jQuery(this).val('');
});



/**
 **************************************************
 EXPAND CATEGORY LISTS
 *
 * @description: hide and show li elements in cat lists
 **************************************************
**/
jQuery('.cat a.expand').click(function () {

	jQuery(this).html(jQuery(this).html() == '<span>alle anzeigen</span><span class="ico"></span>' ? '<span>einklappen</span><span class="ico"></span>' : '<span>alle anzeigen</span><span class="ico"></span>');
	jQuery(this).toggleClass('expanded');
    jQuery(this).parent().find('ul li').toggleClass('show');

   	return false;
});




/**
 **************************************************
 BOOKMARKLINK
 *
 * @description: set the actual site as bookmark
 **************************************************
**/
jQuery.fn.bookmarksite = function(title,url) {
	if(document.all) {
		window.external.AddFavorite(url, title);
	} else if(window.sidebar) {
		window.sidebar.addPanel(title, url, "")
	}
}




/**
 **************************************************
 EXPAND SERVICE BUTTON
 *
 * @description: hide and show the service nav
 **************************************************
**/
jQuery('.service .content a').click( function() {
    jQuery('.slideNav').toggle();
	return false;
});




/**
 **************************************************
 jNice for FORMS
 *
 * @description: activate the jquery.niceforms plugin
 * for every form with the class jNice
 **************************************************
**/
jQuery('form.jNice').jNice();




/**
 **************************************************
 STORE LOCATOR
 *
 * @description: store locator select field - redirect
 * onchange to the selected store
 **************************************************
**/
jQuery('select#city').change( function() {
	var wert = this.options[this.options.selectedIndex].value;

	if(wert == 'none') {
    	return;
	} else {
    	document.location.href = "http://www.pcspezialist-store.de/"+wert+"/";
  	}
});




/**
 **************************************************
 SWITCH ARROWS IN PAYMENT
 *
 * @description: set the actual arrow as visible
 **************************************************
**/
jQuery.fn.showArrow = function(code) {
    jQuery('#paymentItem'+code).find('.info').css('display', 'block');
};

jQuery.fn.hideArrow = function(code) {
    jQuery('#paymentItem'+code).find('.info').css('display', 'none');
};

   // arrow = jQuery(this).children('.detailMethod').children('.info').html();
   // alert(arrow);
   // jQuery(arrow).toggle();
//}




/**
 **************************************************
 SELECT FIELDS with jQuery UI selectable
 *
 * @description: replace the select fields with jQuery UI
 * for styling the fields
 **************************************************
**//*
jQuery('select#city').selectmenu({
	style:'dropdown',
	menuWidth: 174,
	maxHeight: 250
});
*/


/**
 **************************************************
 IE 5.5 / & PNGFIX
 *
 * @description: activate the jquery.pngfix for ie5.5
 * and ie6
 **************************************************
**/
jQuery('.pngFix').pngFix();


/* *** GLOBAL domReady end *** */
});