
/*

CFT 4.0
Tonelli for SGA Storiageo
Javascript procedur for CFT 4.0
16/05/2007

*/

function refreshMap_year_intensity(my_from_year,my_to_year,my_from_intensity,my_to_intensity) {
    //alert(my_from_year + " " + my_to_year + " " + my_from_intensity + " " + my_to_intensity);

    // richiamo la funzione della scelta del tipo di terremoto
    // era richiamata dal primo metodo post poi eliminato
    //refreshMap_init();

    var map = myKaMap.getCurrentMap();
    //var nterrs = map.getLayer('Earthquakes');
    var nterrs_year = map.getLayer('Earthquakes (Selected only)');
    //var nterrs_year_me = map.getLayer('Earthquakes Magnitude (Selected only)');
    var value_incorrect = "no";
    var my_filter = "1=1";

	// annullo l'eventuale nterr memorizzato
    document.getElementById('n_terr').innerHTML = "";
    //var nterrs_pq_year = map.getLayer('Felt localities');
    //alert("Il valore my_from_year Ã¨ " + my_from_year);
    //alert("Il valore my_to_year Ã¨ " + my_to_year);
    //alert("Il valore my_from_intensity Ã¨ " + my_from_intensity);
    //alert("Il valore my_to_intensity Ã¨ " + my_to_intensity);
    //nterrs.setVisibility(false);
	if (document.init_input.selez[0].checked==true ) {
		// All
		my_search = "flagfalseeq != '1'";
		changeearthquaketype('Currently shown earthquakes: ALL',document.forms['init_input'].elements['da_anno'].value,document.forms['init_input'].elements['a_anno'].value,document.forms['init_input'].elements['da_intensita'].value,document.forms['init_input'].elements['a_intensita'].value);
	}
	else if (document.init_input.selez[1].checked==true) {
		// Strong
		my_search = "flagstrongeq = '1'";
		changeearthquaketype('Currently shown earthquakes: STRONG',document.forms['init_input'].elements['da_anno'].value,document.forms['init_input'].elements['a_anno'].value,document.forms['init_input'].elements['da_intensita'].value,document.forms['init_input'].elements['a_intensita'].value);
	}
	else if (document.init_input.selez[2].checked==true) {
		// Unknown
		my_search = "flagunkneq = '1'";
		changeearthquaketype('Currently shown earthquakes: UNKNOWN',document.forms['init_input'].elements['da_anno'].value,document.forms['init_input'].elements['a_anno'].value,document.forms['init_input'].elements['da_intensita'].value,document.forms['init_input'].elements['a_intensita'].value);
	}
	else if (document.init_input.selez[3].checked==true) {
		// New
		my_search = "flagreveq = '1'";
		changeearthquaketype('Currently shown earthquakes: NEW',document.forms['init_input'].elements['da_anno'].value,document.forms['init_input'].elements['a_anno'].value,document.forms['init_input'].elements['da_intensita'].value,document.forms['init_input'].elements['a_intensita'].value);
	}
	else if (document.init_input.selez[4].checked==true) {
		// False
		my_search = "flagfalseeq = '1'";
		changeearthquaketype('Currently shown earthquakes: FALSE',document.forms['init_input'].elements['da_anno'].value,document.forms['init_input'].elements['a_anno'].value,document.forms['init_input'].elements['da_intensita'].value,document.forms['init_input'].elements['a_intensita'].value);
	}

        //  alert("1 Typeof(my_from_year) vale " + isInteger(my_from_year));

	// tutti i valori nulli 
    if (my_from_year == '' && my_to_year == '' && my_from_intensity == '' && my_to_intensity == '' ) 
	//{ my_filter = "annonum between -2000 and 2500";}
	//{ my_filter = "1=1";}
	{ my_filter = my_search;}

	// valore numerico in my_from_year e tutti i valori rimanenti nulli 
     else if ( isInteger(my_from_year) && Trim(my_to_year) == '' && Trim(my_from_intensity) == '' && Trim(my_to_intensity) == '' ) 
	{ my_filter = my_search + " and annonum = " + my_from_year ;
	}

	// valore numerico in my_from_year e my_to_year e tutti i valori rimanenti nulli 
    else if ( isInteger(my_from_year) && isInteger(my_to_year) && Trim(my_from_intensity) == '' && Trim(my_to_intensity) == '' ) 
	{ my_filter = my_search + " and annonum  between " + my_from_year + " and " + my_to_year + " ";}

	// valore numerico in my_from_year e my_to_year e my_from_intensity e tutti i valori rimanenti nulli 
    else if ( isInteger(my_from_year) && isInteger(my_to_year) && isInteger(my_from_intensity) && Trim(my_to_intensity) == '' ) 
	{ my_filter = my_search + " and annonum  between " + my_from_year + " and " + my_to_year + " and io = " + my_from_intensity;
	}

	// valore numerico in my_from_intensity e my_to_intensity e tutti i valori rimanenti nulli 
    else if ( Trim(my_from_year) == '' && Trim(my_to_year) == '' && isInteger(my_from_intensity) && isInteger(my_to_intensity) )
	{ my_filter = my_search + " and  io between " + my_from_intensity + " and  " + my_to_intensity ;
	//alert(my_filter);
	}

	// valore numerico in my_from_year e my_from_intensity e my_to_intensity e my_to_year nullo o errato
    else if ( isInteger(my_from_year) && Trim(my_to_year) == '' && isInteger(my_from_intensity) && isInteger(my_to_intensity) )
	{ my_filter = my_search + " and annonum = " + my_from_year + " and io between " + my_from_intensity + " and  " + my_to_intensity + " ";}

	// valore numerico in my_to_year e my_from_intensity e my_to_intensity e my_from_year nullo o errato
    else if ( isInteger(my_to_year) && Trim(my_from_year) == '' && isInteger(my_from_intensity) && isInteger(my_to_intensity) )
	{ my_filter = my_search + " and annonum = " + my_to_year + " and io between " + my_from_intensity + " and  " + my_to_intensity + " ";}

	// valore numerico in my_from_year e my_to_year e my_from_intensity e my_to_intensity 
    else if ( isInteger(my_from_year) && isInteger(my_to_year) && isInteger(my_from_intensity) && isInteger(my_to_intensity) ) 
	{ my_filter = my_search + " and annonum  between " + my_from_year + " and " + my_to_year + " and io between " + my_from_intensity + " and  " + my_to_intensity;
          //alert("Il valore my_from_year Ã¨ " + my_from_year + " " + typeof(parseInt(my_from_year)));
          //alert("Il valore my_to_year Ã¨ " + my_to_year + " " + typeof(parseInt(my_to_year)));
	}

   else 
	{ alert("Incorrect value");
	  value_incorrect = "si";
	  //alert(my_filter);
	  //alert(typeof(parseFloat(my_from_intensity)));
	} 

	  //alert(typeof(parseFloat(my_from_intensity)));
   //alert("my_filter = " + my_filter);
   //alert("2 Typeof(my_from_year) vale " + typeof(parseInt(my_from_year)));
    if ( value_incorrect != "si") { 
    	//my_filter = "annonum between 1900 and 2000";
    	nterrs_year.replacementVariables = {filtro: my_filter}; //myyear contains the number of year checked by the user
    	//nterrs_year_me.replacementVariables = {filtro: my_filter}; //myyear contains the number of year checked by the user
    	//nterrs_pq_year.replacementVariables = {year: myyear}; //myyear contains the number of year checked by the user

    	nterrs_year.redraw();
    	showLayer("Earthquakes (Selected only)");
    	//nterrs_pq_year.redraw();
    	//myKaMap.zoomToExtents(0,4037500,1693500,5228000);
    	getFullExtent();
	} 
}

