function addEvent(obj, evType, fn, useCapture){
  if (obj.addEventListener){
    obj.addEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Non è stato possibile impostare un gestore di eventi");
  }
}

addEvent(window,'load',init,false);

function init(){
	if(document.getElementById('col-left')){
		noFl();
	  }
	if(document.getElementById('c-right')){
		initOp();
		initCl();
		Hel();
		showBig();
	   }
if(document.getElementById('visit-nousa')){

		var btn = document.getElementById('visit-nousa');
		btn.onclick = function(){
		openDwl("download_en.php","LiquidSkin",750,563,"scrollbars=no");
		return false;
		}
	   }   
	if(document.getElementById('visit-usa')){
		var btn = document.getElementById('visit-usa');
		btn.onclick = function(){
		openDwl("download_us.html","LiquidSkin",750,563,"scrollbars=no");
		return false;
		}
	   }
	if(document.getElementById('visit-ita')){
		var btn = document.getElementById('visit-ita');
		btn.onclick = function(){
		openDwl("download_it.php","LiquidSkin",750,563,"scrollbars=no");
		return false;
		}
	   }
	if(document.getElementById('visit-itanogame')){
		var btn = document.getElementById('visit-itanogame');
		btn.onclick = function(){
		openDwl("download_it.html","LiquidSkin",750,563,"scrollbars=no");
		return false;
		}
	   }	   
	if(document.getElementById('pic-nousa')){
		var btn = document.getElementById('pic-nousa');
		btn.onclick = function(){
		openDwl("download_en.php","LiquidSkin",750,563,"scrollbars=no");
		return false;
		}
	   }   
	if(document.getElementById('pic-usa')){
		var btn = document.getElementById('pic-usa');
		btn.onclick = function(){
		openDwl("download_us.html","LiquidSkin",750,563,"scrollbars=no");
		return false;
		}
	   }
	 if(document.getElementById('pic-ita')){
		var btn = document.getElementById('pic-ita');
		btn.onclick = function(){
		openDwl("download_it.php","LiquidSkin",750,563,"scrollbars=no");
		return false;
		}
	   }
	 if(document.getElementById('pic-itanogame')){
		var btn = document.getElementById('pic-itanogame');
		btn.onclick = function(){
		openDwl("download_it.html","LiquidSkin",750,563,"scrollbars=no");
		return false;
		}
	   }   
	 if(document.getElementById('show-lang')){
		var btnLagn = document.getElementById('show-lang');
		btnLagn.onclick = function(){
		handleLang();
		return false;
		}
	   }
	   /*
	   if(document.getElementById('col-left')){
		 writeSwf();
		}
	    */
	}
	
function Hel(){	
var lev = $("c-1");
//Element.hide(lev);
}

var stato = 0;

function initOp(){
	var link1 = $('link1');
	var link2 = $('link2');
	var link3 = $('link3');
	
	link1.onclick = function(){
		if(stato==0){
		   showAll('c-1','btn-c-1');
		}
		else{
		   handle('c-1','btn-c-1');
		}
	 }
	
	link2.onclick = function(){
	    if(stato==0){
		   showAll('c-2','btn-c-2');
		}
		else{
		   handle('c-2','btn-c-2');
		}
	  }
	  
	link3.onclick = function(){
	    if(stato==0){
		   showAll('c-3','btn-c-3');
	 	}
		else{
		   handle('c-3','btn-c-3');
		}
	  }
}

function initCl(){
	var close1 = $('btn-c-1');
	var close2 = $('btn-c-2');
	var close3 = $('btn-c-3');
	
	close1.onclick = function(){
	  closeAll('c-1','btn-c-1')	
	  }
	
	close2.onclick = function(){
	  closeAll('c-2','btn-c-2')
	  }
	  
	close3.onclick = function(){
	  closeAll('c-3','btn-c-3')
	  }
}
	

function showAll(layer,btn){
	var elem = $(layer);
	var btn = $(btn)
	btn.style.display="block";
	new Effect.SlideDown(layer); 
	new Effect.SlideUp('spacer');
	new Effect.SlideUp('more');
	new Effect.SlideUp('logoHide');
	stato=1;
	currOpened = layer; 
	currButton = btn; 
	return false;
	}	

function closeAll(layer,btn){
	var elem = $(layer);
	var btn = $(btn)
	btn.style.display="none";
	new Effect.SlideUp(layer); 
	new Effect.SlideDown('spacer');
	new Effect.SlideDown('more');
	new Effect.SlideDown('logoHide');
	stato=0;
	currOpened = layer; 
	currButton = btn; 
	return false;
	}

function handle(el,button){
	if(el==currOpened){
		return false;
		}
	else{
		new Effect.SlideUp(currOpened);
		new Effect.SlideDown(el);
		//alert(currButton);
		var btn = $(button);
		var oldBtn = $(currButton);
		btn.style.display='block';
		oldBtn.style.display = 'none';
		
		currButton = button;
		//alert(currButton);
		currOpened = el;
		}	
	}	
	
