function reloadinfo(thatthing)
{
	$('#bmore').hide();
	$('#morepreload').show();
		
	numitems = $('#numitems').val();
	
	switch (thatthing) {
		case 'friends':
			urltarget = 'ajax/reload-friends-dashboard/r:';
			break;
		case 'followers':
			urltarget = 'ajax/reload-followers-dashboard/r:';
			break;
		case 'following':
			urltarget = 'ajax/reload-following-dashboard/r:';
			break;
		case 'requestssent':
			urltarget = 'ajax/reload-requestssent-dashboard/r:';
			break;
		case 'requestsreceived':
			urltarget = 'ajax/reload-requestsreceived-dashboard/r:';
			break;			
		case 'videos':
			urltarget = 'ajax/reload-videos-dashboard/r:';
			break;
		case 'likes':
			urltarget = 'ajax/reload-likes-dashboard/r:';
			break;
		case 'comments':
			urltarget = 'ajax/reload-comments-dashboard/r:';
			break;
		case 'activities':
			urltarget = 'ajax/reload-activities-dashboard/r:';
			break;
		case 'notifications':
			urltarget = 'ajax/reload-notifications-dashboard/r:';
			break;
		case 'messages':
			urltarget = 'ajax/reload-messages-dashboard/r:';
			break;
		case 'posts':
			urltarget = 'ajax/reload-posts-dashboard/r:';
			break;
		case 'photos':
			urltarget = 'ajax/reload-photos-dashboard/r:';
			break;
		case 'albums':
			urltarget = 'ajax/reload-albums-dashboard/r:';
			break;
		case 'grouprequest':
			urltarget = 'ajax/reload-groups-requests/r:';
			break;
		case 'groupmember':
			urltarget = 'ajax/reload-groups-members/r:';
			break;
	}

	$.ajax({
		type: 'POST',
		url: siteurl + urltarget + Math.round(Math.random()*1000),
		data: 'ni=' + numitems + '&idu=' + idu,
		success: function(h){
			switch(h.charAt(0)){
				case '0':
					alert(h.substring(3));
					$('#morepreload').hide();
					$('#bmore').show();
					break;
				
				case '1':
					cad = h.substring(3);
					$('#moreitems').append(cad);
					$('#numitems').val(parseInt($('#numitems').val()) + parseInt(itemperpage));

					$('#morepreload').hide();
					$('#bmore').show();
					$("abbr.timeago").timeago();
					stoprealod = 0;
					break;
					
				case '2':
					cad = h.substring(3);
					$('#moreitems').append(cad);
					$('#moreitemsbar').hide();
					//$('#numitems').val(parseInt($('#numitems').val()) + parseInt(itemperpage));
					$("abbr.timeago").timeago();
					stoprealod = 1;
					break;
			}
		},
		error: function(){
			alert(txt_norequest);
			$('#morepreload').hide();
			$('#bmore').show();
		} //end error
	}); // end ajax
}


/***********************************************************************/

function reload_photosalbum_dashboard()
{
	$('#bmore').hide();
	$('#morepreload').show();
		
	numitems = $('#numitems').val();

	$.ajax({
		type: 'POST',
		url: siteurl + 'ajax/reload-photosalbums-dashboard/r:' + Math.round(Math.random()*1000),
		data: 'ni=' + numitems + '&idu=' + idu + '&coda=' + codalbum,
		success: function(h){
			switch(h.charAt(0)){
				case '0':
					alert(h.substring(3));
					$('#morepreload').hide();
					$('#bmore').show();
					break;
				
				case '1':
					cad = h.substring(3);
					$('#moreitems').append(cad);
					$('#numitems').val(parseInt($('#numitems').val()) + parseInt(itemperpage));

					$('#morepreload').hide();
					$('#bmore').show();
					$("abbr.timeago").timeago();
					stoprealod = 0;
					break;
					
				case '2':
					cad = h.substring(3);
					$('#moreitems').append(cad);
					$('#moreitemsbar').hide();
					//$('#numitems').val(parseInt($('#numitems').val()) + parseInt(itemperpage));
					$("abbr.timeago").timeago();
					stoprealod = 1;
					break;
			}
		},
		error: function(){
			alert(txt_norequest);
			$('#morepreload').hide();
			$('#bmore').show();
		} //end error
	}); // end ajax
}


/***********************************************************************/


function reload_comments(codepost, itemperpage)
{
	$('#linkmore_' + codepost).hide();
	$('#morepreload_' + codepost).show();
	
	numitems = $('#numitems_' + codepost).val();

	$.ajax({
		type: 'POST',
		url: siteurl + 'ajax/reload-comments-post/r:' + Math.round(Math.random()*1000),
		data: 'ni=' + numitems + '&cp=' + codepost,
		success: function(h){
			switch(h.charAt(0)){
				case '0':
					alert(h.substring(3));
					$('#morepreload_' + codepost).hide();
					$('#linkmore_' + codepost).show();
					break;
				
				case '1':
					cad = h.substring(3);
					
					$('#thelistcomments_' + codepost).prepend(cad);
					
					$('#numitems_' + codepost).val(parseInt(numitems) + parseInt(itemperpage));
					
					$('#morepreload_' + codepost).hide();
					$('#linkmore_' + codepost).show();
					$("abbr.timeago").timeago();
					break;
					
				case '2':
					cad = h.substring(3);
					$('#thelistcomments_' + codepost).prepend(cad);
					$('.loadmorecomment_' + codepost).hide();
					$("abbr.timeago").timeago();
					break;
			}
		},
		error: function(){
			alert(txt_norequest);
			$('#morepreload_' + codepost).hide();
			$('#linkmore_' + codepost).show();
		} //end error
	}); // end ajax
}

