
function PopUpWindow(theURL) {
	var nAvailWidth = screen.availWidth;
	var nAvailHeight = screen.availHeight;
	window.open(theURL, '_blank','top=0,left=0,width=' + nAvailWidth + ',height=' + nAvailHeight + ',location=no,menubar=no,status=no,scrollbars=yes,fullScreen=no,resizable=yes,titlebar=no,toolbar=no');
}


function getExtra(psExtraID) {
    
    // ============================================================
    // Questa funzione restituisce il contenuto della sezione extra
    // ============================================================

	var objMenu;
	var sHtml = "";

	while (true) {

		// Deve esistere il div Extra
		if (document.getElementById("extra") == null) break;
        
        // Sezione Extra nella Home		
		if (psExtraID == "home") {
            
            sHtml = "";
            
            // Carne di Genova
            sHtml = sHtml + '<div class="newsbox">';
            sHtml = sHtml + '<h2>Carne di Genova</h2>';
            sHtml = sHtml + "Non solo Bancolat!"
            sHtml = sHtml + "<br />L'iniziativa degli allevatori ";
            sHtml = sHtml + "di Genova si estende con la vendita diretta di carne. ";
            sHtml = sHtml + "Ora č possibile ordinare la carne chiamando direttamente il produttore.";
            sHtml = sHtml + '<br /><a class="linknormal" href="http://www.lacarnedigenova.com" target="_blank">www.lacarnedigenova.com</a>';
            sHtml = sHtml + '</div>';

            // Formaggio fai da te
            sHtml = sHtml + '<div class="newsbox">';
            sHtml = sHtml + '<h2>Formaggio fai da te</h2>';
            sHtml = sHtml + "Istruzioni per l'uso per produrre i casa un buon formaggio";
            sHtml = sHtml + "<br />Per i dettagli visita la sezione ";
            sHtml = sHtml + '<a class="linknormal" href="documenti.asp">documenti</a> ';
            sHtml = sHtml + "di questo sito ";
            sHtml = sHtml + '</div>';

            // Hobby Cheese
            sHtml = sHtml + '<div class="newsbox">';
            sHtml = sHtml + '<h2>Hobby Cheese</h2>';
            sHtml = sHtml + "Presso alcuni distributori di latte sono disponibili kit per farsi il formaggio ";
            sHtml = sHtml + "in casa a partire dal latte crudo per maggiori informazioni visita la sezione ";
            sHtml = sHtml + '<a class="linknormal" href="documenti.htm">documenti</a> ';
            sHtml = sHtml + "di questo sito ";
            sHtml = sHtml + '</div>';

            // Biolą
            sHtml = sHtml + '<div class="newsbox">';
            sHtml = sHtml + '<h2>Biolą</h2>';
            sHtml = sHtml + "Latte crudo latte vero";
            sHtml = sHtml + '<br /><a class="linknormal" href="http://www.biola.it" target="_blank">www.biola.it</a>';            
            sHtml = sHtml + '</div>';

            // Alessandri Donatella
            sHtml = sHtml + '<div class="newsbox">';
            sHtml = sHtml + '<h2>Latte Vero</h2>';
            sHtml = sHtml + "Azienda Agricola Alessandri Donatella"
            sHtml = sHtml + "<br />La Meia di Sopra, 17"
            sHtml = sHtml + "<br />19020 S. San Pietro Vara (SP)"
            sHtml = sHtml + '<br /><a class="linknormal" href="http://www.lattevero.com" target="_blank">www.lattevero.com</a>';
            sHtml = sHtml + '</div>';

		}

				
		if (psExtraID == "xyz") {
			sHtml = "";
		}
		
		objExtra = document.getElementById("extra");
		objExtra.innerHTML = sHtml;
		GetBoxNews();
		
		break;
	}

	objExtra = null;
	if (sHtml == "") alert("Non posso caricare extra");
}

