function getUniqid(){
	var newDate = new Date();
	return newDate.getTime().toString(16);
}

function getMousePosition(timeoutMilliSeconds) {
	// "one" attaches the handler to the event and removes it after it has executed once 
	$(document).one("mousemove", function (event) {
			window.mouse={x:event.pageX, y:event.pageY};
			//console.log(window.mouse);
			// set a timeout so the handler will be attached again after a little while
			setTimeout("getMousePosition(" + timeoutMilliSeconds + ")", timeoutMilliSeconds);
	});
}	

function setCookie(c_name,value,domain,expiredays) {
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+"="+escape(value)+((expiredays==null)?"":";expires="+exdate.toGMTString())+((domain)?";domain="+domain:"");
}

function maxSelectMulti(form, mctr) {
	var ctr = 0;

	for(var i=0; i<form.options.length; i++) {
		if (form.options[i].selected==true)
		ctr++;
	}
	if (ctr>mctr) {
		alert("You have selected too many options, only " + mctr + " are permitted.");
		return false;
	}
	return true;
}

function ucfirst(string) {
    return string.charAt(0).toUpperCase() + string.slice(1);
}

function MultiDimensionalArray(iRows,iCols) {
	var i;
	var j;
	var a = new Array(iRows);
	for (i=0; i < iRows; i++){
		a[i] = new Array(iCols);
		for (j=0; j < iCols; j++){
			a[i][j] = "";
		}
	}
	return(a);
}

function timePassed(time) {
	var currentTime=new Date();
	return Math.floor((currentTime.getTime()/1000)-time)+getTrueTime();
}

function getTimeZone() {
	var d=new Date();
	return -d.getTimezoneOffset();
}

function getTrueTime() {
	return cfg.sv_time-Math.floor(cfg.cv_time/1000);
}

function timeAgo2(time){
	/*adjusts for timezones*/
	var string;
	var absoluteTime=new Date();
	var timeAgo=timePassed(time);
	absoluteTime.setTime((timeAgo)*1000);//timeAgo*10000000);

	if(1>absoluteTime.getTime()) {
		return " Now ";
	}

	var totalDays=0;
	var months=0;
	while(absoluteTime.getTime()>((3600*24*28)*1000)) {
		absoluteTime.setTime(absoluteTime.getTime()-((3600*24*28)*1000));
		totalDays+=28;
		months++;
		if((5*12)<months) { return "over 5 years ago";}
	}

	if(0<Math.floor(months/12)) {
		return Math.floor(months/12) + " years ago ";
	} else if(0<months) {
		return months + " months ago";
	}	else if((absoluteTime.getUTCDate()-1+totalDays)>0) {
		return (absoluteTime.getUTCDate()-1+totalDays)+ " days ago";
	} else if (+absoluteTime.getUTCHours()>0) {
		return absoluteTime.getUTCHours()+" hrs ago";//+absoluteTime.getUTCMinutes()+" mins ";
	} else if (absoluteTime.getUTCMinutes()>0) {
		return absoluteTime.getUTCMinutes()+" mins ago";//+absoluteTime.getUTCSeconds()+" seconds ";
	} else if(absoluteTime.getUTCSeconds()>0) {
		return absoluteTime.getUTCSeconds()+" seconds ago";
	}
	return " could not calculate ";
}

function timeAgo(time) {
	var string;
	var absoluteTime=new Date();
	var timeAgo=timePassed(time);
	absoluteTime.setTime(time*1000);
	return absoluteTime.getUTCDate()+"."+absoluteTime.getUTCHours()+"."+absoluteTime.getUTCMinutes()+"."+absoluteTime.getUTCSeconds();

	var newTime=new Date();
	newTime.setTime(timeAgo*1000);
	if(newTime.getUTCDate()>7) { return "on "+absolute.toDateString(); }
	if(newTime.getUTCDate()>1) {
		string = newTime.getUTCDate()-1; string+=" days";
	}else if(newTime.getUTCHours()>0) {
		string = newTime.getUTCHours()+" hours";
	}else if(newTime.getUTCMinutes()>0) {
		string = newTime.getUTCMinutes()+" minutes";
	}else if(newTime.getUTCSeconds()>0) {
		string = newTime.getUTCSeconds()+" seconds";
	}
	return string+" ago.";
}

