var yoyohome;
window.addEvent('domready', function(){
	var H = document.getSize().y;
	var W = document.getSize().x;
	if(W<1240&&W>1000){
		$('elastic').setStyle('height',(W*0.524).toInt()+'px');		
		$('dockContainer').setStyle('top',(W*0.524).toInt()-104+'px');
		$('dockContainer').setStyle('left',((W-392)/2).toInt()+'px');
	}else if(W>=1240) {
		$('elastic').setStyle('height','650px');
		$('dockContainer').setStyle('left',((W-392)/2).toInt()+'px');
		$('dockContainer').setStyle('top','550px');
	}else if(W<=1000) {
		$('elastic').setStyle('height','524px');
		$('dockContainer').setStyle('top','424px');
		$('dockContainer').setStyle('left','304px');
	}
	
		yoyohome = new Swiff('loader.swf', {
		id: 'homeSWF',
		width: '100%',
		height: '100%',
		container: $('elastic'),
		params: {scale:'Noborder'}

		});
		
		new Swiff('dock_icon.swf', {
		id: 'homeSWF',
		width: '395',
		height: '100',
		container: $('dockContainer'),
		params: {wMode:'transparent',wmode:'transparent'}

		});
	
});



function js_function(sec){
	$('homeSWF').openSection(sec);
}

function closeSplash(){
	$('strato').destroy();
	$('splash').destroy();
}

function openSplash(){
	$('strato').setStyles({
				'opacity':'0.9',
				'display':'block'
	});
	$('splash').setStyle('display','block');
	new Swiff("YoYoPortacard.swf", {width: 660, height: 440,id:"splashSWF", params: { wmode: "transparent", wMode: "transparent"},container: $('splash_cont')});	
}


function getParameter(){
    var allParams = new Array();
    var url = unescape( String(this.location) );
    if(url.indexOf('select/') < 0)
        //return null;
		openSplash();
    var paramList = url.split("select/")[1];
    var params = paramList.split("/");
	var allParams = new Array();
	//allParams['category'] = params[0];
	allParams['section'] = params[0];
    return allParams;
}

function selectSection(){
	var parametri = getParameter();
	if(!parametri){	
		return;
	}else{
		var size = 0, key;
		for (key in parametri) {
			if (parametri.hasOwnProperty(key)) size++;
		}
		if(size == 1){
			js_function(parametri['section']);	
		} 
	}
}

function track(section){
	var pageTracker = _gat._getTracker('UA-21554312-1');
	pageTracker._trackPageview("/"+section);
	window.location.hash = "select/"+section;
}


window.onresize = function(){
	var H = document.getSize().y;
	var W = document.getSize().x;
	if(W<1240&&W>1000){
		$('elastic').setStyle('height',(W*0.524).toInt()+'px');
		$('dockContainer').setStyle('top',(W*0.524).toInt()-104+'px');
		$('dockContainer').setStyle('left',((W-392)/2).toInt()+'px');
	}else if(W>=1240){
		$('elastic').setStyle('height','650px');
		$('dockContainer').setStyle('left',((W-392)/2).toInt()+'px');
		$('dockContainer').setStyle('top','550px');
	}else if(W<=1000) {
		$('elastic').setStyle('height','524px');
		$('dockContainer').setStyle('top','424px');
		$('dockContainer').setStyle('left','304px');
	}
}

function openPopUP(file, nome_pagina, width, height, scrollbars) {
		var w = width;
		var h = height;
		var l = Math.floor((screen.width-w)/2);
		var t = Math.floor((screen.height-h)/2);
		var s = scrollbars;
		window.open(file, nome_pagina, "width=" + w + ",height=" + h + ",top=" + t + ",left=" + l + ",scrollbars=" + s + "");
	} 

