function rate(rating, scene_id) {
	$("#rating_" + scene_id + " a").remove();
	$.post("/ajax/action_rating.php", "type_id=5&item_id=" + scene_id + "&rating=" + rating, function (data) {
		$.jGrowl(data.message);
		if (data.code == 0) {
			$("#rating_" + scene_id + " .filled").
				css("width", data.avg_vote * 20 + "%").
				removeClass("filled").
				addClass("voted");
		}
	}, "json");
}

function loadPager (pager_id, page, pp, total, width, extra, pvar) {
	$.ajax({
		type: "POST",
		url: "/ajax/insert_pager.php",
		data: $.param({
			p: page,
			pp: pp,
			total: total,
			width: width,
			pvar: pvar,
			extra: extra
		}),
		success: function (msg) {$("#" + pager_id).html(msg);}
	});
}

function report_broken( scene_id ){
    
    var ie = false;
    if( navigator.appName == "Microsoft Internet Explorer" )
        ie = true;
    
    var url = "write_rate/report_broken.php?scene_id=" + scene_id;

    var width = 560;
    var height = 300;
    var x = 0;
    var y = 0;
    
    if( ie ){
        x = (document.body.clientWidth - width) / 2;
        y = (document.body.clientHeight - height) / 2;
    }else{
        x = (window.outerWidth - width) / 2;
        y = (window.outerHeight - height) / 2;
    }

    var sOWin;
    var sWinOpts = "align=center,location=no,menubar=no,titlebar=no,toolbar=no,height=" + height + ",width=" + width + ",left=" + Math.round(x) + ",top=" + Math.round(y) + ",resizable=no,scrollbars=yes,status=no";
    
    sOWin = window.open(url, "", sWinOpts);
    
    sOWin.blur();
    sOWin.focus();
    
}

function addToFavorites(type_id, item_id) {
	var data = { item_id: item_id, type_id: type_id, action: "add" };
	$.post("/ajax/action_favorites.php", data, function (data) {
		$.jGrowl(data.message);
	}, "json");
}

function deleteFavorite(type_id, item_id) {
	var data = { item_id: item_id, type_id: type_id, action: "remove" };
	$.post("/ajax/action_favorites.php", data, function (data) {
		$.jGrowl(data.message);
	}, "json");
}
