function ratingmouseover(catnum, comment_ID, setnum) {
    var s = catnum.id.replace("rating_input_form_" + comment_ID + "_" + setnum + "_", '');	
    for (i = 1; i <= 5; i++ ){
        if (i <= s) {
            document.getElementById("rating_input_form_" + comment_ID + "_" + setnum + "_" + i).className = "on";
        } else {
            document.getElementById("rating_input_form_" + comment_ID + "_" + setnum + "_" + i).className = "";
        }
    }	
}
function ratingmouseout(me, comment_ID, setnum) {
    var current = document.getElementById("rating_input_form_" + comment_ID + "_" + setnum + "_rating").value;	
    for (i = 1; i <= 5; i++) {
        if (i <= current) {
            document.getElementById("rating_input_form_" + comment_ID + "_" + setnum + "_" + i).className = "on";
        } else {
            document.getElementById("rating_input_form_" + comment_ID + "_" + setnum + "_" + i).className = "";
        }
    }
}
function rateIt(me, comment_ID, setnum){
    var s = me.id.replace("rating_input_form_" + comment_ID + "_" + setnum + "_", '');
    document.getElementById("rating_input_form_" + comment_ID + "_" + setnum + "_rating").value = s;
    ratingmouseover(me, comment_ID, setnum);
}
function rating_validate(catcount){
    var setcount = 0; 
    for ( var i = 1; i <= catcount; i ++) {
        var txt=document.getElementById("rating_input_form_0_" + i + "_rating").value;
        if(txt!=0) setcount ++; 
    }
    if(setcount == 0) {
        alert("Please at first gimme a rating.");return false;
    } else return true;
}

function onthumbdown(template_id, template_type) {
    jQuery.ajax({
        type: "post",
        url: plugin_url + "/ratingsys-ajax.php",
        data: "action=thumbdown" + "&id=" + template_id + "&template=" + template_type,
        dataType: "xml",
        success: function(xml){
            if ( jQuery(xml).find("status").text() == "1" ) {
                jQuery("#" + template_type + "_" + template_id).html( jQuery(xml).find("content").text() ); 
            }
        },
        error: function(err){
            alert( "Error was occurred while setting the configuration information into DB." );
        }
    }); 
}
function onthumbup(template_id, template_type) {
    jQuery.ajax({
        type: "post",
        url: plugin_url + "/ratingsys-ajax.php",
        data: "action=thumbup" + "&id=" + template_id + "&template=" + template_type,
        dataType: "xml",
        success: function(xml){
            if ( jQuery(xml).find("status").text() == "1" ) {
                jQuery("#" + template_type + "_" + template_id).html( jQuery(xml).find("content").text() ); 
            }
        },
        error: function(err){
            alert( "Error was occurred while setting the configuration information into DB." );
        }
    }); 
}

function process_ratingsys_view(post_id, view_type) {
    jQuery.ajax({
        type: "post", 
        url: plugin_url + "/ratingsys-ajax.php", 
        data: "action=countview" + "&postid=" + post_id + "&viewtype=" + view_type, 
        datatype: "xml", 
        success: function(xml) {}, 
        error: function (err) { alert( "Error on ratingsys views." ); }
    }); 
}