
function encode(s)
{
	var str = "";
	var charToAdd = "";
	var specialChars = "&? @%";
	for (var i = 0; i < s.length; i++)
	{
		for (var j = 0; j < specialChars.length; j++)
		{
			if (s.charAt(i) == specialChars.charAt(j))
			{
				charToAdd = "+";
				break;
			}
			else
			{
				charToAdd = s.charAt(i);
			}
		}
		str += charToAdd;
	}
	return str;
}

//send user to a particular movie on movie-meter
function sendMovie(section, movie, sectionName, movieName) {

    //update the subject line:
    var subject = "A Friend Wants You to See Moviefone's Movie-Meter";


    var urlStr = document.URL.split("?");
    var sendUrl = urlStr[0] + escape("?") + "section=" + section + escape("&") + "movie=" + movie;

    //update the body copy: movieName is name of the movie and sectionName is section (Must See Top 11, Funny, Serious, etc)
    var body = "Check out " + movieName + " in the " + sectionName + " section of Moviefone Movie-Meter at " + sendUrl;

    location = "mailto:?subject=" + subject + "&body=" + body;
}

function imMovie(section, movie, sectionName, movieName) {
    // code to IM a movie
    var urlStr = document.URL.split("?");
	var sendUrl = urlStr[0] + "?section=" + section + "%2526movie=" + movie;

    //update the body copy: movieName is name of the movie and sectionName is section (Must See Top 11, Funny, Serious, etc)
    var body = "Check out " + movieName + " in the " + sectionName + " section of Moviefone Movie-Meter at ";

	location = "aim:goim?message=" + encode(body) + sendUrl;
}

//send user to full list page
function sendFullListPage() {
    //update the subject line:
    var subject = "A Friend Wants You to See Moviefone's Movie-Meter";

    var urlStr = document.URL.split("?");
    var sendUrl = urlStr[0];

    //update body copy;
    var body = "Check out " + sendUrl;

    location = "mailto:?subject=" + subject + "&body=" + body;
}

