		/*
		* zoom immagine con click+shift
		*/

    function ZoomImg(tEvento,h,r,mioid) {
	var arrTasti = [];
        if (tEvento.shiftKey) {
            arrTasti.push("Shift");
        }
			if(arrTasti=="Shift"){
			// controllo
			if(r=="" || !r){
			alert("immagine non trovata, niente zoom.\nimage not found, no zoom.");
			return false;
			}
			//quindi usiamo fancybox
		$('<a href="'+r+'"></a>').fancybox({
		/*  'zoomSpeedIn':500, 
	   'zoomSpeedOut': 600, */
		'overlayShow': false,
		'padding':'4px',
		'hideOnOverlayClick':true,
		'hideOnContentClick':true
		}).click(); // funzionera' con altri broizer che non webkit&moz?
			
			/*inutilezze*/
			try {
			console.warn("hai lo shift premuto, zoommo l'immagine:"+r+" (il tuo rel)");} catch(e){
			//alert("Non hai firebug attivo, attivalo!\n"+e)
			}
			//alert("shift premuto, zoommo l'immagine:"+r);
			return false;
			} else {
			
			/*
			* Lo shift NON c'e'.
			* quindi entriamo nella pagina dell'artiqolo
			*/
			window.location=h; // <---ecco! :P
				/*inutilezze*/
				try {
			console.info("Non hai lo shift premuto - apro NORMALMENTE la pagina a: "+h);
			} catch(e){
			//alert("Non hai firebug attivo, attivalo!\n"+e)
			}
			
			}
    }



function contototalifirst(){
var bl = (jQuery("#slidercount").val()*1);
var sl = (jQuery("#plc").val()*1);
var tot = ((bl + sl)-10);
jQuery("#totali").html(tot);
}

function contototali(){
var bl = (jQuery("#slidercount").val()*1);
var sl = (jQuery("#plc").val()*1);
var tot =((bl + sl)-10);
jQuery("#totali").html(tot);
}

function fullSizeStream() {
if(jQuery("#masthead").css('overflow')=='hidden') {
jQuery("#controlla_stream").removeClass("controlla_stream").addClass("controlla_stream_M");
jQuery('#immagine_fronte').fadeOut('slow');
jQuery('#masthead').css('overflow','visible');
jQuery("#controlla_stream").html("<b>collapse image</b>");
jQuery('#noise_fronte').fadeOut('fast');
// monsters fadeOut
jQuery('#mostro1,#mostro2,#mostro3,#mostro4').hide();
}
else if(jQuery("#masthead").css('overflow')=='visible') {
jQuery("#controlla_stream").removeClass("controlla_stream_M").addClass("controlla_stream");
jQuery('#masthead').css('overflow','hidden');
jQuery('#immagine_fronte').fadeIn('slow');	
jQuery("#controlla_stream").html("<b>enlarge image</b>")
if((jQuery('#plc').val()*1)>8){
jQuery('#noise_fronte').fadeIn('fast');
// monsters fadein
}
	jQuery('#mostro1,#mostro2,#mostro3,#mostro4').show();
	}
}


var xn=0;
jQuery.doTimeout( 'charsMoves', 20000, function(){
	if(xn>3){xn=0;}
	if(xn==0){
	var cf = randoma_val('animazione_mostro1(),animazione_mostro2(),animazione_mostro3(),animazione_mostro4()');
	eval(cf);
	}
	
	if(xn==1) {
	var cf = randoma_val('animazione_mostro1(),animazione_mostro2(),animazione_mostro3(),animazione_mostro4()');
	eval(cf);
	}
	
	if(xn==2){
	var cf = randoma_val('animazione_mostro1(),animazione_mostro2(),animazione_mostro3(),animazione_mostro4()');
	eval(cf);
	}
  
  if(xn==3){
	var cf = randoma_val('animazione_mostro1(),animazione_mostro2(),animazione_mostro3(),animazione_mostro4()');
	eval(cf);
	}
	xn++;
  
  return true;
});

/*'animazioni' villains*/

/*mostro uno: umanograssottellotreqquarti sulla sinistra*/
function animazione_mostro1()
{
jQuery('#mostro1').animate(
			{backgroundPosition:"(0 0)"}, 
			{duration:100}).animate(
			{backgroundPosition:"(0 0)"}, 
			{duration:2000}).animate(
			{backgroundPosition:"(-143 0)"}, 
			{duration:200})
}

/*mostro due: robot dall'alto*/
function animazione_mostro2()
{
jQuery('#mostro2').animate(
			{backgroundPosition:"(240 50)"}, 
			{duration:1500}).animate(
			{backgroundPosition:"(240 -60)"}, {duration:100})
}

/*mostro tre: William S. Burroughs (con lo schioppo) sulla destra*/
function animazione_mostro3()
{
jQuery('#mostro3').animate(
			{backgroundPosition:"(540 40)"}, 
			{duration:500}).animate(
			{backgroundPosition:"(540 40)"},
			{duration:5000}).animate(
				{backgroundPosition:"(740 40)"},
				{duration:300})
}

/*mostro quattro: algaMan sulla destra*/
function animazione_mostro4()
{
jQuery('#mostro4').animate(
			{backgroundPosition:"(640 60)"}, 
			{duration:500}).animate(
			{backgroundPosition:"(640 60)"}, 
			{duration:2000}).animate(
			{backgroundPosition:"(740 60)"},
			{duration:200})
}

/*
restituisce un valore random da una lista (comma separated)
evita risultati ripetuti via cookies 
dipende da: arr_rval() 
*/
function randoma_val(csl)
{
// leggo dal cookie il valore da escludere
var vte =  $.cookie('ex');
try {console.log('valore nel cookie ex:'+vte);}catch(er){}
a=csl.split(',');
arr_rval(a,vte)
var r = a[Math.floor(Math.random()*a.length)];
// aggiorna il cookie
$.cookie('ex', r);
// ritorna il valore
return r;
			}
			
/*
rimuove un valore da un array, ci serve in congiunzione con randoma_val()
per fare in modo che non avvenga per due volte di fila la stessa 'animazione'
*/
function arr_rval(arrayName,arrayElement)
 {
    for(var i=0; i<arrayName.length;i++ )
     { 
        if(arrayName[i]==arrayElement)
            arrayName.splice(i,1); 
      } 
  }
 
/*ritorna true se pari, false se dispari*/ 
  function oddeven(numba)
{
	if (numba%2 == 0){
		return true;
		}
	else{
		return false;
		}
}
/*bookflood stuff*/
function reload(){
  tmp = findSWF("chart");
  x = tmp.reload();
}
function findSWF(movieName) {
  if (navigator.appName.indexOf("Microsoft")!= -1) {
    return window["ie_" + movieName];
  } else {
    return document[movieName];
  }
}