

/*
data modifica: 04/11/2009

funzioni:
	addbookmark
*/

function addbookmark(){
	if (window.sidebar) {
		// versione FF
		window.sidebar.addPanel(document.title, location.href,'');
	} else if( window.external ) {
		// versione IE
		window.external.AddFavorite( location.href, document.title); 
	}
} 

/*
data modifica: 04/11/2009

funzioni:
	createCookie
	readCookie
*/

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = '; expires='+date.toGMTString();
}
  else expires = '';
  document.cookie = name+'='+value+expires+'; path=/';
}
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;
}

/*
data modifica: 04/11/2009

funzioni:
	externalLinks

uso:
	Event.observe(window, 'load', function() {
		externalLinks()
	});
*/

function externalLinks() {
    $$('a[rel="external"]').each(function(link){
        if(link.readAttribute('href') != '' && link.readAttribute('href') != '#'){
            link.writeAttribute('target','_blank');
        }
    });
} 

/*
data modifica: 26/03/2010

funzioni:
	checkForPaste
*/

function checkForPaste(event) {
	var e = event.element();
	if ((e.previousValue && e.value.length > e.previousValue.length + 1) || (!e.previousValue && e.value.length > 1)) { 
		if (e.onpaste) {
			e.onpaste(e)
		} else if (e.readAttribute("onpaste")) {
			eval(e.readAttribute("onpaste"));
		}
	}
	e.previousValue = e.value;
}

/*function firefoxOnPaste() {
    $$('textarea').each(function(e) { 
      if (e.onpaste || e.readAttribute("onpaste")) {
        Event.observe(e,'input',checkForPaste);
      }
    });
  }

if(Prototype.Browser.Gecko){
	document.observe('dom:loaded', firefoxOnPaste);
}*/


/*
data modifica: 04/11/2009

funzioni:
	noCache
*/

function noCache(uri){return uri.concat(/\?/.test(uri)?"&":"?","noCache=",(new Date).getTime(),".",Math.random()*1234567)};