function timeAgo(time, lockTime) {
	if(time>lockTime) {
		return "0 seconds ago.";
	}
	var string;

	var absoluteTime=new Date();
	var timezone=getTimeZone()*60;
	absoluteTime.setTime( (time-timezone)*1000 );
	/*return time+"time "+timezone+"tz "+absoluteTime.getUTCFullYear()+"Y "+absoluteTime.getUTCMonth()+"M "+absoluteTime.getUTCDate()+"D "+absoluteTime.getUTCHours()+"H "+absoluteTime.getUTCMinutes()+"m "+absoluteTime.getUTCSeconds();*/

	var timeAgo=lockTime-time;
	var newTime=new Date();
	newTime.setTime(timeAgo*1000);
	/*return timeAgo+"time "+newTime.getUTCFullYear()+"Y "+newTime.getUTCMonth()+"M "+newTime.getUTCDate()+"D "+newTime.getUTCHours()+"H "+newTime.getUTCMinutes()+"m "+newTime.getUTCSeconds();*/

	if(newTime.getUTCDate()>7) { return "on "+absoluteTime.toDateString(); }

	if(newTime.getUTCMonth()>0) {
		string = newTime.getUTCMonth()+" months";
	}else if(newTime.getUTCDate()>1) {
		string = newTime.getUTCDate()-1; string+=" days";
	}else if(newTime.getUTCHours()>0) {
		string = newTime.getUTCHours()+" hours";
	}else if(newTime.getUTCMinutes()>0) {
		string = newTime.getUTCMinutes()+" minutes";
	}else if(newTime.getUTCSeconds()>0) {
		string = newTime.getUTCSeconds()+" seconds";
	}
	return string+" ago.";
}

function isEven(index) {
	if (index%2==0) {
		return true;
	}
	return false;
}

function isDefined(variable) {
    return (variable==undefined)?false:true;
}

function getViewport() {
	/* the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight */
	if (typeof window.innerWidth != 'undefined') {
		viewportWidth = window.innerWidth,
		viewportHeight = window.innerHeight
	}

	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
		viewportWidth = document.documentElement.clientWidth,
		viewportHeight = document.documentElement.clientHeight
	}

	// older versions of IE
	else {
		viewportWidth = document.getElementsByTagName('body')[0].clientWidth,
		viewportHeight = document.getElementsByTagName('body')[0].clientHeight
	}
	return [viewportWidth, viewportHeight];
}

function return2br(dataStr) {
	return dataStr.replace(/(\r\n|[\r\n])/g, "<br />");
}

function touchLastDiv() {
	/*this is because internet explorer is crap and hates refreshing DOM*/
	/*to force IE to refresh the DOM you can't use setTimeout because IE doesn't refresh the DOM during a setTimeout for whatever reason*/
	/*so to fix this all there's a 1em by 1em inline block at the bottom of the page*/
	/*Animating the width of this block seems to fix IE's stupid DOM manipulation issues*/
	setTimeout('$("#lastDiv").animate({width: "1em"}, 1500);', 1500);
	$("#lastDiv").animate({width: "2em"},1500);
	var lastDivAnimation = true;
}

var moreContentLoading={
	state: false,
	message: "Loading",
	running:function(){
		$("#moreContentLoading>[name='loading']").append('.');
		if($("#moreContentLoading>[name='loading']").text().length>15) {
			$("#moreContentLoading>[name='loading']").text(moreContentLoading.message);
		}
	},
	off:function(){
		window.clearInterval(moreContentLoading.state);
		$("#moreContentLoading>[name='loading']").text(moreContentLoading.message);
	},
	on:function(){
		moreContentLoading.state=setInterval("moreContentLoading.running()", 500);
		$("#moreContentLoading>[name='loading']").text(moreContentLoading.message);
	},
	update:function(str){
			moreContentLoading.message=str;
			moreContentLoading.off();			
	},
	show:function(){
		$("#moreContentLoading").show();
	},
	hide:function() {
		$("#moreContentLoading").hide();
	}
}

