var RootPath = "/phpscripts/";

$(function() {
    loadHighScores();
});

function loadHighScores() {
    var randomnumber = Math.floor(Math.random() * 1000000);
	var myurl = RootPath + "scores.php?id=" + mmGameId + "&rand=" + randomnumber;

	$.ajax({type: "get", url: myurl, success: function(fContent) {
		$("#site_highScores").hide().html(fContent).fadeIn('slow');
    }});
}

function saveScore(pn, s) {
    var randomnumber = Math.floor(Math.random() * 1000000);
    var myurl = RootPath + "score.php?id=" + mmGameId + "&rand=" + randomnumber + "&pn=" + pn + "&s=" + s;

    $.ajax({type: "get", url: myurl, success: function(fContent) {
		window.location.reload();
        /*var score = "<div id=\"site_flashGameBucket_gameScore\"><h3>You Scored:</h3><p>" + s + " points!</p></div>";
        
        if (fContent <= 10) { 
            score += "<div id=\"site_flashGameBucket_gameRank\"><h3>You are Ranked:</h3><p>" + getPlace(fContent) + " Place!</p></div>";
            loadHighScores(); 
        }

        $("#site_scoreInfo").hide().html(score).fadeIn('slow');*/
    }});
}

function getPlace(place) {
    if (place == "1") {
        return "1st";
    } else if (place == "2") {
        return "2nd";
    } else if (place == "3") {
        return "3rd";
    } else {
        return place + "th";
    }
}