

function cercamatr(matricola) {
if(matricola.length == 0) {
// Hide the suggestion box.
$('#listma').hide();
} else {
$.post("suggest_matricola.php", {queryString: ""+matricola+""}, function(data){
if(data.length >0) {
$('#listma').show();
$('#listamatr').html(data);
}
});
}
} // lookup

function filma(listamatr) {
$('#listma').val(listamatr);
setTimeout("$('#listma').hide();", 200);
}



function caller(action,args,container,metod) {
$.ajax({
type : metod,
url : action,
cache: false,
data: action+args,
dataType: 'html',
success: function(data) {
$("#caricamento").fadeIn(300);
$(container).fadeOut(300);
$(container).html(data).fadeIn(600);
$("#caricamento").fadeOut(1000);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
$(container).html('There was an error.').fadeIn(300);
}
});
}


 function doClear(theText) {
     if (theText.value == theText.defaultValue) {
         theText.value = ""
     }
 }
  function doAdd(theText,valore) {
     if (theText.value == "") {
         theText.value = ""+valore+"";
     } 
		 
 }

function addEl(target_id,typ,val,cla,name,size,plu){
$("#dump").replaceWith("<div id='dump'></div>");
$('#dump').html('<br /><input type=\"' + typ + '\" name=\"' + name + '\" id=\"' + name + '\" size=\"' + size + '\" value=\"' + val + '\" onFocus=\"doClear(this);\"');	
}

function addte(target_id,typ,val,cla,name,size,plu){
$("#dump").replaceWith("<div id='dump'></div>");
$('#dump').html('<br /><textarea id=\"game\" onFocus=\"doClear(this);\" style=\"width: 400px; padding: 10px; height: 15px; display: block; font-family:Sans-serif; font-size:1.2em;\">Codice</textarea>');	
}

function boxad(target_id,typ,val,cla,name,size,plu){
$(target_id).replaceWith("<div id='"+target_id+"'><p> </p></div>");
var el=document.createElement('input');
el.type=typ;
if(val)el.value=val;
if(cla)el.id=cla;
if(name)el.name=name;
if(name)el.id=name;
el.size=size;
document.getElementById(target_id).appendChild(el)
if(plu)el.name=name;
}



$(document).ready(function(){
$("#sub").click(function(){
var testo = $("#testo").val();
var foto = $("#foto").val();
var linke = $("#link").val();
var video = $("#video").val();
var tipo = $("#tipo").val();
var index_id = $("#index_id").val();
var game = $("#game").val();
var datastr ='update=OK&text=' + testo + '&foto=' + foto + '&link=' + linke + '&video=' + video + '&index_id=' + index_id + '&game=' + game;
$("#inbox").fadeOut("slow");
caller('addon/power_box.php?index_id=' + index_id + '',""+datastr+"",'#powerbox','POST');
return false;
});
});

$(document).ready(function(){
$("#cond").click(function(){
var testo = $("#testo").val();
var foto = $("#foto").val();
var linke = $("#link").val();
var video = $("#video").val();
var tipo = $("#tipo").val();
var tit_vid = $("#tit_vid").val();
var tit_link = $("#tit_link").val();
var datastr ='update=OK&testo=' +testo+ '&foto=' +foto+ '&link=' +linke+ '&video=' +video+ ' &tit_vid=' +tit_vid+ ' &tit_link=' +tit_link;
$("#condivider").fadeOut("slow");
caller('addon/condividi.php',""+datastr+"",'#condivider','POST');

return false;
});
});

$(document).ready(function(){
$("#come").click(function(){
var cmt = $("#te").val();
var id = $("#id").val();
var index_id = $("#index_id").val();
var id_user = $("#id_user").val();
var data ='update=OK&testo=' + cmt + '&id=' + id + '&index_id=' + index_id + '&id_user=' + id_user;
$("#in_com").html("'"+data+"'");
$("#in_com").fadeOut("slow");
caller('addon/commento.php',""+data+"",'#in_com' + id + '','POST');
return false;
});
});

function fade_o(elem) {
	$('#'+elem).text("");
}