function lockScroll(scrollLock){
	if(true==scrollLock) {
		var scrollHeightLock=$(window).scrollTop();
		$(window).bind('scroll', function () {
			$.scrollTo(scrollHeightLock, {axis: 'y'});
			//setTimeout("$.scrollTo("+scrollHeightLock+", {axis: 'y'});",50);
		});
	} else {
		$(window).unbind('scroll');
		//clearTimeout(scrolldelay);
	}
}

function getTinyLink(url, title) {
	$.post(
		"http://herebegames.com/api/7fw/api-7fw.php",
		{'fullurl': url},
		function(json) {
			if(json.success==true) {
				shorturl=encodeURIComponent(json.link);
				title=encodeURIComponent(title);
				$("#retryTinyBox").hide();
				$("#tinybox").val(json.link);
				$("#toTwitter").	attr('href', "http://herebegames.com/share/twitter.php?tweetMessage="+shorturl);
				$("#toFacebook").	attr('href', "http://www.facebook.com/share.php?u="+url+"&t="+title);
				$("#toStumble").	attr('href', "http://www.stumbleupon.com/submit?url="+url+"&title="+title);
				$("#toReddit").		attr('href', "http://reddit.com/submit?url="+url+"&title="+title);
				$("#toFriend").		attr('href', "http://www.friendfeed.com/share?title="+title+"&link="+url);
				$("#toDiigo").		attr('href', "http://www.diigo.com/post?url="+url+"&title="+title);/*might need &desc*/
				$("#toDigg").		attr('href', "http://digg.com/submit?phase=2&url="+url+"&title="+title);
				$("#toDelicious").	attr('href', "http://delicious.com/post?url="+url+"&title="+title);
	/*
				$("#toTwitter").	attr('href', "http://herebegames.com/share/twitter.php?tweetMessage="+shorturl);
				$("#toFacebook").	attr('href', "http://www.facebook.com/share.php?u="+url+"&t="+title);
				$("#toStumble").	attr('href', "http://www.stumbleupon.com/submit?url="+url+"&title="+title);
				$("#toReddit").		attr('href', "http://reddit.com/submit?url="+url+"&title="+title);
				$("#toFriend").		attr('href', "http://www.friendfeed.com/share?title="+title+"&link="+url);
				$("#toDiigo").		attr('href', "http://www.diigo.com/post?url="+url+"&title="+title);//might need &desc
				$("#toDigg").		attr('href', "http://digg.com/submit?phase=2&url="+url+"&title="+title);
				$("#toDelicious").	attr('href', "http://delicious.com/post?url="+url+"&title="+title);
	*/
			} else {
				$("#retryTinyBox").show();
			}
	}, 'json');
}

/*auction confirmsubmit*/
function aucSubmit(){
	var returnVar=true;
	var error='';
	$(".auctionField").each(function(){
		if($(this).attr('status')=='0'){
			returnVar=false;
			error+=ucfirst($(this).attr('name'))+" field required.<br />";
		}
	});
	$("#auc_error").html(error);
	return returnVar;
}


/*function JavaScript Warning*/
function js_warning(message){
	var quickError;
	$("#quickerror").fadeIn(500);
	$("#quickerror div").text(message);
	if('number'==typeof(quickError)) {;
		clearTimeout(quickError);
	}
	quickError=setTimeout(function(){ $("#quickerror").fadeOut(500).children("div").text(""); }, 5000);
}

/*PUSH EDITOR*/
function edit_setup(fromID, toID) {
	temp='';
	$("#"+fromID+" div").each(function(){
		temp+=$(this).attr('name')+"_"+$(this).text()+"\r\n";
		$("#"+toID+" [name$="+$(this).attr('name')+"]").val($(this).text()).change();
	}).remove();
}


