function saveScreenStatus(val)
{
	hideScreenStatus();	
	if (val == 7)
	{
		showCustomStatus();	
	}
	else
	{
		$.ajax({
			type: 'POST',
			dataType: 'json',
			url: base_url + 'profile/saveScreenStatus/' + Math.random(),
			data: 'screen_status_id=' + val,
			success: function(response){
				if(response.msg == 'DONE')
				{
					$('#userStatus').html(response.status);
					$('#userStatus').focus();
				}
			}
		});
	}
}

function showScreenStatus()
{
	$('#userState').hide();
	$('#userStateEdit').show();
}

function hideScreenStatus()
{
	$('#userStateEdit').hide();
	$('#userState').show();
}

function showCustomStatus()
{
	$('#userState').hide();
	$('#customstateEdit').show();
}

function upDateScreenStatus(val)
{
	
		$.ajax({
			type: 'POST',
			dataType: 'json',
			url: base_url + 'profile/saveScreenStatus/' + Math.random(),
			data: 'screen_status_id=0&value=' + val,
			success: function(response){
				if(response.msg == 'DONE')
				{
					$('#customstateEdit').hide();
					$('#userState').show();
					$('#userStatus').html(response.status);
					$('#userStatus').focus();
				}
			}
		});
	
}

function CancelupDateScreenStatus()
{
	$('#customstateEdit').hide();
	$('#userState').show();
}

// created by jagan

function showEditWallForm(wallid,increment)
{
	var wall 	= 	$('#comments_'+increment).val();
	$('#wall_edit').val(wall);
	$('#edit_wall_id').val(wallid);
	var for_id	=	$('#inline_wall_for_id').val();
	$('#wall_Forid').val(for_id);
	
	tb_show('', '#TB_inline?height=300&width=530&modal=true&inlineId=editwall', false);
}

function edit_wall()
{
	var wall_content 	= $('#wall_edit').val();
	var id       		= $('#edit_wall_id').val();
	var For_id       		= $('#wall_Forid').val();
	
	$.ajax({
		type: 'POST',
		url: base_url + 'profile/editWallContent/' + Math.random(),
		dataType: 'json',
		data: 'wall='+wall_content+'&id='+id+'&wallFor_id='+For_id,
		success: function(response){
			if(response.msg == 'success')
			{
				tb_remove();
				$('#WallContentLists').html(response.tpl);
				//$(response.tpl).prependTo('#WallContentLists').slideDown('slow');
				$('#successInfo').html(response.msgInfo);
				$('#sucsMsg').show('normal', function(){
					setTimeout(function() {
						$('#sucsMsg').fadeOut('slow');
					}, 5000);
				});
				
			}
			else if(response.msg == 'error')
			{
				$('#popupErrorInfo_edit').html(response.msgInfo);
				$('#popupWallErrorMsg_edit').show('normal', function(){
					setTimeout(function() {
						$('#popupWallErrorMsg_edit').fadeOut('slow');
					}, 5000);
				});
			}

		}
	});
}

function showStatusForm()
{
	$('#status_div').hide();
	$('#to_modify').show();
}

function changeProfileStatus()
{
	var status	=	$('#status_value').val();
	
	$.ajax({
		type: 'POST',
		url: base_url + 'profile/changeUserStatus/' + Math.random(),
		dataType: 'json',
		data: 'value='+status,
		success: function(response){
			if(response.msg == 'success')
			{
				$('#status_div').show();
				$('#staus_message').html(response.msgInfo);
				$('#to_modify').hide();	
				
			}
		}
	})
	
}
function cancelProfileStatus()
{
	$('#status_div').show();
	$('#to_modify').hide();	
}

function showNextFeed(userid,limit)
{
	$('#minifeedPageing').block('Loading...'); 
	$.ajax({
		type: 'POST',
		url: base_url + 'profile/paginfMiniFeed/' + Math.random(),
		dataType: 'json',
		data: 'id='+userid+'&value='+limit,
		success: function(response){
			$('#minifeedPageing').unblock(); 
			if(response.msg == 'success')
			{
				$('#minifeedPageing').html(response.tpl);		
				$('#Previous').show();
			}
		}
	});
}

function showPreviousFeed(userid,limit)
{
	$('#minifeedPageing').block('Loading...'); 
	$.ajax({
		type: 'POST',
		url: base_url + 'profile/showPreviousFeed/' + Math.random(),
		dataType: 'json',
		data: 'id='+userid+'&value='+limit,
		success: function(response){
			$('#minifeedPageing').unblock(); 
			if(response.msg == 'success')
			{
				$('#minifeedPageing').html(response.tpl);		
				$('#Previous').show();
			}
		}
	});
}


function showDetails(showdiv,hideTopDiv,showTopDiv)
{
	 $("#"+showdiv).slideDown(300);
	 $("#"+hideTopDiv).show();
	 $("#"+showTopDiv).hide();
}

function hideDetails(showdiv,hideTopDiv,showTopDiv)
{
 	$("#"+showdiv).slideUp(300);
	$("#"+hideTopDiv).hide();
	$("#"+showTopDiv).show();
}

function removeBox(blockName,divId)
{
	$("#"+divId).block('Loading...'); 

	$.ajax({
		type: 'POST',
		url: base_url + 'profile/removeProfileBox/' + Math.random(),
		dataType: 'json',
		data: 'blockName='+blockName+'&div_id='+divId,
		success: function(response){
			if(response.msg == 'success')
			{
					$("#"+divId).unblock(); 
					$("#"+divId).hide();
					$("#addtab").show();
					$("#addTabIcon").show();
					//window.location.href=base_url + 'profile'
			}
		}
	});
}
function addBox(del_id,div_id)
{

	$.ajax({
		type: 'POST',
		url: base_url + 'profile/addProfileBox/' + Math.random(),
		dataType: 'json',
		data: 'del_id='+del_id,
		success: function(response){
			if(response.msg == 'success')
			{
				$("#"+div_id).show();
				showAddTab('ajaxfile');
			
			}
		}
	});
}
function showAddTab(div_id)
{
	$("#addtab").hide();
	$("#addTabIcon").hide();
	$.ajax({
		type: 'POST',
		url: base_url + 'profile/getAddBox/' + Math.random(),
		dataType: 'json',
		//data: 'del_id='+del_id,
		success: function(response){
			if(response.msg == 'success')
			{
				if(response.totalcount==0)
				{
						tb_remove()
				}
				else
				{
					$('#addBlock').html(response.tpl);	
					var reportURL	= '#TB_inline?height=300&width=300&inlineId='+div_id+'&modal=true';
					tb_show('', reportURL, false);
				}
			}
		}
	});
	
}

function validateAddTab()
{
	var ids='';
	if($("input[@type=checkbox]").filter(":checked").length<=0)
	{
		$('#error_messeage').show();
	}
	else
	{
		for(var i=0; i < document.showaddtab.tabs.length; i++)
		{
			if(document.showaddtab.tabs[i].checked)
			 	ids +=document.showaddtab.tabs[i].value + ",";
		}
		var strLen = ids.length;
		ids = ids.slice(0,strLen-1); 
		
		$.ajax({
		type: 'POST',
		url: base_url + 'profile/addAllTab/',
		dataType: 'json',
		data: 'del_id='+ids,
		success: function(response){
										if(response.msg)
										{
											div_id=response.msg;
											temp = div_id.split(',');
											for(var i=0; i < temp.length ; i++)
											{
												$('#'+temp[i]).show();
											}
										}
									}
			});
		showAddTab('ajaxfile');
	
	}
}


