video_view=
{
    current_view: 0,
    showCode: function(t, code, e)
    {
        $(e).val(code);
        return false;
    },
    showAllCode: function(code)
    {
        if (this.current_view==0)
        {
            $('#share_all_code').show();
        }
        if (code=='bb_code' && this.current_view==1)
        {
            this.current_view=0;
            $('#share_all_code').hide();
            return;
        }
        
        if (code=='html_code' && this.current_view==2)
        {
            this.current_view=0;
            $('#share_all_code').hide();
            return;
        }
        
        if (code=='bb_code')
        {
            $('#all_code').val($('#bb_code').text());
            this.current_view=1;
        }
        
        if (code=='html_code')
        {
            $('#all_code').val($('#html_code').text());
            this.current_view=2;
        }
    },
    shareVideo: function()
    {
        $('#share_dialog').jqm().jqmShow();
        return false;
    },
    sendMail: function()
    {
    	$('#share_dialog').jqmHide();
    },
    addBookmark: function(vid)
    {
        if (!confirm('Bạn chắc chắn thêm video này vào nhà mình'))
        {
            return false;
        }
        $.post('/bookmark', 'vid=' + vid, function(data, status){
            if (status=='success' && (data=="1" || data=="0"))
            {
                alert('Video đã được thêm vào nhà bạn');
            }
            else
            {
                alert('Có lỗi khi thêm video vào nhà bạn. Hãy thử lại lần khác');
            }
        });
        return false;
    },
    alertLogin: function()
    {
        alert('Bạn cần đăng nhập để sử dụng chức năng này');
        return false;
    },
    alertViolence: function(vid)
    {
        var width = 500;
        var height = 220;
        var left = parseInt((screen.availWidth/2) - (width/2));
        var top = parseInt((screen.availHeight/2) - (height/2));
        var windowFeatures = "width=" + width + ", height=" + height + ", left=" + left + ", top=" + top + ", screenX=" + left + ",screenY=" + top + ", resizable=no, status=no, menubar=no, scrollbars=no";
        window.open("/alert/" + vid, "subWind", windowFeatures);
        return false;
    },
	getThank: function(uid, vid)
	{
        $.ajax({
			   type: "GET",
			   url: "/thank/get?uid=" + uid + "&vid=" + vid,
		       complete: function(res, s){
		           if (s!="success")
		           {
		            $("#user_thank").html("Social networking service error");
		           }
		           else
		           { 
			        $("#user_thank").html(res.responseText);
			       }
			    }	   
	        });
	},
	setThank: function(vid, val)
	{
        $.ajax({
			   type: "POST",
			   url: "/thank/set?vid=" + vid + "&val=" + val,
               beforeSend: function(req){
				    $("#user_thank").html("Sending...");
			   },
		       complete: function(res, s){
		            if (s=="success")
		            {
			            $("#user_thank").html(res.responseText);
			        }
			        else
			        {
			            $("#user_thank").html("Social networking service error");
			        }
			    }
	        });
	}
}
