// JavaScript Document
  window.onresize=init;
  window.onload=init;
  var urlImg;


  var allHTMLTags = new Array();
  function init(){
    initPopUpMenu();
    height = document.body.scrollHeight;
    margin=(document.body.scrollWidth-900)/2;
    if(navigator.userAgent.indexOf('MSIE 6.0')!=-1 && navigator.userAgent.indexOf('MSIE 7.0')==-1){
      var allHTMLTags=document.getElementsByTagName('*');
      for (var i=0; i<allHTMLTags.length; i++) {
        if (allHTMLTags[i].className=='infor') {
          allHTMLTags[i].style.marginLeft='150px';
        }
      }
      margin=margin;
    }
    if(margin<=0){
      margin=0;
    }
    document.getElementById('cont').style.margin=('0px 0px 0px ' + margin+ 'px');
  }

//--------------Ajax----------------------------
function setXMLHttpRequest() {
    var XHR = null;
    browserUtente = navigator.userAgent.toUpperCase();
    if(typeof(XMLHttpRequest) === "function" || typeof(XMLHttpRequest) === "object") XHR = new XMLHttpRequest();
    else if(window.ActiveXObject && browserUtente.indexOf("MSIE 4") < 0 ) {
        if(browserUtente.indexOf("MSIE 5") < 0) XHR = new ActiveXObject("Msxml2.XMLHTTP");
        else XHR = new ActiveXObject("Microsoft.XMLHTTP");
    }
    return XHR;
}

//-------------Mantenimento della sessione di login-----------

var timeOutState;
function getState(){
  var ajax = setXMLHttpRequest();
  if(timeOutState) clearTimeout(timeOutState);
  if(ajax) {
    ajax.open("post", "./func/controlState.php", true);
    ajax.setRequestHeader("content-type", "application/x-www-form-urlencoded");
    ajax.send("stato="+keyState);
  }
  timeOutState=window.setTimeout(getState,120000);
}

function startAjax() {
    if(state=="Logged"){
        getState();
    }

}
//----------------PopUp page-------------------
function openPopUp(w,h,page){
  window.open(page, '', 'top=10, left=10, width='+w+', height='+h+', status=no, menubar=no, toolbar=no' )
}

function openPopUpMenu(ogg){
  if(document.getElementById(ogg).style.display=='block'){
    document.getElementById(ogg).style.display='none';
  }else{
    document.getElementById(ogg).style.display='block';
  }
}
function initPopUpMenu(){
  var str = "ASDFGHJKLMNBVCXZQWERTYUIOP1234567890";
  for(var i=0;i<str.length;i++){
    if(eval(document.getElementById('ssm'+str.substr(i,1))))document.getElementById('ssm'+str.substr(i,1)).style.display='none';
  }
  if(eval(document.getElementById(ssMenuOpen)))document.getElementById(ssMenuOpen).style.display='block';
}

function resetSearch(){  
  document.location.href="./index.php";
}