//<!--
	
	
	
	
	function link(url, target)
	{
		if(target == 1)	window.open(url, "", "");
		else			document.location.href = url;
	}
	
	function openpopup(pagina,nome,w,h,sb)
	{
		if(document.all)
		{
			var ax = window.screenLeft;
			var ay = window.screenTop;
			var aw = window.document.body.offsetWidth;
			var ah = window.document.body.offsetHeight;
		}
		else
		{
			var ax = window.screenX;
			var ay = window.screenY;
			var aw = window.outerWidth;
			var ah = window.outerHeight;
		}
		if(!sb)
			sb = 'no';
		x=ax+Math.round((aw-w)/2);
		y=ay+Math.round((ah-h)/2);
		tl='top='+y+',left='+x+',';
		window.open(pagina,nome,tl+'toolbar=no,status=no,resizable=1,scrollbars='+sb+',width='+w+',height='+h);
	}
	
	function indirizzoEmailValido(indirizzo)
	{
		if (window.RegExp)
		{
			var nonvalido = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
			var valido = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
			var regnv = new RegExp(nonvalido);
			var regv = new RegExp(valido);
			if (!regnv.test(indirizzo) && regv.test(indirizzo))
			{
				return true;
				return false;
			}	
			else
			{
				if(indirizzo.indexOf("@") >= 0)
				{
					return true;
					return false;
				}
			}
		}
	}
	
	function sendSearch(host,typeOfSearch, modeOfSearch)
	{
		if(modeOfSearch != "fast")
		{
			if(document.searchAdvanced.search_type[0].checked)
				mode = "one";
			else if(document.searchAdvanced.search_type[1].checked)
				mode = "all";
			else if(document.searchAdvanced.search_type[2].checked)
				mode = "exact";
		}
		if(typeOfSearch == "articoli")
		{
			if(modeOfSearch == "fast") 
			this.location = host+"ricerca_articoli.php?search_key="+escape(document.search.search_key.value)+"&type=fast";
			else
			{
				this.location = host+"ricerca_articoli.php?search_key="+escape(document.searchAdvanced.search_key.value)+"&type=advanced&mode="+mode;
			}
		}
		if(typeOfSearch == "aziende")
		{
			if(modeOfSearch == "fast")
			this.location = host+"ricerca_aziende.php?search_key="+escape(document.search.search_key.value)+"&type=fast";
			else
			{
				this.location = host+"ricerca_aziende.php?search_key="+escape(document.searchAdvanced.search_key.value)+"&type=advanced&mode="+mode; 			
			}
		}
	}
	
	function checkSearch(host,typeOfSearch, modeOfSearch)
	{
	
		if (modeOfSearch == "fast")
		{
			if (document.search.search_key.value.length < 3)
			{
				alert("Devi inserire almeno 3 caratteri nel campo di ricerca.");
				document.search.search_key.focus();
				return void(0);
			}
			else
				sendSearch(host,typeOfSearch, "fast");
		}
		else
		{
			if (document.searchAdvanced.search_key.value.length < 3)
			{
				alert("Devi inserire almeno 3 caratteri nel campo di ricerca.");
				document.searchAdvanced.search_key.focus();	    
				return void(0);
			}
			else
				sendSearch(host, typeOfSearch, "advanced");
		}
	}
	
	
	function sendSearchV2(typeOfSearch, modeOfSearch)
	{
		if(modeOfSearch != "fast")
		{
			if(document.searchAdvanced.search_type[0].checked)
				mode = "one";
			else if(document.searchAdvanced.search_type[1].checked)
				mode = "all";
			else if(document.searchAdvanced.search_type[2].checked)
				mode = "exact";
		}
		if(typeOfSearch == "articoli")
		{
			if(modeOfSearch == "fast") 
			this.location = "ricerca_articoli.php?search_key="+escape(document.search.search_key.value)+"&type=fast";
			else
			{
				this.location = "ricerca_articoli.php?search_key="+escape(document.searchAdvanced.search_key.value)+"&type=advanced&mode="+mode;
			}
		}
		if(typeOfSearch == "aziende")
		{
			if(modeOfSearch == "fast")
			this.location = "ricerca_aziende.php?search_key="+escape(document.search.search_key.value)+"&type=fast";
			else
			{
				this.location = "ricerca_aziende.php?search_key="+escape(document.searchAdvanced.search_key.value)+"&type=advanced&mode="+mode; 			
			}
		}
	}
	
	function checkSearchV2(host,typeOfSearch, modeOfSearch)
	{
		if (modeOfSearch == "fast")
		{
			if (document.search.search_key.value.length < 3)
			{
				alert("Devi inserire almeno 3 caratteri nel campo di ricerca.");
				document.search.search_key.focus();
				return void(0);
			}
			else
				sendSearchV2(typeOfSearch, "fast");
		}
		else
		{
			if (document.searchAdvanced.search_key.value.length < 3)
			{
				alert("Devi inserire almeno 3 caratteri nel campo di ricerca.");
				document.searchAdvanced.search_key.focus();	    
				return void(0);
			}
			else
				sendSearchV2(typeOfSearch, "advanced");
		}
	}
	
	$(document).ready(function(){
		if($('#lista_suggerimenti').length != 0){
			lista_suggerimenti();
		}
		
		jQuery('#carousel_articoli').jcarousel({
  		    auto: 4,
  		    scroll: 1,
            wrap: 'last'
		});
				    	
	});
	
	var tempo;
	function lista_suggerimenti(){
		var testo = $("#descrizione").val();
		if (testo.length > 3) {
			clearTimeout(tempo);
			tempo = setTimeout(function(){			
				$.ajax({
				   type: "POST",
				   url: "/suggerimenti.php",
				   dataType: "html",
				   data: {testo: testo, azione: "lista"},
				   cache: false,
				   //scriptCharset: 'iso-8859-1',			   
				   beforeSend: function(){		   
			   			$("#lista_suggerimenti").html('<font color="#CC0000">Caricamento dei percorsi di interesse in corso...</font>');
			   	   },
				   success: function(data, textStatus){
						$("#lista_suggerimenti").html(data);
				   },
			   	   async: false
				});
			}, 1000);
		} else {
			$("#lista_suggerimenti").html('');
		}
		return false;	
	}
	
	function aggiungi_categoria(sezione_id,sottosezione_id,nome_categoria) {	
		var classe = $("#link_"+sezione_id+"_"+sottosezione_id).attr("class");
		var azione = '';
		
		if(classe == 'link_semplice'){
			azione = 'inserisci';
			$(".suggerimenti_cat a").attr("class","link_semplice");
			$("#link_"+sezione_id+"_"+sottosezione_id).attr("class","link_semplice_sele");
		}		
		else{
			azione = 'elimina';
			$("#link_"+sezione_id+"_"+sottosezione_id).attr("class","link_semplice");
		}
		
		$.ajax({
			   type: "POST",
			   url: "/suggerimenti.php",
			   data: { azione:"vis", operazione: azione, sezione_id:sezione_id, sottosezione_id:sottosezione_id},
			   dataType: "html",
			   cache: false,
			   success: function(data, textStatus){
			   		//alert(data);
			   },
			   async: false
		});

	    return false;
	}
	
	function shopAdvancedDisplay()
	{
		document.getElementById('shopAdvanced').style.display = document.getElementById('shopAdvanced').style.display == 'none' ? 'block' : 'none';
		document.getElementById('daEspandere').value = document.getElementById('shopAdvanced').style.display == 'none'
				? 'Ricerca avanzata'
				: 'Ricerca normale';
	}
	
	function shopClick(cid, eshopid, pid, topcategory, subcategory, keyword)
	{
		var catid = 0;
		if(cid != "")
		{
			var url = "http://www.clickstore.com/webservice/ct.php?cid="+ cid +"&amp;ip=<__($obj->ip)/>&amp;sid=<__($obj->sid)/>";
			if(topcategory)	catid = topcategory;
			if(subcategory)	catid = subcategory;
			if(catid)	url += "&amp;catid="+ catid;
			if(keyword)	url += "&amp;keyword="+ keyword;
			url += "&amp;eshopid="+ eshopid;
			if(pid) url += "&amp;pid="+ pid;
			
			document.images.shopImg.src = url;
		}
	}
	
	function clicca(azienda)
		{
			if(azienda != "")
			{
				var url = "<__(WEBSERVICE)/>click_azienda.php?dominio=<__(PORTALE)/>&amp;azienda="+azienda+"&amp;sezione=<__($obj->sezione)/>&amp;sottosezione=<__($obj->sottosezione)/>";
				document.images.intro.src = url;
			}
		}
	
	

// -->
