$(document).ready(function(){
	$(".btnSendMessage").hover(function() {
		$(this).addClass("active");
	}, function() {
		$(this).removeClass("active");
	});
	$(".btnVote").hover(function() {
		$(this).addClass("active");
	}, function() {
		$(this).removeClass("active");
	});
	$("#searchbox input.searchbox").css({'color' : '#a6a6a6'});
	$("#searchbox input.searchbox").val("S\u00F6k p\u00E5 Radiogamer");
	swapValues = [];
	$(".searchbox").each(function(i){
		swapValues[i] = $(this).val();
		$(this).focus(function(){
			if($(this).val() == swapValues[i]) {
				$(this).css({'color' : '#000'});
				$(this).val("");
			}
		}).blur(function(){
			if($.trim($(this).val()) == "") {
				$(this).css({'color' : '#a6a6a6'});
				$(this).val(swapValues[i]);
			}
		});
	});
	$("a.lightbox").lightBox();
	$("a.blank").each(function() {
		$(this).attr("target", "_blank");
		$(this).attr("title", $(this).attr("title")+" - \u00D6ppnas i nytt f\u00F6nster.");
	});
	$("a.external").each(function() {
		$(this).attr("target", "_blank");
		$(this).attr("title", $(this).attr("title")+" - Extern l\u00E4nk (\u00D6ppnas i nytt f\u00F6nster).");
	});
	$("a.player").each(function() {
		$(this).attr("target", "_blank");
		$(this).attr("title", $(this).attr("title")+" - \u00D6ppnas i nytt f\u00F6nster.");
		$(this).click(function() {
			LoadPlayer($(this).attr("href"));
			return false;
		});
	});
	$("textarea[maxlength]").keyup(function(){
		var max = parseInt($(this).attr("maxlength"));
		if($(this).val().length >= max) {
			$(this).val($(this).val().substr(0, $(this).attr("maxlength")));
		}
		$(this).parents().find(".charsRemaining").html("("+(max - $(this).val().length)+" tecken kvar)");
	});
	/*var rightadposition		= $("#right-ad").offset().top;
	$(window).scroll(function(){
		if($(window).scrollTop() > rightadposition){
			$("#right-ad").css("position", "fixed");
			$("#right-ad").css("top", 0);
		}
		if($(window).scrollTop() <= rightadposition){
			$("#right-ad").css("position", "static");
			$("#right-ad").css("top", rightadpositon);
		}
	});*/
	$("a.blog-comment_link").click(function() {
		$(this).parent().next(".blogpostinfo-link").toggle();
		$(this).parent().next(".blogpostinfo-link").children("input").select();
	});
	$("#frmBlogComment").validate({
		rules: {
			fldName: {
				required: true,
				rangelength: [2, 255]
			},
			fldEmailAddress: {
				required: true,
				email: true
			},
			fldComment: {
				required: true
			},
			fldCaptcha: {
				required: true
			}
		},
		messages: {
			fldName: "Du m&aring;ste ange ditt namn.",
			fldEmailAddress: "Du m&aring;ste ange en korrekt e-postadress.",
			fldComment: "Du m&aring;ste skriva en kommentar.",
			fldCaptcha: "Du m&aring;ste ange verifieringskoden."
		}
	});
	$(".scrolltotop").click(function() {
		$("html, body").animate({
			scrollTop: 0
		}, "normal");
	});
});
