// Generated by CoffeeScript 1.8.0
(function() {
  $(function() {
	  $(".toast").hide();
	  localStorage.clear();
	  var meetingId=GetQueryString("meetingId");
	  $.ajax({
		  url: baseUrl + '/api/meeting/find_detail.do',
          data:{meetingId:meetingId} ,
          beforeSend: function() {
              return toast.show();
            },
          success: function(data) {
            if (data.status === 200) {
            	toast.hide();
            	if(data.data.meeting.fid===undefined||data.data.meeting.fid===0){
            		$('#collect').removeClass("cancle");
            	}else{
            		$('#collect').addClass("cancle");
            	}
            	$("#title").html(data.data.meeting.title);
            	$("#mthumbnail").attr("src",data.data.meeting.mthumbnail);
            	$("#organizer").html(data.data.meeting.organizer);
            	$("#organizerSecondary").html(data.data.meeting.organizerSecondary);
            	$("#address").html(data.data.meeting.address);
            	$("#openDate").html(data.data.meeting.openDate);
            	$("#content").html(data.data.meeting.description);
            	var contact = data.data.meeting.contact;
            	if (contact == undefined || contact == '' || contact == null) {
            		$("#bottom").hide();
            	} else {
            		$("#bottom").show();
            		$("#appointment").html("报名电话 " + contact);
            		$("#appointment").attr('href', 'tel:'+contact);
            	}
            }else{
          	  wrongMsg(data.message);
            }
          }
	  });
	  return $("#collect").click(function(){
	    	 var meetingId =GetQueryString("meetingId");
	    	 if(!$('#collect').hasClass("cancle")){
	    		 $.ajax({
				    	url:baseUrl+'/api/user/collect.do',
				    	data:{
				    		favoriteType:3,
				    		relationId:meetingId,
				    		orginUri:location.href,
				    		thumbnail:"../../static/images/meet_collect.jpg"
				    	},
					    success:function(data){
					    	if(data.status===311){	
					    	   localStorage.clear();	
					    	   localStorage.setItem("meetingId", meetingId);
					    	   //toast.show({msg:"还未登录,请先登录"});
					    	   //setTimeout(function(){
					    		   return location.href="../user/login.html";
					    	   //},1000);
					    	}else if(data.status===200){
					    		$('#collect').addClass("cancle");
					        }else{
					        	wrongMsg(data.message);
					        }
					  }
			    	});
	    	 }else{
	    		 $.ajax({
				    	url:baseUrl+'/api/user/cancel_collect.do',
				    	data:{
				    		favoriteType:3,
				    		relationId:meetingId
				    	},	 	    				    
					    success:function(data){
					    	if(data.status===311){	
					    	   localStorage.clear();	
					    	   localStorage.setItem("meetingId", meetingId);
					    	   //toast.show({msg:"还未登录,请先登录"});
					    	   //setTimeout(function(){
					    		   return location.href="../user/login.html";
					    	   //},1000);
					    	}else if(data.status===200){
					    		$('#collect').removeClass("cancle");
					        }else{
					        	wrongMsg(data.message);
					        }
					  }
			    	});
 			    	
 			}
	    	
	    });
  });
    
}).call(this);
