var blocks = new Array();
var loadimg = '<img src="images/loading.gif" alt="Loading.." style="margin:auto;display:block;" />';
var loadimg2 = '<img src="images/loading3.gif" alt="Loading.." align="absmiddle" /> ';
var successimg = '<img src="images/greentick.png" align="absmiddle" /> ';
var fcheck = 0;
function shoutboxClose(block) {
$('#block_shoutbox').animate({height:0,opacity:0}, 500);
		$.ajax({
			type: "GET",
			url: "js/ajax/shoutbox_close.php",
			async: false,
			error:function(ajaxrequest){
				return false;
			},
			success:function(content){
				return true;
			}
		});
}
function sendpm() {
	
	$('#pmsubmit').attr('disabled', true);
	$('#sentpmstatus').fadeIn();
	$('#sentpmstatus').html(loadimg2 + ' Sending message..');
	var id = $('#pmusername').val();
	var subject = $('#pmsubject').val();
	// var message = $('#pmmessage').val();
	var message = tinyMCE.activeEditor.getContent();
		$.ajax({
			type: "POST",
			url: "js/ajax/sendpm.php",
			data: "username=" + id + "&subject="+subject+"&message="+message,
			async: false,
			error:function(ajaxrequest){
				$('#sentpmstatus').html('<div id="error">Failed</div>');
				return false;
			},
			success:function(content){
				if(content == "Message Sent!") {
					$('#sentpmstatus').html(successimg + content);
					setTimeout(function () {$('#newmessage').hide('normal')}, 4000);
					setTimeout(function () {$('#pmsubject').attr('value','')}, 4500);
					//setTimeout(function () {$('#pmmessage').attr('value','')}, 4500);
					setTimeout(function () {tinyMCE.activeEditor.setContent('')}, 4500);
					setTimeout(function () {$('#pmusername').attr('value','')}, 4500);
				} else {
					$('#sentpmstatus').html(loadimg2 + content);
				}
				setTimeout(function () {$('#pmsubmit').attr('disabled', false)}, 5000);
				setTimeout(function () {$('#pmsubmit').show('normal')}, 5000);
				setTimeout(function () {$('#sentpmstatus').fadeOut()}, 4500);
				setTimeout(function () {$('#sentpmstatus').html('')}, 5000);
				return true;
			}
		});
}
function addthanks(to,from,forr) {
	$('#addthanks').html('Sending thanks..');
		$.ajax({
			type: "POST",
			url: "js/ajax/addthanks.php",
			data: "to="+to+"&from="+from+"&for="+forr,
			async: false,
			error:function(ajaxrequest){
				$('#addthanks').html('Failed');
				return false;
			},
			success:function(content){
				$('#addthanks').html(content);
				setTimeout(function() {
						$('#addthanks').animate({
												opacity:0,
												height:0,
												width:0
												}, 500)
										  }, 1000);
				return true;
			}
		});
}
function addfriend(username,id) {
	$('#addfriendb').attr('disabled', true);
	$('#addfriendb').addClass('addfriend_send');
	$('#addfriendb').attr('value', 'Sending Invitation...');
		$.ajax({
			type: "POST",
			url: "js/ajax/addfriend.php",
			data: "id=" + id,
			async: false,
			error:function(ajaxrequest){
				$('#addfriend').html('<div id="error">Failed</div>');
				return false;
			},
			success:function(content){
				$('#addfriendb').attr('value', content);
				$('#addfriendb').addClass('addfriend_success');
				setTimeout(function() {
										  $('#addfriendb').animate({
																  opacity:0,
																  height:0,
																  width:0
																  }, 500)
										  }, 1000);
				return true;
			}
		});
}
function removefriend(username,id) {
	$('#addfriendb').attr('disabled', true);
	$('#addfriendb').addClass('addfriend_send');
	$('#addfriendb').attr('value', 'Removing...');
		$.ajax({
			type: "POST",
			url: "js/ajax/removefriend.php",
			data: "id=" + id,
			async: false,
			error:function(ajaxrequest){
				$('#addfriend').html('<div id="error">Failed</div>');
				return false;
			},
			success:function(content){
				$('#addfriendb').attr('value', content);
				setTimeout(function() {
										  $('#addfriendb').animate({
																  opacity:0,
																  height:0,
																  width:0
																  }, 500)
										  }, 1000);
				return true;
			}
		});
}
function toggleCheck(fn) {
	aryChk=document.fn;
	for(cptChk=0;cptChk<aryChk.length;cptChk++){
	  elem=aryChk[cptChk]
	  if( (elem.type.lower()=='checkbox') && (elem.checked==false) ){
		elem.checked=true;
	  }
	}
}
function toggleBlock(blockname) {
if(blocks[blockname] == 1) {
$('#'+blockname).slideDown('slow');
blocks[blockname] = 0;
} else {
$('#'+blockname).slideUp('slow');
blocks[blockname] = 1;
}
}
function out(message) {
		$.ajax({
			type: "POST",
			url: "js/ajax/shoutbox.php",
			data: "message=" + encodeURIComponent(message),
			async: false,
			error:function(ajaxrequest){
				return false;
			},
			success:function(content){
			document.getElementById('message').value = '';
				$('#shoutbox').load('js/ajax/shoutbox.php');
				return true;
			}
		});
}
function sponsor_click(lid) {
		$.ajax({
			type: "GET",
			url: "js/ajax/sponsor_click.php?id=" + lid,
			async: false,
			error:function(ajaxrequest){
				return false;
			},
			success:function(content){
				return true;
			}
		});
}
function sponsorClose(block) {
$('#block_sponsor1').animate({height:0,opacity:0}, 500);
		$.ajax({
			type: "GET",
			url: "js/ajax/sponsor_close.php",
			async: false,
			error:function(ajaxrequest){
				return false;
			},
			success:function(content){
				return true;
			}
		});
}