// JavaScript Document
function contentSize()
	{
	alert('Altezza pagina: ' + document.outerHeight);
	alert('Altezza pagina: ' + document.innerHeight);	
	alert(document.getElementById('content').style.height); 
	document.getElementById('content').style.height='400px'; 
	alert(document.getElementById('content').style.height);		
	}
	
function Size() {
  var myHeight = 0;
  var m_value = 118;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
	var t=document.getElementById("content");
	t.style.height = myHeight - m_value + 'px';   
	//alert(t.style.height);
  //window.alert( 'Height = ' + myHeight );
}	

function SizeDetail() {
  var myWidth = 0;
  var m_value = 148;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
	var t=document.getElementById("detail_page");
	t.style.width = myWidth - m_value + 'px';   
	//alert(t.style.height);
  //window.alert( 'Height = ' + myHeight );
}	

var id,pause=0,position=0;

function scorrevole_home() 
{
	var i,k,msg="La Libreria Militare - Libreria Specializzata - Casa Editrice - Piu' di  25.000 titoli a catalogo - storia militare - memorialistica - strategia - pensiero e dottrina militare -  armi e armamenti - forze speciali - forze dell'ordine e security - investigazioni private e criminologia -  intelligence - medaglie - uniformologia - araldica - survival e soft air - wargame e modellismo - arti marziali orientali ed occidentali - geopolitica e relazioni internazionali - diritto internazionale bellico e umanitario - sociologia militare -  riviste specializzate - libri rari e d'occasione - Appuntamenti 2011: 26-27 Marzo ARMI & BAGAGLI (Fiera Piacenza) --- 21-22 Maggio MILITALIA (Novegro - Linate) --- 23-24-25 Settembre HOBBY MODEL EXPO (Novegro-Linate)  --- 5-6 Novembre MILITALIA (Novegro - Linate)";
	k=(200/msg.length)+1;
	for(i=0;i<=k;i++) msg+=" "+msg;
		{
			document.getElementById("scorrevole").value=msg.substring(position,position+200);
			document.getElementById("scorrevole_intro").value=msg.substring(position,position+200);
		}
	if(position++==1000) 
		position=0;
	id=setTimeout("scorrevole_home()",200); 
}

function scorrevole() 
{
	var i,k,msg="La Libreria Militare - Libreria Specializzata - Casa Editrice - Piu' di  25.000 titoli a catalogo - storia militare - memorialistica - strategia - pensiero e dottrina militare -  armi e armamenti - forze speciali - forze dell'ordine e security - investigazioni private e criminologia -  intelligence - medaglie - uniformologia - araldica - survival e soft air - wargame e modellismo - arti marziali orientali ed occidentali - geopolitica e relazioni internazionali - diritto internazionale bellico e umanitario - sociologia militare -  riviste specializzate - libri rari e d'occasione - Appuntamenti 2011: 26-27 Marzo ARMI & BAGAGLI (Fiera Piacenza) --- 21-22 Maggio MILITALIA (Novegro - Linate) --- 23-24-25 Settembre HOBBY MODEL EXPO (Novegro-Linate)  --- 5-6 Novembre MILITALIA (Novegro - Linate)";
	k=(200/msg.length)+1;
	for(i=0;i<=k;i++) msg+=" "+msg;
		document.getElementById("scorrevole").value=msg.substring(position,position+200);
	if(position++==1000) 
		position=0;
	id=setTimeout("scorrevole()",200); 
}

function ShowHideMenu_Padre(id)
	{
		//alert('id = '+id+'\ncurrentId = '+currentPadre);
		document.getElementById(id).style.display='block';
		
		if(currentPadre!='')
			document.getElementById(currentPadre).style.display='none';
		
		if(currentPadre==id)
			currentPadre='';
		else
			currentPadre = id;
	}
	
function ShowHideMenu_Figlio(id)
	{
		//alert('id = '+id+'\ncurrentId = '+currentFiglio);
		document.getElementById(id).style.display='block';
		
		if(currentFiglio!='')
			document.getElementById(currentFiglio).style.display='none';
		
		if(currentFiglio==id)
			currentFiglio='';
		else
			currentFiglio = id;
	}
	
function ShowHideMenu_Nipote(id)
	{
		//alert('id = '+id+'\ncurrentId = '+currentNipote);
		document.getElementById(id).style.display='block';
		
		if(currentNipote!='')
			document.getElementById(currentNipote).style.display='none';
		
		if(currentNipote==id)
			currentNipote='';
		else
			currentNipote = id;		
	}
	
function orario(str) {

        searchWin = window.open(str,'orario','scrollbars=no,resizable=no,width=450,height=400,status=no,location=no,toolbar=no');

//        searchWin.refer = self;

}


