var TCApplication = {wsrurl:"/cgi-bin/WebObjects/KissFM.woa/wsr",wosid:null,l:function(k){if (TCApplication.loc && TCApplication.loc[k]) return TCApplication.loc[k]; else return '/'+k+'/';}};
function $tc_wosid() { if (TCApplication.wosid) {return "?"+TCApplication.wosid;} else {return "";} }
/** Start:KissContentNodeCommentView **/
var KissContentNodeCommentView = {

	beginLoading: function(contentNodeId) {
		$(contentNodeId+"_loader").style.display = 'block';
	},
	
	endLoading: function(contentNodeId) {
		$(contentNodeId+"_loader").style.display = 'none';
	},
	
	updateCounter: function(contentNodeId) {
		
		if(!contentNodeId)
		{ return false; }

		var form = $(contentNodeId+"_commentForm");
		
		if(form)
		{
			$(contentNodeId+"_commentCount").update(form['currentCommentsCount'].value);
		}
	},

	onSend: function() {
	},
	
	onUpdateCommentContainer: function(contentNodeId) {
		
		var commentContainer = $(contentNodeId + '_commentContainer');
		
		if(!commentContainer)
		{ return false; }
		
		this.updateCounter(contentNodeId);
	
		if( !commentContainer.style.display || !commentContainer.visible() )
		{	this.showCommentContainer(contentNodeId); }

		this.endLoading(contentNodeId);
	},
	
	toggleCommentContainer: function(componentContentUrl, contentNodeId, _element) {       
		var commentContainer = $(contentNodeId + '_commentContainer')
		
      	if(!componentContentUrl || !commentContainer, !_element)
      	{ return true; }

		if( !commentContainer.style.display || !commentContainer.visible() )
		{
			this.gotoBatch(componentContentUrl, contentNodeId, 1);
			_element.className = 'on';
		}
		else
		{
			this.hideCommentContainer(contentNodeId);
			_element.className = 'off';
		}

		_element.blur();
		
		return false;
	},
	
	showCommentContainer: function(contentNodeId) {
		var commentContainer = $(contentNodeId + '_commentContainer')

		if(commentContainer)
		{ commentContainer.style.display = 'block'; }
	},
	
	hideCommentContainer: function(contentNodeId) {
		var commentContainer = $(contentNodeId + '_commentContainer')
		
		if(commentContainer && commentContainer.visible() )
		{ commentContainer.hide(); }
	},

	updateCommentContainer: function(componentContentUrl, contentNodeId, _callback)
	{	
	    var params = null;
	     
	    if(!componentContentUrl || !contentNodeId)
      	{ return false; }
		
		this.beginLoading(contentNodeId);

		params = ($(contentNodeId+"_commentForm")) ? $(contentNodeId+"_commentForm").serialize(true) : {contentNodeId:contentNodeId};
      	var scope = this;
		new Ajax.Updater(contentNodeId+"_commentContainer", componentContentUrl,
            {
                method:"POST",
                parameters: params,
                onComplete: function() { 
                				scope.onUpdateCommentContainer(contentNodeId); 
                			} //(typeof(_callback) == 'function') ? _callback : null
            }

        );
	},
	
    nextBatch: function(componentContentUrl, contentNodeId) {
    	return this.showBatch(componentContentUrl, contentNodeId, 1);
    },

    prevBatch: function(componentContentUrl, contentNodeId) {
    	return this.showBatch(componentContentUrl, contentNodeId, -1);
    },
        
    showBatch: function(componentContentUrl, contentNodeId, _direction) {
    	if(!componentContentUrl || !contentNodeId || !_direction)
    	{ return false; }

		var form = $(contentNodeId+"_commentForm");
		var batchNumber = form['batchNumber'].value;

		if(_direction > 0)
		{ batchNumber++; }

		if(_direction < 0)
		{ batchNumber--; }
		
		form['batchNumber'].value = batchNumber;
		      	
       	this.updateCommentContainer(componentContentUrl, contentNodeId);
       	
        return false;
    },

    gotoBatch: function(componentContentUrl, contentNodeId, _batchNumber) {
    	if(!componentContentUrl || !contentNodeId || !_batchNumber)
    	{ return false; }

		var form = $(contentNodeId+"_commentForm");
		
		if(form)
		{ 
			form['batchNumber'].value = _batchNumber;
		}
		 
		this.updateCommentContainer(componentContentUrl, contentNodeId);
       	
        return false;
    },
    
    submitComment: function(componentContentUrl, contentNodeId) {
    	if(!componentContentUrl || !contentNodeId)
    	{ return false; }
    		
		var form = $(contentNodeId+"_commentForm");
		form['saveComment'].value = 'true';

		/* 
		var callback = function(scope, id) {
						 return function(){ scope.updateCounter(id); };
						}(this, contentNodeId);
		 */
		 
       	this.updateCommentContainer(componentContentUrl, contentNodeId);
        
        return false;
    }

};
/** End:KissContentNodeCommentView **/
if (!KissContentNodeCommentView) KissContentNodeCommentView={};
KissContentNodeCommentView.contentURL="/cgi-bin/WebObjects/KissFM.woa/ajax/KissContentNodeCommentView"+$tc_wosid();
KissContentNodeCommentView.dataURL="/cgi-bin/WebObjects/KissFM.woa/ajax/KissContentNodeCommentView/data"+$tc_wosid();