/***********************************************************************/

function deletecomment(idcom, idp, idowner, codep) {
	$.ajax({
		type: 'POST',
		url: siteurl + "ajax/posts/r:" + Math.round(Math.random()*1000),
		data: 'todo=5&ic=' + idcom + '&ip=' + idp + '&io=' + idowner,
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					alert(resp.substring(3));
					break;

				case '1':
					$('#numcomments_' + codep).html(parseInt($('#numcomments_' + codep).html()) - 1);
					$("#comment_post_" + idcom).fadeOut(500, function() { $("#comment_post_" + idcom).remove(); });
					break;
			}
		},
		error: function(){
			alert(txt_norequest);
		} //end error
	}); // end ajax
}

/***********************************************************************/

function commentpost(codep, idp, iu) {
	$("#bsavecomm_" + codep).hide();
	$("#iloader_" + codep).show();
	
	comment = $.trim($('#comment_' + codep).val());
	if (comment == '') {
		$('#comment_' + codep).val(comment);
		openandclose('#msgerror2_' + codep, msgnocomment, 1700);
		$('#comment_' + codep).focus();
		$("#bsavecomm_" + codep).show();
		$("#iloader_" + codep).hide();
		return;
	}

	$.ajax({
		type: 'POST',
		url: siteurl + "ajax/posts/r:" + Math.round(Math.random()*1000),
		data: 'todo=4&ip=' + idp + '&iu=' + iu + '&cp=' + codep + '&c=' + encodeURIComponent(comment),
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					openandclose('#msgerror2_' + codep, resp.substring(3), 1700);
					$("#bsavecomm_" + codep).show();
					$("#iloader_" + codep).hide();
					break;
				
				case '1':
					$('#comment_' + codep).css('height','25px');
					$('#comment_' + codep).val('');
					$('#numcomments_' + codep).html(parseInt($('#numcomments_' + codep).html()) + 1);
					$('#replies_' + codep).append(resp.substring(3));
					$("#bsavecomm_" + codep).show();
					$("#iloader_" + codep).hide();
					$("abbr.timeago").timeago();
					break;
			}
		},
		error: function(){
			openandclose('#msgerror2_' + codep, txt_norequest, 1700);
			$("#bsavecomm_" + codep).show();
			$("#iloader_" + codep).hide();
		} //end error
	}); // end ajax
}

/***********************************************************************/

function likepost(codep, idp, iu) {
	$("#llike_" + codep).hide();
	$("#iloaderlike_" + codep).show();

	$.ajax({
		type: 'POST',
		url: siteurl + "ajax/posts/r:" + Math.round(Math.random()*1000),
		data: 'todo=1&ip=' + idp + '&iu=' + iu,
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					openandclose('#msgerror1_' + codep, resp.substring(3), 1700);
					$("#iloaderlike_" + codep).hide();
					$("#llike_" + codep).show();
					break;
				
				case '1':
					$('#numlikes_' + codep).html(parseInt($('#numlikes_' + codep).html()) + 1);
					$("#iloaderlike_" + codep).hide();
					$("#llike_" + codep).hide();
					$("#lulike_" + codep).show();
					break;
			}
		},
		error: function(){
			openandclose('#msgerror1_' + codep, txt_norequest, 1700);
			$("#iloaderlike_" + codep).hide();
			$("#llike_" + codep).show();
		} //end error
	}); // end ajax
}

/***********************************************************************/

function unlikepost(codep, idp, iu) {
	$("#lulike_" + codep).hide();
	$("#iloaderlike_" + codep).show();
	
	$.ajax({
		type: 'POST',
		url: siteurl + "ajax/posts/r:" + Math.round(Math.random()*1000),
		data: 'todo=2&ip=' + idp + '&iu=' + iu,
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					openandclose('#msgerror1_' + codep, resp.substring(3),1700);
					$("#iloaderlike_" + codep).hide();
					$("#lulike_" + codep).show();
					break;
				
				case '1':
					$('#numlikes_' + codep).html(parseInt($('#numlikes_' + codep).html()) - 1);
					$("#iloaderlike_" + codep).hide();
					$("#lulike_" + codep).hide();
					$("#llike_" + codep).show();
					break;
			}
		},
		error: function(){
			openandclose('#msgerror1_' + codep, txt_norequest, 1700);
			$("#iloaderlike_" + codep).hide();
			$("#lulike_" + codep).show();
		} //end error
	}); // end ajax
}

/***********************************************************************/

function deletepost(codep) {
	$.ajax({
		type: 'POST',
		url: siteurl + "ajax/posts/r:" + Math.round(Math.random()*1000),
		data: 'todo=3&cp=' + codep,
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					alert(resp.substring(3));
					break;

				case '1':
					$("#activity_" + codep).fadeOut(500, function() { $("#activity_" + codep).remove(); });
					$('#numposts').html(parseInt($('#numposts').html()) - 1);
					break;
			}
		},
		error: function(){
			alert(txt_norequest);
		} //end error
	}); // end ajax
}

/***********************************************************************/