//orologio in homepage

var timerID = null;
var timerRunning = false;
function stopclock (){
        if(timerRunning)
                clearTimeout(timerID);
        timerRunning = false;
}

function showtime () {
        var now = new Date();
        var hours = now.getHours();
        var minutes = now.getMinutes();
        var seconds = now.getSeconds()
        var timeValue = "" + ((hours >12) ? hours -0 :hours)
        timeValue += ((minutes < 10) ? ":0" : ":") + minutes
        timeValue += ((seconds < 10) ? ":0" : ":") + seconds
        timeValue += (hours >= 12) ? "" : ""
        document.clock.face.value = timeValue;
        timerID = setTimeout("showtime()",1000);
        timerRunning = true;
}

function startclock () {
        // Make sure the clock is stopped
        stopclock();
        showtime();
}

var rhWindow = ""
function openRH(URL,rhWidth,rhHeight) {
    if (!window.rhWindow) {
        rhWindow = window.open(URL,null,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=' + rhWidth + ',height=' + rhHeight);
    }
    else {
        if (!rhWindow.closed) {
            rhWindow.focus();
        }
        else {
            rhWindow = window.open(URL,null,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=' + rhWidth + ',height=' + rhHeight);
        }
    }
	
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


// funzione per assegnare l'oggetto XMLHttpRequest
// compatibile con i browsers più recenti e diffusi
function assegnaXMLHttpRequest() {
	// lista delle variabili locali
	var XHR = null;
	 
	// informazioni sul nome del browser
	browserUtente = navigator.userAgent.toUpperCase();
	
	
	// browser standard con supporto nativo
	// non importa il tipo di browser
	if(typeof(XMLHttpRequest) === "function" || typeof(XMLHttpRequest) === "object")
		XHR = new XMLHttpRequest();

	// browser Internet Explorer
	// è necessario filtrare la versione 4
	else 
		if(window.ActiveXObject && browserUtente.indexOf("MSIE 4") < 0) 
			{
			// la versione 6 di IE ha un nome differente
			// per il tipo di oggetto ActiveX
			if(browserUtente.indexOf("MSIE 5") < 0)
				XHR = new ActiveXObject("Msxml2.XMLHTTP");
		
			// le versioni 5 e 5.5 invece sfruttano lo stesso nome
			else
				XHR = new ActiveXObject("Microsoft.XMLHTTP");
			}
	return XHR;
} 	

function mostra_prodotti(id, pag) 
	{		
	// assegnazione oggetto XMLHttpRequest
    ajax = assegnaXMLHttpRequest();
	if(ajax)
		{		
		// inizializzo la richiesta in GET
		ajax.open("get", "funzione_ajax_categoria.php?id=" + id + "&pag=" + pag, true);
		//alert("funzione_ajax_categoria.php?id=" + id + "&pag=" + pag);
		
		// effettuo la richiesta
		ajax.send(null);
			
		//restituisco il contenuto testuale inserendolo nella pagina
		//alert(ajax.responseText);			
		var content = document.getElementById('lista_articoli');	
		if(ajax.responseText)
			{
			if (content.innerHTML) //per ie
				{
				content.innerHTML += ajax.responseText;
				
				//nascondo il vecchio link "aggiungi prodotti"
				id_link = 'link_ajax_' + pag;
				document.getElementById(id_link).style.display='none';
				}
			else				//per firefox
				{
				content.textContent += ajax.responseText;
				
				//nascondo il vecchio link "aggiungi prodotti"
				id_link = 'link_ajax_' + pag;
				document.getElementById(id_link).style.display='none';

				}
			}
		else
			{
			if (content.innerHTML) //per ie
				content.innerHTML += "Si è verificato un\'errore<br />errore ajax001:<br />" + ajax.responseText;
			else				//per firefox
				content.textContent += "Si è verificato un\'errore<br />errore ajax001:<br />" + ajax.responseText;
			}		
			
		//chiudo la connessione		
		//ajax.setRequestHeader("Connection", "close");					
		}
	else
		{
		alert('Si è verificato un\'errore durante la chiamata del template - eajax002')
		//errore chiamata ajax						
		}
	}
	
function veriForm()
	{
	stringa=document.cerca.key.value;
	if(stringa.length<3)
		{	
		alert('La parola chiave deve essere di almeno 3 caratteri!');
		document.cerca.key.focus();
		return false;
		}		
	}
	
function veriFormRapido()
	{
	stringa=document.rapido.key.value;
	if(stringa.length<3)
		{	
		alert('La parola chiave deve essere di almeno 3 caratteri!');
		document.rapido.key.focus();
		return false;
		}		
	}	