/** Start:KissContentNodeRatingView **/
var KissContentNodeRatingView = {

	beginLoading: function(contentNodeId) {
		$(contentNodeId+"_loader").style.display = 'block';
	},
	
	endLoading: function(contentNodeId) {
		$(contentNodeId+"_loader").style.display = 'none';
	},
	
	updateCounter: function(contentNodeId) {
		
		if(!contentNodeId)
		{ return false; }

		var form = $(contentNodeId+"_ratingForm");
		
		if(form)
		{
			$(contentNodeId+"_averageScore").update(form['currentScore'].value);
		}
	},

	onUpdateRatingContainer: function(contentNodeId) {
		
		var ratingContainer = $(contentNodeId + '_ratingContainer');

		if(!ratingContainer)
		{ return false; }
		
		this.updateCounter(contentNodeId);
		this.updatePanel(contentNodeId);	
				
		if( !ratingContainer.style.display || !ratingContainer.visible() )
		{	this.showRatingContainer(contentNodeId); }

		this.endLoading(contentNodeId);
	},
	
	toggleRatingContainer: function(componentContentUrl, contentNodeId, _element) {       
		var ratingContainer = $(contentNodeId + '_ratingContainer')
		
      	if(!componentContentUrl || !ratingContainer, !_element)
      	{ return true; }

		if( !ratingContainer.style.display || !ratingContainer.visible() )
		{
			this.updateRatingContainer(componentContentUrl, contentNodeId);
			_element.className = 'on';
		}
		else
		{
			this.hideRatingContainer(contentNodeId);
			_element.className = 'off';
		}

		_element.blur();
		
		return false;
	},    
	
	showRatingContainer: function(contentNodeId) {
		var ratingContainer = $(contentNodeId + '_ratingContainer')

		if(ratingContainer)
		{ ratingContainer.style.display = 'block'; }
	},
	
	hideRatingContainer: function(contentNodeId) {
		var ratingContainer = $(contentNodeId + '_ratingContainer')
		
		if(ratingContainer && ratingContainer.visible() )
		{ ratingContainer.hide(); }
	},	

	updateRatingContainer: function(componentContentUrl, contentNodeId, _callback)
	{	
	    var params = null;
	     
	    if(!componentContentUrl || !contentNodeId)
      	{ return false; }
		
		this.beginLoading(contentNodeId);

		params = ($(contentNodeId+"_ratingForm")) ? $(contentNodeId+"_ratingForm").serialize(true) : {contentNodeId:contentNodeId};
      	var scope = this;
		new Ajax.Updater(contentNodeId+"_ratingContainer", componentContentUrl,
            {
                method:"POST",
                parameters: params,
                onComplete: function() { 
                				scope.onUpdateRatingContainer(contentNodeId); 
                			} //(typeof(_callback) == 'function') ? _callback : null
            }

        );
	},
	    
	updateScore: function(contentNodeId, _element) {
		
		var e = $(contentNodeId + '_voteContainer');

		var form = $(contentNodeId+ '_ratingForm');

      	if(!e || !_element || !form )
      	{ return false; }

		e = e.getElementsByTagName('A');

		for(var i = 0; i < e.length; i++)
		{
			if(e[i] == _element)
			{
				e[i].className = 'on';
				form['score'].value = (i + 1);
			}
			else
			{ 
				e[i].className = 'off'; 
			}			
		}
		
		_element.blur();
		
		return false;
	},
	
	updatePanel: function(contentNodeId) {
		
		var panel = $(contentNodeId + '_voteContainer');
		var buttons = null;
		var form = $(contentNodeId+ '_ratingForm');

      	if(!panel || !form)
      	{ return false; }

		try {
			buttons = panel.getElementsByTagName('A');
	
			buttons[form['score'].value - 1].className = 'on';
		} catch(e) {}
		
	},	

    performVote: function(componentContentUrl, contentNodeId) {
    	var form = $(contentNodeId+"_ratingForm");
    	
    	if(!componentContentUrl || !contentNodeId || !form)
    	{ return false; }

		form['performVote'].value  = 'true';

		if(isNaN(form['score'].value) || form['score'].value == 0 || form['score'].value.length < 1 )
		{ form['score'].value = null; }
		 
		this.updateRatingContainer(componentContentUrl, contentNodeId);

        return false;
    }
	
};
/** End:KissContentNodeRatingView **/
if (!KissContentNodeRatingView) KissContentNodeRatingView={};
KissContentNodeRatingView.contentURL="/cgi-bin/WebObjects/KissFM.woa/ajax/KissContentNodeRatingView"+$tc_wosid();
KissContentNodeRatingView.dataURL="/cgi-bin/WebObjects/KissFM.woa/ajax/KissContentNodeRatingView/data"+$tc_wosid();

