// Author : Ronald R
//			Agus D
jQuery.noConflict();

jQuery(document).ready( function() {
	jQuery('.prodSmallThumbs ul li').each(function(i,n) {
		jQuery(n).hover(function() {
			
			jQuery('.prodSmallThumbs ul li').removeClass('imgDown');
			jQuery(n).addClass('imgDown');

      var product = jQuery(n).find('.product-id-hidden').attr('value')
      var web_context = jQuery(n).find('.web-context-hidden').attr('value')

      var image = jQuery('div#product-details-image-' + product).html()
      var name = jQuery('dt#product-details-name-' + product).html()
      var retailer1 = jQuery('dd#product-details-' + product + '-retailer-1').html()
      var retailer2 = jQuery('dd#product-details-' + product + '-retailer-2').html()
      var retailer3 = jQuery('dd#product-details-' + product + '-retailer-3').html()
      var price = jQuery('span#product-details-price-value-' + product).html()
      jQuery('#main-product-details-image').hide().html(image).show()
      jQuery('#main-product-details-name').hide().html(name).show()
      jQuery('#main-display-retailer-1').hide().html(retailer1).show()
      jQuery('#main-display-retailer-2').hide().html(retailer2).show()
      jQuery('#main-display-retailer-3').hide().html(retailer3).show()
      jQuery('#main-display-price-value').hide().html(price).show()
      jQuery('#main-display-add-to-list-id').attr('value', product)
//      jQuery('#main-prod-details').hide().html(p).show()
			
		}, function() {
			//jQuery(n).parent().removeClass('imgDown');
		});
	});
	
	// Simple Carousel
	var carouselShow = 4;
	var carouselWidth = 124;
	var carouselValue = 0;
	var carouselSize = jQuery("ul.carousel li.prodDetailsAndButtons").size();
	var anime = false;
	var maxSize = carouselSize - carouselShow;
	
	function hideCarouselButton() {
		
		carouselValue =  parseFloat(jQuery("ul.carousel").css("left"),10);
		
		if ((maxSize) == 0) {
			jQuery(".leftCarouselArrow a img").hide();
			jQuery(".rightCarouselArrow a img").hide();
		} else if ((carouselValue) == 0) {
			jQuery(".leftCarouselArrow a img").hide();
			jQuery(".rightCarouselArrow a img").show();
		} else if ((carouselValue) == (carouselWidth * maxSize * -1)) {
			jQuery(".rightCarouselArrow a img").hide();
			jQuery(".leftCarouselArrow a img").show();
		} else {
			jQuery(".rightCarouselArrow a img").show();
			jQuery(".leftCarouselArrow a img").show();
		}
		
	}
	
	hideCarouselButton();
	
	jQuery("ul.carousel").css({width: (carouselSize*carouselWidth)+"px"});
	
	jQuery(".rightCarouselArrow").click(function() {
		carouselValue =  parseFloat(jQuery("ul.carousel").css("left"),10);
		
		if ((carouselValue > (carouselWidth * maxSize * -1)) && (anime == false)) {
			anime = true;
			jQuery("ul.carousel").stop().animate({
				left: "-=124px"
			}, 700, function() {
				anime = false;
				hideCarouselButton();
			});
			
		}
		
		return false;
		
	});
	
	jQuery(".leftCarouselArrow").click(function() {
		carouselValue =  parseFloat(jQuery("ul.carousel").css("left"),10);
		
		if ((carouselValue < 0 ) && (anime == false)) {
			anime = true;
			jQuery("ul.carousel").stop().animate({
				left: "+=124px"
	
			}, 700, function() {
				anime = false;
				hideCarouselButton();
			});
		}
		
		return false;
	});

	
});

