// Pagination next
function showNextGiftGroup()
{
	showGiftGroup(currentGiftGroup+1);
}

// Pagination previous
function showPreviousGiftGroup()
{
	showGiftGroup(currentGiftGroup-1);
}

// User clicks a certain page (1, 2, etc)
function showGiftGroup(n)
{	
	if(n > lastGiftGroup) {
		n = lastGiftGroup;
	}
	if(n < 1) {
		n = 1;
	}
	speed = 75;
	
	// Fade out, then fade in.
	$('.giftGroup'+currentGiftGroup).each(function() {
		$(this).fadeOut(speed, function() {
			$('.giftGroup'+n).each(function() {
				$(this).fadeIn(speed);
			});
		});
	});
	
	// Select the proper paginated page.
	$('#page'+currentGiftGroup).removeClass('selected');
	$('#page'+n).addClass('selected');
	
	currentGiftGroup=n;
}

// TODO: implement in PHP products.php
//20100616: mayank to add <br> tag in title if title contains character between 11 to 22.
function titleTwoLines(title)
{
    Title = $.trim(title);

    // only broke for less 22 chars
    var broke = 22;
    if (Title.length>=broke) return Title;

    // only broke until char 10
    broke = 10;
    var pos = Title.indexOf(" ");
    if (pos<=broke) return Title;

    if (pos!=false) return Title.substr(0,pos) +"<br>"+ Title.substr(pos); else return Title;
}
