noFrames();

//istanza oggetti comuni
document.dom = new Dom();
document.browser = new BrowserDetector();
document.locus = new Locus();
document.tabs = new tabManager();

window.onload = runtime;

//var dhtmenu = new DHTMenu();

//configurazione dhtmenu
//dhtmenu.setCssPath("/_css/dhtml_menuvert.css", "menu");		//imposta i css da utilizzare per gestire il menù
//dhtmenu.setLinkClass("selected");							//classe da applicare al link cliccato
//dhtmenu.enablePath("/*", "menu");							//elenco dei path abilitati al menù dinamico
//dhtmenu.init();


//configurazione di locus
document.locus.setParam("separator", " / ");
document.locus.setParam("homePageName", "prodottitipici.provincia.cuneo.it");
document.locus.setParam("dirIndexName", "index.jsp");

//document.locus.dictionary("informazioni", "sportello informazioni");

//configurazione di tabManager
document.tabs.dafaultClass("current");

document.tabs.addTab("prodotti", "/prodotti/index.jsp");
document.tabs.addTab("formaggi", "/prodotti/formaggi/index.jsp");
document.tabs.addTab("ortofrutticoli", "/prodotti/ortofrutta/index.jsp");
document.tabs.addTab("carni", "/prodotti/carni/index.jsp");
document.tabs.addTab("dolci", "/prodotti/dolci/index.jsp");
document.tabs.addTab("vini", "/prodotti/vini/index.jsp");
document.tabs.addTab("altri", "/prodotti/altri/index.jsp");

document.tabs.addTab("prodotti", "/prodotti/[a-zA-Z0-9]+/[a-zA-Z0-9]+/index.jsp");
document.tabs.addTab("ricette", "/prodotti*/ricette/index.jsp");
document.tabs.addTab("manifestazioni", "/prodotti*/manifestazioni/index.jsp");
document.tabs.addTab("aziende", "/prodotti*/aziende/index.jsp");
document.tabs.addTab("foto", "/prodotti*/foto/index.jsp");

document.tabs.addTab("vostrefoto", "/foto/index.jsp");
document.tabs.addTab("inviafoto", "/foto/inviafoto/index.jsp");
document.tabs.addTab("ricette", "/ricette/index.jsp");
document.tabs.addTab("inviaricetta", "/ricette/inviaricetta/index.jsp");
document.tabs.addTab("vostrericette", "/ricette/vostrericette/*");

function runtime()
{
	//if (document.browser.ie55 || document.browser.ie6) css3();
	
	
	/*
		il seguente codice abilita la gestione dinamica di tab e locus.
		ho spostato le due righe direttamente sotto i div interessati per evitare di attendere l'onload
		
		document.tabs.execute();
		document.locus.set('navbar');
	*/
}

function css3()
{
	
	var anchorFilter = new AttributeEndWithFilter("href", "[a-zA-z0-9]+\#");
	var pdfFilter = new AttributeEndWithFilter("href", ".pdf");
	var rssFilter = new AttributeEndWithFilter("href", ".xml");
	var docFilter = new AttributeEndWithFilter("href", ".doc");
	var xlsFilter = new AttributeEndWithFilter("href", ".xls");
	var mp3Filter = new AttributeEndWithFilter("href", ".mp3");
	var emailFilter = new AttributeStartWithFilter("href", "mailto");
	var blankFilter = new AttributeEqualsFilter("target", "_blank");
	var links = document.dom.getChildElements("a", document.getElementById("testo").firstChild, true);
	
	//css3 generico
	links = document.dom.setClass(links, "pdf", pdfFilter);
	links = document.dom.setClass(links, "doc", docFilter);
	links = document.dom.setClass(links, "xls", xlsFilter);
	links = document.dom.setClass(links, "anchor", anchorFilter);
	links = document.dom.setClass(links, "email", emailFilter);
	links = document.dom.setClass(links, "mp3", mp3Filter);
	links = document.dom.setClass(links, "blank", blankFilter);
	document.dom.setClass(links, "rss",  rssFilter);
	document.dom.setClass(document.getElementById("tsAnchor"), "top", null);
	
	//css3 per indici a tendina se presenti
	//if (document.getElementById("indice"))
	//{
	//	var folderFilter = new AttributeEqualsFilter("href", "javascript:foo()");
	//	links = document.dom.getChildElements("a", document.getElementById("indice").firstChild, true);
	//	document.dom.setClass(links, "folder",  folderFilter);
	//}
}

function clearValue()
{
	this.value = "";
}

//function foo(){}

function noFrames()
{
	//eliminazione dei frames
	var pattern = /asp.readspeaker.net/gi;
	if (top.frames.length >= 2 && !pattern.test(top.location))
	{
		top.location = this.location;
	}
}