mmd.models.User = function User()
{
	var self = this
	//properties
	self.email		 	= ""
	self.first_name	= "" 
	self.last_name 	= ""
	self.fbid 		  = ""
	self.created		= new Date().toString()
		
	//assign all the construction vars
	if(arguments[0] != null)
	{
		this.email 			= arguments[0].email
		this.first_name = arguments[0].first_name
		this.last_name 	= arguments[0].last_name
		this.fbid 			= arguments[0].id
	}
	
	console.log(self)
	
	var data = $.param({
				email		 	  : self.email		 ,
				first_name	: self.first_name,
				last_name 	: self.last_name ,
				fbid 		    : self.fbid 		 ,
				created			: self.created
			})
	console.log(data)
	self.save = save = function save(cb)
	{
			$.ajax({
			  url: "/user",
			  type: "POST",
			  dataType: "json",
			  data: data,

			  complete: function() {
			    //called when complete
			  },

			  success: function(data, status, xhr) {
			    //called when successful
					
					if(data.success == true){
						mmd.user = data.user
						cb()
					}
					
			 },

			  error: function() {
			    //called when there is an error
					console.log("error")
			  },
			});
		
		
	}
	
}