function showLayer(layerName) {

var allLayers = myKaMap.getCurrentMap().getAllLayers();

for (var i=0; i<allLayers.length; i++) {

   if(allLayers[i].name == layerName ) {
     	myKaMap.setLayerVisibility( allLayers[i].name, true );
     // allLayers[i].setVisibility(true) // this has some bug
   } else if  ( allLayers[i].name == "Topography" ) {
     	myKaMap.setLayerVisibility( allLayers[i].name, true );
   //} else if  ( allLayers[i].name == "Cartography World" ) {
   //  	myKaMap.setLayerVisibility( allLayers[i].name, true );
   //} else if  ( allLayers[i].name == "Bathymetry" ) {
   //  	myKaMap.setLayerVisibility( allLayers[i].name, true );
   } else if  ( allLayers[i].name == "Felt Localities" ) {
     	//myKaMap.setLayerVisibility( allLayers[i].name, true );
	// questo sotto funziona!!
	allLayers[i].setVisibility(true);
   } else if  ( allLayers[i].name == "Administrative" ) {
     	//myKaMap.setLayerVisibility( allLayers[i].name, true );
	// questo sotto funziona!!
	allLayers[i].setVisibility(true);
   } else if  ( allLayers[i].name == "Rivers and Lakes (Italy)" ) {
     	//myKaMap.setLayerVisibility( allLayers[i].name, true );
	// questo sotto funziona!!
	allLayers[i].setVisibility(true);
     } else {
     myKaMap.setLayerVisibility( allLayers[i].name, false );
     // allLayers[i].setVisibility(false) // this has some bug
    //alert("Il nome del layer Ã¨ " + allLayers[i].name);
   }
 }
}

