function sharepage(){
var urlpa=window.location;
if(window.location.href.indexOf("#") != -1){
	var urlopyui = urlpa.href.split('#');
	var urltyho='#'+urlopyui[1];
	urlpa=urlpa.href.replace(urltyho,"");
}
var titpa=document.title;
document.getElementById('share').innerHTML='Condividi questa notizia:<br><table width="200" border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; border-spacing: 0 0;"><tr><td align="right"><a href="http://www.facebook.com/share.php?u='+urlpa+'" title="condividi su Facebook" target="new"><img src="../images/aggiungi_facebook.png" title="condividi su Facebook" alt="condividi su Facebook" border="0" style="margin-top:4px"></a></td><td align="center" width="50"><a href="http://twitter.com/intent/tweet?status='+titpa+'%3A+'+urlpa+'" title="condividi su Twitter" target="new"><img src="../images/aggiungi_twitter.png" title="condividi su Twitter" alt="condividi su Twitter" border="0" style="margin-top:4px"></a></td><td align="left"><a href="http://www.google.com/reader/link?url='+urlpa+'&title='+titpa+'" title="condividi su Google Buzz" target="new"><img src="../images/aggiungi_google.png" title="condividi su Google Buzz" alt="condividi su Google Buzz" border="0" style="margin-top:4px"></a></td></tr></table>';
}
function comment(vocina)
{
var page = "http://www.bracegirdle.it/Arda/comment.php?comment_id=" + vocina + "&comment_popup=true";
popwin = window.open(page,"","width=460,height=500,left=175,top=30,scrollbars,resizable")
popwin.focus();
}
function fronte()
{
document.getElementById('stand').innerHTML='<img src="../images/children_of_hurin.png" class="icentr" title="fronte">';
}
function profilo()
{
document.getElementById('stand').innerHTML='<img src="../images/children_of_hurin3.jpg" class="icentr" title="profilo">';
}
function interno()
{
document.getElementById('stand').innerHTML='<a href="../images/children_of_hurin4b.jpg" rel="lightbox" title="interno The Children of H&#250;rin"><img src="../images/children_of_hurin4.jpg" class="icentr" alt="interno The Children of H&#250;rin" border="0"></a>';
}
function faccine()
{
if (document.getElementById('faccine').style.display == "none")
		{
		document.getElementById('faccine').style.display = "block";
    }
else {
     document.getElementById('faccine').style.display = "none";
		 }
}
function smile(faccina)
{
  var mess = document.form.comment;
  //Internet Explorer
  if (document.selection) {
		mess.focus();
		sel = document.selection.createRange();
		sel.text = faccina;
		mess.focus();
  }
  //Firefox, Netscape
  else if (mess.selectionStart || mess.selectionStart == "0") {
    var startPos = mess.selectionStart;
    var endPos = mess.selectionEnd;
    var chaine = mess.value;
    mess.value = chaine.substring(0, startPos) + faccina + chaine.substring(endPos, chaine.length);
	} else {
		mess.value += faccina;
	}

mess.focus();
}
function caratteri()
{
if (document.getElementById('caratteri').style.display == "none")
		{
		document.getElementById('caratteri').style.display = "block";
    }
else {
     document.getElementById('caratteri').style.display = "none";
		 }
}
function carattere(car)
{
  var mess = document.form.comment;
  //Internet Explorer
  if (document.selection) {
		mess.focus();
		sel = document.selection.createRange();
		sel.text = car;
		mess.focus();
  }
  //Firefox, Netscape
  else if (mess.selectionStart || mess.selectionStart == "0") {
    var startPos = mess.selectionStart;
    var endPos = mess.selectionEnd;
    var chaine = mess.value;
    mess.value = chaine.substring(0, startPos) + car + chaine.substring(endPos, chaine.length);
	} else {
		mess.value += car;
	}

mess.focus();
}
function form_grassetto()
{
sel = document.selection.createRange();
		if (sel.text.length > 0) {
			sel.text = "<strong>" + sel.text + "</strong>";
		}
		else {
			alert('Seleziona il testo da rendere grassetto\ne clicca questo pulsante :-)');
		}
var text_area = document.form.comment;
text_area.focus();
}
function form_link(tag1,tag2) {
  var mess = document.form.comment;
  //Internet Explorer
  if (document.selection) {
		sel = document.selection.createRange();
		if (sel.text.length > 0) {
			var testo=sel.text;
			var chiedi2=window.prompt("Inserire l`indirizzo a cui collegare il testo: "+testo,"http://");
			if (chiedi2==null){
				  return;
			}
			else {
			     sel.text = tag1 + chiedi2 + '[[/URL]]' + sel.text + tag2;
			}
		}
		else {
			alert('Seleziona il testo da linkare\ne clicca questo pulsante :-)');
			return;
		}
		var text_area = document.form.comment;
		text_area.focus();
  }
  //Firefox, Netscape
  else if (mess.selectionStart || mess.selectionStart == "0") {
    var startPos = mess.selectionStart;
    var endPos = mess.selectionEnd;
    var chaine = mess.value;
    var str = chaine.substring( mess.selectionStart, mess.selectionEnd );

		if	(str.length == 0) {
				var chiedi1=window.prompt("Inserire il testo da linkare","");
					if (chiedi1==null){
				 		 return;
					}
					else {
							var chiedi2=window.prompt("Inserire l`indirizzo a cui collegare il testo: "+chiedi1,"http://");
									if (chiedi2==null){
				  						return;
									}
									else {
											 mess.value = chaine.substring(0, startPos) + tag1 + chiedi2 + '[[/URL]]' + chiedi1 + tag2 + chaine.substring(endPos, chaine.length);
									}
					}
		}
		else {
					var testo=str;
					var chiedi2=window.prompt("Inserire l`indirizzo a cui collegare il testo: "+testo,"http://");
							if (chiedi2==null){
				  				return;
							}
							else {
										mess.value = chaine.substring(0, startPos) + tag1 + chiedi2 + '[[/URL]]' + str + tag2 + chaine.substring(endPos, chaine.length);
							}
		}
	var pos;
	if	(str.length == 0) {
		pos = startPos + tag1.length + chiedi2.length + 8 + chiedi1.length + tag2.length;
	} else {
		pos = startPos + tag1.length + chiedi2.length + 8 + str.length + tag2.length;
	}
   mess.selectionStart = pos;
   mess.selectionEnd = pos;
  }
var text_area = document.form.comment;
text_area.focus();
}
function form_tag(tag1,tag2,txt) {
  var mess = document.form.comment;
  //Internet Explorer
  if (document.selection) {
		sel = document.selection.createRange();
		if (sel.text.length > 0) {
			sel.text = tag1 + sel.text + tag2;
		}
		else {
			alert('Seleziona il testo da rendere ' + txt + '\ne clicca questo pulsante :-)');
		}
		var text_area = document.form.comment;
		text_area.focus();
  }
  //Firefox, Netscape
  else if (mess.selectionStart || mess.selectionStart == "0") {
    var startPos = mess.selectionStart;
    var endPos = mess.selectionEnd;
    var chaine = mess.value;
    var str = chaine.substring( mess.selectionStart, mess.selectionEnd );

    mess.value = chaine.substring(0, startPos) + tag1 + str
                        + tag2 + chaine.substring(endPos, chaine.length);
	var pos;
	if	(str.length == 0) {
		pos = startPos + tag1.length;
	} else {
		pos = startPos + tag1.length + str.length + tag2.length;
	}
   mess.selectionStart = pos;
   mess.selectionEnd = pos;
  }
var text_area = document.form.comment;
text_area.focus();
}
function anteprima()
{
var text_area=document.form.comment;
var testo=text_area.value;
testo=testo.replace(/\n/g,"<br>");
var page = "http://www.bracegirdle.it/blog/anteprima.php?t=" + testo;
popwin = window.open(page,"","width=450,height=300,left=175,top=30,scrollbars,resizable")
popwin.focus();
}
/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Turnea Iulian :: http://www.eurografic.ro */
function iObject() {
  this.i;
  return this;
}
var myObject=new iObject();
myObject.i=0;
var myObject2=new iObject();
myObject2.i=0;
store_text=new Array();

