/* Require for: all files */
/* Function: Show hidden blocks */
function setSpiegazione(spiegazione){document.getElementById("showMe").style.display="block";document.getElementById("con").innerHTML=spiegazione}
function removeSpiegazione(){document.getElementById("con").innerHTML="";document.getElementById("showMe").style.display="none"}
function spiegazione (elemento) {
	switch (elemento) {
		case 'sendimg':
			setSpiegazione ("SendIMG e' un servizio creato da InformArts che permette di uppare con tranquillita' le proprie immagini.");
			break;
		case 'ret':
			setSpiegazione ("RET (sigla di Roberto's Encryption Tool) &egrave; un servizio che permette di criptare e decriptare in Base64, Codici ASCII, Binario, Hex e molto altro.");
			break;
		case 'nopaste':
			setSpiegazione ("Il NoPaste di InformArts serve per poter colorare i propri codici in modo da far comprendere meglio all'utente che visiona il codice. Il NoPaste supporta numerosi linguaggi di programmazione come il C.");
			break;
		case 'prc':
			setSpiegazione ("PRC (sigla di PageRank Checker) e' un servizio offerto da InformArts che permette di controllare in modo semplice il proprio pagerank. Inoltre offre banner da inserire nel proprio sito.");
			break;
		case 'mg':
			setSpiegazione ("L'InformArts MegaGenerator e' un servizio creato precedentemente da Bronsa, successivamente modificato da InformArts. Permette di generare link premium per MegaUpload e MegaVideo gratuitamente in modo totalmente legale.");
			break;
	}
}

/* Require for: single.php */
/* Function: Send a comment */
function sendComment (nickname, site, message, post, name, response) {
	hash = "1a18981bb15b25ed6f28108a79ecd22d";
	if (!site) site = "NULL";
	if (!nickname || !message || !response) { alert ("Non hai inserito tutti i campi necessari!"); return false; }
	$().ajaxSend (
		function (a,b) {
			$("div#loading").hide ();
			$("div#loading").html ("<img src=\"images/loading.gif\" alt=\"Caricamento..\" title=\"Caricamento..\" />");
			$("div#loading").fadeIn ("slow");
		}
	);
	$.post ("./post-"+name+"-"+post+".html", {name: nickname, site: site, message: message, post: post, ajax: 1, hash: hash, response: response}, function (data) {
		if (data.success == 0 && data.html == "NULL") {
			alert ("Impossibile inviare il commento, è stato riscontrato il seguente errore: " + data.message);
			$("div#loading").fadeOut ("slow");
		} else if (data.success == 1 && data.html != "NULL") {
			$("div#loading").fadeOut ("slow");
			$("div#loading").text (data.message);
			$("div#loading").fadeIn ("slow");
			$('html,body').animate({scrollTop: 1200}, 1000);
			setTimeout ("$('div#loading').fadeOut('slow')", 5000);
			document.getElementById("comm").innerHTML = document.getElementById("comm").innerHTML.replace ("Nessun commento!", "");
			$("div#comm").append ("<div id='newcomment"+data.id+"' style='display:none'>"+data.html+"</div>");
			divId = "newcomment"+data.id;
			$("div#"+divId).fadeIn ("slow");
		}
	}, "json");
	
}

function checkPR (site, post) {
	$().ajaxSend (
		function (a,b) {
			$("div#loading").hide ();
			$("div#loading").html ("<img src=\"images/loading.gif\" alt=\"Caricamento..\" title=\"Caricamento..\" />");
			$("div#loading").fadeIn ("slow");
		}
	);
		$.post ("./pagerank.php", {siteToCheck: site, ajax: 1}, function (data) {
			$("div#loading").fadeOut ("slow");
			$("div#loadObject").html(data);
		});
	
}

function premiumLink (links) {
	$().ajaxSend (
		function (a, b) {
			$("div#loading").hide ();
			$("div#tlinks").hide ();
			$("div#loading").html ("<img src=\"images/loading.gif\" alt=\"Caricamento..\" title=\"Caricamento..\" />");
			$("div#loading").fadeIn ("slow");
		}
	);
	$.post ("./megagenerator/index.php", {links: links, ajax: 1}, function (data) {
		if (!data.success && data.html == "NULL") {
			$("div#loading").fadeOut ("slow");
			$("div#loading").text (data.message);
			$("div#loading").fadeIn ("slow");
			setTimeout ("$('div#loading').fadeOut('slow')", 5000);
		} else if (data.success && data.html != "NULL") {
			$("div#loading").fadeOut ("slow");
			$("div#loading").text (data.message);
			$("div#loading").fadeIn ("slow");
			setTimeout ("$('div#loading').fadeOut('slow')", 5000);
			$("div#tlinks").hide ();
			$("div#tlinks").html (data.html);
			$("div#tlinks").fadeIn ("slow");
		}
	}, "json");
}
	
/*
function sendComment (nickname, site, message, post, name) {
	debug = 1;
	if (!site) {site = "NULL";}
	if (!nickname || !message) {
		alert ("Non hai riempito tutti i campi necessari");
		return false;
	}
	requestReturn ("./post-"+name+"-"+post+".html", "post", "loading", "name="+escape(nickname)+"&site="+escape(site)+"&message="+escape(message)+"&post="+post+"&ajax=1");
	x=setInterval ('if (document.getElementById("loading").innerHTML.indexOf("img") == -1) {d=document.getElementById("loading").innerHTML; if (d.indexOf ("span") != -1) {alert("Commento inserito con successo");if(document.getElementById("comm").innerHTML.indexOf("Nessun commento!")!=-1){document.getElementById("comm").innerHTML=document.getElementById("comm").innerHTML.replace("<br /><br />A","A");}document.getElementById("comm").innerHTML=document.getElementById("comm").innerHTML.replace("Nessun commento!","");document.getElementById("comm").innerHTML=document.getElementById("comm").innerHTML+d;document.getElementById("name").value="";document.getElementById("site").value="";document.getElementById("message").value="";}else if (d.indexOf("div")==-1&&d.indexOf("img")==-1){alert(d);}clearInterval(x);}', 5);
}
*/
/* Require for: administration files */
/* Function: Add a string to textbox */

function add (str) {
	document.getElementById("tbox").value = document.getElementById("tbox").value + str;
	document.getElementById("tbox").focus();
	return true;
}

function insertLink () {
	name=prompt("Inserisci il titolo del link (lascia vuoto se vuoi il link come collegamento)"); 
	link_=prompt("Inserisci il link");
	if (!link_) {return false;} if (!name){name=link_;}
	add ("<a href='"+link_+"'>"+name+"</a>");
	return true;
}

function insertImage () {
	title=prompt ("Inserisci il titolo dell'immagine (puoi lasciare vuoto)");
	url=prompt ("Inserisci il link dell'immagine");
	if (!url) return false;
	add ("<img src=\""+url+"\" title=\""+title+"\" alt=\""+title+"\" />");
	return true;
}

function checkTextBox () {

		setInterval ("if(document.getElementById('tbox').value.indexOf('[sep]')!=-1){document.getElementById('long').disabled='true';}else{document.getElementById('long').disabled='';}",50);
		
}

function showSubMenu (menuId) {
	document.getElementById(menuId).style.display = 'block';
}

function hideSubMenu (menuId) {
	document.getElementById(menuId).style.display = 'none';
}