function showLayer_without_localities(layerName) {

var allLayers = myKaMap.getCurrentMap().getAllLayers();

for (var i=0; i<allLayers.length; i++) {

   if(allLayers[i].name == layerName ) {
     	myKaMap.setLayerVisibility( allLayers[i].name, true );
     // allLayers[i].setVisibility(true) // this has some bug
   //} else if  ( allLayers[i].name == "Cartography" ) {
   //  	myKaMap.setLayerVisibility( allLayers[i].name, true );
   } else if  ( allLayers[i].name == "Topography" ) {
     	myKaMap.setLayerVisibility( allLayers[i].name, true );
   } else if  ( allLayers[i].name == "Administrative" ) {
     	myKaMap.setLayerVisibility( allLayers[i].name, true );
   //} else if  ( allLayers[i].name == "Localities" ) {
     	//myKaMap.setLayerVisibility( allLayers[i].name, true );
	// questo sotto funziona!!
	//allLayers[i].setVisibility(true);
   } else if  ( allLayers[i].name == "Rivers and Lakes (Italy)" ) {
     	//myKaMap.setLayerVisibility( allLayers[i].name, true );
	// questo sotto funziona!!
	allLayers[i].setVisibility(true);
   }
   else {
     myKaMap.setLayerVisibility( allLayers[i].name, false );
     // allLayers[i].setVisibility(false) // this has some bug
    //alert("Il nome del layer Ã¨ " + allLayers[i].name);
   }
 }
}

