    $(document).ready(function(){
        $(".submit").hover(function(){
            $(this).css("background", "#79D3FD");
        }, function(){
            $(this).css("background", "#DEF4FE");
        });
      
        
    });
    
    function changeImage(){
        var num = Math.random()*1000;
        var src = "captcha.php?a="+Math.round(num);        
        $("#captchaImage").attr("src", src);    
    }    
   
    function validateForm(){
        var data = $("#voteForm").serialize();
        
        $.ajax({
            url: "ajax.php?action=validate",
            type: "POST",
            cache: false,
            data: data,
            success: function(json)
            {
                $(".error").remove();      
                var response = JSON.parse(json);
                if (response.status == "OK") 
                {
                    $("#voteForm").submit();                
                }
                else 
                {
                    var messages = response.errors;   
                    changeImage();     
                    for (var i = 0; i < messages.length; i++) 
                    {                                
                        if ( messages[i].id != null && messages[i].text != "") 
                        {                    
                            $("#" + messages[i].id).after("<div class='error'>" + messages[i].text + "<\/div>");  
                        }                    
                    }                
                }                 
            }
        });                 
    }
    
    
    function cancel(){
        history.back();
    }
    
    function showMessage(message){
        $("#message").html(message).positioning(0,-200,1,1, 1, 1); 
        $("#jDialogOverlay").css("display", "block");
        setTimeout(function(){
            $('#message').html('');
            $("#jDialogOverlay").fadeOut("slow");
        }, 2000);
        
    }