/*UPLOAD*/
function upload_setup(name, uniqid, userID, multi, fileDesc, fileExt, onFullComplete) {
	if(multi>=1) {multi=true;}else{multi=false;}
	$("#uploader"+uniqid).bind('change', function(){
		var tempHeight=0;
		$("#fileQueue"+uniqid).parent().children(':not(script):not(input)').each(function(i){
			tempHeight+=$(this).height();
			//alert(this.tagName +"+"+$(this).height());
		});
		//alert(tempHeight);
		$(this).animate({height: tempHeight}, 250);
		touchLastDiv();
	});
	$('#fileInput'+uniqid).uploadify({
		'uploader'  : cfg.base_url+'includes/uploadify/uploadify.swf',
		'script'    : cfg.base_url+'includes/upload2.php',
		'cancelImg' : cfg.base_url+'includes/uploadify/cancel.png',
		'buttonText': 'Upload...',
		'fileDesc'	: fileDesc,
		'fileExt'	: fileExt,
		'auto'      : true,
		'width'		: 130,
		'queueID'	: 'fileQueue'+uniqid,
		'wmode'		: 'transparent',
		'multi'		: multi,
		'folder'    : cfg.base_root+'files/upload',
		'method'	: 'POST',
		'simUploadLimit'	:	2,
		scriptData	: {	'userID' : userID },
		onError		: function (event, queueID, fileObj, errorObj) {
			js_warning('<br>'+errorObj.type+'<br>'+errorObj.info);
			$("#fileInput"+uniqid+queueID).remove();
			$("#fileQueue"+uniqid).prepend("<div style='whitespace: pre;'>Failed - "+fileObj.name+"</div>");
			setTimeout('$("#uploader'+uniqid+'").change();', 50);
			return false;
			/*message="fileObj[name]("+fileObj.name+")\n";
			message.="fileObj[size]("+fileObj.size+")\n";
			message.="fileObj[creationDate]("+fileObj.creationDate+")\n";
			message.="fileObj[modificationDate]("+fileObj.modificationDate+")\n";
			message.="fileObj[type]("+fileObj.type+")\n";
			message.="errorObj[type]("+errorObj.type+")\n";
			message.="errorObj[info]("+errorObj.info+")";*/
			//message="File name: "+fileObj.name+"\nError: "+errorObj.type+"\nDetails: "+errorObj.info;
			//alert(message);
		},
		onComplete	: function (event, queueID, fileObj, response, data) {
			response=eval('('+response+')');
			$("#"+name).val(JSON.stringify({'fileObj':fileObj, 'response':response, 'data':data})).change();
			$("#fileQueue"+uniqid).prepend("<div style='whitespace: pre;'>Complete - "+fileObj.name+"</div>");
			setTimeout('$("#uploader'+uniqid+'").change();', 50);
			return true;
			/*message="fileObj[name]("+fileObj.name+")\n";
			message+="fileObj[size]("+fileObj.size+")\n";
			message+="fileObj[creationDate]("+fileObj.creationDate+")\n";
			message+="fileObj[modificationDate]("+fileObj.modificationDate+")\n";
			message+="fileObj[type]("+fileObj.type+")\n";
			message+="data[fileCount]("+data.fileCount+")\n";
			message+="data[speed]("+data.speed+")";*/
			//alert(message);
		},
		onOpen		: function (event, queueID, fileObj) {
			setTimeout('$("#uploader'+uniqid+'").change();', 50);
		},
		onAllComplete	: function (event, data) {
			if(''!=onFullComplete) {
				$(onFullComplete).change();
			}
			setTimeout('$("#uploader'+uniqid+'").change();', 50);
		}
	});
}