function showLayer_without_localities_with_earthquake(layerName) {

var allLayers = myKaMap.getCurrentMap().getAllLayers();

for (var i=0; i<allLayers.length; i++) {
   //alert(allLayers[i].name);
   if(allLayers[i].name == layerName ) {
     	myKaMap.setLayerVisibility( allLayers[i].name, true );
     // allLayers[i].setVisibility(true) // this has some bug
   //} else if  ( allLayers[i].name == "Cartography" ) {
   //  	myKaMap.setLayerVisibility( allLayers[i].name, true );
   } else if  ( allLayers[i].name == "Topography" ) {
     	myKaMap.setLayerVisibility( allLayers[i].name, true );
   } else if  ( allLayers[i].name == "Administrative" ) {
     	myKaMap.setLayerVisibility( allLayers[i].name, true );
   //} else if  ( allLayers[i].name == "Localities" ) {
     	//myKaMap.setLayerVisibility( allLayers[i].name, true );
	// questo sotto funziona!!
	//allLayers[i].setVisibility(true);
   } else if  ( allLayers[i].name == "Rivers and Lakes (Italy)" ) {
     	//myKaMap.setLayerVisibility( allLayers[i].name, true );
	// questo sotto funziona!!
	allLayers[i].setVisibility(true);
   } else if  ( allLayers[i].name == "Earthquakes (Selected only)" ) {
     	//myKaMap.setLayerVisibility( allLayers[i].name, true );
	// questo sotto funziona!!
	allLayers[i].setVisibility(true);
   } else {
     myKaMap.setLayerVisibility( allLayers[i].name, false );
     // allLayers[i].setVisibility(false) // this has some bug
    //alert("Il nome del layer Ã¨ " + allLayers[i].name);
   }
 }
}

function showLayerNterrPq( mynterr, x , y , x1 , y1 , it )  {
    //alert('Valori '+ mynterr + ' ' + x + ' ' + y + ' ' + x1 + ' ' + y1 );
    var map = myKaMap.getCurrentMap();
    var nterrs_pq_year = map.getLayer('Earthquake Felt Localities');
    var nterr = map.getLayer('Earthquake Location');
    var singlebox = map.getLayer('Earthquake Box');

	// settaggio dell'id del terremoto nello span n_nterr
    document.getElementById('n_terr').innerHTML = mynterr;
    //anno = document.forms['mymapInfo'].elements['da_anno'].value;
    //nterrs_pq_year.replacementVariables = {year: anno};
    nterrs_pq_year.replacementVariables = {nterr: mynterr};
    nterr.replacementVariables = {nterr: mynterr};
    singlebox.replacementVariables = {nterr: mynterr};
    showLayer_without_localities("Earthquake Felt Localities");
    myKaMap.setLayerVisibility( 'Earthquake Location', true );
    myKaMap.setLayerVisibility( 'Earthquake Box', false );
    nterrs_pq_year.redraw();
    nterr.redraw();
    singlebox.redraw();
    //myKaMap.setLayerVisibility( "Earthquake year", true );
    //myKaMap.zoomToExtents(x,y,x1,y1);
	// zona da visualizzare in metri intorno all'epicentro
    zona_est = 20000;
    zona_nord = 14000; 
    myKaMap.zoomToExtents(x - zona_est, y - zona_nord, x1 + zona_est, y1 + zona_nord);
    //myKaMap.zoomToExtents(0,4037500,1693500,5228000);
    //getFullExtent();
    myhiliterow(it,'#FBFDCF');
}



function Trim(stringa)
   {
   reTrim=/\s+$|^\s+/g;
   return stringa.replace(reTrim,"");
   }

function refreshMap_localities(my_search)
   {
    var map = myKaMap.getCurrentMap();
    var localities = map.getLayer('Felt Localities (Selected only)');

	//alert(typeof(parseFloat(my_from_intensity)));
	//alert("my_filter = " + my_filter);
	//alert("2 Typeof(my_from_year) vale " + typeof(parseInt(my_from_year)));
    	//my_filter = "annonum between 1900 and 2000";
	//$searchstring = $szSearchfield . ' ~* \'' . $searchstring_base .'\'  ';
	my_search = "descloc ~* \'" + my_search + "\'";
	//alert(my_search);
    	localities.replacementVariables = {ricerca: my_search}; //myyear contains the number of year checked by the user
    	//nterrs_pq_year.replacementVariables = {year: myyear}; //myyear contains the number of year checked by the user
    	showLayer("Felt Localities (Selected only)");
    	localities.redraw();
	getRawObject('queryOut1').innerHTML = '<h3></h3><hr>';
    	//nterrs_pq_year.redraw();
    	//myKaMap.zoomToExtents(0,4037500,1693500,5228000);
	showLayer_without_localities_with_earthquake('Felt Localities (Selected only)');
    	getFullExtent();
 
   }

