 /*
  * REPORT A PHOTO ALBUM 
  */
function reportAlbum(nAlbumId, nUserId)
{
	// we logged in?
	if (nUserId.length > 0)
	{		
		// pop dialog notice box
    	$("#dialogReport").dialog(
	    {
	    	title: 'Clipstar',
            resizable: false,
            close: function() { $(this).dialog('destroy'); },
            buttons: 
            { 
            	"OK": function() 
            	{
            		sReason = $("textarea[name='thereason']").val();
            	
        			$.ajax({
        				url: '/ajax/albumreport/' + nAlbumId,
        				type: 'POST',
        				data: "reason=" + sReason,
        				success: function(sResponse)
        				{
        					if (sResponse=='success') {
        						// set dialog content
        						$("#dialogInfoBody").html('You have reported this album to our moderators!');
        					
        						// pop dialog notice box
        				    	$("#dialogInfo").dialog(
        					    {
        					    	title: 'Clipstar',
        				            resizable: false,
        				            close: function() { $(this).dialog('destroy'); },
        				            buttons: { "OK": function() { $(this).dialog('destroy'); }} 
        					    });        						
        					} else if (sResponse=='exists') {
        						// set dialog content
        						$("#dialogInfoBody").html('You have already reported this album.');
        					
        						// pop dialog notice box
        				    	$("#dialogInfo").dialog(
        					    {
        					    	title: 'Clipstar',
        				            resizable: false,
        				            close: function() { $(this).dialog('destroy'); },
        				            buttons: { "OK": function() { $(this).dialog('destroy'); }} 
        					    });        						
        					} else if (sResponse=='noreason') {
        						// set dialog content
        						$("#dialogInfoBody").html('You must enter a reason for reporting this album.');
        					
        						// pop dialog notice box
        				    	$("#dialogInfo").dialog(
        					    {
        					    	title: 'Clipstar',
        				            resizable: false,
        				            close: function() { $(this).dialog('destroy'); },
        				            buttons: { "OK": function() { $(this).dialog('destroy'); }} 
        					    });           						
        					}
        				},
        				error: function()
        				{
    						// set dialog content
    						$("#dialogInfoBody").html('We are sorry, there seems to have been a problem. Please try again.');
    					
    						// pop dialog notice box
    				    	$("#dialogInfo").dialog(
    					    {
    					    	title: 'Clipstar',
    				            resizable: false,
    				            close: function() { $(this).dialog('destroy'); },
    				            buttons: { "OK": function() { $(this).dialog('destroy'); }} 
    					    });         					
        				}        				
        			});
            		$(this).dialog('destroy'); 
            	}
            } 
	    });
	}
	else
	{
		// set dialog content
		$("#dialogInfoBody").html('You must be a registered user and logged in to report an album. Click <a href="/login/">here to login</a>.');
	
		// pop dialog notice box
    	$("#dialogInfo").dialog(
	    {
	    	title: 'Clipstar',
            resizable: false,
            close: function() { $(this).dialog('destroy'); },
            buttons: { "OK": function() { $(this).dialog('destroy'); }} 
	    });	 		
	}
};