function showBig(){
	var list = document.getElementById("mask-list");
	var listE = list.getElementsByTagName("li");
	for(var i=0;i<listE.length;i++){
		listE[i].onclick= function(){
			handleBig();
			return false;
			}
		}
	}
	
function handleBig(){
	
	}
var aperta=null;

function handleMask(mask,dir){
	//alert(mask);
	if(stato==1){
		closeAll(currOpened,currButton);
		}
	if(dir=='close'){
		new Effect.SlideUp(mask);
		aperta=null
		}
	else{
		if(aperta!=null){
		new Effect.SlideUp(aperta);
		}
		new Effect.SlideDown(mask); 
		aperta = mask;
		}
	}
	

var step = 1
var currRight = 0;
function handlePaging1(){
		
	var eleUL = document.getElementById('mask-list');
	var eleUlCh = eleUL.getElementsByTagName('li')
	
	currRight = currRight-15;
	//alert(currRight)
	if(currRight > -381){
		timerID = setTimeout('handlePaging1()',5);
		eleUL.style.left = currRight + "px";		
	}else{	
		    var btnPrev = document.getElementById('btn_prev');		
		    btnPrev.style.display="inline";
			currRight =0;
			var btnNext= document.getElementById('btn_next');		
			btnNext.style.display="none";
			var btnNext2= document.getElementById('btn_next2');		
			btnNext2.style.display="inline";
			var btnNext3= document.getElementById('btn_next3');		
			btnNext3.style.display="none";
			var btnPrev3= document.getElementById('btn_prev3');		
			btnPrev3.style.display="none";
			
		}
	 
}

var currRight2 = -381;
function handlePaging2(){
		
var eleUL = document.getElementById('mask-list');
	var eleUlCh = eleUL.getElementsByTagName('li')
	currRight2 = currRight2-15;
	
	if(currRight2 > -750){
		timerID = setTimeout('handlePaging2()',5);
		eleUL.style.left = currRight2 + "px";		
	}else{	
		var btnPrev = document.getElementById('btn_prev');		
		btnPrev.style.display="none";
		var btnNext= document.getElementById('btn_next');		
		btnNext.style.display="none";
		var btnNext2= document.getElementById('btn_next2');		
		btnNext2.style.display="none";
		var btnprev2 = document.getElementById('btn_prev2');		
		btnprev2.style.display="inline";
		var btnnext3 = document.getElementById('btn_next3');		
		btnnext3.style.display="inline";
		currRight2=-381
		
		}
	 
}

var currRight3 = -750;
function handlePaging3(){
		
var eleUL = document.getElementById('mask-list');
	var eleUlCh = eleUL.getElementsByTagName('li')
	currRight3 = currRight3-15;
	
	if(currRight3 > -1100){
		timerID = setTimeout('handlePaging3()',5);
		eleUL.style.left = currRight3 + "px";		
	}else{	
		var btnPrev = document.getElementById('btn_prev');		
		btnPrev.style.display="none";
		var btnNext= document.getElementById('btn_next');		
		btnNext.style.display="none";
		var btnNext2= document.getElementById('btn_next2');		
		btnNext2.style.display="none";
		var btnprev2 = document.getElementById('btn_prev2');		
		btnprev2.style.display="none";
		var btnnext3 = document.getElementById('btn_next3');		
		btnnext3.style.display="none";
		var btnprev3 = document.getElementById('btn_prev3');		
		btnprev3.style.display="inline";
		currRight3=-750
		
		}
	 
}


var currRightBack = -381
function handlePagingBack1(curRightBack){
	var eleUL = document.getElementById('mask-list');
	currRightBack = currRightBack+15;
	if(currRightBack < 0){
		timerID = setTimeout('handlePagingBack1()',5);
		eleUL.style.left = currRightBack + "px";
		}
	else{		
		var btnPrev = document.getElementById('btn_prev');		
		btnPrev.style.display="none";
		var btnNext2= document.getElementById('btn_next2');		
		btnNext2.style.display="none";
		var btnNext = document.getElementById('btn_next');		
		btnNext.style.display="inline";
		var btnNext3= document.getElementById('btn_next3');		
		btnNext3.style.display="none";
		var btnPrev3= document.getElementById('btn_prev3');		
		btnPrev3.style.display="none";
		currRightBack=-381
		}
		
	}

var currRightBack2 = -750 
function handlePagingBack2(){
	
	var eleUL = document.getElementById('mask-list');
		
	currRightBack2=currRightBack2+15;
		
	if(currRightBack2 < -370){		
		timerID = setTimeout('handlePagingBack2()',5);
		eleUL.style.left = currRightBack2 + "px";
		}
	else{		
		
		var btnPrev2 = document.getElementById('btn_prev2')
		btnPrev2.style.display="none";
		var btnPrev3 = document.getElementById('btn_prev3')
		btnPrev3.style.display="none";
		var btnPrev = document.getElementById('btn_prev')
		btnPrev.style.display="inline"
		var btnNext= document.getElementById('btn_next');		
		btnNext.style.display="none";
		var btnNext2= document.getElementById('btn_next2');		
		btnNext2.style.display="inline";
		var btnNext2= document.getElementById('btn_next3');		
		btnNext2.style.display="none";
		
		currRightBack2 = -750
		
		}
}	