function refreshMap_init()
   {

	//document.getElementById('search_earthquake').style.visibility = "hidden";
	//document.getElementById('search_localities').style.visibility = "hidden";

	/*
	if (myKaMap.isIE4) {
		document.all('search_earthquake').style.visibility = "visible";
		document.all('search_localities').style.visibility = "visible";
	}
	else {
		document.getElementById('search_earthquake').style.visibility = "visible";
		document.getElementById('search_localities').style.visibility = "visible";
	}
	*/

	//alert(document.getElementById('search_localities').style.visibility);
	//document.mapInfo.search_earthquake.visibility = "visible";
	//document.mapInfo.search_localities.visibility = "visible";

    	var map = myKaMap.getCurrentMap();
    	var earthquake = map.getLayer('Earthquakes');
    	//var earthquake_me = map.getLayer('Earthquakes Magnitude');
        //alert(earthquake);

	//alert(my_all + " " + my_unknown + " " + my_new + " " + my_strong + " " + my_false);

	if (document.init_input.selez[0].checked==true )
		//my_search = "flagfalseeq != '1'";
                // All
		my_search = "not flagfalseeq = '1'";
	else if (document.init_input.selez[1].checked==true)
		// Strong
		my_search = "flagstrongeq = '1'";
	else if (document.init_input.selez[2].checked==true)
		// Unknown
		my_search = "flagunkneq = '1'";
	else if (document.init_input.selez[3].checked==true)
		// New
		my_search = "flagreveq = '1'";
	else if (document.init_input.selez[4].checked==true)
		// False
		my_search = "flagfalseeq = '1'";
	//alert(my_search);
    	earthquake.replacementVariables = {ricerca: my_search}; //myyear contains the number of year checked by the user
    	//earthquake_me.replacementVariables = {ricerca: my_search}; //a myyear contains the number of year checked by the user
    	//nterrs_pq_year.replacementVariables = {year: myyear}; //myyear contains the number of year checked by the user
    	showLayer("Earthquakes");
    	earthquake.redraw();
    	//nterrs_pq_year.redraw();
    	//myKaMap.zoomToExtents(0,4037500,1693500,5228000);
    	getFullExtent();
 
   }

function CheckRadio(IdRadio)
   {
   document.init_input.selez[IdRadio-1].checked=true;
   for (i=1; i<6;i++)
      IdRadio!=i?document.modulo["testo"+i].value="":null;
   }

function changeDescr(toolName)
 {
 //alert(toolName);
 //if (toolDescrizioni[toolName]!=null) {
 document.getElementById('descrFunzTxt').innerHTML = toolName;

 //} else {
 //document.getElementById('descrFunzTxt').innerHTML = "";
 //}
 }

function changeDescr1(toolName)
 {
 //alert(toolName);
 //if (toolDescrizioni[toolName]!=null) {
 document.getElementById('descrFunzTxt1').innerHTML = toolName;

 //} else {
 //document.getElementById('descrFunzTxt').innerHTML = "";
 //}
 }

function changeearthquaketype(toolName,my_from_year,my_to_year,my_from_intensity,my_to_intensity)
 {
 //alert(my_from_year+ ' ' +my_to_year+ ' ' +my_from_intensity+ ' ' +my_to_intensity);
 if (toolName == 'Currently shown earthquakes: FALSE')
	document.getElementById('earthquake_type').style.color='#000099';
 if ( (my_from_year != '') || (my_to_year != '') || (my_from_intensity != '') || (my_to_intensity != '') ) {
		toolName = toolName + ' + Query';	
	}

 document.getElementById('earthquake_type').innerHTML = toolName;

 }

