function writeCookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );
document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}


function deleteCookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" - expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

//* spoiler *//
function toggleLayer(whichLayer)
{
	if (document.getElementById)
	{
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"none";
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"display";
	}
}


function insertcode(code){
	document.forms['postami'].news.value += code;
}

function MM_jumpMenu(targ,selObj,restore){
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;

}

function puliscitext(elm){
	if (!elm.base) elm.base = elm.value
	if (elm.value == elm.base) elm.value = "";
	else if (elm.value == "") elm.value = elm.base;

}

function CheckAll(checkWhat) {
  var inputs = document.getElementsByTagName("input");
  for(index = 0; index < inputs.length; index++){
    if(inputs[index].id == checkWhat)
      if(inputs[index].checked == 0){
        inputs[index].checked = 1;
      }
      else if(inputs[index].checked == 1){
        inputs[index].checked = 0;
      }
  }
}

function search_user(code){
	if (document.forms['postami'].trovato_user.value != "") document.forms['postami'].trovato_user.value = "";
	if (document.forms['postami'].trovato_users.value != "") document.forms['postami'].trovato_users.value = "";
	//NEW INSERT DATE
	document.forms['postami'].trovato_user.value += code;
	document.forms['postami'].trovato_users.value += code;
	//DISABLE TASTE
	document.forms['postami'].trovato_user.disabled = true;
	//EDIT MITTENTE VISIBLE
	var style2 = document.getElementById('e_d').style;
	style2.display = style2.display? "":"visible";
}

function GOedit(){
	//ACTIVE TASTE
	document.forms['postami'].trovato_user.disabled = false;

	if (document.forms['postami'].trovato_user.value != "") document.forms['postami'].trovato_user.value = "";
	if (document.forms['postami'].trovato_users.value != "") document.forms['postami'].trovato_users.value = "";

	//EDIT MITTENTE NoNE VISIBLE
	var style2 = document.getElementById('e_d').style;
	style2.display = style2.display? "":"none";
}

function membri_search(url){
newin = window.open(url,'Titolo','scrollbars=yes,resizable=yes, width=550,height=400,status=no,location=no,toolbar=no');
}

function helpline(help) {

//Aiuti
b_help = "Inserisci Testo in Grassetto";
i_help = "Inserisci Testo in Corsivo";
u_help = "Inserisci Testo Sottolineato";
lnk_help = "Inserisci un Collegamento";
img_help = "Inserisci Immagine";
spoiler_help = "Inserisci Spoiler";
color_help = "Inserisci Tag Colore";

	window.document.getElementById('help_me').innerHTML=eval(help + "_help");
}

function mm_tecno(){
	if (document.forms['search'].ricerca.value != "Personaggi" && document.forms['search'].ricerca.value != "Manga") {
		document.forms['search'].language.disabled = false;
	}
	else {
		document.forms['search'].language.disabled = true;
	}
}

function aggiungi(opt){
	if(opt == "Titolo")
		document.getElementById("language").options[3] = new Option("ENG");
	else
		document.getElementById("language").removeChild(document.getElementById("language").options[3]);
}


// Precarica nella cache le immagini di rollover per la home page
function createImages()
{
	(new Image(89,27)).src = "home_file/home_img/home_hover.jpg";
	(new Image(94,27)).src = "home_file/home_img/forum_hover.jpg";
	(new Image(62,27)).src = "home_file/home_img/lab_hover.jpg";
	(new Image(81,27)).src = "home_file/home_img/chat_hover.jpg";
	(new Image(105,27)).src = "home_file/home_img/gallery_hover.jpg";
}
