if(typeof jQuery != "undefined") {
	jQuery.noConflict();
	jQuery(document).ready(function($) {
	
	
		//Menu
		$('#nav > ul > li').mouseover(function() {
			$('> ul', this).show();
		}).mouseout(function() {
			$('> ul', this).hide();
		});

		// Blog Right Section Grow
		var right = $('#blogR').outerHeight();
		var totalH = $('.blog').height();
		
		if(right<totalH) {
			$("#blogTwitter").css("height",$("#blogTwitter").height()+totalH-right+"px");
		}	

		
		//LightBox
		if($('#pDetL a#btnEnlarge').length>0) {
			$('#pDetL a#btnEnlarge').lightBox();
		}
		/**
		* @section Gallery Images
		* @uses crossfade() (optionally)
		* --------------------------------------------------------------------------------------------------
		*/
		
		$gallery			= $('#gallery_thumbs');
		$galleryImage		= $('#pDetL img');
		$galleryZoom		= $('#pDetL a#btnEnlarge');
		galleryImageFading	= false;
		
		$gallery.bind('click.gallery', {active: 'active'}, function(event){
			var $$, $a, src;
			
			$$		= $(event.target).closest('li');
			$a		= $('a', $$);
			src		= $a.attr('href');
			
			if($$.is(':not(.' + event.data.active + ' , .no-image)')) {
			
				$$.addClass(event.data.active).siblings().removeClass(event.data.active);
				
				if($.fn.crossfade && galleryImageFading === false) {
					galleryImageFading = true;
					$('#pDetL img').crossfade({
						target:		src,
						animated:	true,
						duration:	1250,
						callback:	function() {
							galleryImageFading = false;
						}
					});
				}
				else {
					$galleryImage.attr('src', src);
				}
				
				src = src.replace('&w=560&h=485&zc=1&q=75','&w=936&zc=0&q=75');
				$galleryZoom.attr('href', src);
				
			}
			event.preventDefault();
			$a.blur();
			
		});

		
		/**
		* @section View Category
		* --------------------------------------------------------------------------------------------------
		*/
		if($('#sortMethod1').length>0) {
			$("#sortMethod1").bind("change", callUrl);
			$('#jsOrderBtn1').hide();
		}
		if($('#sortMethod2').length>0) {
			$("#sortMethod2").bind("change", callUrl);
			$('#jsOrderBtn2').hide();
		}
		
		if($('#brandd1').length>0) {
			$("#brandd1").bind("change", callUrl);
			$('#jsBranddBtn1').hide();
		}
		if($('#brandd2').length>0) {
			$("#brandd2").bind("change", callUrl);
			$('#jsBranddBtn2').hide();
		}
		
		if($('#showAmount1').length>0) {
			$("#showAmount1").bind("change", callUrl);
			$('#jsShowAmountBtn1').hide();
		}
		if($('#showAmount2').length>0) {
			$("#showAmount2").bind("change", callUrl);
			$('#jsShowAmountBtn2').hide();
		}
	
		/**
		* @section Reg Page 
		* --------------------------------------------------------------------------------------------------
		*/
		if($('#skipReg').length>0) {
		
			$("#skipReg").click(function(){
				$("#passwordFields").toggle();
			});
		}
		
		
		/**
		* @section Default input value replacement
		* --------------------------------------------------------------------------------------------------
		*/
		$(':text').each(function(i, element){
			var $$, value;

			$$		= $(this);
			value	= $$.attr('title');
			$$.removeAttr('title');

			if($$.is('.default') && $$.val().length > 0) {
				value = $$.val();
			}
			
			$$.data('default', value);

		}).bind('focus', function(event){
			var $$, value;

			$$		= $(this);
			value	= $$.val();

			if(value === $$.data('default')) {
				$$.val('');
			}
		}).bind('blur', function(event){
			var $$, value;

			$$		= $(this);
			value	= $$.val();

			if(value === '') {
				$$.val($$.data('default'));
			}
		});
		
		/**
		* @section Home Page Main Banner
		* --------------------------------------------------------------------------------------------------
		*/
		if($('#home-banners').length>0) {
			$('#home-banners').cycle({ 
				fx:				'fade',
				timeout:		5000,
				delay:			2500,
				startingSlide:	0,
				next:			null,			// selector for element to use as click trigger for next slide 
				prev:			null			// selector for element to use as click trigger for previous slide
			});
		}
		
		if($('#homeBnrR').length>0) {
			$('#homeBnrR').cycle({ 
				fx:				'fade',
				timeout:		3000,
				delay:			0,
				startingSlide:	0,
				next:			null,			// selector for element to use as click trigger for next slide 
				prev:			null			// selector for element to use as click trigger for previous slide
			});
		}
		
		
		
	});
	
}

function incBasket(elm, basket) {
	if(jQuery(elm)) {
		var qty;
		qty = parseInt(jQuery(elm).val());
		
		jQuery(elm).val(qty + 1);
		
		if(basket==true) {
			submitDoc('cart');
		}
	}
}
function decBasket(elm, basket, limit) {
	if(jQuery(elm)) {
		var qty;
		qty = parseInt(jQuery(elm).val());
		
		if(qty>limit) {
			jQuery(elm).val(qty - 1);
		}
		if(basket==true) {
			submitDoc('cart');
		}
	}
}

