/**
 * File javascript per la funzionalità cerca nel sito
 *  
 * @author Giuliana Borzacchiello
 *
 */   


// variabili globali
var data_odierna = "";
var resultsTitle = "Bottega Teatrale Cecconi";
var resultsBgColor = "white";
var resultsFont = "verdana";
var resultsLink = "blue";
var resultsVLink = "blue";

var pages = new Array();
/* Parametri del costruttore new Page()
   1: pages[i].title ; 
   2: pages[i].url ; 
   3: pages[i].description ; 
   4: pages[i].keywords*/
pages[0] = new Page("Bottega Teatrale Cecconi - Home", "home.html", "Bottega Teatrale Cecconi - Realizza il sogno di fare teatro. Recapito telefonico : xxx", "BOTTEGA TEATRALE CECCONI HOME  BACHECA CALENDARIO NEWS");
// Sezione artisti
pages[1] = new Page("Bottega Teatrale Cecconi - Noi Artisti", "artisti_home.html", "Bottega Teatrale Cecconi - Noi Artisti", "ARTISTI COMMEDIE ARTISTA COMMEDIA SCENE ATTI");
pages[2] = new Page("Bottega Teatrale Cecconi - A voc e Masaniell", "artisti_masaniello.html", "Bottega Teatrale Cecconi - A voc e Masaniell", "ARTISTI COMMEDIE ARTISTA COMMEDIA SCENE ATTI VOC E MASANIELL");
pages[3] = new Page("Bottega Teatrale Cecconi - Chi tanto e chi niente", "artisti_chi_tanto_chi_niente.html", "Bottega Teatrale Cecconi - Chi tanto e chi niente", "ARTISTI COMMEDIE ARTISTA COMMEDIA SCENE ATTI CHI TANTO E CHI NIENTE");
pages[4] = new Page("Bottega Teatrale Cecconi - In fondo alla lenza", "artisti_in_fondo_alla_lenza.html", "Bottega Teatrale Cecconi - In fondo alla lenza", "ARTISTI COMMEDIE ARTISTA COMMEDIA SCENE ATTI IN FONDO ALLA LENZA");
pages[5] = new Page("Bottega Teatrale Cecconi - Tre streghe e una farfalla", "artisti_tre_streghe.html", "Bottega Teatrale Cecconi - Tre streghe e una farfalla", "ARTISTI COMMEDIE ARTISTA COMMEDIA SCENE ATTI TRE STREGHE E UNA FARFALLA");
pages[6] = new Page("Bottega Teatrale Cecconi - Zitto Zitto sotto o' lietto", "artisti_zitto_zitto.html", "Bottega Teatrale Cecconi - Zitto Zitto sotto o' lietto", "ARTISTI COMMEDIE ARTISTA COMMEDIA SCENE ATTI ZITTO ZITTO SOTTO O LIETTO");
// Sezione links
pages[7] = new Page("Bottega Teatrale Cecconi - Links", "links.html", "Bottega Teatrale Cecconi - Links", "LINK UTILI");
// Sezione parlano di noi
pages[8] = new Page("Bottega Teatrale Cecconi - Parlano di noi", "parlano_di_noi.html", "Bottega Teatrale Cecconi - Parlano di noi", "STAMPA ARTICOLI ARTICOLO NEWS");
// Sezione contatti
pages[9] = new Page("Bottega Teatrale Cecconi - Contatti", "contattaci.html", "Bottega Teatrale Cecconi - Contattaci", "CONTATTI CONTATTO RECAPITI RECAPITO TELEFONICI TELEFONO MAIL SCRIVI CELLULARE");
// Sezione poesie : Nelle keywords scrivere l'autore
pages[10] = new Page("Bottega Teatrale Cecconi - L'angolo della poesia", "poesia_home.html", "L'angolo della poesia - Home", "POESIE POESIA DEDICHE DEDICA POETI POETA");
pages[11] = new Page("Bottega Teatrale Cecconi - L'angolo della poesia - A voi poeti", "poesia_a_voi_poeti.html", "L'angolo della poesia - A voi poeti", "POESIE POESIA DEDICHE DEDICA POETI POETA A VOI POETI");
pages[12] = new Page("Bottega Teatrale Cecconi - L'angolo della poesia - Questo mio tempo", "poesia_questo_mio_tempo.html", "L'angolo della poesia - Questo mio tempo", "POESIE POESIA DEDICHE DEDICA POETI POETA QUESTO MIO TEMPO");
pages[13] = new Page("Bottega Teatrale Cecconi - L'angolo della poesia - Un ramo d'ulivo", "poesia_ramo_dulivo.html", "L'angolo della poesia - Un ramo d'ulivo", "POESIE POESIA DEDICHE DEDICA POETI POETA UN RAMO D'ULIVO");
pages[14] = new Page("Bottega Teatrale Cecconi - L'angolo della poesia - L' ammore de che?", "poesia_amore.html", "L'angolo della poesia - L'amore de che?", "POESIE POESIA DEDICHE DEDICA POETI POETA L'AMORE DE CHE");
pages[15] = new Page("Bottega Teatrale Cecconi - L'angolo della poesia - Vuless", "poesia_vuless.html", "L'angolo della poesia - Vuless", "POESIE POESIA DEDICHE DEDICA POETI POETA VULESS");



