function Modulo() { //funzione richiamata sul submit di login.php
}
var resizeTimeout;
function Resize() {
  window.clearTimeout(resizeTimeout);
  resizeTimeout = window.setTimeout('ResizeCode();',5000);
}
function ResizeCode() {
/*
  alert("sw="+screen.width+",sh="+screen.height+
        ",iw="+window.innerWidth+",ih="+window.innerHeight+
        ",cw="+document.documentElement.clientWidth+",ch="+document.documentElement.clientHeight+
        ",bw="+document.body.clientWidth+",bh"+document.body.clientHeight+
        ",ow="+document.body.offsetWidth+",oh"+document.body.offsetHeight);
*/
  var myWidth = screen.width, myHeight = screen.height;
/*
  var cookie = leggiCookie('cnc_zoom');
  if(cookie != "") cur_zoom = cookie;
*/
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  var Zoom = myWidth/947;
  var yZoom = myHeight/600;
  if(yZoom < Zoom) Zoom = yZoom;
  document.cookie = "cnc_zoom="+Zoom;
//  alert("w="+myWidth+",h="+myHeight+",cookie="+cookie+", zoom="+Zoom);
  document.body.style.zoom = Zoom;
}
function init() {
  ResizeCode();
//  window.onresize=function(e){Resize();};
/*
  preload('cineteca_on.png,cnc_on.png,contatti_on.png,eventi_on.png,festival_on.png,schede_corti_on.png,cineteca_off.png,cnc_off.png,contatti_off.png,eventi_off.png,festival_off.png,schede_corti_off.png','img/menu/');
  if (!document.getElementById) return
  var imgOriginSrc;
  var imgTemp = new Array();
  var imgarr = document.getElementsByTagName('img');
  for (var i = 0; i < imgarr.length; i++) {
    if (imgarr[i].getAttribute('hsrc')) {
      imgTemp[i] = new Image();
      imgTemp[i].src = imgarr[i].getAttribute('hsrc');
      imgarr[i].onmouseover = function() {
      imgOriginSrc = this.getAttribute('src');
      this.setAttribute('src',this.getAttribute('hsrc'))
      }
      imgarr[i].onmouseout = function() {
      this.setAttribute('src',imgOriginSrc)
      }
    }
    }
*/    
}
function leggiCookie(nomeCookie)
{
  if (document.cookie.length > 0)
  {
    var inizio = document.cookie.indexOf(nomeCookie + "=");
    if (inizio != -1)
    {
      inizio = inizio + nomeCookie.length + 1;
      var fine = document.cookie.indexOf(";",inizio);
      if (fine == -1) fine = document.cookie.length;
      return unescape(document.cookie.substring(inizio,fine));
    }else{
       return "";
    }
  }
  return "";
}
/*
function preload(images,dir) {
    if (document.images) {
        var i = 0;
        var imageArray = new Array();
        imageArray = images.split(',');
        var imageObj = new Image();
        for(i=0; i<=imageArray.length-1; i++) {
           //document.write('<img src="' + dir + imageArray[i] + '" />');// Write to page (uncomment to check images)
            imageObj.src=dir+images[i];
        }
    }
}
*/
function Login() {
        var x,y,wx,wy,wc;
        var de = document.documentElement;
        var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
        var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
        wx=500;
        wy=600;
        x = (screen.width - wx) / 2 ;
        y = (screen.height - wy) / 2 ;
        var LoginURL="post/login.php";
        var LoginPos="absolute";
        LoginFrame = document.createElement("IFRAME");
      	//LoginFrame.setAttribute("src", LoginURL);
    	  LoginFrame.setAttribute("frameBorder", 0);
        LoginFrame.setAttribute("width", "300px");
    	  LoginFrame.setAttribute("height", "250px");
     	  LoginFrame.setAttribute("scrolling", "no");
        LoginFrame.setAttribute("bgcolor", "ffffff");
    	  //LoginFrame.setAttribute("allowTransparency", true);     //era: LoginFrame.allowTransparency = "true";
        document.body.appendChild(LoginFrame);
        LoginFrame.style.position=LoginPos;                //queste 3 righe funzionano in IE7 e non in FF  //VW-EG  080218
        LoginFrame.style.top=y; //VW-EG 080709
        LoginFrame.style.left=x; //VW-EG 080709
        LoginFrame.setAttribute("style", "position:"+LoginPos+";  top: "+y+"px; left: "+x+"px;"); //questo funziona in FF e non in ie //VW-EG 080218
        LoginFrame.style.visibility="visible";
        LoginFrame.src=LoginURL;
}

function PopUp( url,width, height) { 
//alert("url="+url+"  width="+width+"  height="+height);
var ah = screen.availHeight - 30; 
var aw = screen.availWidth - 10; 
var xc = ( aw - width ) / 2; 
var yc = ( ah - height ) / 2; 
    var Sond;
    Sond = document.createElement("IFRAME");
	  Sond.setAttribute("frameBorder", 0);
    Sond.setAttribute("width", width);
	  Sond.setAttribute("height", height);
	  Sond.setAttribute("scrolling", "no");
	  Sond.setAttribute("allowTransparency", true);     //era: VwpFrame.allowTransparency = "true";
    Sond.style.position="absolute";                 //queste 3 righe funzionano in IE7 e non in FF  //VW-EG  080218
    Sond.style.top=yc;
    Sond.style.left=xc;
    Sond.setAttribute("style", "position:absolute; top: "+yc+"px; left: "+xc+"px;"); //questo funziona in FF e non in ie //VW-EG 080218
    Sond.src=url;
	  Sond.style.visibility="visible";
    document.body.appendChild(Sond);   
} 

