image1 = new Image();
image1.src = "imm/icon_error.gif";

image2 = new Image();
image2.src = "images/sfondobrowse3.jpg";





function init() {
	preload("images/play_dwn.gif, images/play_up.gif, images/pause_dwn.gif, images/pause_up.gif");
	}
	
	


function indirizzoEmailValido(indirizzo) {
  if (window.RegExp) {
    var nonvalido = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
    var valido = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
    var regnv = new RegExp(nonvalido);
    var regv = new RegExp(valido);
    if (!regnv.test(indirizzo) && regv.test(indirizzo))
      return true;
    return false;
	}
  else {
    if(indirizzo.indexOf("@") >= 0)
      return true;
    return false;
  	}
  };






var errore;
errore = "<img src='imm/icon_error.gif'>" ;

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// Funzioni Javascript per il flvplayer
// some variables to save
	var currentPosition;
	var currentVolume;
	var currentItem;

	// these functions are caught by the JavascriptView object of the player.
	function sendEvent(typ,prm) { thisMovie("mpl").sendEvent(typ,prm); };
	function getUpdate(typ,pr1,pr2,pid) {
		if(typ == "time") { currentPosition = pr1; }
		else if(typ == "volume") { currentVolume = pr1; }
		else if(typ == "item") { currentItem = pr1; setTimeout("getItemData(currentItem)",100); }
		else if(typ == "state") { currentState = pr1;
		if(currentState==3) { playtoggle();  }
		else if(currentState==0) {
			
			document.getElementById("buttonimg").src=imgDat[1].src;
			flag = false;
			
			}
		}	
		
		
		
		var id = document.getElementById(typ);
		id.innerHTML = typ+ ": "+Math.round(pr1);
		pr2 == undefined ? null: id.innerHTML += ", "+Math.round(pr2);
		if(pid != "null") {
			document.getElementById("pid").innerHTML = "(received from the player with id <i>"+pid+"</i>)";
		}
	};

	// These functions are caught by the feeder object of the player.
	function loadFile(obj) { thisMovie("mpl").loadFile(obj); };
	function addItem(obj,idx) { thisMovie("mpl").addItem(obj,idx); }
	function removeItem(idx) { thisMovie("mpl").removeItem(idx); }
	function getItemData(idx) {
		var obj = thisMovie("mpl").itemData(idx);
		var nodes = "";
		//for(var i in obj) { 
			//nodes += "<li>"+i+": "+obj[i]+"</li>"; 
		//}
		//document.getElementById("data").innerHTML = nodes;
	};

	// This is a javascript handler for the player and is always needed.
	function thisMovie(movieName) {
	    if(navigator.appName.indexOf("Microsoft") != -1) {
			return window[movieName];
		} else {
			return document[movieName];
		}
	};


var flag=false;
var stat=0;
var imgURL;
var imgDat;

function preload(imgStr) {
	imgURL = new Array();
	 imgURL = imgStr.split(',');

	imgDat = new Array();
	for(i=0; i<imgURL.length; i++) { 
		imgDat[i] = new Image();
		imgDat[i].src = imgURL[i];
	}
}



	
function playtoggle() {
	flag=(! flag);
	if (flag) { stat=2;} else {stat=0; }
 	document.getElementById("buttonimg").src=imgDat[stat].src;
}

function stoptoggle() {
	stat= 0;
	sendEvent('stop');	
}


//funzione abbreviativa per la lunghezza della stringa
function Len(StrToLen)
{
return StrToLen.length;
}



////////////// SCRIPT PER IL PAGINATORE



function createRequestObject() {
  
  var ro;

 try {
 ro = new XMLHttpRequest();
 } catch(e){
 try {
 ro = new ActiveXObject("Msxm12.XMLHTTP");
 } catch(e) {
 ro = new ActiveXObject("Microsoft.XMLHTTP");
 }
 } 
  return ro;
}
var http = createRequestObject();

