var wta = {};

// COOL ACCORDION
wta.coolAccordion = function(){
	
	function _init(){
		$('.news > dl').accordion({ 
			header: 'dt', 
			autoheight: true,
			active: false,
			alwaysOpen: false,
			selectedClass: 'open'
		});
	}

	return {
		init: function(){
				$(document).ready(function(){ _init(); });
			}
	}
}();
wta.coolAccordion.init();

// COOL CLICK SOUNDS
wta.coolClickSounds = function(){

	soundManager.url = 'http://www.itscool2.it/assets/flash/'; // directory where SM2 .SWFs live
	
	// disable debug mode after development/testing..
	soundManager.debugMode = false;
	
	function playSound(){
		soundManager.play('click');
	}
	
	
	return {
		init: function(){
		
			soundManager.onload = function() {
				// SM2 has loaded - now you can create and play sounds!
				soundManager.createSound('click','http://www.itscool2.it/assets/audio/click-low.mp3');
			}
	
			$(document).ready(function(){
				// setup degli elementi
				$('.news dt, a').click(function(){
					playSound();
				})
			});
		}		
	}
}();
wta.coolClickSounds.init();

// COOL UTILS
wta.coolUtils = function(){
	
	return {
		openWindow: function(windowWidth, windowHeight, windowName, windowUri){
			var centerWidth = (window.screen.width - windowWidth) / 2;
			var centerHeight = (window.screen.height - windowHeight) / 2;
		
			newWindow = window.open(windowUri, windowName, 'resizable=0,width=' + windowWidth + 
				',height=' + windowHeight + 
				',left=' + centerWidth + 
				',top=' + centerHeight);
			newWindow.focus();
			return newWindow.name;
		}
	}
}();

// COOL COMMENTS
wta.coolComments = function(){
	function _init(){
		$('.inserimenti li.comment').slideUp(0);
		
		$('a.commentLink').click(function(){
			var el = $(this.hash);
			_toggleSlide(el);
			return false;
		})
	}
	
	function _toggleSlide(el){
		if($(el).hasClass('open')){
			$(el).slideUp(300).removeClass('open');
		} else {
			$(el).slideDown(600).addClass('open');
		}
	}
	
	return {
		init: function(){
			$(document).ready(function(){
				_init();
			})
		}
	}
}();
wta.coolComments.init();