/*
pages[16] = new Page("Bottega Teatrale Cecconi - L'angolo della poesia - A voi poeti", "poesia_a_voi_poeti.html", "Bottega Teatrale Cecconi - L'angolo della poesia", "POESIE POESIA DEDICHE DEDICA POETI POETA");
pages[17] = new Page("Bottega Teatrale Cecconi - L'angolo della poesia - A voi poeti", "poesia_a_voi_poeti.html", "Bottega Teatrale Cecconi - L'angolo della poesia", "POESIE POESIA DEDICHE DEDICA POETI POETA");
pages[18] = new Page("Bottega Teatrale Cecconi - L'angolo della poesia - A voi poeti", "poesia_a_voi_poeti.html", "Bottega Teatrale Cecconi - L'angolo della poesia", "POESIE POESIA DEDICHE DEDICA POETI POETA");
pages[19] = new Page("Bottega Teatrale Cecconi - L'angolo della poesia - A voi poeti", "poesia_a_voi_poeti.html", "Bottega Teatrale Cecconi - L'angolo della poesia", "POESIE POESIA DEDICHE DEDICA POETI POETA");
pages[20] = new Page("Bottega Teatrale Cecconi - L'angolo della poesia - A voi poeti", "poesia_a_voi_poeti.html", "Bottega Teatrale Cecconi - L'angolo della poesia", "POESIE POESIA DEDICHE DEDICA POETI POETA");
pages[21] = new Page("Bottega Teatrale Cecconi - L'angolo della poesia - A voi poeti", "poesia_a_voi_poeti.html", "Bottega Teatrale Cecconi - L'angolo della poesia", "POESIE POESIA DEDICHE DEDICA POETI POETA");
pages[22] = new Page("Bottega Teatrale Cecconi - L'angolo della poesia - A voi poeti", "poesia_a_voi_poeti.html", "Bottega Teatrale Cecconi - L'angolo della poesia", "POESIE POESIA DEDICHE DEDICA POETI POETA");


xlien[3] += '<A HREF="poesia_anime_gemelle.html" CLASS=menudyn3>Anime gemelle di Giuliana  </A>';
xlien[3] += '<A HREF="poesia_guastaferro.html" CLASS=menudyn3>Poesia di Giuseppe Guastaferro</A>';
xlien[3] += '<A HREF="poesia_madre.html" CLASS=menudyn3>A mia madre di Graziano Cecconi  </A>';
xlien[3] += '<A HREF="poesia_il_cieco.html" CLASS=menudyn3>Il cieco di piazza Aurora di Graziano Cecconi  </A>';
xlien[3] += '<A HREF="poesia_asinello.html" CLASS=menudyn3>Quel povero asinello di stoffa di Graziano Cecconi  </A>';
xlien[3] += '<A HREF="poesia_cullatore.html" CLASS=menudyn3>O viecchie cullatore di Graziano Cecconi  </A>';
xlien[3] += '<A HREF="poesia_angelo_della_notte.html" CLASS=menudyn3>L\' angelo della notte di Graziano Cecconi</A>';
*/






