/********************************************/
/*	core.js for jquery
/*	Author: davide reppucci | nascar
/*  Author URI: http://www.nascar.it
/*	Version 0.2
/*
/*  PLUGIN LOADED
/*	Autogrow
/*	Looped Slider
/*  checkForm
/*	externalLink
/*
/*  latest update: 27/11/09
/*******************************************/

var core = {
	
	bootstrap : function( _labels ) {
		
		// se ci sono classi accordion
		if ( jQuery('.accordion').length > 0 ) { core.activateAccordion(); }
		
		// se c'è #ubl-form
		if ( jQuery('#ubl-form').length > 0 ) { core.activateBoxLogin(); }
		
		// se c'è #send-form1
		if ( jQuery('#send-form1').length > 0 ) { core.activateSendFriend(); }
		
		// se ci sono classi .slides
		if ( jQuery('.slides').length > 0 ) { core.activateLoopedGallery(); }
		
		// se ci sono textarea con classe expanding
		if ( jQuery('textarea.expanding').length > 0 ) { core.expandTextarea(); }
		
		// se esistono classi .ui-tabs
		if ( jQuery('.ui-tabs').length > 0 ) { core.activateTabs(); }
		
		// se esistono classi .infoAlert
		if ( jQuery('.infoAlert').length > 0 ) { core.activateInfoTooltip(); }
		
		// se esistono classi .infoAlert
		if ( jQuery('#share_gen').length > 0 ) { core.shareIt(); }
		
		// se esiste .pager
		//if ( jQuery('.pager').length > 0 ) { jQuery('.pager').css('width', jQuery('.pager ul').width() ); }
				
		// initializzo il checkForm
		Forms.init(_labels);
		
		// esternalizzo i link con class external
		var externals = new externalLink();
	
	},
	
	// metodo per espandere le textarea
	expandTextarea : function() {
		
		jQuery("textarea.expanding").each(function(i){

		   jQuery(this).autogrow({ maxHeight: 500, minHeight: 100, lineHeight: 23 });
		      
		});	
	
	},
	
	// metodo per attivare il login
    activateBoxLogin : function() {
       
        $('.open-login a').click(function() {

			$('#ubl-form').addClass('opened');
			$('#login-warning').removeClass('here');
			$('#ubl-form').fadeIn('slow');
			$('#login-close').fadeIn('slow');

            return false;
           
        });  
		
		$('#closeX').click( function() {
									 
			$('#ubl-form').fadeOut('slow');
		   $('#ubl-form').removeClass('opened');
		   $('#login-warning').removeClass('here');
		   
		   return false;
			
		});
   
    },
	
	// metodo per attivare l'invio ad un amico
    activateSendFriend : function() {
       
        $('#send_gen').click(function() {

			$('#send-form1').addClass('opened');
			$('#send_warning').removeClass('here');
			$('#send-form1').fadeIn('slow');
			$('#send_close').fadeIn('slow');

            return false;
           
        });  
		
		$('#send_closeX').click( function() {
									 
			$('#send-form1').fadeOut('slow');
		   $('#send-form1').removeClass('opened');
		   $('#send_warning').removeClass('here');
		   
		   return false;
			
		});
   
    },
	
	// metodo per attivare l'accordion
	activateAccordion : function() {
		
		jQuery(".accordion").each(function(i){
		
			jQuery(this).accordion({ header: 'h3', animated: 'slide', autoHeight: false });
		   		      
		});	
	
	},
	
	// metodo per attivare il Looped Slider
	activateLoopedGallery : function() {
	
		jQuery('.container').each(function(i){
		   
		   jQuery(this).loopedSlider({ pagination: '.pagination', containerClick: false, autoStart: false });
		   		      
		});
	
	},
	
	// metodo per attivare i tabs
	activateTabs : function() {

		jQuery(".ui-tabs").each(function(i){

			jQuery(this).tabs({ remote: true, fx: { opacity: 'toggle', duration: 200 } });
		   		      
		});	
	
	},
	
	// metodo per attivare i tooltip info
	activateInfoTooltip : function() {
		
		jQuery(".infoAlert").each(function(i){
		   
		   jQuery(this).tooltip({
			    delay: 0,
			    track: true,
			    fade: 250,
			    top: -40, 
				left: 5,
				showBody: " - "
			});
		   		      
		});	
	
	},
	
	shareIt : function() {
		jQuery("a#share_gen").shareitBtn(); // the button function
		jQuery(".bmarks a").shareitHover();	
	}
	
};