function namedlink(theform, thetype)
{
	link_text_prompt = "Inserisci il testo del Link (ad es. Clicca qui)";
	link_url_prompt = "Inserisci la URL del Link";
	link_email_prompt = "Inserisci l\'indirizzo email da Linkare";
	linktext = prompt(link_text_prompt,"");

	var prompttext;
	if (thetype == "URL")
	{
		prompt_text = link_url_prompt;
		prompt_contents = "http://";
		plus = "";
	}
	else
	{
		prompt_text = link_email_prompt;
		prompt_contents = "";
		plus = "mailto:";
	}
	linkurl = prompt(prompt_text,prompt_contents);
	if ((linkurl != null) && (linkurl != "") && (linkurl != "http://"))
	{
		if ((linktext != null) && (linktext != ""))
		{
			form.testo.value += "[url="+plus+linkurl+"]"+linktext+"[/url]";
		}
		else
		{
			form.testo.value += "[url="+plus+linkurl+"]"+linkurl+"[/url]";
		}
	}
	form.testo.focus();
}

function dolist(theform)
{
	list_type_prompt = "Che tipo di lista vuoi? Metti '1' per una lista numerica, metti 'a' per una lista alfabetica, oppure lascia bianco per una lista con i punti.";
	list_item_prompt = "Metti il valore della lista.\nLascia il campo vuoi, oppure prima 'Annulla' per completare la lista.";

	listtype = prompt(list_type_prompt, "");

	if ((listtype == "a") || (listtype == "1")) {
		thelist = "[list="+listtype+"]\n";
		listend = "[/list="+listtype+"] ";
		}
	else {
		thelist = "[list]\n";
		listend = "[/list] ";
		}
	listentry = "initial";
	while ((listentry != "") && (listentry != null)) {
		listentry = prompt(list_item_prompt, "");
		if ((listentry != "") && (listentry != null))
			thelist = thelist+"[*]"+listentry+"\n";
		}
	theform.testo.value += thelist+listend;
	theform.testo.focus();
}

function addtag(what, view_text)
{
	prompt_text = ""+view_text+"";
	prompt_contents = "";
	tag = prompt(prompt_text,prompt_contents);
	if ((tag != null) && (tag != ""))
	{
		form.testo.value += "["+what+"]"+tag+"[/"+what+"]";
		form.testo.focus();
	}
}

function vote_dir_link(id)
{
	var votechoose = document.getElementById('votechoose_'+id);
	var votelink = document.getElementById('votelink_'+id);
	var voteoutput = '';

	for(i = 1; i < 6; i++)
	{
		voteoutput += '<a href="vote?id='+id+'&vote='+i+'"><strong>'+i+'</strong></a> ';
	}
	
	if(! votechoose) votechoose = eval('document.all.votechoose_'+id);
	if(! votelink) votelink = eval('document.all.votelink_'+id);

	if(votechoose.style.display == 'block')
	{
		votechoose.style.display='none';
		votelink.innerHTML = 'Vota';
	}
	else
	{
		votechoose.style.display='block';
		votechoose.innerHTML = voteoutput;
		votelink.innerHTML = 'Non votare';
	}
}

function correlated_article(correlatedoutput)
{
	var correlatedarticle = document.getElementById('correlated_article');
	var correlatedlink = document.getElementById('correlated_link');

	if(correlatedarticle.style.display == 'block')
	{
		correlatedarticle.style.display = 'none';
		correlatedlink.innerHTML = 'Articoli correlati';
	}
	else
	{
		correlatedarticle.style.display = 'block';
		correlatedarticle.style.padding = '5px';
		correlatedarticle.style.border = 'solid 1px #3399CC';
		correlatedarticle.innerHTML = correlatedoutput;
		correlatedlink.innerHTML = 'Articoli correlati (Chiudi)<br /><br />';
	}
}

function article_preview()
{
   	window.open('', 'preview', 'toolbar=0, location=0, status=0, menubar=0, scrollbars=1, resizable=1, width=600, height=500');

   	document.form.action = '/user.html/write-article?preview=true';	
	document.form.testo = "preview";
	document.form.submit();
}

function clikker(a, b)
{
	if (a.style.display =='')
	{
		a.style.display = 'none';
		b.src='/img/ingrandisci.gif';
	}
	else
	{
		a.style.display='';
		b.src='/img/chiudi.gif';
	}
}

function alert_msg(msg)
{
	alert(msg);
}

/*
function select_jump_to(form_name, field_name, url, null_value)
{
	var my_to = form_name.field_name.selectedIndex;
	if (my_to == null_value)
	{
		alert("Attenzione!\nNon è possibile inserire il proprio sito nella directory principale!");
	}
	else
	{
		url_to = form_name.field_name.options[my_to].value;
		window.location.assign(url_to);
	}
}
*/
function jump_to_location(form)
{ 
	var my_to = jump_menu.id.selectedIndex;
	if (my_to == "top")
	{
		alert("Attenzione!\nNon è possibile inserire il proprio sito nella directory principale!");
	}
	else
	{
		cururl = jump_menu.id.options[my_to].value;
		window.location.assign(cururl);
	}
}

function show_and_hide(one, two)
{
	if(document.getElementById)
	{
		doc_1=document.getElementById(one);
		doc_2=document.getElementById(two);
		if(doc_1.style.display == "none")
		{
			doc_1.style.display = "block";
			doc_2.style.display = "none";
		}
		else
		{
			doc_1.style.display = "none";
			doc_2.style.display = "block";
		}
	}
}

function lyrics_info(info_output)
{
	var info_doc = document.getElementById('div_info');

	if(info_doc.style.display == 'block')
	{
		info_doc.style.display = 'none';
		info_doc.innerHTML = '';
	}
	else
	{
		info_doc.style.display = 'block';
		info_doc.style.background = 'url(/img/lyrics/infobg.gif)';
		info_doc.style.width = '300px';
		info_doc.style.height = '180px';
		info_doc.style.padding = '5px';
		info_doc.innerHTML = info_output;
	}
}
