$(document).ready(function(){
		
	$('li').show();
		
	$('#bxcar').bxCarousel({
		display_num: 6,
		move: 6,
		speed:3000,
		auto_interval:8000,
		/*
		prev_text:'',
		next_text:'',
		*/
		
		prev_image:'images/btn-next1.png',
		next_image:'images/btn-next1-06.png',
		
		auto: true,
		controls: true,
		margin: 7,
		auto_hover: true
	});
	
			
	$('img[title]').qtip({
		content		: false, // Set the tooltip content to the current corner
		position	: {
			corner	: {
				tooltip	: 'topMiddle', // Use the corner...
				target	: 'bottomMiddle' // ...and opposite corner
			}
		},
		show : {
			when : 'mouseover'
		},
		hide	: 'mouseout', // Don't specify a hide event
		style	: {
			border: {
				width	: 5,
				radius	: 10
			},
			padding		: 10, 
			textAlign	: 'center',
			tip			: true, // Give it a speech bubble tip with automatic corner detection
			name		: 'dark' // Style it according to the preset 'cream' style
	   }
	});
	
	//Rating
	 
	 $("[id^=rating_]").hover(function() {
		rid = $(this).attr("id").split("_")[1];
		$("#rating_"+rid).children("[class^=star_]").children('img').hover(function() {
			$("#rating_"+rid).children("[class^=star_]").children('img').removeClass("hover");
			
			var hovered = $(this).parent().attr("class").split("_")[1];
			while(hovered > 0) {
				$("#rating_"+rid).children(".star_"+hovered).children('img').addClass("hover");
				hovered--;
			}

		});
	});

	$("[id^=rating_]").children("[class^=star_]").click(function() {
		
		var current_star = $(this).attr("class").split("_")[1];
		var rid = $(this).parent().attr("id").split("_")[1];
		$('#rating_'+rid).load('send.php', {rating: current_star, id: rid});
		return false;
	});
	 
	// dropdown time period in most popular
	$('#popularFilter select').change( function(){
		var selectedVal =  $('#popularFilter select').val();
		if(selectedVal == 'period')
			document.location = 'index.php?sort=DownloadCountPeriod';
		else
			document.location = 'index.php?sort=DownloadCount';
	});
	
	if($('#tabs ul li.current').attr('id') == 'mostPopularTab')
		$('#popularFilter').show();
	else
		$('#popularFilter').hide();
			
});


function ddAlert()
{
	var Info = "Click on the widget title for more information about this widget.<br/> Drag the widget icon over your toolbar to install it.";
	jAlert(Info, 'Drag & Drop');
}

