/**
 * @author BlackSheep Alias Swa.Th
 */

 
 function loading() {
 	
/*	if(Browser.Engine.trident4||Browser.Engine.trident5) {
		//alert('a');
		location.href='not.html';
		}*/
 	
 	h = window.innerHeight;
 	w = window.innerWidth;
 	
 	if (Browser.Engine.trident) {
 		try {
 			h = document.documentElement.clientHeight;
 			w = document.documentElement.clientWidth;
 		} 
 		catch (e) {
 			alert(e);
 		}
 		
 	}
	
//	uno_tre = h - 544;
//	uno_tre -= (uno_tre %= 2);
//	uno_tre /= 2;
//	
//	if (h <= 544) {
//		$('Content-Intro').setStyle('margin-top', 0);
//	} else {
//		$('Content-Intro').setStyle('margin-top', uno_tre);
//	}
		

	$('Content-Intro').setStyle('visibility','visible');
	
	
	
	if(Progress()) change(100);
	
 }
 
function Progress(){
	try {
	$('Progress').set('morph', {
			duration: 5000,
			link: 'chain'
		}).morph({
			'width': 0,
			'opacity': 0,
			'filter:alpha': 0
		});	
	} catch (e) {
		alert(e)
	}
	if(preloadALL()) return true;
}

function change(value){
	try {
		
//	$('Sfondo').set('morph', {
//			duration: 5000,
//			link: 'chain'
//		}).morph({
//			'opacity': (1 - (value/100)),
//			'filter:alpha': (100 - value)
//		});	
		
		
	$('Caricamento').set('morph', {
			duration: 4500,
			link: 'chain'
		}).morph({
			'opacity': (1 - (value/100)),
			'filter:alpha': (100 - value)
		});	
	} catch (e) {
		alert(e)
	}
	try {
		setTimeout(function(){
		location.href='homepage.php'}, 5100);
		//alert('ok2');
	
	} catch (e) {
		alert(e);
	}


	
}

function setting(value) {
	
	var prog;
	prog = $('Progress').clientWidth - (value * 5,84);
	if(prog<0) prog = 0;
	//alert(prog);
	$('Progress').setStyle('width', prog);
	
}

function preloadALL() {
	
	preload('imgs/background.jpg');
	preload('imgs/bg-all-site-2.png');
	preload('imgs/cover-premio-urania.png');
	//alert('ok');
	return true;
}

function preload(url) {
	try {
		//alert('a');
		heavyImage = new Image(); 
		heavyImage.src = url;	
		return true;
	} catch (e) {
		alert(e);
	}
}

