jQuery.fn.TxtSwap = function(content) {
  this.each(function(){
		var $this = $(this);
		if (typeof content == 'undefined') {
			if (typeof this.title != 'undefined' && this.title != '' ) {
				$this.content = this.title;
			}
		}
	$this.click(function(){
			this.value = '';
		});
		$this.blur(function(){
			if(this.value == '')       
				this.value = $this.content;
		});
  });
};
jQuery.fn.fadeToggle = function(speed, easing, callback) {
return this.animate({opacity: 'toggle'}, speed, easing, callback); 
};
jQuery.fn.blindToggle = function(speed, easing, callback) {
   var h = this.height() + parseInt(this.css('paddingTop')) + parseInt(this.css('paddingBottom'));
   return this.animate({marginTop: parseInt(this.css('marginTop')) < 0 ? 0 : -h}, speed, easing, callback); 
};
$(document).ready(function() {
	$("a.prod-lightbox").lightBox({
	product: true,
	overlayBgColor: '#397dad',
	overlayOpacity: 0.7,
	imageBlank: './_ui/images/lightbox-blank.gif',
	imageLoading: './_ui/images/lightbox-ico-loading.gif',
	imageBtnClose: './_ui/images/lightbox-btn-close.gif',
	imageBtnPrev: './_ui/images/lightbox-btn-prev.gif',
	imageBtnNext: './_ui/images/lightbox-btn-next.gif',
	containerResizeSpeed: 350,
	txtImage: 'Product',
	txtOf: 'of'
   });
	$("a.cart-lightbox").lightBox({
	overlayBgColor: '#397dad',
	overlayOpacity: 0.7,
	imageBlank: './_ui/images/lightbox-blank.gif',
	imageLoading: './_ui/images/lightbox-ico-loading.gif',
	imageBtnClose: './_ui/images/lightbox-btn-close.gif',
	imageBtnPrev: './_ui/images/lightbox-btn-prev.gif',
	imageBtnNext: './_ui/images/lightbox-btn-next.gif',
	containerResizeSpeed: 350,
	txtImage: 'Product',
	txtOf: 'of'
   });
	$('#search-box').TxtSwap('Enter Search Term');  // set Title
	$('form.newsletter .tf').TxtSwap();  // use the title value of the element
	$('form.subscribeForm .text').TxtSwap();
	$("a[rel='newWindow']").attr("target","_blank");
	$('.togglebutton').click(
		function(){
			var $this = $(this);
			var $break = '#break-'+$this.attr('rel');
			var $minImg = '#miniImg-'+$this.attr('rel');
			var $item = '#item-'+$this.attr('rel');
			var $financial = $item+' .cartItemFinancial';
			var $options = $item+' .cartItemOptions';
			$($options).hide();
			if ($this.val() == 'Show Details') {
				$this.val('Hide Details');
				$($minImg).fadeOut(350,
					function(){
						$($item).height(220);
						$($financial).css('clear','left');
						$($options).fadeIn(100);
						$($break).fadeToggle();
					}
				);
			}
			else {
				$this.val('Show Details')
				$($break).fadeToggle(600,
					function(){
						$($item).height(110);
						//$($financial).css('margin-top','15px');
						$($options).fadeIn(100);
						$($minImg).fadeIn(350);
					}
				);
			}
		}
	);
	
	$('.bigOne span.desc').hide();
	$('.bigOne').hover(
			function(){
					$this = $(this);
					$this.find('span.desc').fadeToggle(750);
			},
			function(){
					$this =$(this);
					$this.find('span.desc').fadeToggle(750);
			}
	);
	$('.prodImg').click(function(){
		var src = $(this).attr("rel");
		src = src.replace("w=50","w=170");
		src = src.replace("h=50","h=200");
		$("#prodimg").attr("src","resize8d43.html?img=./upload/photo/"+src+"&w=170&h=200");
		$("#lboxLink").attr("href","./upload/photo/"+src);
	})
	/*$("#featured-productss a").click(
		function(){
			$("#featured-productss").toggleClass("active");
			}
		);
				   
	 $('a.show_retailer').click(function(){
	 $('#featured-products').slideDown("slow");
	 $('a.show_retailer').hide(); 
	 $('a.hide_retailer').show();
   });
	 $('a.hide_retailer').click(function(){
	 $('#featured-products').slideUp("normal");
	$('a.hide_retailer').hide();
	$('a.show_retailer').show(); 
   });*/

   /*$("input.text, textarea.text").focusFields("#d40000", 1, "#f3e784", );*/              //E-mail Address

   
	//$("#search-query").click(function(){
	//		this.value = '';
	//});
	//$("#search-query").blur(function(){
	//	if(this.value == '')       
	//		this.value = 'Enter Search term';
	//});
	//  
	//$("#name").click(function(){
	//	if(this.value == 'Name') 
	//		this.value = '';
	//});
	//$("#name").blur(function(){
	//	 if(this.value == '')       
	//		this.value = 'Name';
	//});
	//  
	//$("#email").click(function(){
	//	if(this.value == 'E-mail Address') 
	//		this.value = '';
	//});
	//$("#email").blur(function(){
	//	 if(this.value == '')       
	//		this.value = 'E-mail Address';
	//});
	//$("input:text, textarea, input:password").each(function(){
	//	if(this.value == '')
	//		this.value = this.title;
	//});
	//$("input:text, textarea, input:password").click(function(){
	//	if(this.value == this.title)
	//		this.value = '';
	//});
	//$("input:text, textarea, input:password").blur(function(){
	//	if(this.value == '')
	//		this.value = this.title;
	//});
	//$("input:image, input:button, button:submit").click(function(){
	//	$(this.form.elements).each(function(){
	//		if(this.type =='text' || this.type =='textarea' || this.type =='password'){
	//			if(this.value == this.title && this.title != ''){
	//				this.value='';
	//			}
	//		}
	//	});
	//});
 });
 
 
 function swap_image(newimg,alt, title)
{
	document.getElementById('si').src   = 'resize1ad5.html?w=300&amp;h=300&amp;img='+newimg;
	document.getElementById('rt').href  = newimg;
	document.getElementById('rt').alt   = alt;
	document.getElementById('rt').title = title;

	// <a href="./upload/photo/{$product->default_image.path}" rel="lightbox" alt="{$product->images[0].alt}" title="{$product->images[0].title}">View larger image</a>
	return true;
}