/** Start:KissMessageBoardView **/
var KissMessageBoardView={
	toggleNewEntryForm: function(messageBoardId, _element) {
		var e = $("messageBoardNewEntryControls_"+messageBoardId); 

		if(!e || !_element) { 
			return false; 
		}
		 
		if(e.style.display != 'block' || !e.visible()) {
			 e.style.display='block';
			 _element.className = 'on';
		} 
		else {
			e.style.display='none';			
			_element.className = 'off';
		} 

		_element.blur();
		 
		return false;
	},
		
	
	createNewEntry: function(componentContentUrl, messageBoardId) {
		if(!componentContentUrl || !messageBoardId) { 
			return false; 
		}
      	
		var messageBoardContainerForm = $("messageBoardContainerForm_"+messageBoardId); 
		var params=messageBoardContainerForm.serialize(true);
		params.action="createEntry";
		
		var scope = this;
		
		new Ajax.Updater("messageBoardEntriesContainer_"+messageBoardId, componentContentUrl,
            {
                method:"POST",
                parameters: params//,
               // onComplete: function() { scope.previousBatch(componentContentUrl, messageBoardId); }
            }

        );
		return false;
	},
	
	cancelNewEntry: function(componentContentUrl, messageBoardId) {
		if(!componentContentUrl || !messageBoardId) { 
			return false; 
		}
      	
		var messageBoardContainerForm = $("messageBoardContainerForm_"+messageBoardId); 
		messageBoardContainerForm['message'].value ="";
		return this.toggleNewEntryForm(messageBoardId);
	},
	
	deleteEntry: function(messageBoardId, boardEntryId) {				
		if(!messageBoardId || !boardEntryId) { 
			return false; 
		}
      	
		var messageBoardContainerForm = $("messageBoardContainerForm_"+messageBoardId); 
		var params=messageBoardContainerForm.serialize(true);
		params.action="deleteEntry";
		params.boardEntryId=boardEntryId;
		new Ajax.Updater("messageBoardEntriesContainer_"+messageBoardId, this.contentURL,
            {
                method:"POST",
                parameters: params
            }

        );
		return false;
	},
	
	previousBatch: function(componentContentUrl, messageBoardId) {
		if(!componentContentUrl || !messageBoardId) { 
			return false; 
		}
      	
		var messageBoardContainerForm = $("messageBoardContainerForm_"+messageBoardId); 
		var params=messageBoardContainerForm.serialize(true);
		params.action="previousBatch";
		new Ajax.Updater("messageBoardEntriesContainer_"+messageBoardId, componentContentUrl,
            {
                method:"POST",
                parameters: params
            }

        );
		return false;
	},
	
	nextBatch: function(componentContentUrl, messageBoardId) {
		if(!componentContentUrl || !messageBoardId) { 
			return false; 
		}      	
		var messageBoardContainerForm = $("messageBoardContainerForm_"+messageBoardId); 
		var params=messageBoardContainerForm.serialize(true);
		params.action="nextBatch";
		new Ajax.Updater("messageBoardEntriesContainer_"+messageBoardId, componentContentUrl,
            {
                method:"POST",
                parameters: params
            }
        );
		return false;
	},
	
	saveAuthorizationRules: function(messageBoardId) {
		//alert(messageBoardId);
		if(!messageBoardId) { 
			return false; 
		}      	
		var authorizationRulesForm = $("messageBoardAuthorizationEditor_"+messageBoardId); 
		
		//var params=authorizationRulesForm.serialize(true);
//		params.action="saveAuthorizationRules";
		authorizationRulesForm.submit();
		//new Ajax.Updater("messageBoardEntriesContainer_"+messageBoardId, this.contentURL,
//            {
//                method:"POST",
//                parameters: params
//            }
//        );
        
        
		return false;
	},
	
	toggleAuthorizationRules: function(messageBoardId, _element) {       
		var e = $(messageBoardId);
		
		if(!e || !_element) { 
			return false; 
		}
		 
		if(e.style.display != 'block' || !e.visible()) {
			 e.style.display='block';
			 _element.className = 'on';
		} 
		else {
			e.style.display='none';			
			_element.className = 'off';
		} 

		_element.blur();
		
		return false;
	}
		
				
};
/** End:KissMessageBoardView **/
if (!KissMessageBoardView) KissMessageBoardView={};
KissMessageBoardView.contentURL="/cgi-bin/WebObjects/KissFM.woa/ajax/KissMessageBoardView"+$tc_wosid();
KissMessageBoardView.dataURL="/cgi-bin/WebObjects/KissFM.woa/ajax/KissMessageBoardView/data"+$tc_wosid();

