$(document).ready(function(){

$("input#username").css("background","url(/_img/enter-username.gif) #e6f0f6 no-repeat");
$("input#userpass").css("background","url(/_img/enter-password.gif) #e6f0f6 no-repeat");


$("input#username").
    focus(
      function(event){
      $("input#username").css("background-image","none");
        return false;});

$("input#username").
    blur(
      function(event){
      if($("input#username").attr("value") == undefined) 
      {
      	$("input#username").css("background","url(/_img/enter-username.gif) #e6f0f6 no-repeat");
      }
        return false;});

$("input#userpass").
    focus(
      function(event){
	      $("input#userpass").css("background-image","none");
        return false;
      });
      
$("input#userpass").
    blur(
      function(event){
      
      if($("input#userpass").attr("value") == undefined) 
      {
				$("input#userpass").css("background","url(/_img/enter-password.gif) #e6f0f6 no-repeat");
      }
        return false;});      
      
      
});
function doVote(id, value){
	$.ajax({
		type: "GET",
		url: "/bestoftheweb/vote.html",
		data: "ajax=1&id="+id+"&vote="+value,
		success: function(msg){
			setRating(msg);

		}
	});
}

function slide(x){
	$("div#"+x).slideToggle("slow");
	if($("div#"+x+" p.close").length == 0){

		$("div#"+x).append('<p class="slidefooter close"><a href="" onclick="slide(\''+x+'\');return false;">Close</a></p>');

	}
}

function setRating(msg){
	$("div#votestars a").each(function(){
		if(($(this).attr("id")).substring(4,5) <= msg)
		{
			$(this).attr("class", "selected");
		}
		else
		{
			$(this).attr("class", "");
		}
		}
	);
	
}

function setCategory(){
	var cat = $("select#section").val();
	$("select#nav").val(0);
	$("select#nav option").each(
		function(){
		//alert($(this).attr("class"));
			if($(this).attr("class") != cat){
			//alert('Hello');
				$(this).attr('disabled', 'disabled');
			}
			else{
				$(this).removeAttr('disabled');
			}
		}
	);
}