/*
 * String : indica l'output da visualizzare.
 * content: indica il content usato: 2 colonne, 3 colonne, 1 colonna.
 *
*/
function GoSearch(string,content) {
	
     var c = content;
	var output = "";
	output += "<font face=\"" + resultsFont + "\" size=\"2\">";
	output += "<span  class='intestazione_blocco'><center>" + resultsTitle + "</center></span>";
	
	
	if (string == defaultValue) {
           
		output += "<br><center><span class= 'intestazione_blocco2' > Errore: immetti una parola.</center></span> <br>";
	} else {
	      
		output += "Ecco i risulati della ricerca per la parola \"" + string + "\".<br><br>";
		
		var numofpages = 0;
		var tempoutput = "";
		
		for (i = 0; i < pages.length; i++) {
			if (pages[i].keywords.indexOf(string.toUpperCase()) !=-1) {
				numofpages++;
				tempoutput += "<hr><b>" + numofpages + ".</b>&nbsp;<a href=\"" + pages[i].url + "\">" + pages[i].title + "</a><br>";
				tempoutput += pages[i].description;
				tempoutput += "<br><br><font size=\"1\"><b><a href=\"" + pages[i].url + "\" target=\"_blank\">[ Apri in una nuova finestra ]</a></b></font><br>";
			}
		}
		
		if (numofpages > 0) {
			output += "La ricerca ha prodotto " + numofpages + " risultati.<br><br>";
			output += tempoutput;
			output += "<hr>";
		} else {
			output += "Spiacente, la ricerca non ha prodotto risultati.<br><br>";
		}
		
		// output += "<br><b>&nbsp;&nbsp;&nbsp;<a href=\"javascript:history.go(-1)\"> <img src=\"images/back.gif\" alt=\"Back\" border=0></a></b>";
		
	}
	output += "</font>";
	
	output +="<br><br><br><center>";
	 output +="<form name='searchForm2'  id='searchForm2' onSubmit='return false'>"+
            "<span class='intestazione_blocco3'>Cerca nel sito: &nbsp;</span>"+
            "<input type ='hidden' value='"+content+"' name='content' id='content'>"+
            "<input type=text size=22 maxlength=100 name=input2 value=\"immetti una sola parola\" class=miniFont"+
            "      onfocus=\"javascript:if(this.value==this.defaultValue){this.value='';}\""+
            "      onBlur=\"javascript:if(this.value== ''){this.value=this.defaultValue;}\">"+
            "&nbsp;&nbsp;"+
            "<a href=\"javascript:GoSearch(document.searchForm2.input2.value,document.searchForm2.content.value)\">"+
            "<img src=\"resources/images/icone/trova.png\" border=0>" +
            "</a>"+
            //"<input type='button' value='Cerca' onClick=\"GoSearch(document.searchForm2.input2.value)\" >"+
         "</form>";
	output +="</center>";

     var previousInnerHTML = new String();
   
    if (content == '1')
        {
          
           previousInnerHTML = document.getElementById('content').innerHTML;
           document.getElementById('content').innerHTML = output;

        }
      
  if (content == '3')
        {
        
          previousInnerHTML = document.getElementById('content3Colonne').innerHTML;
          document.getElementById('content3Colonne').innerHTML = output; 
        } 
      
}
	