/** Start:KissMessageBordEntryViewNC **/
var KissMessageBordEntryViewNC={

	displayNewCommentForm: function(messageBoardId, boardEntryId) {		
		if (! messageBoardId || !boardEntryId) return false;
		var f = $("messageBoardNewCommentControls_"+messageBoardId+"_"+boardEntryId); 
		f.style.display='block';					
		return false;
	},
	
	cancelNewComment: function(componentContentUrl, messageBoardId, boardEntryId) {
		if(!componentContentUrl || !messageBoardId || !boardEntryId) { 
			return false; 
		}
		
		var messageBoardEntryContainerForm = $("messageBoardEntryContainerForm_"+messageBoardId+"_"+boardEntryId); 
		messageBoardEntryContainerForm['message'].value ="";
		
		var f = $("messageBoardNewCommentControls_"+messageBoardId+"_"+boardEntryId); 
		f.style.display='none';					
		return false;
	},
	
	createNewComment: function(componentContentUrl, messageBoardId, boardEntryId) {
		if(!componentContentUrl || !messageBoardId || !boardEntryId) { 
			return false; 
		}
      	
		var messageBoardEntryContainerForm = $("messageBoardEntryContainerForm_"+messageBoardId+"_"+boardEntryId); 
		var params=messageBoardEntryContainerForm.serialize(true);
		params.action="createComment";
		new Ajax.Updater("messageBoardEntryContainer_"+messageBoardId+"_"+boardEntryId, componentContentUrl,
            {
                method:"POST",
                parameters: params
            }
        );

		return false;
	},
			
	deleteComment: function(componentContentUrl, messageBoardId, boardEntryId, boardCommentId) {
		//alert(componentContentUrl);
		if(!componentContentUrl || !messageBoardId || !boardEntryId || !boardCommentId) { 
			return false; 
		}
      	
		var messageBoardEntryContainerForm = $("messageBoardEntryContainerForm_"+messageBoardId+"_"+boardEntryId); 
		var params=messageBoardEntryContainerForm.serialize(true);
		params.action="deleteComment";		
		params.boardCommentId=boardCommentId;
		new Ajax.Updater("messageBoardEntryContainer_"+messageBoardId +"_" +boardEntryId, componentContentUrl,
            {
                method:"POST",
                parameters: params
            }
        );
		return false;
	},
	previousBatch: function(componentContentUrl, messageBoardId, boardEntryId) {
		if(!componentContentUrl || !messageBoardId || !boardEntryId) { 
			return false; 
		}      	
		var messageBoardEntryContainerForm = $("messageBoardEntryContainerForm_"+messageBoardId+"_"+boardEntryId); 		
		var params=messageBoardEntryContainerForm.serialize(true);
		params.action="previousCommentBatch";
		new Ajax.Updater("messageBoardEntryContainer_"+messageBoardId+"_"+boardEntryId, componentContentUrl,
            {
                method:"POST",
                parameters: params
            }

        );
		return false;
	},
	
	nextBatch: function(componentContentUrl, messageBoardId, boardEntryId) {
		if(!componentContentUrl || !messageBoardId || !boardEntryId) { 
			return false; 
		}     	
		var messageBoardEntryContainerForm = $("messageBoardEntryContainerForm_"+messageBoardId+"_"+boardEntryId); 
		var params=messageBoardEntryContainerForm.serialize(true);
		params.action="nextCommentBatch";
		new Ajax.Updater("messageBoardEntryContainer_"+messageBoardId+"_"+boardEntryId, componentContentUrl,
            {
                method:"POST",
                parameters: params
            }
        );
		return false;
	},
	
	toggleComments: function(componentContentUrl, messageBoardId, boardEntryId, _element) {
		if(!componentContentUrl || !messageBoardId || !boardEntryId) { 
			return false; 
		}     	
		
		
		var messageBoardEntryContainerForm = $("messageBoardEntryContainerForm_"+messageBoardId+"_"+boardEntryId); 		
		var currentBatch=messageBoardEntryContainerForm['commentBatchNumber'].value;
		if (currentBatch==0){
			messageBoardEntryContainerForm['commentBatchNumber'].value=1;
		}
		else{
			messageBoardEntryContainerForm['commentBatchNumber'].value=0;
		}
		
		//alert(messageBoardEntryContainerForm['commentBatchNumber'].value);
		var params=messageBoardEntryContainerForm.serialize(true);
		params.action="gotoCommentBatch";
		new Ajax.Updater("messageBoardEntryContainer_"+messageBoardId+"_"+boardEntryId, componentContentUrl,
            {
                method:"POST",
                parameters: params
            }
        );
	
		if( _element )
		{
			_element.className = 'on';
			_element.blur();
		}
		else
		{
			_element.className = 'off';
			_element.blur();	
		}

	
		return false;
	}
};
/** End:KissMessageBordEntryViewNC **/
if (!KissMessageBordEntryViewNC) KissMessageBordEntryViewNC={};
KissMessageBordEntryViewNC.contentURL="/cgi-bin/WebObjects/KissFM.woa/ajax/KissMessageBordEntryViewNC"+$tc_wosid();
KissMessageBordEntryViewNC.dataURL="/cgi-bin/WebObjects/KissFM.woa/ajax/KissMessageBordEntryViewNC/data"+$tc_wosid();