function reportpost(codep) {
	$.ajax({
		type: 'POST',
		url: siteurl + "ajax/posts/r:" + Math.round(Math.random()*1000),
		data: 'todo=7&cp=' + codep,
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					alert(resp.substring(3));
					break;
				case '1':
					$("#bundorp_" + codep).show();
					$("#msgpr_" + codep).show();
					$("#activity_" + codep).fadeOut(300, function(){
						$("#msgaction_" + codep).fadeIn(300);
					});					
					break;
			}
		},
		error: function(){
			alert(txt_norequest);
		} //end error
	}); // end ajax
}

/***********************************************************************/

function undoReportPost(codep) {
	$.ajax({
		type: 'POST',
		url: siteurl + "ajax/posts/r:" + Math.round(Math.random()*1000),
		data: 'todo=9&cp=' + codep,
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					alert(resp.substring(3));
					break;
				case '1':
					$("#msgaction_" + codep).fadeOut(300, function(){
						$("#activity_" + codep).fadeIn(300, function(){
							$("#bundorp_" + codep).hide();
							$("#msgpr_" + codep).hide();
						});
					});					
					break;
			}
		},
		error: function(){
			alert(txt_norequest);
		} //end error
	}); // end ajax
}

/***********************************************************************/

function hiddenpost(codep) {
	$.ajax({
		type: 'POST',
		url: siteurl + "ajax/posts/r:" + Math.round(Math.random()*1000),
		data: 'todo=8&cp=' + codep,
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					alert(resp.substring(3));
					break;
				case '1':
					$("#bundohp_" + codep).show();
					$("#msgph_" + codep).show();
					$("#activity_" + codep).fadeOut(300, function(){
						$("#msgaction_" + codep).fadeIn(300);
					});
					break;
			}
		},
		error: function(){
			alert(txt_norequest);
		} //end error
	}); // end ajax
}

/***********************************************************************/

function undoHiddenPost(codep) {
	$.ajax({
		type: 'POST',
		url: siteurl + "ajax/posts/r:" + Math.round(Math.random()*1000),
		data: 'todo=10&cp=' + codep,
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					alert(resp.substring(3));
					break;
				case '1':
					$("#msgaction_" + codep).fadeOut(300, function(){
						$("#activity_" + codep).fadeIn(300, function(){
							$("#msgph_" + codep).hide();
							$("#bundohp_" + codep).hide();	
						});
					});					
					break;
			}
		},
		error: function(){
			alert(txt_norequest);
		} //end error
	}); // end ajax
}

/***********************************************************************/

function sharepost(codep, idp, iu, pin, idw, wsee) {

	$("#areabshare_" + codep).hide();
	$("#iloadershare_" + codep).show();
	
	pin = $(pin).val();
	idw = $(idw).val();
	wsee = $(wsee).val();
	
	txtshare = $.trim($('#txtshare_' + codep).val());

	$.ajax({
		type: 'POST',
		url: siteurl + "ajax/posts/r:" + Math.round(Math.random()*1000),
		data: 'todo=6&ip=' + idp + '&iu=' + iu + '&cp=' + codep + '&pin=' + pin + '&idw=' + idw + '&wsee=' + wsee + '&tsh=' + encodeURIComponent(txtshare),
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					openandclose('#msgerrorshare_' + codep, resp.substring(3), 1700);
					$("#areabshare_" + codep).show();
					$("#iloadershare_" + codep).hide();
					break;				
				case '1':
					$("#shareok_" + codep).html(resp.substring(3));
					$("#share_" + codep).slideUp('low',function(){
						$("#shareok_" + codep).slideDown('low');
					});
					setTimeout(function(){
						$("#shareok_" + codep).slideUp('low',function(){
							$("#accesories_" + codep).slideDown('low');
							$('#txtshare_' + codep).val('');
							$("#areabshare_" + codep).show();
							$("#iloadershare_" + codep).hide();
						});
					}, 3000);
					break;
			}
		},
		error: function(){
			openandclose('#msgerrorshare_' + codep, txt_norequest, 1700);
			$("#areabshare_" + codep).show();
			$("#iloadershare_" + codep).hide();
		} //end error
	}); // end ajax

}

/***********************************************************************/

function loadcategorypages(idcat, msgcategory, msgsubcategory, divcategories, divsubcategories ){
	$(divcategories).html('<option value="0">' + msgcategory + '</option>');
	$(divcategories).attr('disabled','true');
	$(divsubcategories).html('<option value="0">' + msgsubcategory + '</option>');
	$.ajax({
		type: 'POST',
		url:  siteurl + "ajax/dashboard-getcategories/r:" + Math.round(Math.random()*1000),
		data: 'idcat=' + idcat,
		success: function(h){
			switch(h.charAt(0)){
				case '0':
					break;
				case '1':
					$(divcategories).html(h.substring(3));
					$(divcategories).removeAttr('disabled');
					break;
			}
		},
		error: function(){
		} //end error
	}); // end ajax
}

function loadsubcategorypages(idcat, idsubcat, msgcsubcategory, divsubcategories) {	
	$(divsubcategories).html('<option value="0">' + msgcsubcategory + '</option>');
	$(divsubcategories).attr('disabled','true');
	$.ajax({
		type: 'POST',
		url: siteurl + "ajax/dashboard-getsubcategories/r:" + Math.round(Math.random()*1000),
		data: 'idcat=' + idcat + '&idsubcat=' + idsubcat,
		success: function(h){
			switch(h.charAt(0)){
				case '0':
					break;
				case '1':
					$(divsubcategories).html(h.substring(3));
					$(divsubcategories).removeAttr('disabled');
					break;
			}
		},
		error: function(){
		} //end error
	}); // end ajax	
}