//store_text[0] store initial textarea value
store_text[0]="";

function countclik() {
  myObject.i++;
  var y=myObject.i;
  var x=document.form.comment.value;
  store_text[y]=x;
}

function annulla() {
  if ((myObject2.i)<(myObject.i)) {
    myObject2.i++;
  } else {
    alert("Non ci sono azioni da annullare.");
  }
  var z=store_text.length;
  z=z-myObject2.i;
  if (store_text[z]) {
  	document.form.comment.value=store_text[z];
  } else {
  	document.form.comment.value=store_text[0];
  }
}

function ripristina() {
  if((myObject2.i)>1) {
    myObject2.i--;
  } else {
    alert("Non ci sono azioni da ripristinare.");
  }
  var z=store_text.length;
  z=z-myObject2.i;
  if (store_text[z]) {
    document.form.comment.value=store_text[z];
  } else {
  document.form.comment.value=store_text[0];
  }
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function toglispazi(str) {
var out = "", flag = 0;
for (i = 0; i < str.length; i++) {
if (str.charAt(i) != " ") {
out += str.charAt(i);
flag = 0;
}
else {
if(flag == 0) {
out += " ";
flag = 1;
}
}
}
return out;
}
function controlla()
{
z=document.form.name.value;
z=toglispazi(z);
document.form.name.value=z;
z=z.replace(/\[\[\[/g,"");
z=z.replace(/]]]/g,"");
z=z.toString().replace(/^[ \t\r\n]+/,'').replace(/[ \t\r\n]+$/,'');
document.form.name.value=z;
if (z == '' || z == ' ' || z == '   ') {
alert ('Inserire un nome.');
document.form.controllo.value=0;
return false;
}
if (z.length < 4) {
alert ('Il nome deve essere almeno di 4 caratteri.');
document.form.controllo.value=0;
return false;
}
email=document.form.email.value;
email=toglispazi(email);
document.form.email.value=email;
email=email.toString().replace(/^[ \t\r\n]+/,'').replace(/[ \t\r\n]+$/,'');
document.form.email.value=email;
if (email != '') {
	 Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	 if (Filtro.test(email)){
    	return true;
	 }
	 else  {
      	 alert("Devi inserire un indirizzo e-mail valido");
      	 document.form.email.focus();
				 document.form.controllo.value=0;
      	 return false;
   }
}
x=document.form.title.value;
x=toglispazi(x);
document.form.title.value=x;
x=x.toString().replace(/^[ \t\r\n]+/,'').replace(/[ \t\r\n]+$/,'');
document.form.title.value=x;
if (x != '') {
	 if (x.length < 4) {
	 		alert ('Il titolo deve essere almeno di 4 caratteri.');
	 		document.form.controllo.value=0;
	 		return false;
	 }
}
y=document.form.homepage.value;
y=toglispazi(y);
document.form.homepage.value=y;
y=y.toString().replace(/^[ \t\r\n]+/,'').replace(/[ \t\r\n]+$/,'');
document.form.homepage.value=y;
if (y != '') {
	 if (y != 'http://'){
	 		var v = new RegExp();
	 		v.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\.[A-Za-z0-9-_%&\?\/.=]+$");
	 		if (!v.test(document.form.homepage.value)) {
	    	 alert("Indirizzo web non corretto.");
				 document.form.controllo.value=0;
				 return false;
	 		}
	 }

}
f=document.form.comment.value;
f=toglispazi(f);
document.form.comment.value=f;
f=f.toString().replace(/^[ \t\r\n]+/,'').replace(/[ \t\r\n]+$/,'');
document.form.comment.value=f;
if (f == '' || f == ' ' || f == '   ') {
alert ('Inserire il testo del commento.');
document.form.controllo.value=0;
return false;
}
if (f.length < 10) {
alert ('Il commento deve essere almeno di 10 caratteri.');
document.form.controllo.value=0;
return false;
}
var c = readCookie('utente')
if (c) {
	document.form.name.value = '[[[' + c + ']]]';
	document.form.homepage.value = 'http://';
	document.form.controllo.value=1;
	}
}
function vera()
{
if (document.form.controllo.value==0){
	 return false;
}
}