function getFooter(psFooterID) {

    // =============================================================
    // Questa funzione restituisce il contenuto della sezione Footer
    // =============================================================

	var objMenu;
	var sHtml = "";

	while (true) {

		// Deve esistere il div Navigation
		if (document.getElementById("navigation") == null) break;
		
		if (psFooterID == "home") {
		    sHtml = "";
    	    sHtml = sHtml + '<b>© 1997-2009 - ASSOCIAZIONE PROVINCIALE ALLEVATORI GENOVA</b><br>';
    	    sHtml = sHtml + 'GIURIDICAMENTE RICONOSCIUTA CON D.G.R. LIGURIA 5761 DEL 20-10-1983<br>';
    	    sHtml = sHtml + 'Salita S. Leonardo 18/2 - 16128 GENOVA Tel. 010.8606637 Fax 010 8606713<br><br>';	    	
		    sHtml = sHtml + 'Ultimo aggiornamento: 27/09/2009';
		}
		
		if (psFooterID == "xyz") {
			sHtml = "";
		}
		
		objFooter = document.getElementById("footer");
		objFooter.innerHTML = sHtml;
		break;
	}

	objMenu = null;
	if (sHtml == "") alert("Non posso caricare il menu");
}



function getNavigation(psMenuID) {

    // =============================================================
    // Questa funzione restituisce il contenuto della sezione Footer
    // =============================================================

	var objMenu;
	var sHtml = "";
	var sHeight = "";

	while (true) {

		// Deve esistere il div Navigation
		if (document.getElementById("navigation") == null) break;
				
		if (psMenuID == "home") {		
		    sHtml = "";
		    sHtml = sHtml + '<div class="newsbox">';
            sHtml = sHtml + '<ul>';
            sHtml = sHtml + '<li><img src="images/bulletgreen.gif"><a href="index.asp">Home page</a></li>';
            sHtml = sHtml + '<li><img src="images/bulletgreen.gif"><a href="prodotto.asp">Prodotto</a></li>';
            sHtml = sHtml + '<li><img src="images/bulletgreen.gif"><a href="distributori.asp">Distributori</a></li>';
            sHtml = sHtml + '<li><img src="images/bulletgreen.gif"><a href="documenti.asp">Documenti</a></li>';
            sHtml = sHtml + '<li><img src="images/bulletgreen.gif"><a href="diconodinoi.asp">Dicono di noi</a></li>';
            sHtml = sHtml + '<li><img src="images/bulletgreen.gif"><a href="link.asp">Link</a></li>';
		    sHtml = sHtml + '<li><img src="images/bulletgreen.gif"><a href="guestbookform.asp">Scrivi un commento</a></li>';
		    sHtml = sHtml + '<li><img src="images/bulletgreen.gif"><a href="guestbookresults.asp">Leggi i commenti</a></li>';
            sHtml = sHtml + '<li><img src="images/bulletgreen.gif"><a target="_blank" href="http://www.tradefast.net/lattecrudoinliguriacms/default.asp?AUTHMODE=STD_AUTH">Area riservata</a></li>';
            sHtml = sHtml + '<li><img src="images/bulletgreen.gif"><a href="http://www.tradefast.net/lattecrudoinligurianalisi/default.asp?AUTHMODE=STD_AUTH">Analisi</a></li>';

            
            sHtml = sHtml + '</ul>';
            sHtml = sHtml + '</div>';
		}
        
        //Aziende agricole
        sHtml = sHtml + '<div class="newsbox">';
        sHtml = sHtml + '<h2>Aziende Agricole</h2>';
        sHtml = sHtml + getProduttori();
        sHtml = sHtml + '</div>';
                		
		if (psMenuID == "xyz") {
			sHtml = "";
		}
		
		objMenu = document.getElementById("navigation");				
		objMenu.innerHTML = "";
		objMenu.innerHTML = sHtml;
		//GetBoxDispo();

        nHeight = objMenu.getAttribute("offsetHeight");
		nHeight = objMenu.getAttribute("Height");
		document.getElementById("container").height = nHeight;
		document.getElementById("extra").height = nHeight;
		//document.getElementById("content").offsetHeight = "2000px";
        
        if ((objMenu.offsetHeight + 500) > document.getElementById("content").offsetHeight) {
            sHeight = "height:" + (objMenu.offsetHeight + 500) + "px";
		    document.getElementById("content").setAttribute('style', sHeight);
		}		
		break;
	}

	objMenu = null;
	if (sHtml == "") alert("Non posso caricare il menu");
}


