function tos() {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open('bth/tos.php', '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=600,left = 540,top = 300');");
}
function openSmilies() {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open('bth/smilies.php', '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=300,height=300,left = 540,top = 250');");
}

function popupsb() {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open('bth/shoutbox.php', '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=1,width=775,height=575,left = 540,top = 500');");
}

function deletealbum(id)
{
	msgQuestion = "Are you sure you want to delete this album?";
	userResponse = confirm(msgQuestion);
	if (userResponse == 1) {
		new Ajax.Request('bth/deletealbum.php',
		{
			parameters: {id: id},
			onSuccess: function(transport)
					   {
							if(transport.responseText = "sucess")
							{
								Effect.Fade('album_' + id, { duration: 1.0 });
							}
					   }
		});	} else {
			return;
		}
}
function tos() {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open('bth/tos.php', '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=600,left = 540,top = 300');");
}
function rename_album(a)
{
	album = "album-" + a;
	albumdo = "album-" + a;
	Event.stopObserving(albumdo);
	var show = function(d)
	{
		data = d.responseText;
		$(albumdo).innerHTML = d.responseText;
	}
	
	$(albumdo).innerHTML = "Loading...";
	new Ajax.Request("bth/doupdate.php?id="+a,
	{
		onSuccess:show
	}
	);
 
}
function do_album(a,b)
{
	album = "album-" + b;
	albumdo = "album-" + b;
		
	var show = function(d)
	{
		$(albumdo).innerHTML = d.responseText;
	}
	$(albumdo).innerHTML = "Saving...";
	new Ajax.Request("bth/getupdate.php",
	{
		parameters:"id=" + b + "&title=" + a,
		onSuccess:show
	}
	);
}
function display_album(a)
{
	display = "display-" + a;
	displaydo = "display-" + a;
	Event.stopObserving(displaydo);
	var show = function(d)
	{
		data = d.responseText;
		$(displaydo).innerHTML = d.responseText;
	}
	
	$(displaydo).innerHTML = "Loading...";
	new Ajax.Request("bth/doupdate_display.php?id="+a,
	{
		onSuccess:show
	}
	);
 
}
function do_display_album(a,b)
{
	display = "display-" + b;
	displaydo = "display-" + b;
		
	var show = function(d)
	{
		$(displaydo).innerHTML = d.responseText;
	}
	$(displaydo).innerHTML = "Saving...";
	new Ajax.Request("bth/getupdate_display.php",
	{
		parameters:"id=" + b + "&option=" + a,
		onSuccess:show
	}
	);
}

function rate(score, user)
{
	new Ajax.Request('bth/rate.php',
	{
		parameters: {score: score, user: user},
		onSuccess: function(transport)
				   {
				   	  document.getElementById('rating').innerHTML = transport.responseText;
				   }
	});
}
var i = 1;
function numstars(score)
{
	if(isNaN(score)) { return; }
	
	i = 1;
	
	for(i=1;i<=5;i++)
	{
		document.getElementById('rating_' + i).src = "images/vote_off.gif";
	}
		
	i = 1;
	
	for(i=1;i<=score;i++)
	{
		document.getElementById('rating_' + i).src = "images/vote_on.gif";
	}
}
function reportcomment(comment)
{
	msgQuestion = "Are you sure you want to report this comment?";
	userResponse = confirm(msgQuestion);
	if (userResponse == 1) {
		new Ajax.Request('bth/reportcomment.php',
		{
			parameters: {comment: comment},
			onSuccess: function(transport)
					   {
					   	  alert("Comment Reported");
					   }
		});	} else {
			return;
		}
}

function deletecomment(comment, userid)
{
	msgQuestion = "Are you sure you want to delete this comment?";
	userResponse = confirm(msgQuestion);
	if (userResponse == 1) {
		new Ajax.Request('bth/deletecomment.php',
		{
			parameters: {comment: comment},
			onSuccess: function(transport)
					   {
							if(transport.responseText = "sucess")
							{
								Effect.Fade('comment_' + comment, { duration: 1.0 });
							}
					   }
		});	} else {
			return;
		}
}

