/***************************************************************************
 *       ___ _   _                    ____           _       _
 *      |  _| | | |_ __  _ _  ___    / ___|  ___ _ _(_)_ __ | |_
 *      | |_| |_| | '_ \| '_)/ _ \   \___ \ / __| '_) | '_ \| __| 
 *      |  _|  _  | |_) | | | (_) |   ___) | (__| | | | |_) | |_ 
 *      |_| |_| |_| .__/|_|  \___/   |____/ \___|_| |_| .__/ \__|
 *                |_|  www.fhpro.de                   |_|
 *
 *   Copyright            : (c) 2006 Frank Hinkel
 *   Kontakt              : info@fhpro.de
 *
 ***************************************************************************/

/*** COMMENTS ***/
function FhproComments() {
    this._videoId;
    this.cboxObj;    	
}
FhproComments.prototype = 
{    
	initialize: function() 
	{
	    this.cboxObj = CLweb2.getElem('CommentsBoxHtml');	    
	    this.cboxObj.innerHTML = '<div class="loadingMsg"> Lade Kommentare ... </div>';
	},
	//
	//	switchComments()
	//	hide / show Comments
	//	
	switchComments: function(commentIsDisplay, activeVideo)
	{   
        this._videoId = activeVideo;
        this.getComments();
	},
	writeLoadMsg: function() 
	{
	    this.cboxObj.innerHTML = '<div class="loadingMsg">lade Kommentare...</div>';	    
	},
	getComments: function()
	{
        var getCommentsObj = new FhproWeb2Ajax();
	    getCommentsObj.debug = false;
	    getCommentsObj.Request('CallBackGetComments','post','/ajax/362','','do=comments&subdo=loadComments&VideoItem=' + this._videoId);	    	    
	},
	submitComment: function()
	{
        var elem = CLweb2.getElem('FormComment');        
        if (elem.value.length < 3)
        {
            alert("Bitte gib einen Kommentar ein.");
            return;
        }   
        var writeCommentsObj = new FhproWeb2Ajax();
	    writeCommentsObj.debug = false;
	    writeCommentsObj.Request('CallBackWriteComments','post','/ajax/362','SendFormComment','do=comments&subdo=saveComment&VideoItem=' + this._videoId);	    	    	    
	},
	removeComment: function(num)
	{
        if (num < 1)
            return;
            
        var writeCommentsObj = new FhproWeb2Ajax();
	    writeCommentsObj.debug = false;
	    writeCommentsObj.Request('CallBackDelComments','post','/ajax/362','','do=comments&subdo=removeComment&VideoItem=' + this._videoId + '&comId=' + num);	    	    	                
	}
}
FhproWeb2Ajax.prototype.CallBackDelComments = function()
{ 
    try 
    {
    	eval(this.request.responseText);
    	 
	    // Bei Fehler abbrechen
	    if (cbObj[0].ErrCode != '-1')
	    {
        	alert(cbObj[0].ErrMsg);
        	return;
    	}        
    	// Reload
    	CLcomments.getComments(); 
    }
    catch (e) 
    {
    	alert("Konnte Kommentar nicht löschen."); 
		return;
    }    
}
FhproWeb2Ajax.prototype.CallBackWriteComments = function()
{ 
    try 
    {
    	eval(this.request.responseText);
    	 
	    // Bei Fehler abbrechen
	    if (cbObj[0].ErrCode != '-1')
	    {
        	alert(cbObj[0].ErrMsg);
        	return;
    	}        
    	// Reload
    	CLcomments.getComments(); 
    }
    catch (e) 
    {
    	alert("Konnte Kommentar nicht speichern."); 
		return;
    }    
}
FhproWeb2Ajax.prototype.CallBackGetComments = function()
{ 
    try 
    {
    	eval(this.request.responseText);
    	 
	    // Bei Fehler abbrechen
	    if (cbObj[0].ErrCode != '-1')
	    {
        	alert(cbObj[0].ErrMsg);
        	return;
    	} 
    	CLcomments.cboxObj.innerHTML = cbObj[1].Content;  
    }
    catch (e) 
    {
    	alert("Konnte Kommentare nicht laden."); 
		return;
    }    
}
var CLcomments = new FhproComments(); 
