// JavaScript Document
var XMLHTTP;
var dest;

function blocking(nr)
{
	if (document.layers)
	{
		current = (document.layers[nr].display == 'none') ? 'block' : 'none';
		document.layers[nr].display = current;
	}
	else if (document.all)
	{
		current = (document.all[nr].style.display == 'none') ? 'block' : 'none';
		document.all[nr].style.display = current;
	}
	else if (document.getElementById)
	{
		vista = (document.getElementById(nr).style.display == 'none') ? 'block' : 'none';
		document.getElementById(nr).style.display = vista;
	}
}

function richiestastato(continente,stato,destinazione,destinazione2)
{
	ricstato('netricerca',continente,stato)
	if (stato != "" && stato != "IT") {
	//if (stato != "" ) {
		XMLHTTP="";
		dest = destinazione2;
		document.getElementById(destinazione2).style.visibility = "visible";
		blocking(destinazione2);
		var url = "sales_store.asp?reg=&continente="+continente+"&stato=" + stato;
		XMLHTTP = RicavaBrowser(CambioStato);
		XMLHTTP.open("GET", url, true);
		XMLHTTP.send(null);
		//document.getElementById('netricerca').style.visibility = "visible";
	}
}


function richiestareg(continente,reg,stato,destinazione)
{
	dest = destinazione;
	//alert(dest);
	//document.getElementById(dest).innerHTML = "";
	var url = "sales.asp?continente="+continente+"&reg="+reg+"&stato=" + stato;
	XMLHTTP = RicavaBrowser(CambioStato);
	XMLHTTP.open("GET", url, true);
	XMLHTTP.send(null);
	
	if (stato != "" && reg != 0) {
		dest = "sfsales";
		document.getElementById(dest).style.visibility = "visible";
		blocking(dest);
		var url = "sales_store.asp?continente="+continente+"&reg="+reg+"&stato=" + stato;
		XMLHTTP = RicavaBrowser(CambioStato);
		XMLHTTP.open("GET", url, true);
		XMLHTTP.send(null);
		
		//document.getElementById('netricerca').style.visibility = "hidden";
	}
 
}


function ricstato(destinazione,continente,stato) {

	XMLHTTP="";
	dest = destinazione;
	//document.getElementById(dest).innerHTML = "";
	var url = "sales.asp?continente="+continente+"&stato=" + stato;
	XMLHTTP = RicavaBrowser(CambioStato);
	XMLHTTP.open("GET", url, true);
	XMLHTTP.send(null);	
}

function riccom(destinazione,idfreeimg,sotto) {
	dest = destinazione;
	
	//document.getElementById(destinazione).innerHTML ="<div align='center' style='position:absolute; width:50%; height:50%;' ><br><br><br><img src='images/ajax-loader.gif'/></div>";
	
	//document.getElementById("imgatt").style.visibility = "visible";
	
	var url = "ajax_com.asp?idfreeimg="+idfreeimg+"&sotto="+sotto;
	XMLHTTP = RicavaBrowser(CambioStato);
	XMLHTTP.open("GET", url, true);
	XMLHTTP.send(null);	
	
	
}


function CambioStato()
{ 
    if (XMLHTTP.readyState == 4)
    { 
        var R = document.getElementById(dest);
        R.innerHTML = XMLHTTP.responseText;
    }
}

function RicavaBrowser(QualeBrowser)
{
    if (navigator.userAgent.indexOf("MSIE") != (-1))
    {
        var Classe = "Msxml2.XMLHTTP";
        if (navigator.appVersion.indexOf("MSIE 5.5") != (-1));
        {
            Classe = "Microsoft.XMLHTTP";
        } 
        try
        {
            OggettoXMLHTTP = new ActiveXObject(Classe);
            OggettoXMLHTTP.onreadystatechange = QualeBrowser;
            return OggettoXMLHTTP;
        }
        catch(e)
        {
            alert("Errore: l'ActiveX non verrą eseguito!");
        }
    }
    else if (navigator.userAgent.indexOf("Mozilla") != (-1))
    {
        OggettoXMLHTTP = new XMLHttpRequest();
        OggettoXMLHTTP.onload = QualeBrowser;
        OggettoXMLHTTP.onerror = QualeBrowser;
        return OggettoXMLHTTP;
    }
    else
    {
        alert("error");
    }
}
