(function($){
	
	$(document).ready(function(){
	


		
	//Bookmark
	
	try {
		$('#top_user_nav .bookmark').css('display', 'block').click(function(){
			var url = window.location.href
			var title = $('head title').html();
			if (window.sidebar) { // Mozilla Firefox Bookmark
				window.sidebar.addPanel(title, url, '');
			} else if( window.external ) { // IE Favorite
				window.external.AddFavorite( url, title);
			} else if(window.opera) { // Opera 7+
				return false; // do nothing - the rel="sidebar" should do the trick
			} else { // for Safari, Konq etc - browsers who do not support bookmarking scripts (that i could find anyway)
				 alert('Unfortunately, this browser does not support the requested action,'
				 + ' please bookmark this page manually.');
			}
			return false;
		});
	}
	catch(e) { }
	
	
	//Input default text
	window.check_inputs = function(){
		$('.input_default_text').each(function(){
			if(!this._default_text){
				this._default_text = this.value;
				if(this.type == 'password'){
					this._text_input = document.createElement('input');
					
					this._text_input.type = 'text';
					this._text_input.className = this.className;
					this._text_input._text_password = this;
					this._text_input.value = this.value;
					this.value = '';
					
					$(this).removeClass('default_text');
					
					$(this._text_input).css({
						'position': 'absolute',
						'top': $(this).position().top + 'px',
						'left': $(this).position().left + 'px',
						'margin-top': '0',
						'display': 'block'
						});
					
					this.parentNode.appendChild(this._text_input);
					
					$(this.parentNode).css({'height': $(this.parentNode).outerHeight() + 'px'});
					
					$(this._text_input).focus(function(){
						$(this).css({'display': 'none'});
						$(this._text_password).focus();
					});
					
					$(this).focus(function(){
						if( $(this._text_input).css('display') == 'block' )
							$(this._text_input).focus();
					});
					$(this).change(function(){
						if( $(this._text_input).css('display') == 'block' )
							$(this._text_input).focus();
					});
					
					
					$(this).blur(function(){
						if(this.value == '')
							$(this._text_input).css({'display': 'block'});
					});
					
					}
				else {
					$(this).focus(function(){
						if(this.value == this._default_text){
							this.value = '';
							$(this).removeClass('default_text');
							}
						return true;
					});
					$(this).blur(function(){
						if(this.value == ''){
							$(this).addClass('default_text');
							this.value = this._default_text;
							}
						return true;
					});
					}
				}
		});
	};
	window.check_inputs();

	var simple_inputs = function(){
		$('.text.simple').each(function(){
			if(!this._default_text){
				this._default_text = this.value;

				$(this).focus(function(){
					if(this.value == this._default_text){
						this.value = '';
						$(this).removeClass('default_text');
						}
					return true;
				});
				$(this).blur(function(){
					if(this.value == ''){
						$(this).addClass('default_text');
						this.value = this._default_text;
						}
					return true;
				});
				}
		});
	};
	simple_inputs();
	
	
	
	//!Spinner
	$('.input_spinner').each(function(){
		
		$('.plus', this).click(function(){
			var input = $('input', $(this).parent());
			if(parseInt(input.val()) < parseInt(input.attr('alt')))
				input.val(parseInt(input.val()) + 1);
		}).disableTextSelect();
		
		$('.minus', this).click(function(){
			var input = $('input', $(this).parent());
			
			if(parseInt(input.val()) > 0)
				input.val(parseInt(input.val()) - 1);
		}).disableTextSelect();
		
		
	});
	
	//Lightbox controller
	window.cover = {
		'wrapper': false,
		'cover': false,
		'visible': false,
		'render': function(){
			if(this.cover)
				$(this.cover).css({
					'width': '100%',
					'height': $(document).height() + 'px'
				});
			
			if(this.wrapper)
				$(this.wrapper).css({
					'top':  parseInt( ($(window).height() / 2)  - ( this.height / 2 ) ) + $(document).scrollTop()   + 'px',
					'left': parseInt( ($(window).width() / 2) - ( this.width / 2 ) + document.body.scrollLeft ) + 'px'
				});
			},
		'resize': function(){
			
			},
		'show': function(width, height, html){
			
			if( typeof width == 'function' ){
				html = width;
				width = 100;
				height = 100;
				}
			
			height -= 70;
			
			this.width = width;
			this.height = height;
			this.html = html;
			
			
			if(!this.cover){
				this.cover = document.createElement('div');
				$(this.cover).css({
					'width': '100%',
					'height': $(document).height() + 'px',
					'background': '#000',
					'position': 'absolute',
					'top': '0px',
					'left': '0',
					'right': '0',
					'opacity': 0.4,
					'z-index': 99,
					'display': 'none'
				}).addClass('lightbox_cover_wrapper').click(function(){
					cover.hide();
					});
				$(document.body).append(this.cover);
				
				this.render();
				$(window).resize(function(){
					window.cover.render();
				});
				
				}
			else
				this.render();
			
			if(!this.wrapper){
				this.wrapper = document.createElement('div');
				$(this.wrapper).css({
					'background': '#FFF',
					'border': '1px solid #000',
					'padding': '35px 25px',
					'position': 'absolute',
					'display': 'none',
					'z-index': 998
				}).addClass('lightbox_content_wrapper').html('<a class="close">X</a><div class="lightbox_content"></div>');
				$(document.body).append(this.wrapper);
				$('.close', this.wrapper).click(function(){
					cover.hide();
					return false;
				});
				}
			
			$(this.wrapper).css({
				'width': width + 'px',
				'height': height + 'px',
				'top':  parseInt( ($(window).height() / 2)  - ( height / 2 ) ) + $(document).scrollTop()   + 'px',
				'left': parseInt( ($(window).width() / 2) - ( width / 2 ) + document.body.scrollLeft ) + 'px',
				'opacity': 0,
				'display': 'block'
			});
			
			if( typeof html == 'function'){
				$('.lightbox_content', this.wrapper).html('<div class="loading">loading</div>');
				html.call($('.lightbox_content', this.wrapper).get(0));
				}
			else
				$('.lightbox_content', this.wrapper).html(html);
			
			
			check_inputs();
			$(this.cover).css({'opacity': 0, 'display': 'block'}).animate({'opacity': 0.4}, 'fast', null, function(){
				$(cover.wrapper).animate({'opacity': 1}, 'fast');
			});
			this.visible = true;
			},
		'hide': function(){
			$(this.wrapper).animate({'opacity': 0}, 'fast', null, function(){
				$(this).css({'display': 'none'});
			});
			$(this.cover).animate({'opacity': 0}, 'fast', null, function(){
				$(this).css({'display': 'none'});
			});
			this.visible = false;
			}
		};
	$(document).keypress(function(ev){
		if(cover.visible && ev.keyCode == 27)
			cover.hide();
	});
	
	
	
	//Sub Menu
	(function(){
		//Init
		var mm = $('#main_menu').innerWidth();
		$('#submenu_wrapper ul').each(function(){
			$(this).css({
				'opacity': 0,
				'display': 'block'
			});
			
			
			var li_controller = $('#main_menu .pages .' + this.className);
			
			var width = 0;
			$('li', this).each(function(){
				width += $(this).width();
			});
				
			this._left = parseInt( ((li_controller.width() / 2) + li_controller.position().left) - (width / 2) );
			
			if($('#main_menu').innerWidth() < this._left + width)
				this._left = mm - width
			if(this._left < 0)
				this._left = 0;
			
			$(this).css({
				'width': (mm - this._left) + 'px',
				'padding-left': this._left + 'px'
			});
			
			$(this).get(0)._opacity = 0;
		});
		
		var current = $('#submenu_wrapper').attr('class');
		var current_submenu = false;
		var current_menu = false;
		
		if(current){
			current_menu = $('#main_menu .' + current).addClass('selected');
			current_submenu = $('#submenu_wrapper .' + current).css({
				'opacity': 1,
				'z-index': 2
			});
			}
		
		
		var fade_in = function(){
			
			if(typeof this._opacity == 'undefined')
				this._opacity = 0;
			
			if(this._opacity < 100){
				this._opacity += 15;
				$(this).css('opacity', this._opacity / 100);
				return true;
				}
			else{
				this._opacity = 100;
				$(this).css('opacity', this._opacity / 100); 
				return false;
				}
			}

		var fade_out = function(){
			
			if(typeof this._opacity == 'undefined')
				this._opacity = 0;
			
			if(this._opacity > 0){
				this._opacity -= 4;
				$(this).css('opacity', this._opacity / 100); 
				return true;
				}
			else{
				this._opacity = 0;
				$(this).css('opacity', this._opacity / 100); 
				return false;
				}
			}
		
		
		
		$('.pages').mouseout(function(ev){
			var is_mainmenu = $(ev.relatedTarget).parents('.pages').length ? true : false;
			var is_submenu = $(ev.relatedTarget).parents('#submenu_wrapper').length ? true : false;
			if(!is_mainmenu && !is_submenu && current_submenu && current_submenu.get(0).className != current){
				current_submenu.css('z-index', 1);
				ijs.worker.add('img_' + current_submenu.get(0).className, fade_out, current_submenu);
				current_menu.removeClass('selected');
				current_submenu = current_menu = false;
				if(current){
					current_menu = $('#main_menu .' + current);
					current_submenu = $('#submenu_wrapper .' + current);
					current_submenu.css('z-index', 2);
					current_menu.addClass('selected');
					ijs.worker.add('img_' + current, fade_in, current_submenu);
					}
				}
		});
		
		
		$('#submenu_wrapper').mouseout(function(ev){
			var is_mainmenu = $(ev.relatedTarget).parents('.pages').length ? true : false;
			var is_submenu = $(ev.relatedTarget).parents('#submenu_wrapper').length ? true : false;
			
			if(!is_mainmenu && !is_submenu && current_submenu && current_submenu.get(0).className != current){
				current_submenu.css('z-index', 1);
				ijs.worker.add('img_' + current_submenu.get(0).className, fade_out, current_submenu);
				current_menu.removeClass('selected');
				current_submenu = current_menu = false;
				if(current){
					current_menu = $('#main_menu .' + current);
					current_submenu = $('#submenu_wrapper .' + current);
					current_submenu.css('z-index', 2);
					current_menu.addClass('selected');
					ijs.worker.add('img_' + current, fade_in, current_submenu);
					}
				}
		});
	
		
		$('#main_menu .pages a').mouseover(function(ev){
			
			var className = this.parentNode.className.replace(/first /, '').replace(/ selected/, '');
			
			if(!current_submenu || current_submenu.get(0).className != className){
				if(current_submenu){
					ijs.worker.add('img_' + current_submenu.get(0).className, fade_out, current_submenu);
					current_menu.removeClass('selected');
					current_submenu.css('z-index', 1);
					}
				
				current_menu = $(this.parentNode);
				current_submenu = $('#submenu_wrapper .'+ className);;
				current_submenu.css('z-index', 2);
				current_menu.addClass('selected');
				ijs.worker.add('img_' + className, fade_in, current_submenu);
				}
			
		});
	})();
	
	
	$('.products .meta h2 em').each(function(){
		
		$('.brands img[alt="'+ this.innerHTML +'"]').each(function(){
			if( !this._swapped ) {
				var url = this.src.split('.');
				url[url.length - 2] += '_hover';
				this.src = url.join('.');
				this._swapped = true;
				this._url = this.src;
			}
		});
		
	});
	
	
	
	//Swap color image 
	$('.add-color img').hover(
		function(){
			if( !this._swapped ) {
				this._url = this.src;
				var url = this.src.split('.');
				url[url.length - 2] += '_hover';
				this.src = url.join('.');
				this._swapped = true;
			}
		},
		function(){
			if( this.src != this._url ) 
				this._swapped = false;
			this.src = this._url;
			}
		);
	
	
	$('.fade-images').each(function(){
		var images = [];
		var current = 0;
		var delay = $('.images', this).attr('alt') ? parseInt($('.images', this).attr('alt')) : 3000;
		var main_img = $('img', this).css({'z-index': 2});
		var link = $('a:first', this);
		main_img.get(0)._link = link.attr('href');
		main_img.get(0)._title = link.attr('title');
		images.push(main_img);

		$('.images a', this).each(function(){
			var img = document.createElement('img');
			img.src = $(this).attr('alt');
			$(img).css({
				'z-index': 1,
				'opacity': 0
				});
			img._link = $(this).attr('href');
			img._title = $(this).html();
			main_img.parent().append(img);
			images.push($(img));
			
			$(img).css('left', - $(img).position().left + 'px');
		});
		
		var clear_interval = false
		var fade = function(){
			current++;
			if(current > images.length - 1)
				current = 0;
			
			images[current].css({'opacity': 0, 'z-index': !current ? 3 : 2}).animate({'opacity': 1}, 1200, null, function(){
				images[current].css({'z-index': 2});
				images[current - 1 < 0 ? images.length - 1 : current - 1 ].css({'z-index': 1});
				link.attr('href', images[current].get(0)._link);
				link.attr('title', images[current].get(0)._title);
				
				});
			};
		if($('.images a', this).length) {
			var cicle_interval = setInterval(fade, delay);
			$('img', this).hover(
				function(){
					clearInterval(cicle_interval);
				}, function(){
					 cicle_interval = setInterval(fade, delay);
				});
		}
		
	});
	
	
	
	
	
	$('.accordion-menu li').not('.selected').each(function(){
		this._ul = $('ul', this);
		if(this._ul.length){
			this._ul_height = this._ul.get(0).scrollHeight + 'px';
			$(this).hover(
				function(){
					this._ul.animate({'height': this._ul_height}, {'duration': 'slow', 'queue': false});
					},
				function(){
					this._ul.animate({'height': '0px'}, {'duration': 'slow', 'queue': false});
					}
				);
			}
	});
		
	
	$('.image-zoomer').each(function(){
		var full_wrapper = $('.image_full img', this).css('cursor', 'pointer').click(function(){
			zoom.click();
			return false;
		});
		
		
		full_wrapper.parent().mousemove(function(ev){
			if(full_wrapper._zoom){
				this.scrollLeft =  (ev.pageX - $(this).offset().left) / $(this).outerWidth() * (this.scrollWidth - $(this).outerWidth());
				this.scrollTop =  (ev.pageY - $(this).offset().top) / $(this).outerHeight() * (this.scrollHeight - $(this).outerHeight());
				}
		});
		
		var loading = document.createElement('div');
		loading = $(loading);
		loading.css({
			'position': 'absolute',
			'top': '0px',
			'left': '0px',
			'padding': '10px',
			'background': '#FFF',
			'display': 'none'
		}).html('loading...');
		full_wrapper.parent().append(loading);
		
		
		full_wrapper.load(function(){
			if(full_wrapper._loading){
				loading.css('display', 'none');
				full_wrapper._zoom = true;
				full_wrapper._loading = false;
				full_wrapper.parent().addClass('zoom');
				full_wrapper.css('cursor', 'crosshair');
			}
		});
		
		
		
		var zoom = $('.zoom_bloc .zoom', this).click(function(){
			//window.cover.show(full_wrapper.width(), full_wrapper.height() + 50, '<img src="'+ full_wrapper.attr('src') +'" />');
			if(!full_wrapper._zoom){
				full_wrapper._loading = true;
				full_wrapper.attr('rel', full_wrapper.attr('src'));
				full_wrapper.attr('src', $(this).attr('rel'));
				full_wrapper.parent().get(0).scrollLeft = 0;
				full_wrapper.parent().get(0).scrollTop = 0;
				if( !$.browser.msie && parseInt($.browser.version) != 6 )
					loading.css('display', 'block');
				$(this).addClass('minus');
			} else {
				full_wrapper.parent().removeClass('zoom');
				full_wrapper._zoom = false;
				full_wrapper.css('cursor', 'pointer');
				full_wrapper.attr('src', full_wrapper.attr('rel'));
				full_wrapper.parent().get(0).scrollLeft = 0;
				full_wrapper.parent().get(0).scrollTop = 0;
				$(this).removeClass('minus');
				}
			return false;
		});
		// !Zoom
		$('.thumbs a', this).not('.zoom').click(function(){
			var img = $(this).attr('href');
			var full = $(this).attr('rel');
			full_wrapper.animate({'opacity': 0}, 'fast', null, function(){
				full_wrapper._zoom = false;
				full_wrapper.parent().get(0).scrollLeft = 0;
				full_wrapper.parent().get(0).scrollTop = 0;
				full_wrapper.css('cursor', 'pointer');
				full_wrapper.parent().removeClass('zoom');
				zoom.attr('href', img);
				zoom.attr('rel', full);
				if(!full_wrapper.get(0)._onload){
					full_wrapper.get(0)._onload = true;
					full_wrapper.load(function(){
						full_wrapper.animate({'opacity': 1}, 'fast');
						});
					}
				full_wrapper.attr('src', img);
			});
			return false;
		});
	});
	
	});
	
	$(window).load(function(){
		$('.marque-scroller').each(function(){
		
			var scrollWidth = this.scrollWidth;
			var delay = 50;
			var wrapper = $(this).css({'height': $(this).height() + 'px'});
			var scroll_offset = scrollWidth;
			var step = 2;
			
			
			var scroll_wrapper = document.createElement('div');
			scroll_wrapper = $(scroll_wrapper).html(this.innerHTML).css({
				'position': 'absolute',
				'top': parseInt($(this).css('padding-top')) + 'px',
				'left': '0px',
				'width': scrollWidth + 'px'
				});
			
			var clone_wrapper = document.createElement('div');
			clone_wrapper = $(clone_wrapper).html(this.innerHTML).css({
				'position': 'absolute',
				'top': parseInt($(this).css('padding-top')) + 'px',
				'left': scrollWidth + 'px',
				'width': scrollWidth + 'px'
				});
				
			this.innerHTML = '';
			this.appendChild(scroll_wrapper.get(0));
			this.appendChild(clone_wrapper.get(0));
			
			$('.add-color img').hover(
				function(){
					this._url = this.src;
					var url = this.src.split('.');
					url[url.length - 2] += '_hover';
					this.src = url.join('.');
					},
				function(){
					this.src = this._url;
					}
				);
			
			wrapper.scrollLeft(scrollWidth);
			
			var scroll = function(){
				wrapper.scrollLeft(scroll_offset);
				scroll_offset -= step;
				if(scroll_offset < 0){
					scroll_offset = scrollWidth;
					wrapper.scrollLeft(scrollWidth);
					}
				}
			
			var interval_id = setInterval(scroll ,delay);
			$(this).hover(
				function(){
					clearInterval(interval_id);
				},
				function(){
					interval_id = setInterval(scroll ,delay);
				});
			//*/
		});
	
	
	$('.refer_a_friend').not('.registered').click(function(){
		window.cover.show(350, 235, function(){
			var wrapper = $(this);
			$.get(config_dir+'index.php?fuseaction=ajax.refer_friend', {} , function(data, status){
				$(wrapper).html(data);
				window.check_inputs();
			});
		});
		return false;
	});
	
	
	$('.product_request_form').click(function(){
		window.cover.show(300, 255, function(){
			var wrapper = $(this);
			$.get(config_dir+'index.php?fuseaction=ajax.product_request', {} , function(data, status){
				$(wrapper).html(data);
				window.check_inputs();
			});
		});
		return false;
	});
	
	
	$('a.frogot_password').click(function(){
		window.cover.show(300, 150, function(){
			var wrapper = $(this);
			$.get(config_dir+'index.php?fuseaction=ajax.forgotten_password', {} , function(data, status){
				$(wrapper).html(data);
				window.check_inputs();
			});
		});
		return false;
	});
	
	if( window.showRegisterLightBox ) {
		
		window.cover.show(600, 450, function(){
			var wrapper = $(this);
			$.get(config_dir+'index.php?fuseaction=ajax.register', {} , function(data, status){
				$(wrapper).html(data);
				window.check_inputs();
			});
		});
		
	}	
	
	
	$('.add-to-cart').click(function(){
		var id = $(this).attr('rel');
		if (id == '#') {
			window.location.href = $('.moreinfo', $(this).parent()).attr('href');
		} else {
			window.cover.show(350, 235, function(){
				var wrapper = this;
				$.get(config_dir+'index.php?fuseaction=ajax.add_to_cart', {'option_id': id} , function(data, status){
					$(wrapper).html(data);
					$('.continue-shopping', wrapper).click(function(){
						window.cover.hide();
						return false;
					});
				});
				
				});
		}
		return false;
	});
	
	$('.ps_login').click(function(){
		window.cover.show(350, 150, function(){
			var wrapper = $(this);
			$.get(config_dir+'index.php?fuseaction=ajax.ps_login', {} , function(data, status){
				$(wrapper).html(data);
				window.check_inputs();
			});
		});
		return false;
	});

	// !Gestion des options
	//$('#select_options select').live('change', function(){
	$('#select_options select').livequery(function() {
	$(this).change(function(){
	//$('#select_options select').change(function() {
		//$('#test').html('.');
		current_cb = $(this);
		selected = '';
		// Récup de la valeur
		valeur = $(this).val();
		id = $(this).attr('alt');
		// Suppression des autres
		$('#select_options select').each(function(index) {
			selected += (selected) ? '_' + $(this).val() : $(this).val();
			if ($(this).html() != current_cb.html()){
				empty = $(this).attr('alt');
				$(this).html('');
			}
	  	});
		
		// Loading
		$('#loader').show();
		// Ajax
		$.get(
			config_dir+'index.php?fuseaction=ajax.update_option', 
			{ 
				option_id: id,
				value_id: valeur,
				product_id: $('#product_id').val(),
				selected: selected
			}, 
			function(data, status){
				// maj combos
				$('#option_'+id).html('');
				$('#option_'+id).html(data.init);
				if (typeof empty != 'undefined'){
					$('#option_'+empty).html(data.autres);
				}
				
				// mise à jour stock
				if (data.statut){
					$('#current_price').html(data.statut.price);
					$('#q').attr('alt', data.statut.stock);
					$('#option_id').val(data.statut.id);
				}
				
				// Changement de l'image
				if (data.image) {
					changeImageOption('/images/product/main/image'+data.image.id+'.'+data.image.imagetype, '/images/product/zoom/image'+data.image.id+'.'+data.image.imagetype);
				} else {
					first_thumb = $('.thumbs a');
					changeImageOption($(first_thumb[0]).attr('href'), $(first_thumb[0]).attr('rel'));
				}
				
				$('#loader').hide();
			},
			'json');

	});
	});
	
	function changeImageOption(img, full){
		var full_wrapper = $('.image_full img');
		var zoom = $('.zoom_bloc .zoom');
		full_wrapper.animate({'opacity': 0}, 'fast', null, function(){
		    full_wrapper._zoom = false;
		    full_wrapper.parent().get(0).scrollLeft = 0;
		    full_wrapper.parent().get(0).scrollTop = 0;
		    full_wrapper.css('cursor', 'pointer');
		    full_wrapper.parent().removeClass('zoom');
		    zoom.attr('href', img);
		    zoom.attr('rel', full);
		    if(!full_wrapper.get(0)._onload){
		    	full_wrapper.get(0)._onload = true;
		    	full_wrapper.load(function(){
		    		full_wrapper.animate({'opacity': 1}, 'fast');
		    		});
		    	}
		    full_wrapper.attr('src', img);
		});
		return false;
	}
	
	$('.submit-to-cart').click(function(){
		$(this).parent().submit();
		return false;
	});
	
	$('.frmAddToCart').submit(function(){
		var errorOptions = false;
		var qty = parseInt($('.input_spinner input', $(this)).val());
		var max = parseInt($('.input_spinner input', $(this)).attr('alt'));
		var this_frm = this;

		$('#select_options select').each(function(index) {
			if ($(this).val() == 0) {
				errorOptions = true;
			}
	  	});
	  	
	  	if (errorOptions) {
			alert(option_error);
			return false;
	  	}

		if(qty == 0){
			alert(zero_error);
			return false;
		}
		
		if(qty > max){
			alert(too_many_error+' '+max);
			return false;
		}
		
		window.cover.show(350, 235, function(){
			var wrapper = this;
			$.get(config_dir+'index.php?fuseaction=ajax.add_to_cart', $(this_frm).serialize() , function(data, status){
				$(wrapper).html(data);
				$('.continue-shopping', wrapper).click(function(){
					window.cover.hide();
					return false;
				});
			});
			
			});
		
		return false;
	});
	
	$('.newsletter form').submit(function(){
		if($('#newsletter_email').val() == newsletter_email)
			$('#newsletter_email').val('');
			
		var validation = new Validator(function(errors){
			var error = [];
			for(i=0;i<errors.length;i++)
			{
				var error_msg = '';
				switch(errors[i].errorCode)
				{
					case "E1":
						error_msg = errors[i].field_name+" "+newsletter_empty;
						break;
					case "E4":
						error_msg = errors[i].field_name+" "+newsletter_invalid;
						break;
				}
				error[error.length] = error_msg;
			}
			
			if($('#newsletter_email').val() == '')
				$('#newsletter_email').val(newsletter_email);
			
			if(error.length)
				alert(error.join("\n"))
		});

		validation.addField('newsletter_email', newsletter_email, 'email|required');
		if(validation.validate())
		{
			var email = $('input.text', this).val();
			window.cover.show(350, 150, function(){
				var wrapper = this;
				$.get(config_dir+'index.php?fuseaction=ajax.newsletter_subscription', {'email': email} , function(data, status){
					$(wrapper).html(data);
					$('#newsletter_email').val(newsletter_email);
					$('.continue-shopping', wrapper).click(function(){
						window.cover.hide();
						return false;
					});
				});
				
				});
		}
		return false;
	});
	
	if( $.browser.safari && navigator.platform.indexOf('Win') != -1 ){
		var s = navigator.userAgent.indexOf('Version/') + String('Version/').length;
		if( parseInt(navigator.userAgent.substr(s, navigator.userAgent.indexOf('Safari') - s)) <= 3 )
			$('body').addClass('safari3');
		}
	
	});
	
	if( $.browser.msie) {
		$('html').addClass('ie').addClass('ie'+ parseInt($.browser.version));
	}
	
	
	 if ($.browser.mozilla) {
        $.fn.disableTextSelect = function() {
            return this.each(function() {
                $(this).css({
                    'MozUserSelect' : 'none'
                });
            });
        };
    } else if ($.browser.msie) {
        $.fn.disableTextSelect = function() {
            return this.each(function() {
                $(this).bind('selectstart', function() {
                    return false;
                });
            });
        };
    } else {
        $.fn.disableTextSelect = function() {
            return this.each(function() {
                $(this).mousedown(function() {
                    return false;
                });
            });
        };
    }
	
})(jQuery);