//===============================================================
// setFocus: assegna il focus nelle form al primo campo
//===============================================================

function setFocus() {
	if (document.forms[0]!=null) {
		for (var i = 0; i < document.forms[0].elements.length; i++) {
				if (document.forms[0].elements[i].type != "hidden") {
					try {
					document.forms[0].elements[i].focus();
					break;
					}
					catch(e) {}
				}

		}
	}
}

//===============================================================
// GetXmlHttpObject: Mi restituisce l'oggetto Http
//===============================================================

function GetXmlHttpObject(handler) { 
		
    var objXMLHttpRequest=null;
    if (navigator.userAgent.indexOf("Opera")>=0) {
        alert("This example doesn't work in Opera");
        return objXMLHttpRequest; 
    }
    if (navigator.userAgent.indexOf("MSIE")>=0) { 
        var strName=""; 

        if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
	        strName="Microsoft.XMLHTTP";
        else if (navigator.appVersion.indexOf("MSIE 6.0")>=0)
	        strName="Microsoft.XMLHTTP";
        else if (navigator.appVersion.indexOf("MSIE 7.0")>=0)
	        strName="Microsoft.XMLHTTP";
        else if (navigator.appVersion.indexOf("MSIE 8.0")>=0)
	        strName="Microsoft.XMLHTTP";
        else
	        strName = "Msxml2.XMLHTTP";
			
        try {
	        objXMLHttpRequest = new ActiveXObject(strName);
	        objXMLHttpRequest.onreadystatechange=handler;
	        return objXMLHttpRequest;
        } 
        catch(e) { 
	        alert(e.message);
	        return objXMLHttpRequest;
        } 
    } 
    if (navigator.userAgent.indexOf("Mozilla")>=0) {
        objXMLHttpRequest=new XMLHttpRequest();
        objXMLHttpRequest.onload=handler;
        objXMLHttpRequest.onerror=handler; 
        return objXMLHttpRequest;
    }        
}        

//function GetBoxDispo() {
//    var sPostURL = "getboxdisponibilita.asp";
//    var postData = "";
//    var objXMLHttpRequest = null;
    
//	objXMLHttpRequest = GetXmlHttpObject(stateChanged);
					
//	if (objXMLHttpRequest != null ) {					
//		objXMLHttpRequest.open("POST", sPostURL, true);
//		objXMLHttpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
//		objXMLHttpRequest.send(postData);
//	}


//    function stateChanged() {		  
//        if (objXMLHttpRequest.readyState==4 || objXMLHttpRequest.readyState =="complete") { 
//	        document.getElementById("divBoxDispo").innerHTML = unescape(objXMLHttpRequest.responseText);
	        //document.getElementById("divBoxDispo").innerHTML = "Etą 10,22"
//        }
//    }            
//}

function GetBoxNews() {
//    document.getElementById("divBoxNews").innerHTML = "BOX NEWS";
//    var sPostURL = "getboxtrovacarne.asp";
//    var postData = "";
//    var objXMLHttpRequest = null;
    
//	objXMLHttpRequest = GetXmlHttpObject(changedTrovaCarne);
					
//	if (objXMLHttpRequest != null ) {					
//		objXMLHttpRequest.open("POST", sPostURL, true);
//		objXMLHttpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
//		objXMLHttpRequest.send(postData);
//	}


//    function changedTrovaCarne() {		  
//        if (objXMLHttpRequest.readyState==4 || objXMLHttpRequest.readyState =="complete") { 
//	        document.getElementById("divBoxTrovaCarne").innerHTML = unescape(objXMLHttpRequest.responseText);	        
//        }
//    }      
}
        