$(function() {

	//$('#rateblock').html($rateblock);
	//$('#wishlist').html($wishlist);
	
	if ($('#product-details-full').height() > 200) {
		$('#product-details-full, #product-details-short').toggle();
		$('#product-details-show').click(function() {
			$('#product-details-full, #product-details-short').slideToggle();
			return false;
		});
	}
	
	// images

	$("a.productImages").fancybox();

	// social bookmarks

	$('ul.social_icons a').hover(function() {
		$(this).find('img:not(.small)').css('opacity', 1);
	}, function() {
		$(this).find('img:not(.small)').css('opacity', 0);
	}).find('img:not(.small)').css('opacity', 0);
	;

	// tabs

	$('.tabs li a').click(function() {
		$('.tabs li').removeClass('active');
		$(this).parent().addClass('active');

		var $container = $('#' + $(this).attr('target'));
		var $url = $(this).attr('href');
		$url = $url.substr($url.indexOf('#'));
		$container.load(location.href, {
			load : $url
		});
		$(this).blur();
		return false;
	});

});

// review

function postReview(obj) {
	$.post(location.href, $('input[name], textarea[name]', obj), function(msg) {
		if (msg.match(/ERR: .*/)) {
			// if error
			alert(msg.substr(4));
		} else {
			$('#cont').html(msg);
			// $('textarea.expanding').autogrow(); //autogrow implementation on
			// TEXTAREA with class='expanded'
		}
	});
	return false;
}

// wishlist

function wishlistSwitch() {
	$('#wishlist').load(location.href, {
		wishlist : 1
	});
}

function setAlert() {
	$('#wishlist').load(location.href, {
		setalert : $('input[name="alertprice"]').val()
	});
}
function removeAlert() {
	$('#wishlist').load(location.href, {
		setalert : 0
	});
}