/***********************************************************************/

function createPage(diverror, bsubmit)
{
	$(bsubmit).attr('disabled','true');
	
	idcat = $('#pagecategory').val();
	if (idcat == '-1') {
		openandclose(diverror, txt_choose_category, 1700);
		$('#pagecategory').focus();
		setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 2000);
		return;
	}

	idsubcat = $('#pagesubcategory').val();
	if (idsubcat == '-1') {
		openandclose(diverror, txt_choose_subcategory, 1700);
		$('#pagesubcategory').focus();
		setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 2000);
		return;
	}

	titlepage = $('#titlepage').val();
	if (titlepage == '') {
		openandclose(diverror, txt_enter_title, 1700);
		$('#titlepage').focus();
		setTimeout(function() { $(bsubmit).removeAttr('disabled'); }, 2000);
		return;
	}

	urlpage = $('#urlpage').val();
	if (urlpage == '') {
		openandclose(diverror, txt_enter_url, 1700);
		$('#urlpage').focus();
		setTimeout(function() { $(bsubmit).removeAttr('disabled'); }, 2000);
		return;
	}

	if (!validateURLPageOrGroup(urlpage)) {
		openandclose(diverror, txt_url_invalid, 1700);
		$('#urlpage').focus();
		setTimeout(function() { $(bsubmit).removeAttr('disabled'); }, 2000);
		return;
	}
	
	descriptionpage = $('#descriptionpage').val();

	$.ajax({
		type: 'POST',
		url: siteurl + 'ajax/dashboard-pages/r:' + Math.round(Math.random()*1000),
		data: 'todo=1&idc=' + idcat + '&idsc=' + idsubcat + '&tp=' + encodeURIComponent(titlepage) + '&up=' + encodeURIComponent(urlpage) + '&dp=' + encodeURIComponent(descriptionpage),
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					openandclose(diverror,resp.substring(3),2000);
					setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
					break;
				case '1':
					self.location = siteurl + 'dashboard/pages';
					break;
			}
		},
		error: function(){
			openandclose(diverror,admin_norequest,2000);
			setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
		} //end error
	}); // end ajax	
	
}

/***********************************************************************/

function updatePage(diverror, divok, bsubmit)
{
	$(bsubmit).attr('disabled','true');
	
	idcat = $('#pagecategory').val();
	if (idcat == '-1') {
		openandclose(diverror, txt_choose_category, 1700);
		$('#pagecategory').focus();
		setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 2000);
		return;
	}

	idsubcat = $('#pagesubcategory').val();
	if (idsubcat == '-1') {
		openandclose(diverror, txt_choose_subcategory, 1700);
		$('#pagesubcategory').focus();
		setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 2000);
		return;
	}

	titlepage = $('#titlepage').val();
	if (titlepage == '') {
		openandclose(diverror, txt_enter_title, 1700);
		$('#titlepage').focus();
		setTimeout(function() { $(bsubmit).removeAttr('disabled'); }, 2000);
		return;
	}
	
	descriptionpage = $('#descriptionpage').val();

	$.ajax({
		type: 'POST',
		url: siteurl + 'ajax/dashboard-pages/r:' + Math.round(Math.random()*1000),
		data: 'todo=2&idc=' + idcat + '&idsc=' + idsubcat + '&tp=' + encodeURIComponent(titlepage) + '&cp=' + cpage + '&dp=' + encodeURIComponent(descriptionpage),
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					openandclose(diverror,resp.substring(3),2000);
					setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
					break;
				case '1':
					openandclose(divok,resp.substring(3),2000);
					setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
					break;
			}
		},
		error: function(){
			openandclose(diverror,admin_norequest,2000);
			setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
		} //end error
	}); // end ajax	
	
}

/***********************************************************************/

function updateAvatarPage(diverror, divok, bsubmit)
{
	$(bsubmit).attr('disabled','true');

	loadedimage=$.trim($('#loadedimage').val());
	if (loadedimage == '') {
		openandclose(diverror,page_avat_msg3,1700);
		setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 2000); 
		return;
	}
	
	didchanges=$('#didchanges').val();

	$.ajax({
		type: 'POST',
		url: siteurl + 'ajax/dashboard-pages/r:' + Math.round(Math.random()*1000),
		data: 'todo=3&dch=' + didchanges + '&limg=' + loadedimage + '&cp=' + cpage,
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					openandclose(diverror,resp.substring(3),2000);
					setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
					break;
				case '1':
					$('#loadedimage').val(loadedimage);
					$('#didchanges').val(0);
					oneimage = new Image();
					oneimage.src = siteurl + folderavatarspages + loadedimage;
					openandclose(divok,resp.substring(3),2000);
					setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
					break;
			}
		},
		error: function(){
			openandclose(diverror,mi_norequest,2000);
			setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
		} //end error
	}); // end ajax	

}

/***********************************************************************/

