// JavaScript Document

function Indietro()
{
    var scroll = new Fx.Scroll('ctl00_phMain_up1', {
			wait: false,
			duration: 1500,
			transition: Fx.Transitions.Quad.easeInOut
		});
	scroll.toElement('continenti');
	$$('a.btnSx').setStyle('display', 'none');
}

function DoAjaxCall(the_request, tipo)
{
    var request=null;
    if(window.XMLHttpRequest)
        request=new XMLHttpRequest();
    else if(window.ActiveXObject)
            request=new ActiveObject("Microsoft.XMLHTTP");
    if (request)
    {
        request.open("GET", the_request);
        request.onreadystatechange=function()
            {
                if(request.readyState==4)
                {
                   // alert(request.responseText);
                    // INIETTARE HTML NEL DIV DALLA PAGINA
                    if(tipo=='NAZIONE')                        
                        $('dvSinistra').innerHTML=request.responseText;
                    if(tipo=='DISTRIBUTORE')
                        $('col-destra').innerHTML=request.responseText;                                       
	                
	                // SCROLL VERTICALE
	                var divToDelete=$('myScrollbar');
                    if(divToDelete!=null)
                        divToDelete.remove();
                    $('dvColonnaCentraleNazioni').setStyle('width','800px');
                    var listScroll = $$('.scroll');
                    var scr = new ScrollBar(listScroll[0].getParent(), listScroll[0], {
                        'arrows': false,
                        'hScroll': false
                    });
                    
                    
                }
            }
        request.send(null);
    }
}

function GetHtmlCode(urlRequest, tipoParam, tipo, continenteParam, continenteID, nazioneParam, nazioneID, linguaParam, linguaID)
{
    var requestToDo=urlRequest+ '?'+linguaParam+'='+linguaID+'&'+tipoParam+'=NAZIONE&'+continenteParam+'='+continenteID+'&'+nazioneParam+'='+nazioneID;
    DoAjaxCall(requestToDo, 'NAZIONE');
    requestToDo=urlRequest+'?'+linguaParam+'='+linguaID+'&'+tipoParam+'=DISTRIBUTORE&'+continenteParam+'='+continenteID+'&'+nazioneParam+'='+nazioneID;
    DoAjaxCall(requestToDo, 'DISTRIBUTORE');
    
    // SLIDE ORIZZONTALE
    var scroll = new Fx.Scroll('ctl00_phMain_up1', {
            wait: false,
            duration: 1500,
            transition: Fx.Transitions.Quad.easeInOut
        });

    // SCROLL VERTICALE
    var divToDelete=$('myScrollbar');
    if(divToDelete!=null)
        divToDelete.remove();
    $('dvColonnaCentraleNazioni').setStyle('width','800px');
    var listScroll = $$('.scroll');
    var scr = new ScrollBar(listScroll[0].getParent(), listScroll[0], {
        'arrows': false,
        'hScroll': false
    });
        
    scroll.toElement('nazioni');
    $$('a.btnSx').setStyle('display', 'block');
    // FORZO IL CARICAMENTO DEI DISTRIBUTORI ASSOCIATI ALLA PRIMA NAZIONE DEL CONTINENTE CORRENTE
    //if(tipo=="NAZIONE")
    //{
    //    requestToDo='http://localhost/sanleonardo/gethtmlcode.aspx?'+linguaParam+'='+linguaID+'&'+tipoParam+'=DISTRIBUTORE&'+continenteParam+'='+continenteID+'&'+nazioneParam+'='+nazioneID;
    //    DoAjaxCall(requestToDo, 'DISTRIBUTORE');
    //}
}