/*<![CDATA[*/(function(a){a.fn.autoResize=function(j){var b=a.extend({onResize:function(){},animate:true,animateDuration:50,animateCallback:function(){},extraSpace:20,limit:1000},j);this.filter('textarea').each(function(){var c=a(this).css({resize:'none','overflow-y':'hidden'}),k=c.height(),f=(function(){var l=['height','width','lineHeight','textDecoration','letterSpacing'],h={};a.each(l,function(d,e){h[e]=c.css(e)});return c.clone().removeAttr('id').removeAttr('name').css({position:'absolute',top:0,left:-9999}).css(h).insertBefore(c)})(),i=null,g=function(){f.height(0).val(a(this).val()).scrollTop(10000);var d=Math.max(f.scrollTop(),k)+b.extraSpace,e=a(this).add(f);if(i===d){return}i=d;if(d>=b.limit){a(this).css('overflow-y','');return}b.onResize.call(this);b.animate&&c.css('display')==='block'?e.stop().animate({height:d},b.animateDuration,b.animateCallback):e.height(d)};c.unbind('.dynSiz').bind('keyup.dynSiz',g).bind('keydown.dynSiz',g).bind('change.dynSiz',g)});return this}})(jQuery);$('textarea#testo').autoResize();/*]]>*/
/*<![CDATA[*/(function(a){a.fn.autoResize=function(j){var b=a.extend({onResize:function(){},animate:true,animateDuration:50,animateCallback:function(){},extraSpace:20,limit:1000},j);this.filter('textarea').each(function(){var c=a(this).css({resize:'none','overflow-y':'hidden'}),k=c.height(),f=(function(){var l=['height','width','lineHeight','textDecoration','letterSpacing'],h={};a.each(l,function(d,e){h[e]=c.css(e)});return c.clone().removeAttr('id').removeAttr('name').css({position:'absolute',top:0,left:-9999}).css(h).insertBefore(c)})(),i=null,g=function(){f.height(0).val(a(this).val()).scrollTop(10000);var d=Math.max(f.scrollTop(),k)+b.extraSpace,e=a(this).add(f);if(i===d){return}i=d;if(d>=b.limit){a(this).css('overflow-y','');return}b.onResize.call(this);b.animate&&c.css('display')==='block'?e.stop().animate({height:d},b.animateDuration,b.animateCallback):e.height(d)};c.unbind('.dynSiz').bind('keyup.dynSiz',g).bind('keydown.dynSiz',g).bind('change.dynSiz',g)});return this}})(jQuery);$('textarea#te').autoResize();/*]]>*/
/*<![CDATA[*/(function(a){a.fn.autoResize=function(j){var b=a.extend({onResize:function(){},animate:true,animateDuration:50,animateCallback:function(){},extraSpace:20,limit:1000},j);this.filter('textarea').each(function(){var c=a(this).css({resize:'none','overflow-y':'hidden'}),k=c.height(),f=(function(){var l=['height','width','lineHeight','textDecoration','letterSpacing'],h={};a.each(l,function(d,e){h[e]=c.css(e)});return c.clone().removeAttr('id').removeAttr('name').css({position:'absolute',top:0,left:-9999}).css(h).insertBefore(c)})(),i=null,g=function(){f.height(0).val(a(this).val()).scrollTop(10000);var d=Math.max(f.scrollTop(),k)+b.extraSpace,e=a(this).add(f);if(i===d){return}i=d;if(d>=b.limit){a(this).css('overflow-y','');return}b.onResize.call(this);b.animate&&c.css('display')==='block'?e.stop().animate({height:d},b.animateDuration,b.animateCallback):e.height(d)};c.unbind('.dynSiz').bind('keyup.dynSiz',g).bind('keydown.dynSiz',g).bind('change.dynSiz',g)});return this}})(jQuery);$('textarea#game').autoResize();/*]]>*/

function out(elem) {
	$('#'+elem).hide("fast");
}

// imposta il cookie sNome = sValore
// per la durata di iGiorni
function setCookie(sNome, sValore, iGiorni) {
var dtOggi = new Date()
var dtExpires = new Date()
dtExpires.setTime
(dtOggi.getTime() + 24 * iGiorni * 3600000)
document.cookie = sNome + "=" + escape(sValore) +
"; expires=" + dtExpires.toGMTString();
document.getElementById('body').style.backgroundColor=sValore
}

function leggiCookie(sNome)
{
if (document.cookie.length > 0)
{
var inizio = document.cookie.indexOf(sNome + "=");
if (inizio != -1)
{
inizio = inizio + sNome.length + 1;
var fine = document.cookie.indexOf(";",inizio);
if (fine == -1) fine = document.cookie.length;

return unescape(document.cookie.substring(inizio,fine));
}else{
return document.getElementById('body').style.backgroundColor="#005E3F";;
}
}
return "";
}