function updateCoverPage(diverror, divok, bsubmit)
{
	$(bsubmit).attr('disabled','true');

	loadedcover=$.trim($('#loadedcover').val());
	if (loadedcover == '') {
		openandclose(diverror,page_cov_msg3,1700);
		setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 2000); 
		return;
	}
	
	didchangescov=$('#didchangescov').val();

	$.ajax({
		type: 'POST',
		url: siteurl + 'ajax/dashboard-pages/r:' + Math.round(Math.random()*1000),
		data: 'todo=4&dch=' + didchangescov + '&limg=' + loadedcover + '&cp=' + cpage,
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					openandclose(diverror,resp.substring(3),2000);
					setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
					break;
				case '1':
					$('#loadedcover').val(loadedcover);
					$('#didchangescov').val(0);
					oneimage = new Image();
					oneimage.src = siteurl + foldercoverspages + loadedcover;
					openandclose(divok,resp.substring(3),2000);
					setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
					break;
			}
		},
		error: function(){
			openandclose(diverror,mi_norequest,2000);
			setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
		} //end error
	}); // end ajax	

}

/***********************************************************************/

function createGroup(diverror, bsubmit)
{
	$(bsubmit).attr('disabled','true');
	
	privacygroup = $('#privacygroup').val();

	namegroup = $('#namegroup').val();
	if (namegroup == '') {
		openandclose(diverror, txt_enter_name, 1700);
		$('#namegroup').focus();
		setTimeout(function() { $(bsubmit).removeAttr('disabled'); }, 2000);
		return;
	}

	urlgroup = $('#urlgroup').val();
	if (urlgroup == '') {
		openandclose(diverror, txt_enter_url, 1700);
		$('#urlgroup').focus();
		setTimeout(function() { $(bsubmit).removeAttr('disabled'); }, 2000);
		return;
	}

	if (!validateURLPageOrGroup(urlgroup)) {
		openandclose(diverror, txt_url_invalid, 1700);
		$('#urlgroup').focus();
		setTimeout(function() { $(bsubmit).removeAttr('disabled'); }, 2000);
		return;
	}
	
	descriptiongroup = $('#descriptiongroup').val();

	$.ajax({
		type: 'POST',
		url: siteurl + 'ajax/dashboard-groups/r:' + Math.round(Math.random()*1000),
		data: 'todo=1&pg=' + privacygroup + '&ng=' + encodeURIComponent(namegroup) + '&ug=' + encodeURIComponent(urlgroup) + '&dg=' + encodeURIComponent(descriptiongroup),
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					openandclose(diverror,resp.substring(3),2000);
					setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
					break;
				case '1':
					self.location = siteurl + 'dashboard/groups';
					break;
			}
		},
		error: function(){
			openandclose(diverror,admin_norequest,2000);
			setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
		} //end error
	}); // end ajax	
	
}

/***********************************************************************/

function updateGroup(diverror, divok, bsubmit)
{
	$(bsubmit).attr('disabled','true');
	
	privacygroup = $('#privacygroup').val();

	namegroup = $('#namegroup').val();
	if (namegroup == '') {
		openandclose(diverror, txt_enter_name, 1700);
		$('#namegroup').focus();
		setTimeout(function() { $(bsubmit).removeAttr('disabled'); }, 2000);
		return;
	}
	
	descriptiongroup = $('#descriptiongroup').val();

	$.ajax({
		type: 'POST',
		url: siteurl + 'ajax/dashboard-groups/r:' + Math.round(Math.random()*1000),
		data: 'todo=2&priv=' + privacygroup + '&ng=' + encodeURIComponent(namegroup) + '&cg=' + cgroup + '&dg=' + encodeURIComponent(descriptiongroup),
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					openandclose(diverror,resp.substring(3),2000);
					setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
					break;
				case '1':
					openandclose(divok,resp.substring(3),2000);
					setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
					break;
			}
		},
		error: function(){
			openandclose(diverror,admin_norequest,2000);
			setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
		} //end error
	}); // end ajax	
	
}

/***********************************************************************/

function updateCoverGroup(diverror, divok, bsubmit)
{
	$(bsubmit).attr('disabled','true');

	loadedcover=$.trim($('#loadedcover').val());
	if (loadedcover == '') {
		openandclose(diverror,group_cov_msg3,1700);
		setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 2000); 
		return;
	}
	
	didchangescov=$('#didchangescov').val();

	$.ajax({
		type: 'POST',
		url: siteurl + 'ajax/dashboard-groups/r:' + Math.round(Math.random()*1000),
		data: 'todo=3&dch=' + didchangescov + '&limg=' + loadedcover + '&cg=' + cgroup,
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					openandclose(diverror,resp.substring(3),2000);
					setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
					break;
				case '1':
					$('#loadedcover').val(loadedcover);
					$('#didchangescov').val(0);
					oneimage = new Image();
					oneimage.src = siteurl + foldercoversgroups + loadedcover;
					openandclose(divok,resp.substring(3),2000);
					setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
					break;
			}
		},
		error: function(){
			openandclose(diverror,mi_norequest,2000);
			setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
		} //end error
	}); // end ajax	

}

/***********************************************************************/

