window.addEvent('domready', function() {

	// box commenta
	if ($('formComm') != null) {
		$('formComm').fade(0);
	}

	// + visititati + recenti (HP)
	if ($('hpP') != null) {
		$('visitati').fade(0.5);
		$('visitati').getElements('.rg').fade(0);
	}

	// box di ricerca (in tutte le pagine tranne quella di registrazione)
	if ($('rP') == null) {
		$('boxFind').getElement('.opzioni').fade(0);
		$('boxFind').getElement('.bt02').fade(0);
	}

	// validazione form registrazione
	if ($('rP') != null) {
		new FormCheck('formReg', {
			display : {
				tipsPosition : "left",
				tipsOffsetX : 160,
				tipsOffsetY : 0
			},
			alerts : {}
		});
	}
	
	//alert Login
	var myLogin = new mooSlide2({
								slideSpeed: 1500,
								fadeSpeed: 500,
								toggler:'loginH',
								content: 'boxLogin',
								height:250,
								close: false,
								effects:Fx.Transitions.Bounce.easeOut, 
								from:'top'
								});
	//optional: AutoStart the slider on page load:
	//MyLogin.run();
	$('btClose01').addEvent('click', function(e){
		e = new Event(e);
		myLogin.clearit();
		e.stop();
	});

	//box inserimento video check form
	if ($('fIncV') != null) {
		new FormCheck('formVid', {
			display : {
				tipsPosition : "left",
				tipsOffsetX : 0,
				tipsOffsetY : 0
			},
			alerts : {}
		});
	}

});

// script per cambiare la classe ad un specifico id
function changeClass(boxId01,nomeClass) {
	$(boxId01).set('class',nomeClass);
}

// script per effetto fade di un specifico id
function fadeBubu(boxId01,fadeVal) {
	$(boxId01).fade(fadeVal);
	}

// box ricerca (tutte le pagine)
function tipoRic(stato) {
	var myEffect = new Fx.Tween('boxFind');
	var myEffect2 = new Fx.Tween('boxFind');
	
	if ($('hpP') != null || $('rrP') != null ) {
		if (stato == 'on') {
			myEffect.start('height', '114px', '143px');
			$('boxFind').getElement('.bt01').fade(0);
			$('boxFind').setStyle('background-color', '#FC0');
			(function(){
				$('boxFind').set('class', 'on');
				$('boxFind').setStyle('background-color', 'transparent');
				$('boxFind').getElement('.opzioni').fade(1);
				$('boxFind').getElement('.bt02').fade(1);
			}).delay(500);
		} else {
			myEffect.start('height', '143px', '114px');
			$('boxFind').getElement('.opzioni').fade(0);
			$('boxFind').getElement('.bt02').fade(0);
			(function(){
				$('boxFind').set('class', 'off');
				$('boxFind').getElement('.bt01').fade(1);
			}).delay(500);
		}
	} else {
		if (stato == 'on') {
			myEffect2.start('height', '62px', '117px');
			myEffect.start('background-color', '#333', '#FC0');
			$('boxFind').getElement('.bt01').fade(0);
			(function(){
				$('boxFind').set('class', 'on');
				$('boxFind').getElement('.opzioni').fade(1);
				$('boxFind').getElement('.bt02').fade(1);
			}).delay(500);
		} else {
			myEffect2.start('height', '117px', '62px');
			myEffect.start('background-color', '#FC0', '#333');
			$('boxFind').getElement('.opzioni').fade(0);
			$('boxFind').getElement('.bt02').fade(0);
			(function(){
				$('boxFind').set('class', 'off');
				$('boxFind').getElement('.bt01').fade(1);
			}).delay(500);
		}
	}
}

// aggiungi commento (Video e TV)
function addComm(stato) {
	if (stato == 'apri') {
		$('formComm').fade(1);
		$('boxComm').set('class', 'on');
		$('boxComm').getElement('.cont').setStyle('overflow', 'hidden');
		$('boxComm').getElement('.bt00').fade(0);
	} else {
		$('formComm').fade(0);
		$('fcommenta').reset();
		$('boxComm').getElement('.cont').setStyle('overflow', 'auto');
		(function(){
			$('boxComm').set('class', 'off');
			$('boxComm').getElement('.bt00').fade(1);
		}).delay(500);
	}
}

// + visititati + recenti (HP)
function listVideo(tipo) {
	if (tipo == 'recenti') {
		$('visitati').fade(0.5);
		$('visitati').getElements('.rg').fade(0);
		$('boxPiuVR').set('class', 'recenti');
		$('recenti').fade(1);
		$('recenti').getElements('.rg').fade(1);
	} else {
		$('recenti').fade(0.5);
		$('recenti').getElements('.rg').fade(0);
		$('boxPiuVR').set('class', 'visitati');
		$('visitati').fade(1);
		$('visitati').getElements('.rg').fade(1);
	}
}

// includi video
function incVideo(){
	var stato = $('boxIncV').hasClass('off');

	if (stato == true) {
		$('boxIncV').set('class', 'on');
	} else {
		(function(){
			$('boxIncV').set('class', 'off');
		}).delay(500);
	}
}