function reportuser(user)
{
	var userResponse = prompt('Why do you want to report this user?');
	
	if(userResponse == null) {
		return;
	} else if(userResponse == "") {
		alert("You did not enter a reason!");
	} else {
		new Ajax.Request('bth/reportuser.php',
				{
					parameters: {user: user, reason: userResponse},
					onSuccess: function(transport)
							   {
							   	  alert("User Reported");
							   }
				});
	}
}

function postcomment(id)
{
	var comment = document.getElementById('comment').value;
	var user = id;
	if(comment == "") {
		alert("You did not enter a comment!");
		return;
	} else {
		new Ajax.Request('bth/docomment.php',
				{
					parameters: {user: user, comment: comment},
					onSuccess: function(transport)
							{
								var response = transport.responseText || "no response text";
								if(response.match("<table") != null) {
								  	document.getElementById('comment').value = '';
									document.getElementById('message').innerHTML = '<span style="color:green;">Comment Posted.</span>';
						  			Effect.Pulsate(document.getElementById('message'), { pulses: 2, duration: 0.5 });
						  			$('comments').insert({top: '<div id="newcomment" style="display: none;">' + response + '</div>'});
						  			RoundedTop("div.bthCommentsNew","#F5F5F5","#FFF");
									RoundedBottom("div.bthCommentsNew","#F5F5F5","#FFF");
						  			Effect.Appear('newcomment', { duration: 0.5 });
								} else {
									document.getElementById('message').innerHTML = transport.responseText;
						  			Effect.Pulsate(document.getElementById('message'), { pulses: 2, duration: 0.5 });
						  		}
							}
				});
	}
}

function GetComments(id)
{
	new Ajax.Request('bth/getcomments.php?id='+id,
	{
		method: 'get',
  		onSuccess: function(transport)
				   {
				   	  document.getElementById('comments').innerHTML = transport.responseText;
					  Effect.Pulsate(document.getElementById('comments'), { pulses: 2, duration: 0.5 });
				   }
	});
}
function addFriend(id)
{
		new Ajax.Request('bth/dofriends.php?act=add',
		{
			parameters: {add: id, id: id},
			onSuccess: function(transport)
					   {
							if(transport.responseText == "sucess")
							{
								Effect.Fade('friend_img', { duration: 1.0 });
							}
					   }
		});
}
function GetFriends(page,user)
{
	new Ajax.Request('bth/getfriends.php?id='+user+'&page='+ page + '',
	{
		method: 'get',
  		onSuccess: function(transport)
				   {
				   	  document.getElementById('friends').innerHTML = transport.responseText;
					  RoundedTop("li.bthBoxFriends","#F5F5F5","#FFF");
					  RoundedBottom("li.bthBoxFriends","#F5F5F5","#FFF");				   
					}
	});
}

function GetMyFriends(page)
{
	new Ajax.Request('bth/getmyfriends.php?page='+ page + '',
	{
		method: 'get',
  		onSuccess: function(transport)
				   {
				   	  document.getElementById('friends').innerHTML = transport.responseText;
					  RoundedTop("li.bthBox","#F5F5F5","#FFF");
					  RoundedBottom("li.bthBox","#F5F5F5","#FFF");	
				   }
	});
}