function pg(page){
  document.search.page.value=page;
  document.search.submit();
}

function checkEnter(e){ //e is event object passed from function invocation
  var characterCode //literal character code will be stored in this variable
  if(e && e.which){ //if which property of event object is supported (NN4)
    e = e
    characterCode = e.which //character code is contained in NN4's which property
  } else {
    e = event
    characterCode = e.keyCode //character code is contained in IE's keyCode property
  }
  if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
    document.search.submit() //submit the form
    return false 
  } else {
    return true 
  }
}

function hPicScroll(mode) { //mode: -1 = scroll right, 0 = no scroll, 1 = scroll left
  window.hpicscroll.startScrolling(mode);
}

var vScrollDiv, vScrollStep, vScrollSize, vScrollInterval=200, vScrollTimer=false, vscrollArrow;

function vScrollOnce() {
  var newtop = vScrollDiv.offsetTop + vScrollStep;
  var mintop = vScrollSize - vScrollDiv.offsetHeight;
  if (newtop <= 0 && newtop >= mintop) {
    vScrollDiv.style.top = newtop;
    if(!vScrollTimer) vScrollTimer = setInterval(vScrollOnce, vScrollInterval);
  } else clearInterval(vScrollTimer);
  vScrollCheck(vScrollDiv.id, vScrollArrow);
}

function vScroll(div, step, arrow) {
  vScrollDiv = document.getElementById(div);
  vScrollStep = step;
  vScrollSize = document.getElementById(div+"_scroll").offsetHeight;
  vScrollArrow = arrow;
  vScrollOnce();
}

function vScrollStop() {
  clearInterval(vScrollTimer);
  vScrollTimer = false;
}

function vScrollCheck(div, arrow) {
var divsize, scrollsize, top;
  divsize = document.getElementById(div).offsetHeight;
//  alert(divsize);
  scrollsize = document.getElementById(div+"_scroll").offsetHeight;
 // alert(scrollsize);
  top = document.getElementById(div).offsetTop;
  document.getElementById(arrow+"_top").style.visibility = (top == 0)?"hidden":"visible";
  document.getElementById(arrow+"_bottom").style.visibility = (top+divsize <= scrollsize)?"hidden":"visible";
}

var hScrollDiv, hScrollStep, hScrollSize, hScrollInterval=200, hScrollTimer=false, hScrollArrow;

function hScrollOnce() {
  var newleft = hScrollDiv.offsetLeft + hScrollStep;
  var minleft = hScrollSize - hScrollDiv.offsetWidth;
  if (newleft <= 0 && newleft >= minleft) {
    hScrollDiv.style.left = newleft;
    if(!hScrollTimer) hScrollTimer = setInterval(hScrollOnce, hScrollInterval);
  } else clearInterval(hScrollTimer);
  hScrollCheck(hScrollDiv.id, hScrollArrow);
}

function hScroll(div, step, arrow) {
  hScrollArrow = arrow;
  hScrollDiv = document.getElementById(div);
  hScrollStep = step;
  hScrollSize = document.getElementById(div+"_scroll").offsetWidth;
  hScrollOnce();
}

function hScrollStop() {
  clearInterval(hScrollTimer);
  hScrollTimer = false;
}

function hScrollCheck(div, arrow) {
var divsize, scrollsize, left;
  divsize = document.getElementById(div).offsetWidth;
  scrollsize = document.getElementById(div+"_scroll").offsetWidth;
  left = document.getElementById(div).offsetLeft;
  document.getElementById(arrow+"_sx").style.visibility = (left == 0)?"hidden":"visible";
  document.getElementById(arrow+"_dx").style.visibility = (left+divsize <= scrollsize)?"hidden":"visible";
}

function p(n) {
  document.link_people.id_people.value = n;
  document.link_people.submit();
}
function m(n) {
  document.link_movie.movie.value = n;
  document.link_movie.submit();
}

function n(n) {
  document.link_news.n.value = n;
  document.link_news.submit();
}

function Play(n) {
  document.link_play.movie.value = n;
  document.link_play.action="player.php?id="+n
  document.link_play.submit();
} 

/*  inizio funzione di Httrequest */
function createRequestObject() {
	var ro;
	var browser = navigator.appName;
	if(window.ActiveXObject){
		ro = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		ro = new XMLHttpRequest();
	}
	return ro;
}

var http = createRequestObject();
var monitor;
function sndReq(array) {
  /* adesso prendo costruisco i parametri dall'array*/
  var elenco="";
  for (var d in array) {   
  elenco += d+"="+array[d]+"&";  
}  
  
  http.open('get', 'api.php?'+elenco +'time='+ new Date().getTime());
  http.onreadystatechange =handleResponse;
	http.send(null);
  if(elenco.indexOf("InfoRoom")=="-1"){
  monitor=setInterval("Attesa()",300);
  }
}

function Attesa(){
  if(http.readyState!="4"){
    document.getElementById("attesa").style.visibility="visible";
  }else{
    document.getElementById("attesa").style.visibility="hidden";
    clearInterval("monitor");
  }
}

function handleResponse(div) {
	if(http.readyState == 4){
		var response = http.responseText;
		var update = new Array();
    if(response.indexOf('|' != -1)) {
			update = response.split('|');
      if(update[1]=="refresh"){
		    var CP = document.location.href.split("?")[0].split("#")[0];
        document.location.href=CP;
      }else if(update[0]=="alert"){
        alert(update[1]);
        location.href="../";
      }else{
       document.getElementById(update[0]).innerHTML = update[1];
			}
		}
	}
}
/*  fine funzione di Httrequest */

