//funzione base per il percorso dei clip
function chiamaMetodo(clip, frame) {
	try {
	    var IE = navigator.appName.indexOf("IE") != -1;
	    var filmato = IE ? window.worldMap : window.document.worldMap;
	    filmato.TCallFrame(clip, frame);
    } catch (e) {
		// TODO: handle exception 
		//alert(e);
	}
}
//singole funzioni che eseguono determinate azioni sui frame che hanno numero uguale all'id dell'area
function gotoContinente(id) {
    chiamaMetodo("_root.controller.controllo_globo", id);
}
function gotoNazione(id) {
    chiamaMetodo("_root.controller.controllo_nazione", id);
}
function gotoRegione(id) {
    chiamaMetodo("_root.controller.controllo_regione", id);
}
function gotoProvincia(id) {
    chiamaMetodo("_root.controller.controllo_provincia", id);
}
//0: disattivata, 1: attivata
function modalWin(status) {
	try {
	    chiamaMetodo("_root.controller.controllo_modale", status);
	} catch (e) {
		// TODO: handle exception
		alert(e);
	}
}
//function zoomOut() {
//    chiamaMetodo("_root.controller.controllo_zoomout", 1);
//}
/**
* Action da flash
*/
function doActionDaFlash(operazione, idProvincia, idRegione) {
    document.getElementById("idProvincia").value = idProvincia;
    document.getElementById("idRegione").value = idRegione;
    if (document.forms[0].name == "immobiliForm") {
        doImmobileAction(document.forms[0], operazione);
    }
    if (document.forms[0].name == "agenzieForm") {
        doAgenziaAction(document.forms[0], operazione);
    }
}

/******************************************************/

function resetArea() {
	resetComune();
	resetProvincia();
	resetRegione()
	resetNazione();
 	textIndDiv('continente-sel', "<font color=\"#000000\">Selezionare continente...</font>", '', '', 'container');
}

/******************************************************/

/******************************************************/

function zoomOutContinenteDaFlash() {
	resetNazione();
 	textIndDiv('continente-sel', "<font color=\"#000000\">Selezionare continente...</font>", '', '', 'container');
}

/******************************************************/

function caricaListaNazioni(idContinente, index, form) {
	reloadNazioni(idContinente, form, index);
}
//** reload continente **/
function reloadContinenteDaFlash(id,descrizione) {
	textIndDiv('continente-sel', descrizione, 'idContinente', id, 'Continente');
	caricaListaNazioni(id, id, document.forms[0]); 
}
function zoomOutNazioneDaFlash(id) {
	caricaListaNazioni(id, id, document.forms[0]); 
}

/******************************************************/

function caricaListaRegioni(idNazione, index, form) {
    reloadRegioni(idNazione, form, index);
}
function reloadNazioneDaFlash(id, descrizione) {
	textIndDiv('nazione-sel', descrizione, 'idNazione', id, 'Nazione');
	caricaListaRegioni(id, id, document.forms[0]); 
}
function zoomOutRegioneDaFlash(id) {
	caricaListaRegioni(id, id, document.forms[0]); 
}

/******************************************************/

function caricaListaProvince(idRegione, index, form) {
 	reloadProvince(idRegione, form, index);
}

function reloadRegioneDaFlash(id, descrizione) {
	textIndDiv('regione-sel', descrizione, 'idRegione', id, 'Regione');
	caricaListaProvince(id, id, document.forms[0]); 
}

/******************************************************/

function caricaListaComuni(idProvincia, index, form) {
    reloadComuni(idProvincia, form, index);
}

function reloadProvinceDaFlash(id, descrizione, idRegione, descRegione) {
	if (idRegione != '' && idRegione != document.forms[0].elements["idRegione"].value) {
		textIndDiv('regione-sel', descRegione, 'idRegione', idRegione, 'Regione');
	}
	textIndDiv('provincia-sel', descrizione, 'idProvincia', id, 'Provincia');
	caricaListaComuni(id, id, document.forms[0]);	
}

/******************************************************/

/********javascript per aprire le immagini in finestre ******/
function popImage(imageURL,imageTitle){
// Set the horizontal and vertical position for the popup

PositionX = 100;
PositionY = 100;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultWidth  = 620;
defaultHeight = 620;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;

if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;

if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
writeln('width=100-(document.body.clientWidth-document.images[0].width);');
writeln('height=100-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
close();		
}}