function createAds(diverror, bsubmit)
{
	$(bsubmit).attr('disabled','true');
	
	headline = $('#headline').val();
	if (headline == '') {
		openandclose(diverror, txt_err_headline, 1700);
		$('#headline').focus();
		setTimeout(function() { $(bsubmit).removeAttr('disabled'); }, 2000);
		return;
	}

	description1 = $('#description1').val();
	if (description1 == '') {
		openandclose(diverror, txt_err_descrip1, 1700);
		$('#description1').focus();
		setTimeout(function() { $(bsubmit).removeAttr('disabled'); }, 2000);
		return;
	}
	
	description2 = $('#description2').val();
	if (description2 == '') {
		openandclose(diverror, txt_err_descrip2, 1700);
		$('#description2').focus();
		setTimeout(function() { $(bsubmit).removeAttr('disabled'); }, 2000);
		return;
	}
	
	displayurl = $('#displayurl').val();
	if (displayurl == '') {
		openandclose(diverror, txt_err_displayu, 1700);
		$('#displayurl').focus();
		setTimeout(function() { $(bsubmit).removeAttr('disabled'); }, 2000);
		return;
	}

	destinationurl = $('#destinationurl').val();
	if (destinationurl == '') {
		openandclose(diverror, txt_err_destinau, 1700);
		$('#destinationurl').focus();
		setTimeout(function() { $(bsubmit).removeAttr('disabled'); }, 2000);
		return;
	}

	$.ajax({
		type: 'POST',
		url: siteurl + 'ajax/dashboard-myads/r:' + Math.round(Math.random()*1000),
		data: 'todo=1&h=' + encodeURIComponent(headline) + '&ld1=' + encodeURIComponent(description1) + '&ld2=' + encodeURIComponent(description2) + '&urldisp=' + encodeURIComponent(displayurl) + '&urldest=' + encodeURIComponent(destinationurl),
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					openandclose(diverror,resp.substring(3),2000);
					setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
					break;
				case '1':
					self.location = siteurl + 'dashboard/myads';
					break;
			}
		},
		error: function(){
			openandclose(diverror,admin_norequest,2000);
			setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
		} //end error
	}); // end ajax	
	
}

/***********************************************************************/

function updateAds(diverror, divok, bsubmit)
{
	$(bsubmit).attr('disabled','true');
	
	headline = $('#headline').val();
	if (headline == '') {
		openandclose(diverror, txt_err_headline, 1700);
		$('#headline').focus();
		setTimeout(function() { $(bsubmit).removeAttr('disabled'); }, 2000);
		return;
	}

	description1 = $('#description1').val();
	if (description1 == '') {
		openandclose(diverror, txt_err_descrip1, 1700);
		$('#description1').focus();
		setTimeout(function() { $(bsubmit).removeAttr('disabled'); }, 2000);
		return;
	}
	
	description2 = $('#description2').val();
	if (description2 == '') {
		openandclose(diverror, txt_err_descrip2, 1700);
		$('#description2').focus();
		setTimeout(function() { $(bsubmit).removeAttr('disabled'); }, 2000);
		return;
	}
	
	displayurl = $('#displayurl').val();
	if (displayurl == '') {
		openandclose(diverror, txt_err_displayu, 1700);
		$('#displayurl').focus();
		setTimeout(function() { $(bsubmit).removeAttr('disabled'); }, 2000);
		return;
	}

	destinationurl = $('#destinationurl').val();
	if (destinationurl == '') {
		openandclose(diverror, txt_err_destinau, 1700);
		$('#destinationurl').focus();
		setTimeout(function() { $(bsubmit).removeAttr('disabled'); }, 2000);
		return;
	}

	$.ajax({
		type: 'POST',
		url: siteurl + 'ajax/dashboard-myads/r:' + Math.round(Math.random()*1000),
		data: 'todo=2&codad=' + codad + '&h=' + encodeURIComponent(headline) + '&ld1=' + encodeURIComponent(description1) + '&ld2=' + encodeURIComponent(description2) + '&urldisp=' + encodeURIComponent(displayurl) + '&urldest=' + encodeURIComponent(destinationurl),
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					openandclose(diverror,resp.substring(3),2000);
					setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
					break;
				case '1':
					openandclose(divok,resp.substring(3),2000);
					setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
					break;
			}
		},
		error: function(){
			openandclose(diverror,admin_norequest,2000);
			setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
		} //end error
	}); // end ajax	
	
}

/***********************************************************************/

function updateImageAd(diverror, divok, bsubmit)
{
	$(bsubmit).attr('disabled','true');

	loadedimage=$.trim($('#loadedimage').val());
	if (loadedimage == '') {
		openandclose(diverror,ad_msg3,1700);
		setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 2000); 
		return;
	}
	
	didchanges=$('#didchanges').val();

	$.ajax({
		type: 'POST',
		url: siteurl + 'ajax/dashboard-myads/r:' + Math.round(Math.random()*1000),
		data: 'todo=5&dch=' + didchanges + '&limg=' + loadedimage + '&codad=' + codad,
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					openandclose(diverror,resp.substring(3),2000);
					setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
					break;
				case '1':
					$('#loadedimage').val(loadedimage);
					$('#didchanges').val(0);
					oneimage = new Image();
					oneimage.src = siteurl + folderads + loadedimage;
					openandclose(divok,resp.substring(3),2000);
					setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
					self.location = siteurl + 'dashboard/myads/edit/a:' + codad;
					break;
			}
		},
		error: function(){
			openandclose(diverror,mi_norequest,2000);
			setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
		} //end error
	}); // end ajax	

}

/***********************************************************************/


function deleteAd(divitem, codad)
{
	if (confirm(msgdelete)) {

	$.ajax({
		type: 'POST',
		url: siteurl + 'ajax/dashboard-myads/r:' + Math.round(Math.random()*1000),
		data: 'todo=4&ca=' + codad,
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					alert(resp.substring(3));
					break;
				case '1':
					$(divitem).fadeOut(500, function() { $(divitem).remove(); });
					break;
			}
		},
		error: function(){
			alert(admin_norequest);
		} //end error
	}); // end ajax	
	
	}
}

