$(function(){
	/*Control of video cookie existence, ad remove the "vota" button
	var c_name = $(".videodata").val();
	if(document.cookie.length > 0) {
		c_start = document.cookie.indexOf(c_name+'=');
		if(c_start === -1) {
			$(".votelink").css('display','inline');
		}
	}*/

	/*Setting "rating stars on-off" effect on right col videos*/
	$(".vid").hover(
		function() {
			$(".pngFix",this).css("display","inline");
			$(".pngFix",this).css("width","16px");
			$(".pngFix",this).css("height","16px");
		},	
		function() {
			$(".pngFix",this).css("display","none");
		}
	);
	
	/*Manage displays of the voting stars div on text "vota"*/
	$(".vote").click(
		function() {
			$("#stats").css("display","none");
			$(".starsys").css("display","block");
			return false;
		}
	);
	
	/*Manage "on-off" effect on stars to vote the video*/
	$(".nova").hover(
		function() {
			$(this).prevAll().andSelf().find(".pngFix").css("display","inline");
			$(this).prevAll().andSelf().find(".pngFix").css("width","16px");
		},
		function() {
			$(".starsys").find(".pngFix").css("display","none");
		}
	);
	
	/*Collect vote onclick the relative star, do a GET request to collect the vote
		and output the result message in the box, removing the voting system*/
	$(".nova").click(		
		function() {
			var video = $(".videodata").val();
			if($.browser.msie) {
				var vote = $(".pngFix", this).attr("title");
			}
			else {
				var vote = $("img", this).attr("alt");
			}
			
			$.post("/portale/canali/video/voting/index.php",
				{ id:video,v:vote},
				function(data) {
					$("#voted").html(data);
				}
			);
			$(".starsys").css("display","none");
			$("#voted").css("display","block");
			return false;
		}
	);
	
	/*Change scroller arrows color on hover*/
	
	$(".ScrollLeft, .ScrollRight").hover(
		function() {
			$(this).css('color', '#333');
		},
		function() {
			$(this).css('color', '#bbb');
		}
	);
	
	$("a" , ".HScroller").hover(
		function() {
			$(".title",this).css('text-decoration', 'underline');
		},
		function() {
			$(".title",this).css('text-decoration', 'none');
		}
	);
	
	/*Underline category text on hover category buttons*/
	
	$("a",".categories").hover(
		function() {
			$(".text",this).css('text-decoration','underline');
		},
		function() {
			$(".text",this).css('text-decoration','none');
		}
	
	
	);
	
});

