$(document).ready(function() {
	$("#voteFrm").submit(function() {
		DoVote();
		return false;
	});
    
    // link with games
    $(".top10 a").mouseover( function() {
        $(this).parent().parent().next().fadeIn("fast");
     } ).mouseout( function() {
        $(this).parent().parent().next().fadeOut("fast");
     } );
     
    // link with top10
    $(".top10_downloadsLnk").click( function(e) {
        e.preventDefault();
        var topTitle = $(this).parent().parent().prev().prev().prev();
        var topDivD = $(this).parent().prev().prev().prev();
        var topDivU = $(this).parent().prev().prev();
        if (topDivD.css('display') == 'none' ) {
            topDivU.hide();
            topDivD.show();
            topTitle.html('Top 10 Downloads');
        }
     } );
	 
     $(".top10_userLnk").click( function(e) {
        e.preventDefault();
        var topTitle = $(this).parent().parent().prev().prev().prev();
        var topDivD = $(this).parent().prev().prev().prev();
        var topDivU = $(this).parent().prev().prev();
        if (topDivU.css('display') == 'none' ) {
            topDivD.hide();
            topDivU.show();
            topTitle.html('Top 10 User Rated');
        }
     } );
	 
});


// make ajax request to vote script
function DoVote()
{
	var vote_name = $("#voteFrm input[@name='vote_name']").val(); 
	var vote = $("#voteFrm input:radio[@name='vote']:checked").val(); 
	
	if ( vote == null ) 
		$('#voteMsg').html('Please pick variant you voting for');
	else {
		$.post( $("#voteFrm").attr("action"), {
			vote_name: vote_name,
			vote: vote
		},
		function(data) {
			$("#voteFrm").html(data).fadeIn("slow");			
		}
		);
	}
	
}