/*
 * Classe di gestione per i componenti della pagina
 * Tutti i componeti che necessitano una gestione interattivata devono essere registrati in questa classe
 * N.B.: Tutti gli item aggiunti a questa classe devono avere un attributo section e type valido per la loro identificazione
 */

 function compManager(){
 	this.items=new Array(); //Array che contiene tutti i componenti registrati sulla pagina
	
	this.addItem=addItem;
	this.getCompBySection=getCompBySection;
	this.getCompByType=getCompByType;
	
	function addItem(item){ //Aggiunge un nuovo componenete all'array principale
		this.items.push(item);
	}
	
	function getCompBySection(section){ //Ritorna un array con tutti i componenti di una sezione specifica
		var buffer_cmp=new Array();
		
		var i=0;
		for (i = 0; i < this.items.length; i++) {
			if(this.items[i].section==section){
				buffer_cmp.push(this.items[i]);
			}
		}
		
		return buffer_cmp;
	}
	
	function getCompByType(type){ //Ritorna un array con tutti i componenti di una sezione specifica
		var buffer_cmp=new Array();
		
		var i=0;
		for (i = 0; i < this.items.length; i++) {
			if(this.items[i].type==type){
				buffer_cmp.push(this.items[i]);
			}
		}
		
		return buffer_cmp;
	}
 }
 
 var components=new compManager();
 
 $(document).ready(function(){
	    $(document).bind("contextmenu",function(e){
	        return false;
	    });
            
            $("ul.sf-menu").superfish();
	});
 
 /*
  * Definizione della funzione trim per le stringhe
  */
 String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ""); };
 
 /*
  * Funzione Document Ready Puņ gestire l'onload di tutti i componenti
  */
 $(document).ready(function() {
 	/*
 	 * Popup delle foto nei contenuti utente
 	 */
 	/*$("a.userPopup").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200,
		'autoDimensions':	true,
		'hideOnContentClick': true
	});*/
});

