﻿// JavaScript Document

$(document).ready(function(){	

		   		   
			//_typeface_js.initialize();
			
			gapi.plusone.go("social_box");	
			
			 $('a.email').nospam({
				replaceText: true,
				filterLevel: 'low'
			});  
			
			
			$('.product_image_box') 
			.cycle({ 
				fx:     'fade', 
				speed:  1000, 
				timeout: 4000
			});
			
			function img_cycle(){
				$('.product_image_box') 
				.cycle({ 
					fx:     'fade', 
					speed:  1000, 
					timeout: 4000
				});
			}
			
			
			
			
			$('.product_image_box, #wrap, .mousetrap, .cloud-zoom-big').live('mouseleave', 
				function(){ $('.product_image_box') .cycle('resume');
			})
			
			$('.product_image_box, #wrap, .mousetrap, .cloud-zoom-big').live('mouseenter', 
				function(){ $('.product_image_box') .cycle('pause');
			})
			
			
			

							
			
			var menu_height = $('.menu table').height();
			
			$('.menu_item_1' ).hover(function() {
				//alert('asd');
				$( ".left_flag" ).toggleClass( "left_flag_active", 0 );
				//return false;
			});
			
			$('.menu_item_6' ).hover(function() {
				//alert('asd');
				$( ".right_flag" ).toggleClass( "right_flag_active", 0 );
				//return false;
			});
			
			$('.post_form .submit input, .login_box_form .submit input, .registration_form .submit input, .rendeles').live('mouseenter',
				function(){$(this).stop().animate({backgroundColor: '#167AF9', color: '#ffffff'}, 250);}				
			);
			
			$('.post_form .submit input, .login_box_form .submit input, .registration_form .submit input, .rendeles').live('mouseleave',
				function(){$(this).stop().animate({backgroundColor: '#ffffff', color: '#167AF9'}, 250);}				
			);
			
			$('.main_basket').hover(
				function(){$('.main_basket_content').fadeIn(250);}, 
				function(){$('.main_basket_content').fadeOut(250);}
			);
			
			$('.main_basket_link2').live('mouseenter',
				function(){$(this).stop().animate({backgroundColor: '#000000'}, 250);}
			);
			
			$('.main_basket_link2').live('mouseleave',
				function(){$(this).stop().animate({backgroundColor: '#167AF9'}, 250);}
			);
			
			
			$('.black_button').hover(
				function(){$(this).stop().animate({backgroundColor: '#167AF9', color: '#ffffff'}, 250);}, 
				function(){$(this).stop().animate({backgroundColor: '#000000', color: '#ffffff'}, 250);}
			);
			
			$('.login_link, .admin_link').hover(
				function(){$(this).find('.link_text').stop().animate({backgroundColor: '#000000', color: '#ffffff'}, 250);}, 
				function(){$(this).find('.link_text').stop().animate({backgroundColor: '#ffffff', color: '#000000'}, 250);}
			);
			
			$('#footer_inner a').hover(
				function(){$(this).stop().animate({ color: '#000000'}, 250);}, 
				function(){$(this).stop().animate({ color: '#167AF9'}, 250);}
			);
			
			
			
			
			$('.main_menu_sub').hover(
				function(){
						$(this).stop().animate({color: '#ffffff'}, 250).children('.arnyek').stop().fadeTo(250, 1);
				}, 
				function(){
						$(this).stop().animate({color: '#000000'}, 250).children('.arnyek').hide(0);
				}
			);
			
			$('.product_back, .clear_basket').live('mouseenter', function(){
					$(this).find('.link_text').stop().animate({color: '#ffffff'}, 250);
					$(this).find('.arnyek').stop().fadeIn(250);
				
			});
			
			$('.product_back, .clear_basket').live('mouseleave', function(){
					$(this).find('.link_text').stop().animate({color: '#167AF9'}, 250);
					$(this).find('.arnyek').stop().fadeOut(250);			
			});
			
			$('.details_button').live('mouseenter', function(){
					$(this).stop().animate({color: '#167AF9'}, 250);				
			});
			
			$('.details_button').live('mouseleave', function(){
					$(this).stop().animate({color: '#000000'}, 250);				
			});
			
			$('.reference_close_button').live('mouseenter', function(){
					$(this).find('.link_text').stop().animate({backgroundColor: '#000000'}, 250);				
			});
			
			$('.reference_close_button').live('mouseleave', function(){
					$(this).find('.link_text').stop().animate({backgroundColor: '#167AF9'}, 250);				
			});
			
			
			
			
			/*
			
			$('.main_menu_sub').hover(
				function(){$(this).toggleClass( "colored", 300 ); },
				function(){$(this).toggleClass( "colored", 300 ); }
			);
			*/
			//$( "#effect" ).toggleClass( "newClass", 1000 );
			
			$('.menu_box div').height(menu_height);
			
			//$("#tabs").tabs().addClass('ui-tabs-vertical ui-helper-clearfix');
			//$("#tabs li").removeClass('ui-corner-top').addClass('ui-corner-left');
			
			
			$( '#captcha_link' ).click( function() {
				$( '#captcha_img' ).attr('src', baseUrl + 'users/securimage/' + Math.random()); // Append random number to prevent caching
				$( '#captcha_code' ).val('');
				return false;
			});
			
			
			$('.submit_link').live('click', function(){
				$(this).parent().parent().ajaxSubmit({
							success:	function (responseText, statusText, xhr, $form)  { 
								var basket_item_num = 0;
								var basket_item = $('.main_basket_content .top').html(responseText).find('.basket_quantity').each(function(){
									basket_item_num += parseInt($(this).text());	
								});
								
								if($('.menu_item_1').attr('id') == 'hu'){
									$('.basket_link').queue(function(){
										$(this).fadeOut(300, function(){$(this).text( basket_item_num + 'db termék a kosárban').fadeIn(300);} );	
										$(this).dequeue();																	
									});
									
								} else {
									$('.basket_link').queue(function(){
										$(this).fadeOut(300, function(){$(this).text( basket_item_num + ' item(s) in the cart').fadeIn(300);} );
										$(this).dequeue();
									});
								}								
								
								var obj = $('.main_basket_content');
								if($('.main_basket_content').filter(':visible').size()==0){
									obj.queue(function(){
										$(this).show('blind', 500);
										$(this).delay(10000);
										$(this).hide('blind', 500);
										$(this).dequeue();
									});
								} else {
									obj.clearQueue();
									obj.queue(function(){
										$(this).delay(8000);
										$(this).hide('blind', 500);
										$(this).dequeue();
									});
									//obj.stop();
								}
										
							} 		  
				});	
				return false;	
			});
			
			
			
			function loader_show(){
				$('.ajax_loader').show('drop', {direction:'right'});
			}
			
			function loader_hide(){
				$('.ajax_loader').hide('drop', {direction:'right'});
			}
			
			
			
			$('.product_main_link, .color_product, .more_details').live('click',function() {	
				var obj = $(this);
				//obj.parent().children('.ajaxloader2').show();
				$('.right_col_wrapper').css('overflow', 'hidden');
				$('.product_popup').hide(0);
				
				loader_show();
				
				$('.product_hide_label').show();				
				
					$.ajax({
							url: obj.attr('href'),
							type: "GET",
							cache: false,
							success: function(data){
								
								var left_poz = parseInt($('.right_col_container').css('left'))-750;
								$('.right_col_container').append(data).stop();
								
								gapi.plusone.go("social_box");
								
								
								init_gallery();
								//$(".product_box").hoverIntent( config );	
								$(".random_product_box").hoverIntent( config_random );
								
								$('.right_col_container').delay(1000).animate({'left': left_poz+'px'}, 2000, function(){
									init_zoom();
									loader_hide();	
									//_typeface_js.initialize();
									$('.product_popup').hide(0);
																																						 
								});
								
							}
					});
				return false;
			});
			
			$('.reference_main_link').live('click',function() {	
				var obj = $(this);
				obj.parent().addClass('reference_active');	
				var sor = Math.ceil(parseInt(obj.attr('rel'))/4);
				//obj.parent().children('.ajaxloader2').show();			
					
					//$('.ajax_box :visible').hide('blind', {}, 2000, function(){});
					loader_show();
					
					
					if($('.ajax_box').filter(':visible').size() == 0){
						
						$.ajax({
							url: obj.attr('href'),
							type: "GET",
							cache: false,
							success: function(data){
								$('.ajax_box').html(data);
								//_typeface_js.initialize();
								var top_poz =  sor * (-214) + (sor-1) * (-16);
								$('#reference_bottom').stop().delay(1000).animate({'top': top_poz + 'px'}, 2000, function(){								
									loader_hide();																		  
								});								
								$('#ajax_box_' + sor).show('blind', {}, 2000);
								
								init_gallery();
								
								
							}
						});
						
					}
					
					if($('.ajax_box').filter(':visible').size() > 0){
																
							var top_poz = parseInt($('#reference_bottom').css('top'))+209;
							$('#reference_bottom').stop().animate({'top': '0px'}, 2000);
							$('.ajax_box').filter(':visible').hide('blind', {}, 2000, function(){
								$.ajax({
									url: obj.attr('href'),
									type: "GET",
									cache: false,
									success: function(data){
										$('.ajax_box').html(data);
										var top_poz =  sor * (-214) + (sor-1) * (-16);
										$('#reference_bottom').stop().delay(200).animate({'top': top_poz + 'px'}, 2000, function(){
											obj.parent().addClass('reference_active');			
											loader_hide();																  
										});								
										$('#ajax_box_' + sor).show('blind', {}, 2000);
										
										init_gallery();
										
										
									}
								});
							});	
							$('.reference_active').removeClass('reference_active');

					}
					
					
				return false;
			});
			
			$('.reference_close').live('click',function() {
				loader_show();	
				var top_poz = parseInt($('#reference_bottom').css('top'))+209;
				$('#reference_bottom').stop().animate({'top': '0px'}, 2000, function(){loader_hide();});
				$(this).parent().parent().hide('blind', {}, 2000);	
				$('.reference_active').removeClass('reference_active');
				return false;
			});
			
			
			function reference_close(){
				$('.reference_close').live('click',function() {													
					var top_poz = parseInt($('#reference_bottom').css('top'))+209;
					$('#reference_bottom').stop().animate({'top': '0px'}, 2000);
					$(this).parent().parent().hide('blind', {}, 2000);	
					$('.reference_active').removeClass('reference_active');
					return false;
				});	
			}
			
			$('.product_back').live('click',function() {	
				var obj = $(this);
				var left_poz = parseInt($('.right_col_container').css('left')) + 750;
				/* FIX */
				left_poz = 0;
				$('.ajax_loader').hide();
				$('.right_col_container').stop().animate({'left': left_poz+'px'}, 2000, function(){
					$('.product_hide_label').hide();	
					$('.right_col_container').children( '.right_col:not(:first)' ).remove();					
					$('.right_col_wrapper').css('overflow', 'visible');
					//obj.parent().remove();
				});
				return false;
			});
			
			$('.news_details').live('click',function() {	
				var obj = $(this);
				obj.parent().children('.ajaxloader2').show();
					$.ajax({
							url: obj.attr('href'),
							type: "GET",
							cache: false,
							success: function(data){
								obj.parent().hide();
								obj.parent().children('.ajaxloader2').hide();
								obj.parent().parent().children('.ajax_box').html(data).show('blind', {}, 2000);
								init_gallery();
							}
					});
				return false;
			});
			
			$('.news_close').live('click',function() {	
				var obj = $(this);
				obj.parent().parent().parent().children('.details_box').first().show();
				obj.parent().parent().hide('blind', {}, 2000);
				return false;
			});
			
			$('.new_post').live('click', function(){
				$('.post_form').each(function(){
					if($(this).css('display') == 'none'){
						$(this).show('blind', {}, 1000, function(){
							$('#PostText').focus();
						});
						
					} else {
						$(this).hide('blind', {}, 1000);
					}
				});
				return false;
			});
			
			$('.minusz').live('click', function(){
											
				var popup_class_array = $(this).parent().attr('class');
				var popup_class = popup_class_array.split(' ');
				var active_popup_id = '#' + popup_class[1];
				var id_number = popup_class[1].split('_');
				var id_number = id_number[1];
				
				var obj = $(active_popup_id + ' .quantity');
				var product_id = $('#Order' + id_number + 'ProductId').val();
				var size = $('#Order' + id_number + 'Size').val();
				var inner = $('#Order' + id_number + 'Inner').val();
				
					$.ajax({
							url: baseUrl + 'items/change_basket/' + product_id + '-' + obj.val()+'-' +size+ '-' + inner + '/minusz',
							type: "GET",
							cache: false,
							success: function(data){
							
								$('.main_basket_content .top').html(data);
								
							}
					});
				
				
				
				//alert( product_id + '-' + obj.val()+'-' +size+ '-' + inner);
				
				var obj2 = $(this).parent().children('.quantity');
				var ar = $(this).parent().children('.ar');
				var penz = $(this).parent().children('.penz').attr('value');
				var basket_total = $(this).parent().parent().find('.basket_total');
				
				
				if(obj.attr('value') >1 ){
					obj2.attr('value', parseInt(obj2.attr('value'))-1 );
					obj.attr('value', parseInt(obj.attr('value'))-1 );
				}
				
				if(penz == 'FT'){
					basket_total.html(number_format( obj.attr('value') * ar.attr('value') , 0, '', '.') +' '+penz );
				} else {
					basket_total.html(number_format( obj.attr('value') * ar.attr('value') , 2, '.', '') +' '+penz );
				}
				
				price_calculator();
				
				return false;
			});
			
			$('.minusz2').live('click', function(){				
				var obj = $(this).parent().children('.quantity');
				
				if(obj.attr('value') >1 ){
					obj.attr('value', parseInt(obj.attr('value'))-1 );
				}				
				return false;
			});
			
			$('.plusz').live('click', function(){
				var popup_class_array = $(this).parent().attr('class');
				var popup_class = popup_class_array.split(' ');
				var active_popup_id = '#' + popup_class[1];
				
				var obj = $(active_popup_id + ' .quantity');
				var qu = obj.attr('value');
				obj.attr('value', parseInt(obj.attr('value'))+1 );
				//alert(obj.attr('value'));
				
				var id_number = popup_class[1].split('_');
				var id_number = id_number[1];
				
				var obj = $(active_popup_id + ' .quantity');
				var product_id = $('#Order' + id_number + 'ProductId').val();
				var size = $('#Order' + id_number + 'Size').val();
				var inner = $('#Order' + id_number + 'Inner').val();
				
					$.ajax({
							url: baseUrl + 'items/change_basket/' + product_id + '-' + qu +'-' +size+ '-' + inner + '/plusz',
							type: "GET",
							cache: false,
							success: function(data){
							
								$('.main_basket_content .top').html(data);
							
								
								//init_zoom();
								//$('.product_image_box a img').hover( function(){init_zoom();});
							}
					});
				
				
				
				var obj2 = $(this).parent().children('.quantity');
				var ar = $(this).parent().children('.ar');
				var penz = $(this).parent().children('.penz').attr('value');
				var basket_total = $(this).parent().parent().find('.basket_total');
				
				obj2.attr('value', parseInt(obj2.attr('value'))+1 );
				if(penz == 'FT'){
					basket_total.html(number_format( obj.attr('value') * ar.attr('value') , 0, '', '.') +' '+penz );
				} else {
					basket_total.html(number_format( obj.attr('value') * ar.attr('value') , 2, '.', '') +' '+penz );
				}
				price_calculator();
				
				return false;
			});
			
			$('.plusz2').live('click', function(){				
				var obj = $(this).parent().children('.quantity');

				obj.attr('value', parseInt(obj.attr('value'))+1 );
								
				return false;
			});
			
			function price_calculator(){
				var ossz = 0;
				var penz;
				$('.product_box .quantity').each(function(){
					var mennyiseg = $(this).attr('value');
					var ar = $(this).parent().children('.ar').attr('value');
					penz = $(this).parent().children('.penz').attr('value');
					var basket_total = $(this).parent().parent().find('.basket_total');
					
					
					if(penz == 'FT'){
						ossz += mennyiseg * ar;
						basket_total.html(number_format( mennyiseg * ar , 0, '', '') +' '+penz );
					} else {
						ossz += mennyiseg * ar;
						basket_total.html(number_format( mennyiseg * ar , 2, '.', '') +' '+penz );
					}
					
					
				});
				
				if(penz == 'FT'){
					$('.total').html(number_format( ossz , 0, '', '.') +' '+penz);
				} else {
					$('.total').html(number_format( ossz , 2, '.', '') +' '+penz);
				}
			}
			
			$('.quantity').live('keyup', function(){
				price_calculator();
			});
			
			price_calculator();
			
			$('.inner_select').live('change', function(){
				$('.normal_price').hide();
				var v = $('.inner_select').attr('value');
				$('.inner_' + v).show();
			});
			
			
			function number_format( number, decimals, dec_point, thousands_sep ) {
				// http://kevin.vanzonneveld.net
				// +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
				// +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
				// +     bugfix by: Michael White (http://crestidg.com)
				// +     bugfix by: Benjamin Lupton
				// +     bugfix by: Allan Jensen (http://www.winternet.no)
				// +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)    
				// *     example 1: number_format(1234.5678, 2, '.', '');
				// *     returns 1: 1234.57     
			 
				var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
				var d = dec_point == undefined ? "," : dec_point;
				var t = thousands_sep == undefined ? "." : thousands_sep, s = n < 0 ? "-" : "";
				var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
				
				return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
			}
			
			
			
			function init_gallery(){
				$(".fancy").fancybox(
					{
						'padding'			: 1,
						'zoomOpacity'			: true,
						'zoomSpeedIn'			: 500,
						'zoomSpeedOut'			: 500,
						'overlayColor'			: '#777777',
						'overlayOpacity'		: 0.7,
						'hideOnOverlayClick'	: true
				}); 			
			}
			
			init_gallery();
			
			

			
			$(".fancy_video").live('click', function() {

				$.fancybox({

					'padding'		: 0,
					'autoScale'		: false,
					'transitionIn'	: 'elastic',
					'transitionOut'	: 'elastic',
					'easingIn'      : 'easeOutBack',
					'easingOut'     : 'easeInBack',
					'title'			: this.title,
					'overlayColor'			: '#777777',
					'overlayOpacity'		: 0.7,
					'hideOnOverlayClick'	: true,
					'width'			: 640,
					'height'		: 385,
					'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
					'type'			: 'swf',
					'swf'			: {
						'wmode'				: 'transparent',
						'allowfullscreen'	: 'true'
					}
				});
	
				return false;

			});
			
			
			function init_zoom(){
				img_cycle();
				$('.cloud-zoom, .cloud-zoom-gallery').CloudZoom();
				
				/*
				$('.product_image_box img').each(function(){
						var obj = $(this);
						var height = $(this).height();
						var width  = $(this).width();		
						
						var zoomWidth = 0;
						var zoomHeight = 0;
						
						if(width == 346){
							zoomWidth = 725 - width;
							zoomHeight = height-2;
						} else {
							zoomWidth = 532 - width;
							zoomHeight = height-2;
						}
						
						var zoomWidth = 260;
						var zoomHeight = 260;
						
						var options = {
								zoomWidth: zoomWidth,
								zoomHeight: zoomHeight,
									xOffset: 0,
									yOffset: 0,
									title  : false,
									position: "left" //and MORE OPTIONS
						};
						
						$(this).parent().jqzoom(options);
				});
				*/
				
			}
			
			init_zoom();
			

			
			$('.product_pictures a').live('click',function() {	
				var obj = $(this);
					$.ajax({
							url: obj.attr('href'),
							type: "GET",
							cache: false,
							success: function(data){
								$('.product_image_box').html(data);
								$(document).ready(function(){
									init_zoom();		   
								});
								//init_zoom();
								//$('.product_image_box a img').hover( function(){init_zoom();});
							}
					});
				return false;
			});
			

	$("#UserRegistrationForm").validate({
		rules: {

			UserEmail: {
				required: true,
				email: true
			},
			UserPrivacy: "required"
		},
		messages: {

			UserEmail: "Please enter a valid email address",
			UserPrivacy: "Please accept our policy"
		}
	});
	
	$('.username_input').focusout(function(){
		var obj = $(this);
		var value = obj.val();
		if(value.length > 3){
			$.ajax({
				url: baseUrl + 'users/unique/' + value,
				type: "GET",
				cache: false,
				success: function(data){
					$('.user_unique').replaceWith(data);
					$('.user_unique').parent().children('.error-message').remove();
				}
			});	
		}
	});
	
	
	$('.post_form form .submit input').live('click',function(){
		$('.post_form form').ajaxSubmit({
							success:	function (responseText, statusText, xhr, $form)  { 
								$('.posts_box').prepend(responseText);
								$('.posts_box .post').first().show('blind', {}, 500, function(){
									$('.post_form form textarea').val('');
									$('.post_form').hide('blind', {}, 500);															  
								});
								
							} 		  
		});	
	  	return false;
	});
	

	
	/*
		var content = $(this).html();
		var id = $(this).attr('id');
		var id_num = id.split('_');
		var sor = Math.floor((id_num[1]-1) / 4) + 1;
		var left = (180 * ((id_num[1]-1) % 4)) - 3;
		var top = 235 * (sor-1) + 20;
		
		
				$('.product_details').each(function(){
			if($(this).css('display') == 'block'){
				$(this).hide('blind', {}, 500, function(){
						$(this).parent().css('z-index', 3);		
						$(this).parent().removeClass('active_product');	
						
				});
			}
		});
	*/
	
	
	
	var config = {    
		 over: makeTall, // function = onMouseOver callback (REQUIRED)    
		 sensitivity: 1,
		 timeout: 300, // number = milliseconds delay before onMouseOut    
		 out: makeShort // function = onMouseOut callback (REQUIRED)    
	};
	
	var config_random = {    
		 over: makeTall_random, // function = onMouseOver callback (REQUIRED)    
		 sensitivity: 1,
		 timeout: 300, // number = milliseconds delay before onMouseOut    
		 out: makeShort // function = onMouseOut callback (REQUIRED)    
	};
	
	$(".product_box").hoverIntent( config );
	$(".random_product_box").hoverIntent( config_random );
	
	function makeTall(){
		var obj = $(this);
		var id = $(this).attr('id');
		var content = $(this).html();
		var id_num = id.split('_');
		var sor = Math.floor((id_num[1]-1) / 4) + 1;
		var left = (185 * ((id_num[1]-1) % 4))+ 6;
		var top = 246 * (sor-1) + 19;
		
		var quantity = obj.children('.basket_details').children('.quantity').attr('value');
		//alert(quantity);
		//$('.product_popup').hide(0);
		
		$('.product_popup .popup_content').html(content);
		$('.product_popup .popup_content').children('.basket_details').children('.quantity').attr('value', quantity);
		$('.product_popup').css({'left': left, 'top': top }).fadeIn(200);
	}
	
	function makeTall_random(){
		var obj = $(this);
		var id = $(this).attr('class');
		var content = $(this).html();
		var id_num = id.split('_');
		var sor = Math.floor((parseInt(id_num[1])-1) / 4) + 1;
		var left = (185 * ((parseInt(id_num[1])-1) % 4))+6;
		var top = 246 * (sor-1)-5;
		
		//$('.product_popup').hide(0);
		
			obj.parent().children('.random_product_popup').children('.popup_content').html(content);
			obj.parent().children('.random_product_popup').css({'left': left, 'top': top }).fadeIn(200);
			
	}
	
	function makeShort(){}
	
	$('.product_popup, .random_product_popup').live('mouseleave', function(){
		$(this).hide(0);
	});
	
	
	
	
	$( "#accordion" ).accordion({
			event: "mouseover",
			active: false
	});
	
	$('#accordion').mouseleave(function(){
		//$( ".product_details2" ).css('display', 'none');
		
		$( "#accordion" ).accordion({
			event: "mouseover",
			active: false
		});
	});
	
	
	
	/*											  
	$(".product_box").hover(
		function(){
			var obj = $(this);
			
			
			setTimeout(function(){
				var details = $('.product_box .product_details:visible');
				if(details.size() == 0 ){
					obj.stop(true, true).css('z-index', 1000).addClass('active_product_stop');
						obj.stop(true, true).children('.product_details').show('blind', {}, 300, function(){
							obj.removeClass('active_product_stop');
							obj.addClass('active_product');														 
					});
				}
			}, 500);
				
		},function(){
 			var obj = $(this);
			var details = $('.product_box .product_details:visible');
			
			if(details.size() > 0 ){
				details.each(function(){
					$(this).stop().hide('blind', {}, 300, function(){
						$(this).parent().removeClass('active_product').css('z-index', 3);
					});
				});
			}
			
			//obj.stop().children('.product_details').hide('blind', {}, 300, function(){});
	});

	
	
	$('.product_box').live('mouseenter',function(){						  
		var obj = $(this);
		var details = $('.product_box .product_details:visible');

		if(details.size() > 0 ){
			details.parent().removeClass('active_product_stop').addClass('active_product');
			details.hide('blind', {}, 300, function(){
					$(this).parent().removeClass('active_product').css('z-index', 3);
			
			setTimeout(
				function(){
					obj.css('z-index', 1000).addClass('active_product_stop');
					obj.children('.product_details').show('blind', {}, 300, function(){
								obj.removeClass('active_product_stop');
								obj.addClass('active_product');														 
					});
				},
				300
			);
			
			});
		
		} else {
			obj.css('z-index', 1000).addClass('active_product_stop');
			obj.children('.product_details').show('blind', {}, 300, function(){
						obj.removeClass('active_product_stop');
						obj.addClass('active_product');														 
			});
		}
			
	});
	*/
	
	
	/*
	$('.product_box').live('mouseleave',function(){
		var obj = $(this);		
		obj.removeClass('active_product_stop');
		obj.addClass('active_product');
		obj.children('.product_details').hide('blind', {}, 500, function(){
				obj.removeClass('active_product');		
				obj.css('z-index', 3);
		});

	});
		*/
		
	//Sidebar Accordion Menu:


	
	$("#main-nav h3 a.nav-top-item").click(function(){
			//$("#main-nav li a.nav-top-item").removeClass('current');
			$(this).toggleClass('current');
	});
			
		$("#main-nav li ul").hide(); // Hide all sub menus

		$("#main-nav li a.current").parent().find("ul").slideToggle("slow"); // Slide down the current menu item's sub menu

		$("#main-nav li a.nav-top-item").click( 
					
			function () {
				$('#main-nav li a.current').removeClass('current');
				$(this).addClass('current');
				$(this).parent().siblings().find("ul").slideUp("normal"); // Slide up all sub menus except the one clicked
				$(this).next().slideToggle("normal"); // Slide down the clicked sub menu
				return false;
			}
		);

		$("#main-nav li a.no-submenu").click(
			function () {
				window.location.href=(this.href); // Just open the link instead of a sub menu
				return false;
			}
		); 
	

});