function myopenwindownloc(nloc) {
		window.open('http://storing.ingv.it/cft_new/nloc2cat.phtml?loclist='+nloc,'Locality','width=600, height=500, resizable=yes, scrollbars=yes, status=no');
				}

function hiLiteRows(){
		var table = document.getElementById('heartquaketable');
		//var table = document.getElementById('search_earthquake');
		//alert("Il valore di table Ã¨ " + table);

		//if (!table) {
		for (var i=0;i<table.rows.length;i++)
		{
			table.rows[i].onmouseover = function () {this.origColor=this.style.backgroundColor;
								 this.style.backgroundColor='#cccc00';
								}
		table.rows[i].onmouseout = function () {this.style.backgroundColor=this.origColor;}
		}
		//}
	}
//window.onload = function() { hiLiteRows(); }

function myhiliterow(it,color) {
        // Tonelli 03/05/2007 per evidenziare la riga
        // rendo bianchi tutti i background
        mytable = it.parentNode.parentNode.parentNode;
        i = 0;
    	while (mytable.rows[i] != null) {
		mytable.rows[i].style.backgroundColor = "white";
		i++;
	}
        // rendo rosa la riga scelta
        tr = it.parentNode.parentNode;
        //tr.style.backgroundColor = '#FFDADE'; // rgb(255,218,222)
        tr.style.backgroundColor = color;
	//tr.style.backgroundColor = 'yellow';
	//alert(tr.style.backgroundColor);
        // fine Tonelli
}

function nloc2cat_geo(nloc,descloc,it) {
    var szLayers = '';
    var layers = myKaMap.getCurrentMap().getQueryableLayers();
    if(layers.length==0) {
     alert("No queryable layers at this scale and extent");
     return;
    }
    //alert("Le variabili passate sono " + eventID + " " + queryType );
    for (var i=0;i<layers.length;i++) {
        szLayers = szLayers + "," + layers[i].name;
         //var map = myKaMap.getCurrentMap();
         //layer=map.getLayer(layers[i].name);
         //alert(layer.name);
         //alert(layer.visible);
         //alert(typeof(layer));
         //alert(getObject(layer));
	 //alert(myKaMap.getCurrentMap().getLayer(1));
    }

    myhiliterow(it,'#FBFDCF');


    var extent = myKaMap.getGeoExtents();
    var scale = myKaMap.getCurrentScale();
    var cMap = myKaMap.getCurrentMap().name;
    var general_search = '';

    var  params='map='+cMap+'&scale='+scale+'&groups='+szLayers+'&extent='+extent[0]+'|'+extent[1]+'|'+extent[2]+'|'+extent[3]+'&nloc='+nloc+'&descloc='+descloc;

    getRawObject('queryOut1').innerHTML = '<h3>Processing query. <br> please wait...</h3><hr>';
    call('nloc2cat_geo.php?'+params,this, myQueryOutput1);

    //document.location.href = '#zonalocalita';
    //document.location = '#fine_pagina';
    //window.location = "#qq"
    //window.location = "#fine_pagina";
    //window.location.hash = '#zona_localita';
    //window.location.hash = '#fine_pagina';
    //jumptoanchor();
    //window.location.hash='#fine_pagina';
    //location='#fine_pagina';
    //window.scrollBy(0,1000);
    //window.scrollBy(0,1000);
    //var coll = document.all.tags("identifier");
   //if (coll.length >= 5)
   //{
   //   coll(4).style.textDecoration = "underline";
   //   coll(4).scrollIntoView(false);
   //}

    //document.getElementById("service").scrollIntoView(false);
    //window.scrollTo(0,10000);
    //scroll(0,1000);
    //getScrollXY();
    //bopMe();

    //myid = document.getElementById('identifier');
    //alert(myid.id);
    //parent.parent.parent.parent.myid.scrollTo(0,10000);
    //document.documentElement.identifier.scrollTo(0,10000);

    //scrollTop

    var objDiv = document.getElementById("identifier");
    //alert(objDiv.scrollHeight);
    objDiv.scrollTop = objDiv.scrollHeight + 1500;

}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  alert(scrOfX + ' ' + scrOfY );
  return [ scrOfX, scrOfY ];
}