var currRightBack3 = -1100 
function handlePagingBack3(){
	
	var eleUL = document.getElementById('mask-list');
		
	currRightBack3=currRightBack3+15;
		
	if(currRightBack3 < -750){		
		timerID = setTimeout('handlePagingBack3()',5);
		eleUL.style.left = currRightBack3 + "px";
		}
	else{		
		var btnPrev2 = document.getElementById('btn_prev2')
		btnPrev2.style.display="inline";
		var btnPrev = document.getElementById('btn_prev')
		btnPrev.style.display="none"
		var btnPrev3 = document.getElementById('btn_prev3')
		btnPrev3.style.display="none"
		var btnNext= document.getElementById('btn_next');		
		btnNext.style.display="none";
		var btnNext3= document.getElementById('btn_next3');		
		btnNext3.style.display="inline";
		currRightBack3 = -1100
		
		}
}

var currLang=0;	
function handleLang(){
	if(currLang==0){
	   new Effect.SlideDown('lang-link',{duration: .5});
	   currLang=1;	
	   return false;
	  }
	  else{
		  new Effect.SlideUp('lang-link',{duration: .4});
		  currLang=0;	
		  return false;
		  }
	}	
/*
var language='';
function writeSwf(){
var cont = document.getElementById("col-left");
var loc = location.search;
	if(location.search){
		if(loc=='?lang=IT'){
			language = "lang=IT";
		}
		else if(loc=='?lang=EN'){
			language = "lang=EN";
		}
	}
	else{
		language="lang=EN";
	}	
	
cont.innerHTML="<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='596' height='617'>"+
			   "<param name='movie' value='swf/maschera.swf' />"+
			   "<param name='quality' value='high' />"+
			   "<param name='FlashVars' value='"+ language +"' />"+
			   "<embed src='swf/maschera.swf' FlashVars='"+ language +"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='596' height='617'></embed>"
			   "</object>";
}
*/
function openDwl(url,nome,w,h,scrollbars){
	currWidth=screen.width;
	currHeight=screen.height;
	wleft=(currWidth/2)-381;
	wtop=(currHeight/2)-300;
	fin=window.open(url,nome,"width="+w+",height="+h+",left="+wleft+",top="+wtop+","+scrollbars);
	if(fin==null){
		alert("ATTENZIONE: L'apertura della finestra è stata bloccata \n Per visualizzarla consentire l'apertura di finestre popup")
		}
	}
	
function checkFlash(mvc){
var versione=false;
var flashinstalled = 0;
var flashversion = 0;
var isIE=false;
var flash7IE;
if (navigator.plugins && navigator.plugins.length)
{
	x = navigator.plugins["Shockwave Flash"];
	if (x)
	{
		flashinstalled = 2;
		y = x.description;
		flashversion = y.charAt(y.indexOf('.')-1);
	}
	else {
		flashinstalled = 1; //qui flash non è installato
		}
	if (navigator.plugins["Shockwave Flash 2.0"]) //solo per flash 2
		{
			flashinstalled = 2;
			flashversion = 2;
		}
	}
else if (navigator.mimeTypes && navigator.mimeTypes.length) //controllo il myme type per quei browser che nn hanno array di plugin
	{
		x = navigator.mimeTypes['application/x-shockwave-flash'];
		if (x && x.enabledPlugin)
			flashinstalled = 2;
		else
			flashinstalled = 1;
	}
else {
	//solo per IE
			try {
					isIE=true;//se entra qui e imposta a true è solo IE
					flash7IE = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.8");
					if (!flash7IE){
						versione=flash7IE;
						}
					else{
						versione=true;
						}
				}
			catch(e){
				versione=false;
				}
	}
// se non è IE....
if (!isIE) {
	flashNonIE=parseInt(flashversion);
	
		if (flashNonIE>7) {
			versione=true;
			}
			else {
				 versione=false/*flashNonIE*/;
				 }
	}
	//alert(flashversion)
	return versione;
}


function noFl(lang){
	
	if (document.getElementById('col-left')){
	
		var verFlash=checkFlash('col-left');
			if (verFlash==false && lang=="ita") {
				document.getElementById('col-left').innerHTML='<p id="no-flash">Attenzione per visualizzare il filmato &egrave; necessario installare la versione aggiornata di Adobe Flash Player, scaricabile gratuitamente dal sito  <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&Lang=Italian" target="_blank">Adobe</a></p>';
				}
			if (verFlash==false && lang=="eng") {
				document.getElementById('col-left').innerHTML='<p id="no-flash">An updated version of Adobe Flash Player is required, you can download it for free at <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&Lang=English" target="_blank">Adobe Web Site</a></p>';
				}	
		}
}		