var com_userAgent=navigator.userAgent.toLowerCase();
//linux
if(com_userAgent.indexOf("linux")!==-1){
document.write('<style>');
document.write('.com_v7-riga-top_off, .com_v7-riga-top_on{font-size:11px}');
document.write('.com_v7-riga-sotto-top,.com_v7-riga-sotto-top_on{font-size:10px}');
document.write('</style>');
}

if(com_userAgent.indexOf("safari")!==-1){
document.write('<style>');
document.write('#com_v7-click-cerca{top:145px;}');
document.write('#com_v7-dove{font-size:11px;}');
document.write('#com_v7-query{font-size:11px;}');
document.write('</style>');
}
//adv
function adv_flashDisp(flashobj)
{if (typeof(flashobj)!=='undefined'&&flashobj!==''){document.write(flashobj);}}

	
function getRightEncode(type,query)
{
	 //New
	var q;
	if (query===null)
	{
		query=document.search.query.value;	
	}
	if ((type==='web') || (type==='aziende') || (type==='img') || (type==='pagg'))
	{
		q=encodeURIComponent(query);
	}
	else
	{
		q=escape(query).replace(/\+/g,"%2b");
	}
	return q;
}

function com07e_controlla(){
	//q=escape(document.search.query.value).replace(/\+/g,"%2b");
	q=getRightEncode('web',null);  //New
	if (q === '') {
		location.href='http://arianna.libero.it/';
		return false;
	}
	else
	{
		return true;
	}
}

function getRightTarget(type,serverName,ariannaBase)
{
	if ((type==='web') || (type==='aziende'))
	{
		urlBase = serverName;
	}
	else
	{
		if (serverName.indexOf('sse12')>0)  //New
		{
			urlBase = ariannaBase;
		}
		else
		{
			urlBase = serverName;
		}
	}
	return urlBase;
}

function com07c_gotoUrl(type,e,isFromAriannaDomain,q,isSeat,onlyQuery,dv)
{
	/*
	Legenda parametri:
	type: tipo sezione richiesta (es:img, web, etc..)
	e: evento che ha generato la chiamata alla funzione
	isFromAriannaDomain: 0=La pagina che chiama questa funzione non appartiene
							al dominio arianna.libero.it (es: spazio.libero.it)
						1 =La pagina che chiama questa funzione appartiene
							al dominio arianna.libero.it
	q: query utente (completa di "dove" nel caso che la chiamata proviene da aziende)
	isSeat: indica se la pagina da cui si è chiamata la funzione appartiene alla sezione "aziende"
	onlyQuery: query utente semplice (nel senso che in caso di seat non contiene il dove)
	dv: valore di "dove" nel caso di "seat". Valore vuoto altrimenti.
	*/

	var u="";
	
	var ariannaBase = 'arianna.libero.it';

	//var urlBase = window.location.host;

	var urlBase = "";
	if (isFromAriannaDomain===1)
	{
		var serverName=window.location.host;
		serverName=serverName.substring(serverName.indexOf("-a")+1);
		urlBase = serverName;
	}
	else
	{
		urlBase = ariannaBase;
	}
	

	var position=-1;
	if (type === 'img')
	{
		//u=urlBase + '/mmedia/abin/img?from=3&query='+q;
		u=urlBase + '/mmedia/abin/img?from=3&query='+onlyQuery;
		position=1;
	}
	else if (type === 'web')
	{
		//u=urlBase + '/search/abin/integrata.cgi?regione=12&query='+q;
		u=urlBase + '/search/abin/integrata.cgi?regione=12&query='+onlyQuery;
		position=2;
	}
	else if (type === 'usenet')
	{
		//u=ariannaBase + '/usenet/cgi-bin/SearchNews.epl?KEYWORDS='+q+'&TABLES=RECENT_MSG';
		u=ariannaBase + '/usenet/cgi-bin/SearchNews.epl?KEYWORDS='+onlyQuery+'&TABLES=RECENT_MSG';
		position=3;
	}
	else if (type === 'pagb')
	{
		u='paginebianche.libero.it/execute.cgi?btt=0&tl=2&tr=101&tc=&cb=20&tq=2&qs='+q;
		position=4;
	}
	else if (type === 'tut')
	{
		u='tuttocitta.libero.it/tcolnew/index_libero.html#sez=1015&com='+q;
		position=5;
	}
	else if ((type === 'aziende') || (type === 'pagg'))
	{
		u=urlBase + '/search/abin/integrata.cgi?query='+onlyQuery;
		if (isSeat===1)
		{
			//La query è partita dalla sezione "aziende"
			u+='&regione=11&dv='+dv;
		}
		else
		{
			u+='&regione=110&dv='+dv;
			
		}
		position=6;
		if (onlyQuery=='')
		{
			q='';
		}
	}
	else if (type === 'ann')
	{
		u=urlBase + '/annunci/abin/annunci?advRegion=5&query='+onlyQuery+'&searchCity='+dv;
		position=7;
	}
	else if (type === 'video')
	{
		//u=urlBase + '/video/abin/video?from=3&query='+q;
		u=urlBase + '/video/abin/video?from=3&query='+onlyQuery;	
		position=8;
	}
	else if (type === 'lvideo')
	{
		u='video.libero.it/app/search/?idx=all&advRegion=3&q='+q;
		position=15;
	}
	else if (type === 'altre')
	{
		u=urlBase + '/allsearch.html?'+q;
		position=9;
	}
	else if (type === 'news')
	{
		//u=urlBase + '/news/search/abin/news?r=12&query='+q;
		u=urlBase + '/news/search/abin/news?r=12&query='+onlyQuery;
		position=10;
	}
	else if (type === 'blog')
	{
		//u=urlBase + '/blog/search/abin/blog?o=d&from=12&query='+q;
		u=urlBase + '/blog/search/abin/blog?o=d&from=12&query='+onlyQuery;
		position=12;
	}
	/*
	else if (type === 'shop')
	{
		u='shopping.libero.it/ctl/do/search?siteSearchQuery='+q+'&fromform=true';
		position=14;
	}
	*/
	else if (type === 'local')
	{
		//alert(dv);
		//if ( ( typeof(dv) === 'undefined' ) || ( dv.length <= 2) )
		if (  typeof(dv) === 'undefined' ) 
		{
			dv ="";
		}
		u='local.libero.it/search.phtml?cosa='+onlyQuery+'&unibox='+dv;
		position=14;
	}

	
	if (q === '')
	{
		if (e.target) { targ = e.target; }
		else if (e.srcElement) { targ = e.srcElement; }
		if (targ.nodeType === 3) 
		{
			targ = targ.parentNode; // defeat Safari bug
		}
		u = targ.href;    

	}
	clickServer(u,"HF1","13","s" + position);
	return false;
}
function com07c_go(type,e)
{
	q=getRightEncode(type,null);  //New
	return com07c_gotoUrl(type,e,1,q,0,q,"");
}