/**********************************************************************/

function payNow(diverror, bsubmit)
{
	$(bsubmit).attr('disabled','true');
	$(bsubmit).hide();
	$('#gifpreload').show();
	
	cPlan = $('#valCPlan').val();

	if (cPlan == '') {
		openandclose(diverror, txt_err_plan, 1700);
		setTimeout(function() { $(bsubmit).removeAttr('disabled'); }, 2000);
		$('#gifpreload').hide();
		$(bsubmit).show();
		return;
	}
	
	$('#formPay').attr('action','https://www.paypal.com/cgi-bin/webscr');
	$('#cmd').val("_xclick");
	$('#business').val(empay);
	$('#return').val(siteurl + 'dashboard/myads/completedpayment');
	$('#notify_url').val(siteurl + 'dashboard/myads/paymentpin');
	$('#item_number').val(cPlan);
	$('#item_name').val($('#np_' + cPlan).val());
	$('#amount').val($('#pp_' + cPlan).val());
	$('#quantity').val(1);
	$('#currency_code').val('USD');
	$('#custom').val(codad + ':' + cPlan);	
	$('#formPay').submit();
}

/***********************************************************************/


function updateStatus(diverror, divok, bsubmit)
{
	$(bsubmit).attr('disabled','true');
	
	statusad = $('#statusad').val();

	$.ajax({
		type: 'POST',
		url: siteurl + 'ajax/dashboard-myads/r:' + Math.round(Math.random()*1000),
		data: 'todo=3&codad=' + codad + '&st=' + statusad,
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					openandclose(diverror,resp.substring(3),2000);
					setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
					break;
				case '1':
					openandclose(divok,resp.substring(3),2000);
					setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
					break;
			}
		},
		error: function(){
			openandclose(diverror,admin_norequest,2000);
			setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
		} //end error
	}); // end ajax		
}

/***********************************************************************/


function reportComment(idcomment, idowner) {
	$.ajax({
		type: 'POST',
		url: siteurl + "ajax/posts/r:" + Math.round(Math.random()*1000),
		data: 'todo=11&idc=' + idcomment + '&ido=' + idowner,
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					alert(resp.substring(3));
					break;
				case '1':
					$("#bundorc_" + idcomment).show();
					$("#msgcr_" + idcomment).show();
					$("#comment_post_" + idcomment).fadeOut(300, function(){
						$("#msgaction_" + idcomment).fadeIn(300);
					});					
					break;
			}
		},
		error: function(){
			alert(txt_norequest);
		} //end error
	}); // end ajax
}

/***********************************************************************/

function hiddenComment(idcomment) {
	$.ajax({
		type: 'POST',
		url: siteurl + "ajax/posts/r:" + Math.round(Math.random()*1000),
		data: 'todo=12&idc=' + idcomment,
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					alert(resp.substring(3));
					break;
				case '1':
					$("#bundohc_" + idcomment).show();
					$("#msgch_" + idcomment).show();
					$("#comment_post_" + idcomment).fadeOut(300, function(){
						$("#msgaction_" + idcomment).fadeIn(300);
					});					
					break;
			}
		},
		error: function(){
			alert(txt_norequest);
		} //end error
	}); // end ajax
}

/***********************************************************************/


function undoReportComment(idcomment) {
	$.ajax({
		type: 'POST',
		url: siteurl + "ajax/posts/r:" + Math.round(Math.random()*1000),
		data: 'todo=13&idc=' + idcomment,
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					alert(resp.substring(3));
					break;
				case '1':					
					$("#msgaction_" + idcomment).fadeOut(300, function(){
						$("#comment_post_" + idcomment).fadeIn(300, function(){
							$("#msgcr_" + idcomment).hide();
							$("#bundorc_" + idcomment).hide();
							$("#bactioncomment_" + idcomment).fadeIn(300);
						});
					});				
					break;
			}
		},
		error: function(){
			alert(txt_norequest);
		} //end error
	}); // end ajax
}

/***********************************************************************/

function undoHiddenComment(idcomment) {
	$.ajax({
		type: 'POST',
		url: siteurl + "ajax/posts/r:" + Math.round(Math.random()*1000),
		data: 'todo=14&idc=' + idcomment,
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					alert(resp.substring(3));
					break;
				case '1':
					$("#msgaction_" + idcomment).fadeOut(300, function(){
						$("#comment_post_" + idcomment).fadeIn(300, function(){
							$("#msgch_" + idcomment).hide();
							$("#bundohc_" + idcomment).hide();
							$("#bactioncomment_" + idcomment).fadeIn(300);
						});
					});
					break;
			}
		},
		error: function(){
			alert(txt_norequest);
		} //end error
	}); // end ajax
}

/***********************************************************************/