function creaPagina() {
	
	var pagina = "<html>";
	/* HEAD - start  */
	pagina += "<head>";
	pagina += "<title>" + resultsTitle + "</title>";
	pagina += "<SCRIPT type=text/javascript>AddCSS('../css/Reset.css')</SCRIPT>";
	pagina += "<LINK href='css/Style_Celeste.css' type='text/css' rel='stylesheet'>";
	pagina += "<SCRIPT src='js/funzioni.js' type='text/javascript' charset=utf-8></SCRIPT>";
	pagina += "<SCRIPT src='scroller.js' type='text/javascript' charset=utf-8></SCRIPT>";
	pagina += "<!-- Aggiungo il Css che contiene proprietà dei Css3 per separare il CSS essenziale (validato) da quello non essenziale -->";
	pagina += "<SCRIPT src='addCSS.js' type='text/javascript'></SCRIPT>";
	pagina += "<SCRIPT type='text/javascript'>AddCSS('css/CSS3.css')</SCRIPT>";
	pagina += "<SCRIPT src='cerca.js' type='text/javascript'></SCRIPT>";
	pagina += "</head>"
	/* HEAD - end  */
	
	/* BODY -  start */
	pagina += "<BODY onload=loadImages()>";
	// DIv CONTAINER
	pagina += "<DIV id=container>";
	// DIV TOP
	pagina += "<DIV id=top>";
	pagina += "<TABLE width='100%' border=0><TBODY>";
	pagina += "<TR>";
	pagina += "<TD align=left>"+data_odierna+"</TD>";
	pagina += "<TD align=right width=450px>"+
	           "<A href='http://www.bottegateatralececconi.it/index.html'>"+ 
	           " <IMG height=15 alt=Home src='images/home.gif'  width=15 border=0> Home </A>"+
	           "<A  href='mailto:giulianaborzacchiello@hotmail.it'><IMG height=15 alt=Contattaci  src='images/contattaci.png' width=15 border=0>"+
	           " Contattaci </A></TD>";
	pagina += "<TD align='right' valign='middle'>"+
	           "<form name='searchForm'  id='searchForm' onSubmit=vreturn false'>"+
	           " <span class='miniFont'>Cerca nel sito:</span>"+
	           " <input type='text' size='22' maxlength='100' name='input' value ='immetti una sola parola' class='miniFont'>"+
	           " <input type='button' value='Cerca' onClick='GoSearch(document.searchForm.input.value,)' class='miniFont'> <!-- document.searchForm.input.value -->"+
	           " </form></TD>";
	pagina +="</TR>";  
	pagina +="</TBODY></TABLE>"+
	         "</DIV>";
	//  end DIV TOP
	
	// start div header
	pagina += "<DIV id=header>"+
	          "	<TABLE width='100%' border=0>"+
	          "		<TBODY>"+
	          "			<TR>"+
	          "				<TD align=left><IMG title='Bottega Teatrale Cecconi' height=134 alt='Bottega Teatrale Cecconi'  src='images/logo.png'   width=190> </TD>"+
	          "			</TR>"+
	          "		</TBODY>"+
	          "	</TABLE>"+
	          "</DIV>";
  // end div header
	
	// start div menu
	pagina += "<DIV id=menu align='center'>"+
	          "	...<SCRIPT src='js/menu.js' type='text/javascript'></SCRIPT>"+
						" </DIV>";
	// end div menu
	
	// start div content
	pagina += "<DIV id=content align='center'>";
	pagina += "<font face=\"" + resultsFont + "\" size=\"2\">";
	pagina += "<h2>" + resultsTitle + "</h2>";
	
	
	//pagina += "</DIV>";
	// end div content
	// end div container
	//pagina +="</DIV>";                    
	/* end BODY  */
	//pagina +="</BODY></HTML>";    
	
	return pagina;
  }
  
  
function Page(title, url, description, keywords) {
	
	if (title.length > 100) {
		title = title.substring(0, 100) + "...";
	}
	
	if (description.length > 100) {
		description = description.substring(0, 90) + "...";
	}
	this.title = title;
	this.url = url;
	this.description = description;
	this.keywords = keywords;
	return this;
	
}

/**
	* Questa funzione ritorna la data correnta formattata nel modo seguente : Oggi è Venerdì 12 Novembre 2010 
	*
	*/
function data_corrente2(){

    /*
     * Per estrarre i dati della data:
     * var hour        = now.getHours();
     * var minute      = now.getMinutes();
     * var second      = now.getSeconds();
     * var monthnumber = now.getMonth();
     * var monthday    = now.getDate();
     * var year        = now.getYear();
     *
     */
    if (now.getHours()< 10)
        ore= "0"+now.getHours()
    if (now.getMinutes()<10)
        minuti= "0"+now.getMinutes()
    data_odierna = "<span class='top_dinamico' >Oggi è "+ dayName[now.getDay()] + " " +
        now.getDate() + " " +
        monName[now.getMonth()] + " "+ year;
    return data_odierna;    
}