//funzione per l'onclick del paginatore
function sbPaginatore2(pagina, categoria, sezione) {
 // http.open('get', 'elencovideo.php?pagina=' + pagina + '&categoria=' + categoria + '&sid=' + Math.random());
 http.open('get', 'elencovideo.php?pagina=' + pagina + '&categoria=' + categoria + '&sezione=' + sezione + '&sid=' + Math.random());
    http.onreadystatechange = handleResponse;
  http.send(null);
}


function handleResponse() {
  if(http.readyState == 4) {
    var response = http.responseText;
    document.getElementById('elencovideo').innerHTML = response;
  }
}


///////////////// FINE SCRIPT PER IL PAGINATORE




function sbEntra()
  {
  if(FrmForm.frmusername.value == "")
    {
    alert("ATTENZIONE!!! INSERIRE IL NOME DELL'OPERATORE");
    }else{
    FrmForm.action="accesso.php";
    FrmForm.submit();
    }	
  }

function Accesso()
  {
 document.location.href = "login.php";
  }


function sblogout(){

	
	document.location.href = "logout.php";
	
}  
  
 
 function sbnuova(){
 
	
	document.location.href = "modificanews.php?nuova=Si";

} 

function sbleggi(news)
{

document.location.href = "news/leggiarticolo.php?news=" + news; 	
	
}


function cambiacolore(who)
  {
  who.style.backgroundColor="#BDDBEF"
  }
function coloreoriginale(who)
  {
  who.style.backgroundColor="#F0F6FB"
  } 


 function sbtorna(){

document.form.conferma.value = 'No';
	document.form.action = "form.php";
	document.form.target = "_self";
	document.form.submit();
} 
function sbconferma(){

	document.form.conferma.value = 'Si';
	document.form.action = "form.php";
	document.form.target = "_self";
	document.form.submit();
}  


function sbmostratitolo(sezione, titolo_video, descrizione_video) {
	
	if (sezione) {
		
		if (Len(descrizione_video) < '1') { duepunti = ""; }else{ duepunti= ":" ;}
	
    document.getElementById("playerctrl").innerHTML = "<font color='red'>" + sezione + "&nbsp;-&nbsp;</font>" + titolo_video + duepunti + " " + descrizione_video;
	
	}
}




function createRequestObject2() {
  
  var ro2;

 try {
 ro2 = new XMLHttpRequest();
 } catch(e){
 try {
 ro2 = new ActiveXObject("Msxm12.XMLHTTP");
 } catch(e) {
 ro2 = new ActiveXObject("Microsoft.XMLHTTP");
 }
 } 
  return ro2;
}
var http2 = createRequestObject2();

//funzione per l'onclick del paginatore
function VisitaVideo(video) {
 // http.open('get', 'elencovideo.php?pagina=' + pagina + '&categoria=' + categoria + '&sid=' + Math.random());
 http.open('get', 'visitavideo.php?video=' + video + '&sid=' + Math.random());
    http.onreadystatechange = handleResponse2;
	//alert("visita video "+ video);
  http.send(null);
}


function handleResponse2() {
  if(http2.readyState == 4) {
    var response = http2.responseText;
    document.getElementById('visitavideo').innerHTML = response;
  }
}

function createPlayer(theFile) {
	var s1 = new SWFObject("flvplayer/flvplayer.swf","mpl","576","452","9.0.115");
	s1.addParam("allowfullscreen","true");
	s1.addVariable("file", theFile);
	s1.addVariable("autostart", "true");
	s1.addVariable("displayheight","432");
	s1.addVariable("enablejs","true");
	s1.addVariable("smoothing","true");
	s1.addVariable("javascriptid","mpl");
	s1.addVariable("backcolor","0xEFEEEA");
	s1.addVariable("screencolor","0x000000");
	s1.addVariable("overstretch","true");
	s1.addVariable("repeat","true");
	s1.addVariable("shuffle","false");
  s1.addParam("wmode", "transparent"); 
	//s1.addVariable("overstretch","fit");
	//s1.addVariable("overstretch ","true");
	s1.write("Player");
}

function Show(id) {

var k = document.getElementById(id).style;
k.zIndex = 300;
}
function Hide(id) {

var k = document.getElementById(id).style;
k.zIndex = -1;
}

