
function search()
{
var str = document.searchform.search.value;
str = encodeURI(str);
if(str == "")
    return;
document.location.href = "/search/" + str + "/";
}
function openWindow(id)
{
window.open('/comment.php?id='+id,'','location=1,status=1,scrollbars=1,height=500,width=500');
}

$(document).ready(function(){
    
    
          $('.ratings_stars').hover(
            // Handles the mouseover
            function() {
                $(this).prevAll().andSelf().addClass('ratings_over');
                //$(this).nextAll().removeClass('ratings_vote'); 
            },
            // Handles the mouseout
            function() {
                $(this).prevAll().andSelf().removeClass('ratings_over');
                // can't use 'this' because it wont contain the updated data
                //set_votes($(this).parent());
            }
        );
        
        
        // This actually records the vote
        $('.ratings_stars').bind('click', function() {
            var star = this;            
            var id = $(star).parent().attr('id').replace("i","");
            
            $.ajax({
               url : "/index.php?do=ajaxVote",
               data : ({"star" : $(star).attr('class'), "id" : id}),
               type : "POST",
               beforeSend : function(){
                    $("#vote"+id).html("<img src='/Files/Loading.gif' height='16'>");
               },
               success : function(ret){
                    var sc = ret.substring(0,1);
                    var oth = ret.substring(1);
                    if(sc != "e")                    
                        set_votes($(star).parent(),sc);
                    $("#vote"+id).html(oth);                    
               } 
            });                                                   
        });
    
    $(".hovItem").hover(
    function() {
        $(this).stop().animate({ opacity: 1.0 }, 500);
    },
   function() {
       $(this).stop().animate({ opacity: 0.50 }, 500);
   });
    
    
});


function LoadFriends()
{
    $("#page-body").hide('slow');
    $("#page-body").show('slow');
    
    $.ajax({
        url: "/?do=LoadFriends",
        beforeSend : function(){
            $("#page-body").html("<div align=center><img src='/Files/Loading.gif' width=16></div>");
        },
        success : function(ret){
            $("#page-body").html(ret);
        }
    })
        
}


function highlight(elemnt) {document.getElementById(elemnt)
.select();document.getElementById(elemnt).focus();if (document.all) {textRange = document.
getElementById(elemnt).createTextRange();textRange.execCommand("RemoveFormat")
;textRange.execCommand("Copy");alert("?? ???? ?? ????? ????? ??? ??");}}



 function set_votes(widget,avg) {        
        
        $(widget).find('.star_' + avg).prevAll().andSelf().addClass('ratings_vote');
        $(widget).find('.star_' + avg).nextAll().removeClass('ratings_vote');         
    }


        
        
function randRefresh()
{
    $.ajax({
        url : "/?do=ajaxGetRandomImage",
        beforeSend : function(){
            $("#RandIm").html("<img src='/Files/Loading.gif' width=24>");
        },
        success : function(ret){            
            $("#RandIm").html(ret);
        }
    });
}
