// JavaScript Document

function getXMLHttp()
{
  var xmlHttp

  try
  {
    //Firefox, Opera 8.0+, Safari
    xmlHttp = new XMLHttpRequest();
  }
  catch(e)
  {
    //Internet Explorer
    try
    {
      xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
      try
      {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch(e)
      {
        alert("Your browser does not support AJAX!")
        return false;
      }
    }
  }
  return xmlHttp;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features,'scrollbars=yes','resizable=yes','top=0','left=0');
}


function check(input, num_min) {
	
	e = document.getElementById(input);
	s = document.getElementById('send');
	
	nom=document.getElementById('nome');
	ema=document.getElementById('email');
	pho=document.getElementById('phone');
	tex=document.getElementById('text');
	

if(input=='send'){
	if ( (nom.value=='') || (ema.value=='') || (pho.value=='') || (tex.value=='') ){
		check('nome');
		check('email');
		check('phone');
		check('text');
		return false;
	}
	else{
		return true;
	}
}
else{	
	if(e.value==''){
		e.style.border='1px solid red';
	}
	else{
		e.style.border='1px solid green';
	}
}
}


function lista(num)
{
var xmlHttp = getXMLHttp();
//document.write(num);
  xmlHttp.onreadystatechange = function()
  {
    if(xmlHttp.readyState == 4)
    {
      listn(xmlHttp.responseText, num);
    }
  }
  
  xmlHttp.open("GET", "funzioni/functions.php?a=lista&num="+num, true);
  xmlHttp.send(null);
}


function listn(response, num)
{	
	$(document).ready(function() {
		$("div#lista").hide();
		$("div#lista").fadeIn("normal");
		$("a#li1").removeClass('current');
		$("a#li2").removeClass('current');
		$("a#li3").removeClass('current');
		$("a#li4").removeClass('current');
		$("a#li"+num).addClass('current');
	});
	
var ntm = document.getElementById('lista');
	ntm.innerHTML = response;
}
