var last_p = null;
var last_profile_story_lang = null;


function changeContent(p)
{
	if (last_p) {
		$(last_p+'-left').style.display = 'none';
		$(last_p+'-right').style.display = 'none';
		$('menu-'+last_p).className = 'menu-item';
	}
	
	$(p+'-left').style.display = 'block';
	$(p+'-right').style.display = 'block';
	$('menu-'+p).className = 'menu-item act';
	
	last_p = p;
}
/*
var profile_show_details_state = false;

function changeProfileShowDetailsState(obj)
{
	profile_show_details_state = obj.value;
}
*/
function changeUserShowDetails(obj)
{
	var v = (obj.checked) ? 1 : 0;
		new Ajax.Request('/profile/changeUserShowDetails?v='+v, {
		    method: 'get',
		    onSuccess: function(transport) {
		    }
		  });
	
}
function showProfileStory(p)
{
	t = 0;
	
	if (last_profile_story_lang) {
		if (last_profile_story_lang == p) return;
		Effect.BlindUp('profile_story_'+last_profile_story_lang,{ duration: 0.5 });
		t = 1050;
	}
	
	setTimeout("Effect.BlindDown('profile_story_"+p+"',{ duration: 0.5 })", t);
	last_profile_story_lang = p;
}

function sendWmProfileAnket(id)
{
	Ext.MessageBox.confirm("", txtSendWMConfirmI18n, function(btn){
		if(btn == 'yes'){
			new Ajax.Request('/profile/sendWelcomeMail?id='+id, {
			    method: 'get',
			    onSuccess: function(transport) {
					if ($('btn-send-wm'))
						$('btn-send-wm').style.display = 'none'; 
					Ext.MessageBox.alert("", txtSendWMDoneI18n, 1); 	
			    }
			  });
		}
	});
}

function deleteProfileAnket(id)
{
	//Ext.saveChanges();
	
	Ext.MessageBox.confirm("", confirmDeleteText, function(btn){
		if(btn == 'yes'){
			new Ajax.Request('/profile/deleteSurvey?id='+id, {
			    method: 'get',
			    onSuccess: function(transport) {
					if ($('profile-right-part'))
						$('profile-right-part').style.display='none'; 
					Ext.getCmp('profilegrid').getStore().reload();
			    }
			  });
		}
	});
		
		
	//Ext.getCmp('profilegrid').reconfigure(Ext.getCmp('profilegridstore'),Ext.getCmp('profilegrid').getColumnModel());
}


function showProfileBlockWithBlind(id)
{	
	if ($(id).style.display == 'none') {
		Effect.BlindDown(id,{ duration: 0.3 });	
	} else {
		Effect.BlindUp(id,{ duration: 0.3 });	
	}
}

function showProfilePhoto()
{	
	if ($('profile_my_photo').style.display == 'none') {
		Effect.BlindDown('profile_my_photo',{ duration: 0.3 });	
	} else {
		Effect.BlindUp('profile_my_photo',{ duration: 0.3 });	
	}
}