function bopMe() {
  if (document.all) {
    ps.scroll(0,ps.document.body.scrollHeight);
    y = ps.document.body.scrollHeight;
    } else {
      ps.scroll(0,ps.document.height);
      y = ps.document.height;
      }
}

function clear_zone(zone)  {
	//alert('Zone vale ' + zone);
	if (zone == 'queryOut')
		getRawObject('queryOut').innerHTML = '';
	else if (zone == 'queryOut1')
		getRawObject('queryOut1').innerHTML = '';
	else if (zone == 'querysingleOut')
		getRawObject('querysingleOut').innerHTML = '';
}

function myLastInitialized() {
	// Tonelli ultima procedura startup
	// --------------------------------------

	//alert(this.isIE4);

	// visualizzazione di tuuti i terremoti tranne i falsi
	/*
    	var map = myKaMap.getCurrentMap();
	//alert("Sono qui!");
        // per partire con tutti i terremoti
	//my_search = "not flagfalseeq = '1'";
       // per partire con i terremoti Strong
	my_search = "flagstrongeq = '1'";
    	var earthquakes = map.getLayer('Earthquakes');

	//alert(my_search);
    	earthquakes.replacementVariables = {ricerca: my_search};
    	showLayer("Earthquakes");
    	earthquakes.redraw();
	*/

	refreshMap_year_intensity(document.forms['init_input'].elements['da_anno'].value,document.forms['init_input'].elements['a_anno'].value,document.forms['init_input'].elements['da_intensita'].value,document.forms['init_input'].elements['a_intensita'].value);

	// Write the type of eartquake in the toolbar
	changeearthquaketype('Currently shown earthquakes: STRONG', document.getElementById('da_anno').value,document.getElementById('a_anno').value,document.getElementById('da_intensita').value,document.getElementById('a_intensita').value);

	// --------------------------------------
	// view help initial and control cookies
	help = readCookie('initial_help');
	//alert("Cookies "+help);
	//alert("Cookies "+typeof(help));
	//var help = Cookies['initial_help'];
	//if(help == '' || help == 'yes')
	if(help == null) {
		createCookie('initial_help','yes',365);
		showContent('help_no_html.html');
		}
	else if (help == 'yes')
		showContent('help_no_html.html');

	// --------------------------------------
	// setting the RSH
	//dhtmlHistory.initialize();

	// add ourselves as a listener for history
	// change events
	//dhtmlHistory.addListener(handleHistoryChange);

	// determine our current location so we can
	// initialize ourselves at startup
	//var initialLocation = dhtmlHistory.getCurrentLocation();

	// if no location specified, use the default
	//if (initialLocation == null)
	//	initialLocation = "location1";

	// now initialize our starting UI
	//updateUI(initialLocation, null);

}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

// function for RSH
function updateUI(newLocation, historyData) {
  var output = document.getElementById("output");
  
  // simply display the location and the
  // data
  var historyMessage;
  if (historyData != null)
    historyMessage = historyData.message;

  var message = "New location: "
                + newLocation 
                + ", history data="
                + historyMessage;

  output.innerHTML = message;
}

function handleHistoryChange(newLocation, historyData) {
  // use the history data to update our UI for RSH
  updateUI(newLocation, historyData);
	}

function jumptoanchor() {	
	//if anchor exist in url
	if(window.location.href.match(/#(\w.+)/))
	{
		//jump to anchor
		window.location.hash=window.location.href.match(/#(\w.+)/)[1]; 
	}
}

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if ( c = "-") continue;
        if (((c < "0") || (c > "9") )) return false;
    }
    // All characters are numbers.
    return true;
}