/*Auto content loader - Scrolling*/
/*
function scroll_auto_bind(divID) {
	$("#"+divID).unbind().bind('scroll change', function() {
		scroll_auto_load(divID);
	});
}


function scroll_auto_load(divID) {
	divHeight=0;
	console.log(divID);
	$("#"+divID).children("div").each(function(){
		divHeight+=$(this).height();
	});
	if( (divHeight-100 < ($("#"+divID).scrollTop()+$("#"+divID).height())) &&  parseInt($("#"+divID).attr('page'))>-1 ) {
		$("#"+divID).unbind();
		$.post(cfg.base_url+'includes/ajax/getFiles_ajax.php', {id: '', type: 'image', noExtras: true, imageLink: false, titleLink: false, page: $("#"+divID).attr('page')}, function(json) {
			if(json.length<500){
				$("#"+divID).attr('page', -1);
			} else {
				$("#"+divID).append(json);
				$("#"+divID).attr('page', parseInt($("#"+divID).attr('page'))+1);
				touchLastDiv();
				$("#"+divID+" .width_100 .pointer").removeClass('pointer');
				$("#"+divID+" .width_100 .grid").addClass('pointer').unbind('click').bind('click', function() {
					$("#imgID").val($(this).attr('object')).change();
					$("#imgName").val($(this).children('div').text()).change();
					$("#showImg").attr('src', cfg.sv_file + "?id=" + $(this).attr('object') + "&thumb=yes").change();
				});
			}
			scroll_auto_bind(divID);
		});
	}
}
*/
/*div save and reload*/
/*
function refresh_save(button) {
	refreshControl = new Object();
	$(button).each(function(){
		target=($("#"+$(this).attr('link')).get(0));
		refreshControl[target.attributes.id.value] = new Object();
		$.each($(target.attributes), function(index){
			refreshControl[target.attributes.id.value][target.attributes[index].name]=target.attributes[index].value;
		});
	});
}
function refresh_load(button) {
	$.each(refreshControl[button], function(index) {
		$("#"+button).attr(index, refreshControl[button][index]);
	});
	$("#"+button).change();
}
*/
function title_append(name) {
	document.title+=" "+name;
}

function ajax_codes(value) {
	switch(value) {
		case "success":
			return "Request Complete";
			break;
			
		case "notmodified":
			return "Nothing new happened"
			break;
			
		case "error":
			return "Request Incomplete: Please try again";
			break;
			
		case "timeout":
			return "Request Timeout: Please try again";
			break;
			
		case "abort":
			return "Request Canceled: Client terminated Request";
			break;
		break;
		
		case "parsererror":
			return "Oh crap: this shouldn't be happening, you should report this in the bug section of the forums";
			break;
		
		default:
			return "Default: we seriously doubt an error took place, but it's not impossible";
			break;
		break;
	}
}

function change_game_favorite(object, callback) {
	$.ajax({
		type: 'POST',
		url: cfg.base_url+"includes/ajax/changeGameFav.php",
		data: {
					'data': object.attr('data'),
					'value':object.val()
				},
		success: function(data) {
			window[callback](true, data, object);
		},
		complete: function(jqXHR, response) {
			switch(response) {
				case "success":
				break;
				case "notmodified":
				break;
				/*case "error":*/
				/*case "timeout":*/
				/*case "abort":*/
				/*case "parsererror":*/
				default:
					window[callback](false, response, object);
				break;
			}
			//delete ajaxCtrl[ajaxRequestID]['ttl'];
		},
		dataType: 'json'
	});
}

function update_game_favorite(response, data, object) {
	if(true==response && 'true'==data.response) {
		$("."+data.pushback).attr('data', data.returnData);
		$("."+data.pushback).children('img').attr('src', data.link);
	}	else {
	}
}
/*
function getGameComment(offsetVar, limitVar, idVar, typeVar, typeSubVar, uniqidVar) {
	$.getJSON("<?=$cfg[site][base_url]?>includes/ajax/getcomments.php", {offset: offsetVar, limit: limitVar, id: idVar, type: typeVar, typeSub: typeSubVar}, function(json) {
		if(0==offsetVar) {
			$("#loading"+uniqidVar).hide();
		}
		var tick=offsetVar;
		$.each(json, function(i, comment) {
			//alert(i + comment['from']);
			if(isDefined(comment['end'])) {
				$("#getMoreComments"+uniqidVar).remove();
				$("#comments"+uniqidVar).append("<span style='display:block; margin-bottom:10px;'>"+comment['end']+"</span>");
			}else{
				var temp="";
				temp="<div class='colorgrid"+(isEven(tick)?1:0)+"' id='"+i+"'>";
				temp+="<span style='padding-bottom:12px;'>"+(comment['from'].length>1?"<a href='<?=$cfg['site']['base_url']?>members/profile.php?u="+comment['from']+"'>"+comment['from']+"</a> wrote:":"")+"<br>"+timeAgo(comment['when'],<?=time();?>)+"<? if($permissions->check('comments-$type', 'delete')) { ?><br><span onclick='$.post(\"<?=$cfg['site']['base_url']?>includes/ajax/deletecomments.php?seid=<?=$encryption->urlEncode(array('who'=>$user->ID, 'lulsalt'=>$_SERVER['REMOTE_ADDR'],))?>\", {id: "+i+"}, function(json) {$(\"#"+i+"\").text(\"Deleted\");}, \"json\");'>[delete]</span><? } ?></span>";
				temp+="<span style='padding-bottom:18px;'>"+comment['text']+"</span>";
				temp+="</div>";
				$("#comments"+uniqidVar).append(temp);
				tick++;
			}
			touchLastDiv();
		});
	});
	return offsetVar+limitVar;
}
*/


