// JavaScript Document
function caricaSezioneWeb (url,id) {
//alert(url+"-"+id);
	var XmlHttp = zXmlHttp.createRequest();
	XmlHttp.open("get",url+"sid="+Math.random(),true);
	XmlHttp.onreadystatechange = function() {
		if(XmlHttp.readyState == 4) {
			if(XmlHttp.status == 200) {
			var area = document.getElementById(id);
			//alert(XmlHttp.responseText);
			if(id=="occupazionePrecedente") {
				area.innerHTML += XmlHttp.responseText;
			} else {
					area.innerHTML = XmlHttp.responseText;
				}

			} else {
			alert(XmlHttp.responseText);
			}
		}
	}
	XmlHttp.send(null);
}

function getValore(oForm) {
	var a_parametri = new Array();
	for(var i=0; i<oForm.elements.length;i++) {
		if(oForm.elements[i].type=="checkbox"){
			if(oForm.elements[i].checked){
				var parametro = encodeURIComponent(oForm.elements[i].name);
				parametro += "=";
				parametro += encodeURIComponent(oForm.elements[i].value);
				a_parametri.push(parametro);
			}
		} else {
			var parametro = encodeURIComponent(oForm.elements[i].name);
			parametro += "=";
			parametro += encodeURIComponent(oForm.elements[i].value);
			a_parametri.push(parametro);
		}

	}
	return a_parametri.join("&");
}
function ricerca(idForm,id) {
var oForm = document.forms[idForm];
	var sBody = getValore(oForm);
	var XmlHttp = zXmlHttp.createRequest();
	XmlHttp.open("post",oForm.action,true);
	XmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	XmlHttp.onreadystatechange = function() {
	if(XmlHttp.readyState == 4) {
		if(XmlHttp.status == 200) {
			//alert(XmlHttp.responseText);
			var area = document.getElementById(id);
			area.innerHTML = XmlHttp.responseText;
			} else {
				alert(XmlHttp.responseText);
				}
			}
		}
	XmlHttp.send(sBody);
}

function sl(){
	setTimeout("hiden()", 6000);
	//alert("v");
	$("#box2").fadeIn("slow");
}
function hiden() {
	$("#vetrina").load("/home/vetrina.php");
	$("#bannertop").load("/banner/top.php");
	$("#box2").load("/home/contenutiBoxTopSpeciale.php");
	$("#box2").hide("slow"); 
	setTimeout("sl()", 1000);
	//alert("n");
}

      var headline_count;
      var headline_interval;
      var current_headline = 0;
      var old_headline = 0;


 
 function headline_rotate() {
   current_headline = (old_headline + 1) % headline_count; 
   $("div.headline:eq(" + old_headline + ")").animate({top: 40},"slow", function() {
     $(this).css('top','20px');
   });
   $("div.headline:eq(" + current_headline + ")").show().animate({top: 0},"slow");  
   old_headline = current_headline;
 }
 
 
 function sivamtime() {
  now=new Date();
  hour=now.getHours();
  min=now.getMinutes();
  sec=now.getSeconds();

if (min<=9) { min="0"+min; }
if (sec<=9) { sec="0"+sec; }
if (hour>12) { hour=hour-12; add="pm"; }
else { hour=hour; add="am"; }
if (hour==12) { add="pm"; }

document.timeForm.field.value = ((hour<=9) ? "0"+hour : hour) + ":" + min + ":" + sec + " " + add;

setTimeout("sivamtime()", 1000);
}
window.onload = sivamtime;


function autoDate () {
	var tDay = new Date();
	var tMonth = tDay.getMonth()+1;
	var tDate = tDay.getDate();
	if ( tMonth < 10) tMonth = "0"+tMonth;
	if ( tDate < 10) tDate = "0"+tDate;
	document.getElementById("tDate").value = tDate+"/"+tMonth+"/"+tDay.getFullYear();
 	}

	// Multiple onload function created by: Simon Willison
	// http://simonwillison.net/2004/May/26/addLoadEvent/
	function addLoadEvent(func) {
  	var oldonload = window.onload;
  	if (typeof window.onload != 'function') {
    window.onload = func;
  	} else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    	}
  	}
	}

	addLoadEvent(function() {
  	autoDate();
	});