function acceptFriend(id)
{
		new Ajax.Request('bth/dofriends.php?act=accept',
		{
			parameters: {accept: id, id: id},
			onSuccess: function(transport)
					   {
							if(transport.responseText == "sucess")
							{
								Effect.Fade('friend_request_' + id, { duration: 1.0 });
							}
					   }
		});
}
function removeFriend(id,pageid)
{
		new Ajax.Request('bth/dofriends.php?act=remove',
		{
			parameters: {remove: id, id: id},
			onSuccess: function(transport)
					   {
							if(transport.responseText == "sucess")
							{
								Effect.Fade('friend_' + id, { duration: 1.0 });
								GetMyFriends(pageid);
							}
					   }
		});
}
function declineFriend(id)
{
		new Ajax.Request('bth/dofriends.php?act=decline',
		{
			parameters: {decline: id, id: id},
			onSuccess: function(transport)
					   {
							if(transport.responseText == "sucess")
							{
								Effect.Fade('friend_request_' + id, { duration: 1.0 });
							}
					   }
		});
}
function acceptAll()
{
		id = "all";
		new Ajax.Request('bth/dofriends.php?act=acceptall',
		{
			parameters: {acceptall: id},
			onSuccess: function(transport)
					   {
							if(transport.responseText == "sucess")
							{
								loadPage('bth/friends.php');
							}
					   }
		});
}
function declineAll()
{
		id = "all";
		new Ajax.Request('bth/dofriends.php?act=declineall',
		{
			parameters: {declineall: id},
			onSuccess: function(transport)
					   {
							if(transport.responseText == "sucess")
							{
								loadPage('bth/friends.php');
							}
					   }
		});
}
function addslashes(str) {
	str=str.replace(/\\/g,'\\\\');
	str=str.replace(/\'/g,'\\\'');
	str=str.replace(/\"/g,'\\"');
	str=str.replace(/\0/g,'\\0');
	return str;
}
function sendShout() {
	var message = document.getElementById("message").value;
	message = addslashes(message);
	if(message == "") {
		return;
	}
	document.getElementById("message").value = "";
	new Ajax.Request('bth/shout_do.php?act=send', {
		method: 'post',
		parameters: {shout: message},
		onSuccess: function(transport){
			
			document.getElementById("message").focus();	
		}
	});
}

function updateShoutFormat(type) {
	var bold = document.getElementById("bold").value;
	var italic = document.getElementById("italic").value;
	var underline = document.getElementById("underline").value;
	var color = document.getElementById("color").value;
	
	if(type == "bold") {
		if(bold == "B") {
			document.getElementById("bold").value = "B*";
			bold = "B*";
		} else {
			document.getElementById("bold").value = "B";
			bold = "B";
		}
	}
	if(type == "italic") {
		if(italic == "I") {
			document.getElementById("italic").value = "I*";
			italic = "I*";
		} else {
			document.getElementById("italic").value = "I";
			italic = "I";
		}
	}
	if(type == "underline") {
		if(underline == "U") {
			document.getElementById("underline").value = "U*";
			underline = "U*";
		} else {
			document.getElementById("underline").value = "U";
			underline = "U";
		}
	}
	new Ajax.Request('bth/shout_update.php', {
		method: 'post',
		parameters: {bold: bold, underline: underline, italic: italic, color: color}
	});	
}




function staffstartShouts() {
	staffgetShouts = new Ajax.PeriodicalUpdater('staffshoutarea', 'bth/staffshout_do.php?act=view', { method: 'get' });
}

function staffstopShouts() {
	staffgetShouts.stop();
}

function staffsendShout() {
	var message = document.getElementById("message").value;
	
	if(message == "") {
		return;
	}
	document.getElementById("message").value = "";
	new Ajax.Request('bth/staffshout_do.php?act=send', {
		method: 'post',
		parameters: {shout: message},
		onSuccess: function(transport){
			
			document.getElementById("message").focus();	
		}
	});
}

function staffupdateShoutFormat(type) {
	var bold = document.getElementById("bold").value;
	var italic = document.getElementById("italic").value;
	var underline = document.getElementById("underline").value;
	var color = document.getElementById("color").value;
	
	if(type == "bold") {
		if(bold == "B") {
			document.getElementById("bold").value = "B*";
			bold = "B*";
		} else {
			document.getElementById("bold").value = "B";
			bold = "B";
		}
	}
	if(type == "italic") {
		if(italic == "I") {
			document.getElementById("italic").value = "I*";
			italic = "I*";
		} else {
			document.getElementById("italic").value = "I";
			italic = "I";
		}
	}
	if(type == "underline") {
		if(underline == "U") {
			document.getElementById("underline").value = "U*";
			underline = "U*";
		} else {
			document.getElementById("underline").value = "U";
			underline = "U";
		}
	}
	new Ajax.Request('bth/staffshout_update.php', {
		method: 'post',
		parameters: {bold: bold, underline: underline, italic: italic, color: color}
	});	
}



function addemote(whattoadd)
{
	document.getElementById("message").value = document.getElementById("message").value + '' + whattoadd + '';
	document.getElementById("message").focus();
}

function banManager(type)
{
	if(type == "ban") {
		var message = "/ban ";
		var userResponse = prompt('Please enter the username of the person you wish to ban.');
	} else if(type == "unban") {
		var message = "/unban ";
		var userResponse = prompt('Please enter the username of the person you wish to unban.');
	}	
	if(userResponse == null) {
		return;
	} else if(userResponse == "") {
		return;
	} else {
		addemote(message + userResponse);
	}
}

function change_album(a,albumid)
{
	display = "album-" + a;
	displaydo = "album-" + a;
	Event.stopObserving(displaydo);
	var show = function(d)
	{
		data = d.responseText;
		$(displaydo).innerHTML = d.responseText;
	}
	
	$(displaydo).innerHTML = "Loading...";
	new Ajax.Request("bth/dochange_album.php?id="+a+"&album="+albumid,
	{
		onSuccess:show
	}
	);
 
}
function do_change_album(a,b,albumid)
{
	album = "album-" + b;
	albumdo = "album-" + b;
		
	var show = function(d)
	{
		$(albumdo).innerHTML = d.responseText;
		loadPage('bth/viewalbum.php?id='+albumid);
	}
	$(albumdo).innerHTML = "Saving...";
	new Ajax.Request("bth/getchange_album.php",
	{
		parameters:"id=" + b + "&album=" + a,
		onSuccess:show
	}
	);
}
function deletepic(id)
{
	msgQuestion = "Are you sure you want to delete this photo?";
	userResponse = confirm(msgQuestion);
	if (userResponse == 1) {
		new Ajax.Request('bth/deletephoto.php',
		{
			parameters: {id: id},
			onSuccess: function(transport)
					   {
							if(transport.responseText = "sucess")
							{
								Effect.Fade('photo_' + id, { duration: 1.0 });
							}
					   }
		});	} else {
			return;
		}
}
function albumcover(id,albumid)
{
		new Ajax.Request('bth/albumcover.php',
		{
			parameters: {id: id, album: albumid},
			onSuccess: function(transport)
					   {
							if(transport.responseText = "sucess")
							{
								loadPage('bth/viewalbum.php?id='+albumid);
							}
					   }
		});
}
function defaultphoto(id,albumid)
{
		new Ajax.Request('bth/defaultphoto.php',
		{
			parameters: {id: id},
			onSuccess: function(transport)
					   {
							if(transport.responseText = "sucess")
							{
								loadPage('bth/viewalbum.php?id='+albumid);
							}
					   }
		});
}

function display_photo(a)
{
	display = "display-" + a;
	displaydo = "display-" + a;
	Event.stopObserving(displaydo);
	var show = function(d)
	{
		data = d.responseText;
		$(displaydo).innerHTML = d.responseText;
	}
	
	$(displaydo).innerHTML = "Loading...";
	new Ajax.Request("bth/doupdate_display_photo.php?id="+a,
	{
		onSuccess:show
	}
	);

}

function do_display_photo(a,b)
{
	display = "display-" + b;
	displaydo = "display-" + b;
		
	var show = function(d)
	{
		$(displaydo).innerHTML = d.responseText;
	}
	$(displaydo).innerHTML = "Saving...";
	new Ajax.Request("bth/getupdate_display_photo.php",
	{
		parameters:"id=" + b + "&option=" + a,
		onSuccess:show
	}
	);
}

function getMembers(page,letter)
{
	new Ajax.Request('bth/getmembers.php?page='+ page + '&l=' + letter,
	{
		method: 'get',
  		onSuccess: function(transport)
				   {
				   	  document.getElementById('members').innerHTML = transport.responseText;
					  RoundedTop("li.bthBox","#F5F5F5","#FFF");
					  RoundedBottom("li.bthBox","#F5F5F5","#FFF");
				   }
	});
}

function getSearch(page,search)
{
	new Ajax.Request('bth/getsearch.php?page='+ page + '&search=' + search,
	{
		method: 'get',
  		onSuccess: function(transport)
				   {
				   	  document.getElementById('search_results').innerHTML = transport.responseText;
					  RoundedTop("li.bthBox","#F5F5F5","#FFF");
					  RoundedBottom("li.bthBox","#F5F5F5","#FFF");
				   }
	});
}

function doSearch() {
	var search = document.getElementById("search").value;
	getSearch('1', search);
}

function bthStaffListCats() {
	var ListOrder = Sortable.serialize('sortableList_staff');
	document.getElementById("right_middle").innerHTML = "<center><img src=images/progress_habbos.gif></center>";
	new Ajax.Request('bth/admin/stafflist/stafflist_cats.php', {
		method: 'post',
		parameters: {sortableListOrder: ListOrder},
		onSuccess: function(transport) {
			var response = transport.responseText || "no response text";
			document.getElementById("right_middle").innerHTML = response;  
			Sortable.create('sortableList_staff',{tag:'li'});
		}
	});	
}

function deletecat(id,name)
{
	msgQuestion = "Are you sure you want to delete "+name+"?";
	userResponse = confirm(msgQuestion);
	if (userResponse == 1) {
		new Ajax.Request('bth/admin/stafflist/deletecat.php',
		{
			parameters: {id: id},
			onSuccess: function(transport)
					   {
							if(transport.responseText = "sucess")
							{
								alert(name+" Deleted");
								loadPage("bth/admin/stafflist/stafflist_cats.php");
							}
					   }
		});	} else {
			return;
		}
}

function bthStaffListItems(catid) {
	var ListOrder = Sortable.serialize('sortableList_staff');
	document.getElementById("right_middle").innerHTML = "<center><img src=images/progress_habbos.gif></center>";
	
	new Ajax.Request('bth/admin/stafflist/stafflist_items.php?id='+catid, {
		method: 'post',
		parameters: {sortableListOrder: ListOrder},
		onSuccess: function(transport) {
			var response = transport.responseText || "no response text";
			document.getElementById("right_middle").innerHTML = response;  
			Sortable.create('sortableList_staff',{tag:'li'});
		}
	});	
}

function deleteitem(id,name,catid)
{
	msgQuestion = "Are you sure you want to delete "+name+"?";
	userResponse = confirm(msgQuestion);
	if (userResponse == 1) {
		new Ajax.Request('bth/admin/stafflist/deleteitem.php',
		{
			parameters: {id: id},
			onSuccess: function(transport)
					   {
							if(transport.responseText = "sucess")
							{
								alert(name+" Deleted");
								loadPage("bth/admin/stafflist/stafflist_items.php?id="+catid);
							}
					   }
		});	} else {
			return;
		}
}
function getAlbum(id) {
	new Ajax.Request('bth/getAlbum.php',
	{
		parameters: {id: id},
		onSuccess: function(transport)
				   {
				      var response = transport.responseText || "no response text";
				      document.getElementById("album").innerHTML = response;
				   }
	});
}
function uploaderFileStatusChanged( uploader, file ) {
	if( file.isFinished() && file.getType() == 0 ) {
		getAlbum(albumid);
		uploader.removeFile( file );
	}
	if( file.isFinished() && file.getType() == 1 ) {
		uploader.removeFile( file );
	}
	status = uploader.getStatus();
}
function caption_photo(a)
{
	caption = "caption-" + a;
	captiondo = "caption-" + a;
	Event.stopObserving(captiondo);
	var show = function(d)
	{
		data = d.responseText;
		$(captiondo).innerHTML = d.responseText;
	}
	
	$(captiondo).innerHTML = "Loading...";
	new Ajax.Request("bth/docaption.php?id="+a,
	{
		onSuccess:show
	}
	);
 
}
function do_caption(a,b)
{
	caption = "caption-" + b;
	captiondo = "caption-" + b;
		
	var show = function(d)
	{
		$(captiondo).innerHTML = d.responseText;
	}
	$(captiondo).innerHTML = "Saving...";
	new Ajax.Request("bth/getcaption.php",
	{
		parameters:"id=" + b + "&caption=" + a,
		onSuccess:show
	}
	);
}

function bthForgot() {
	var username = document.getElementById("forgot_username").value;
	var email = document.getElementById("forgot_email").value;
	
	document.getElementById("right_middle").innerHTML = "<center><img src=images/progress_habbos.gif></center>";
	new Ajax.Request('bth/forgot.php', {
		method: 'post',
		parameters: {username: username, email: email},
		onSuccess: function(transport){
			var response = transport.responseText || "no response text";
			document.getElementById("right_middle").innerHTML = response;    	
		}
	});
}
function bthTopFriends() {
	var ListOrder = Sortable.serialize('sortableList_friends');
	document.getElementById("right_middle").innerHTML = "<center><img src=images/progress_habbos.gif></center>";
	new Ajax.Updater("right_middle", "bth/top_friends.php", {
		parameters: {sortableListOrder: ListOrder},
		evalScripts: true,
		onComplete: function(transport) {
			var response = transport.responseText || "";	
			$("right_middle").innerHTML = response;
		}
	});
}

function superlookupmod() {
	var usersearch = document.getElementById("usersearch").value;
	var searchtype = document.getElementById("searchtype").value;
	
	document.getElementById("right_middle").innerHTML = "<center><img src=images/progress_habbos.gif></center>";
	new Ajax.Request('bth/mod/userlookup.php', {
		method: 'post',
		parameters: {usersearch: usersearch, searchtype: searchtype},
		onSuccess: function(transport){
			var response = transport.responseText || "no response text";
			document.getElementById("right_middle").innerHTML = response;    	
		}
	});
}
function ipcheckuser(username, pkmethod, searchip) {
	document.getElementById("right_middle").innerHTML = "<center><img src=images/progress_habbos.gif></center>";
	new Ajax.Request('bth/mod/ipcheck.php', {
		method: pkmethod,
		parameters: {username: username, searchip: searchip},
		onSuccess: function(transport){
			var response = transport.responseText || "no response text";
			document.getElementById("right_middle").innerHTML = response;    	
		}
	});
}

function ipcheckdups() {
	var username = document.getElementById("username").value;
	var searchip = document.getElementById("searchip").value;
	
	document.getElementById("right_middle").innerHTML = "<center><img src=images/progress_habbos.gif></center>";
	new Ajax.Request('bth/mod/ipcheck.php', {
		method: 'post',
		parameters: {username: username, searchip: searchip},
		onSuccess: function(transport){
			var response = transport.responseText || "no response text";
			document.getElementById("right_middle").innerHTML = response;    	
		}
	});
}

function walltowall() {
	var u1 = document.getElementById("u1").value;
	var u2 = document.getElementById("u2").value;
	
	document.getElementById("right_middle").innerHTML = "<center><img src=images/progress_habbos.gif></center>";
	new Ajax.Request('bth/walltowallform.php', {
		method: 'post',
		parameters: {u1: u1, u2: u2},
		onSuccess: function(transport){
			var response = transport.responseText || "no response text";
			document.getElementById("right_middle").innerHTML = response;    	
		}
	});
}



function displayAlert(msg) {
	alert(msg);
}

function createPopUp(popUpCode) { 
	var div = document.createElement("div"); 
	div.innerHTML = popUpCode; 
	document.body.appendChild(div.firstChild); 
}
function moreComments(userid, lastcomment) {
	$("next_comment").remove();
	
	var A = Builder.node("div", {
		id: "comment-progress",
		style: "margin: 20px 0 60px 294px;"
	});
	$("comments").appendChild(A);
          	
	new Ajax.Updater($("comments"), "/bth/getMoreComments.php", {
		method: "post",
		parameters: "userid="+userid+"&lastcomment="+lastcomment,
		evalScripts: true,
		insertion: "bottom",
		onComplete: function (F, E) {
			$("comment-progress").remove();
		}.bind(this)
	})
}
function useDonator(id) {
	new Ajax.Request('bth/store/useDonator.php?id='+id,
	{
		method: 'get',
		onSuccess: function(transport)
			{
				if(transport.responseText == "success") {
					getMyColors();
				} else { 
					alert("Some sort of error occured, please try again.");
				}
			}
	});
}
function purchaseDonator(id) {
	var cost = $("cost[" + id + "]").value;
	var name = $("name[" + id + "]").value;
	if(cost != "") {
		var check2 = confirm ("Are you sure you want to purchase \""+name+"\" for "+cost+" points?");
		if(check2) {
			new Ajax.Request('bth/store/transaction.php?type=color&id='+id+'&cost='+cost,
			{
				method: 'get',
		  		onSuccess: function(transport)
					{
						if(transport.responseText == "success") {
							updateCredits();
							alert("You have succesfully purchased \""+name+"\".");
							getMyColors();
						} else if(transport.responseText == "insufficient") {
							alert("You have insufficient points in your account!");
						} else {
							alert("Some sort of error occured, please try again.");
						}
					}
			});
		}	
	}
}
function updateCredits() {
	new Ajax.Request('bth/store/getCredits.php',
	{
		method: 'get',
		onSuccess: function(transport)
			{
				$("numcreds").innerHTML = transport.responseText;
			}
	});
}
function getMyColors() {
	new Ajax.Request('bth/store/getMyColors.php',
	{
		method: 'get',
		onSuccess: function(transport)
			{
				$("mycurrentcolors").innerHTML = transport.responseText;
			}
	});
}
function previewHover(score, image, image_hover, id)
{
	if(isNaN(score)) { return; }
	i = 1;
	for(i=1;i<=5;i++)
	{
		document.getElementById(id + '_preview_' + i).src = image;
	}
	i = 1;
	for(i=1;i<=score;i++)
	{
		document.getElementById(id + '_preview_' + i).src = image_hover;
	}
}
function useStar(id) {
	new Ajax.Request('bth/store/useStar.php?id='+id,
	{
		method: 'get',
		onSuccess: function(transport)
			{
				if(transport.responseText == "success") {
					getMyStars();
				} else { 
					alert("Some sort of error occured, please try again.");
				}
			}
	});
}
function purchaseStar(id) {
	var cost = $("cost[" + id + "]").value;
	var name = $("name[" + id + "]").value;
	if(cost != "") {
		var check2 = confirm ("Are you sure you want to purchase \""+name+"\" for "+cost+" points?");
		if(check2) {
			new Ajax.Request('bth/store/transaction.php?type=star&id='+id,
			{
				method: 'get',
		  		onSuccess: function(transport)
					{
						if(transport.responseText == "success") {
							updateCredits();
							alert("You have succesfully purchased \""+name+"\".");
							getMyStars();
						} else if(transport.responseText == "insufficient") {
							alert("You have insufficient points in your account!");
						} else if(transport.responseText ==  "existing") {
							alert("You have already purchased this!");
						} else {
							alert("Some sort of error occured, please try again.");
						}
					}
			});
		}	
	}
}
function getMyStars() {
	new Ajax.Request('bth/store/getMyStars.php',
	{
		method: 'get',
		onSuccess: function(transport)
			{
				$("mycurrentstars").innerHTML = transport.responseText;
			}
	});
}
function refreshSwfUpload() {
	$("submit2").hide();
	new Ajax.Updater('flashfile', '/bth/upload/uploadswf.html', {
		method: 'get',
		evalScripts: true
	});
	
}