/*generally callback is returnRating*/
function addRating(object, callback) {
	$.ajax({
		type: 'POST',
		url: cfg.base_url+"includes/ajax/addratings.php",
		data: {data: object.attr('data')},
		success: function(data) {
			object.html(data)
		},
		success: function(data) {
			window[callback](true, data, object);
		},

		complete: function(jqXHR, response) {
			switch(response) {
				case "success":
				case "notmodified":
				break;
				/*case "error":*/
				/*case "timeout":*/
				/*case "abort":*/
				/*case "parsererror":*/
				default:
					window[callback](true, data, object);
				break;
			}
			//delete ajaxCtrl[ajaxRequestID]['ttl'];
		},
		dataType: 'json'
	});
}

function returnRating(response, data, object) {
	object.parent('#myRating').text(data.data)
}


/*generally callback is returnComments*/
function getComments(object, callback) {
	object.prepend("<div id='commentsLoading'>Loading...</div>");
	$.ajax({
		type: 'POST',
		url: cfg.base_url+"includes/ajax/getcomments.php",
		data: {
			data: object.attr('data')
		},
		success: function(data) {
			$("#commentsLoading").remove();
			window[callback](true, data, object);
		},
		complete: function(jqXHR, response) {
			switch(response) {
				case "success":
				break;
				case "notmodified":
				break;
				/*case "error":*/
				/*case "timeout":*/
				/*case "abort":*/
				/*case "parsererror":*/
				default:
					$("#commentsLoading").remove();
					window[callback](false, response, object);
				break;
			}
			//delete ajaxCtrl[ajaxRequestID]['ttl'];
		},
		dataType: 'json'
	});
}

/*generally callback is returnComments*/
function addComment(object, callback){
	$.ajax({
		type: 'POST',
		url: cfg.base_url+"includes/ajax/addcomments.php",
		data: {
			data: object.attr('data'),
			message: object.val()
		},
		success: function(data) {
			window[callback](true, data, object);
		},
		complete: function(jqXHR, response) {
			switch(response) {
				case "success":
				break;
				case "notmodified":
				break;
				/*case "error":*/
				/*case "timeout":*/
				/*case "abort":*/
				/*case "parsererror":*/
				default:
					window[callback](false, response, object);
				break;
			}
			//delete ajaxCtrl[ajaxRequestID]['ttl'];
		},
		dataType: 'json'
	});
}

function returnComments(response, data, object) {
	if(false==response) {
		object.before("<div>"+ajax_codes(data)+"</div>");
		return false;
	}
	if('false'==data.result) {
		object.before("<div>"+data.data.error+"</div>");
		return false;
	}
	object.val('');
	object.attr('data', data.returnData);
	$.each(data.data, function(i, index) {
		if("EOF"!=index.message) {
			
			if(typeof(index.ID)!='undefined') {
				var userLink=index.name.nameLink;
			} else {
				var userLink=index.name;
			}
			
			if(typeof(index.link)!='undefined') {
				var deleting="<div class='deleteConfirm pointer' data='"+index.link+"'>[delete]</div>";
			} else {
				var deleting='';
			}
			
			var temp=
				"<tr class='colorgrid"+(i%2)+"' link='comment_"+index.cID+"'>"+
					"<td style='padding: 2px 10px 10px 10px'>"+userLink+"<br>"+timeAgo2(index.time)+"<br>"+deleting+"</td>"+
					"<td>"+index.message+"</td>"+
				"</tr>"
			$("#"+data.pushback+" .comments").append(temp);

		} else { $("#"+data.pushback+" .getMoreComments").hide(); }
	});

}