function createAlbum(diverror, divok, formadd, bsubmit)
{
	$(bsubmit).attr('disabled','true');
	
	namealbum = $('#namealbum').val();
	if (namealbum == '') {
		openandclose(diverror, txt_error_namealbum, 1700);
		$('#namealbum').focus();
		setTimeout(function() { $(bsubmit).removeAttr('disabled'); }, 2000);
		return;
	}

	descriptionalbum = $('#descriptionalbum').val();
	
	privacy = $('#privacy').val();

	$.ajax({
		type: 'POST',
		url: siteurl + 'ajax/dashboard-myalbums/r:' + Math.round(Math.random()*1000),
		data: 'todo=1&namea=' + encodeURIComponent(namealbum) + '&desc=' + encodeURIComponent(descriptionalbum) + '&priv=' + privacy,
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					openandclose(diverror,resp.substring(3),2000);
					setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
					break;
				case '1':
					$('#linkaddphotos').attr('href', siteurl + 'dashboard/myalbums/a:' + resp.substring(3));
					$(formadd).slideUp('low',function(){
						$(msgok).slideDown('low');
					});
					break;
			}
		},
		error: function(){
			openandclose(diverror,txt_norequest,2000);
			setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
		} //end error
	}); // end ajax	
	
}

/***********************************************************************/

function updateAlbum(diverror, divok, bsubmit)
{
	$(bsubmit).attr('disabled','true');
	
	namealbum = $('#namealbum').val();
	if (namealbum == '') {
		openandclose(diverror, txt_error_namealbum, 1700);
		$('#namealbum').focus();
		setTimeout(function() { $(bsubmit).removeAttr('disabled'); }, 2000);
		return;
	}

	descriptionalbum = $('#descriptionalbum').val();
	
	privacy = $('#privacy').val();

	$.ajax({
		type: 'POST',
		url: siteurl + 'ajax/dashboard-myalbums/r:' + Math.round(Math.random()*1000),
		data: 'todo=2&namea=' + encodeURIComponent(namealbum) + '&desc=' + encodeURIComponent(descriptionalbum) + '&priv=' + privacy + '&codea=' + codea,
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					openandclose(diverror,resp.substring(3),2000);
					setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
					break;
				case '1':
					openandclose(divok,resp.substring(3),2000);
					setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
					break;
			}
		},
		error: function(){
			openandclose(diverror,txt_norequest,2000);
			setTimeout(function() {$(bsubmit).removeAttr('disabled');}, 3000); 
		} //end error
	}); // end ajax	
	
}

/***********************************************************************/

function deletePhotoAlbum(divitem, codea, codeph) {
	$.ajax({
		type: 'POST',
		url: siteurl + 'ajax/dashboard-myalbums/r:' + Math.round(Math.random()*1000),
		data: 'todo=4&codea=' + codea + '&codeph=' + codeph,
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					alert(resp.substring(3));
					break;
				case '1':
					$(divitem).fadeOut(500, function() { $(divitem).remove(); });
					break;
			}
		},
		error: function(){
			alert(txt_norequest);
		} //end error
	}); // end ajax		
}

function deleteAlbum(divitem, codalbum)
{
	if (confirm(txt_msgalertdelete)) {

	$.ajax({
		type: 'POST',
		url: siteurl + 'ajax/dashboard-myalbums/r:' + Math.round(Math.random()*1000),
		data: 'todo=3&codea=' + codalbum,
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					alert(resp.substring(3));
					break;
				case '1':
					$(divitem).fadeOut(500, function() { $(divitem).remove(); });
					break;
			}
		},
		error: function(){
			alert(txt_norequest);
		} //end error
	}); // end ajax	
	
	}
}

/**********************************************************************/

function acceptRequestMember(idgroup, iduser, divitem, divok)
{
	$.ajax({
		type: 'POST',
		url: siteurl + 'ajax/dashboard-groups/r:' + Math.round(Math.random()*1000),
		data: 'todo=4&idg=' + idgroup + '&idu=' + iduser,
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					alert(resp.substring(3));
					break;
				case '1':
					$(divitem).slideUp('fast', function(){
						$(divok).slideDown('fast');
					});
					break;
			}
		},
		error: function(){
			alert(txt_norequest);
		} //end error
	}); // end ajax	
}

/**********************************************************************/

function rejectRequestMember(idgroup, iduser, divitem)
{
	$.ajax({
		type: 'POST',
		url: siteurl + 'ajax/dashboard-groups/r:' + Math.round(Math.random()*1000),
		data: 'todo=5&idg=' + idgroup + '&idu=' + iduser,
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					alert(resp.substring(3));
					break;
				case '1':
					$(divitem).fadeOut();
					break;
			}
		},
		error: function(){
			alert(txt_norequest);
		} //end error
	}); // end ajax	
}


/**********************************************************************/

function removeMember(idgroup, iduser, divitem)
{
	$.ajax({
		type: 'POST',
		url: siteurl + 'ajax/dashboard-groups/r:' + Math.round(Math.random()*1000),
		data: 'todo=6&idg=' + idgroup + '&idu=' + iduser,
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					alert(resp.substring(3));
					break;
				case '1':
					$(divitem).fadeOut();
					break;
			}
		},
		error: function(){
			alert(txt_norequest);
		} //end error
	}); // end ajax	
}

/**********************************************************************/

function addMemberToGroup(idgroup, iduser, divitem, divok)
{
	$.ajax({
		type: 'POST',
		url: siteurl + 'ajax/dashboard-groups/r:' + Math.round(Math.random()*1000),
		data: 'todo=7&idg=' + idgroup + '&idu=' + iduser,
		success: function(resp){
			switch(resp.charAt(0)){
				case '0':
					alert(resp.substring(3));
					break;
				case '1':
					$(divitem).slideUp('fast', function(){
						$(divok).slideDown('fast');
					});
					break;
			}
		},
		error: function(){
			alert(txt_norequest);
		} //end error
	}); // end ajax	
}

/**********************************************************************/