var o_AR=0;
function advovl_swapVisibility(elmIDToShow,elmIDToHide)
{
	if (!document.all) { return; }
	objToShow=document.all[elmIDToShow];
	objToHide=document.all[elmIDToHide];
	if (objToShow){objToShow.style.visibility="visible";}
	if (objToHide){objToHide.style.visibility="hidden";}
}


function com07b_view(elem)
{
	var versionPrefix="com_v7"; //Cambiare ogni volta che cambia la versioen dei css
	
	if (document.getElementById) 
	{
		ARMenu_a = document.getElementById(elem).style;
		ARMenu_a_link = document.getElementById(elem+"_link");
		if ( ARMenu_a.display === "block" ) 
		{ 
			ARMenu_a.display = "none"; 
			ARMenu_a_link.className = elem+"_link1";

			//advovl_showElement('select');
			//advovl_swapVisibility( versionPrefix + '-fonte', versionPrefix + '-fonte-text');
		}
		else 
		{ 
			//advovl_hideElement('select');
			//advovl_swapVisibility(versionPrefix + '-fonte-text', versionPrefix + '-fonte');

			ARMenu_a.display = "block";
			ARMenu_a_link.className = elem+"_link2";

			if( elem === (versionPrefix + "-AR")) { o_AR=1; }
		}
	}
}

function com07b_close(){
	var versionPrefix="com_v7"; //Cambiare ogni volta che cambia la versioen dei css

	if(o_AR===0)
	{
		if (document.getElementById) 
		{
			ARMenu_a = document.getElementById(versionPrefix + '-AR').style;
			ARMenu_a_link = document.getElementById(versionPrefix + "-AR_link");
			ARMenu_a.display = "none";
			ARMenu_a_link.className = versionPrefix + "-AR_link1";
		}
		//advovl_showElement('select');
		advovl_swapVisibility(versionPrefix + '-fonte',versionPrefix + '-fonte-text');
	}
	else
	{ 
		o_AR=0;
	}
}


function advovl_hideElement(elmID)
{
	if (!document.all) { return; }
	for (i=0;i<document.all.tags(elmID).length;i++)
	{	
		obj=document.all.tags(elmID)[i];
		if (!obj||!obj.offsetParent) { continue; }
		obj.style.visibility="hidden";
	}
}
function advovl_showElement(elmID)
{
	if (!document.all) { return; }
	for (i=0;i<document.all.tags(elmID).length; i++)
	{
		obj=document.all.tags(elmID)[i];
		if (!obj||!obj.offsetParent) { continue; }
		obj.style.visibility="visible";
	}
}