function deleteComment(object) {
		$.ajax({
		type: 'POST',
		url: cfg.base_url+"includes/ajax/deleteComments.php",
		data: {
			data: object.attr('data'),
		},
		success: function(data) {
			var parentObj = $(object).parents('tr');
			$(parentObj).children('td').html('');
			$(parentObj).children('td:first').html('[deleted]')
			//window[callback](true, data, object);
		},
		complete: function(jqXHR, response) {
			switch(response) {
				case "success":
				break;
				case "notmodified":
				break;
				/*case "error":*/
				/*case "timeout":*/
				/*case "abort":*/
				/*case "parsererror":*/
				default:
					//window[callback](false, response, object);
				break;
			}
			//delete ajaxCtrl[ajaxRequestID]['ttl'];
		},
		dataType: 'json'
	});

}

/*generally callback is returnLeaderboard*/
function getLeaderboard(object, callback) {
	object.prepend("<div id='leaderboardLoading'>Loading...</div>");
	$.ajax({
		type: 'POST',
		url: cfg.base_url+"includes/ajax/getLeaderboards.php",
		data: {
			data: object.attr('data')
		},
		success: function(data) {
			$("#leaderboardLoading").remove();
			window[callback](true, data, object);
		},
		complete: function(jqXHR, response) {
			switch(response) {
				case "success":
				break;
				case "notmodified":
				break;
				/*case "error":*/
				/*case "timeout":*/
				/*case "abort":*/
				/*case "parsererror":*/
				default:
					$("#leaderboardLoading").remove();
					window[callback](false, response, object);
				break;
			}
			//delete ajaxCtrl[ajaxRequestID]['ttl'];
		},
		dataType: 'json'
	});
}

function returnLeaderboard(response, data, object) {
	if(false==response) {return false;}
	object.attr('data', data.returnData);
	$("#"+data.pushback+"").append(data.data);
	if('false'==data.result) { object.hide(); }
}

function addTag(object, callback) {
	$.ajax({
		type: 'POST',
		url: cfg.base_url+"includes/ajax/add_object_tag.php",
		data: {
			data: object.attr('data'),
			message: object.val()
		},
		success: function(data) {
			object.val('');
			window[callback](true, data, object);
		},
		complete: function(jqXHR, response) {
			switch(response) {
				case "success":
				break;
				case "notmodified":
				break;
				/*case "error":*/
				/*case "timeout":*/
				/*case "abort":*/
				/*case "parsererror":*/
				default:
					window[callback](false, response, object);
				break;
			}
		},
		dataType: 'json'
	});
}

function returnAddTag(response, data, object) {
	if(false==response) {
		var tmp=data;
		data=new Object();
		data.message="Could not add tag: "+tmp+".";
	}
	object.parent().append('<div>'+data.message+'</div>');
}

function manageTag(object, callback) {
	$.ajax({
		type: 'POST',
		url: cfg.base_url+"includes/ajax/manage_tags.php",
		data: {
			data: object.attr('data'),
			message: object.val()
		},
		success: function(data) {
			object.val('');
			window[callback](true, data, object);
		},
		complete: function(jqXHR, response) {
			switch(response) {
				case "success":
				break;
				case "notmodified":
				break;
				/*case "error":*/
				/*case "timeout":*/
				/*case "abort":*/
				/*case "parsererror":*/
				default:
					window[callback](false, response, object);
				break;
			}
		},
		dataType: 'json'
	});
}

function returnManageTag(response, data, object) {
	if(false==response) {return false;}


}
