

var citizen_id = null;
var resetME =true;

function confess(cid){
	
	//set stuff here
	var n = $('#c_'+cid+' a').html();
	$("#profile-name").html(n);
	$("#profile-image").html('<img src="http://www.buddytown.org/_file_storage/01/passport_'+cid+'_.jpg" >');
	$('#message-center').fadeIn();
	$('body').scrollTo('body', {axis:'y',duration:500} );
	
	
	
	citizen_id = cid;
	
	 $.cookie('cook_id', cid, { expires: 20, path: '/', domain: 'buddytown.org'});
	//$.cookie('cook_id', cid);
	 //$('#profile-info').html('loading');
	/*
		$.ajax({
			data:{
				citizen_id:citizen_id
			},
		  url: 'http://www.buddytown.org/api/rest/?method=citizens.getDetails&format=json',
		  success: function(data) {
		
		    		user = data.data[0];
					if(user.crush_total==0){
						msgt = "Hasn't been crushed yet. Be the first!";
					}else{
						msgt= 'Been crushed... '+user.crush_total+' times.'
					}
					$('#profile-info').html(msgt);
		  }
		});
		
	*/
		
	$.getJSON('http://www.buddytown.org/api/rest/?method=citizens.getDetails&citizen_id='+citizen_id+'&format=json', function(data) {
		
		user = data.data[0];
		if(user.crush_total==0){
			msgt = "Hasn't been crushed yet. Be the first!";
		}else{
			msgt= 'Been crushed... '+user.crush_total+' times.'
		}
		$('#profile-info').html(msgt);
		
	});
	
	
	//
	
	//get citizen info
}

function limitText(limitField, limitNum) {
    if (limitField.value.length > limitNum) {
        limitField.value = limitField.value.substring(0, limitNum);
    } 
}

function submitCrush(){
	if(resetME){
		resetME=false;
		var mVal = $('#message').val();
		if(mVal!=''){
			$.ajax({
				data:{
					citizen_id:citizen_id,
					message:mVal
				},
			  url: 'http://www.buddytown.org/api/rest/?method=crush.sendMessage',
			  success: function(data) {
					resetME=true;
			    	$('#message-center').hide();
					$('#message').val('');
			  }
			});
		}else{
			$('#stext').html("Pull it together.");
		}
	}
}

$(document).ready(function(){
	
	$("#sbutton").click(function(){
		submitCrush();
	});
	//do zoom her
});