var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;

var tempX = 0;
var tempY = 0;

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

function emailCheck(e) {
	regex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	return regex.test(e);
}

function getCookie(postid) {
   postid += "=";
   startpos = document.cookie.indexOf(postid);
   if(startpos == -1)
      return '';
   
   startpos = startpos + postid.length;
   if(document.cookie.indexOf("|", startpos) != -1)
      endpos = document.cookie.indexOf("|", startpos);
   else
      endpos = document.cookie.length;

   return unescape(document.cookie.substring(startpos, endpos));
}


function assegnaXMLHttpRequest() {
var
 XHR = null,
 browserUtente = navigator.userAgent.toUpperCase();

 if(typeof(XMLHttpRequest) === "function" || typeof(XMLHttpRequest) === "object")
  XHR = new XMLHttpRequest();

 else if(
  window.ActiveXObject &&
  browserUtente.indexOf("MSIE 4") < 0
 ) {

  if(browserUtente.indexOf("MSIE 5") < 0)
   XHR = new ActiveXObject("Msxml2.XMLHTTP");
  else
   XHR = new ActiveXObject("Microsoft.XMLHTTP");
 }
 return XHR;
}

function AjaxGet(url,layer){
	var ajax = assegnaXMLHttpRequest();
	var r=Math.floor(Math.random()*10000)
	if(ajax) {
		ajax.open("get", url + "&r="+r, false);
 		ajax.send(null);
 		document.getElementById(layer).innerHTML=ajax.responseText;
 	}
 	else{
 		alert('Attenzione! Ajax non inizializzato');
 	}
}

function AjaxGetReturn(url){
	document.getElementById('body').style.cursor='wait';
	var ajax = assegnaXMLHttpRequest();
	var r=Math.floor(Math.random()*10000)
	if(ajax) {
		ajax.open("get", url + "&r="+r, false);
 		ajax.send(null);
 		document.getElementById('body').style.cursor='default';
 		return ajax.responseText;
 	}
 	else{
 		alert('Attenzione! Ajax non inizializzato');
 		document.getElementById('body').style.cursor='default';
 		return false;
 	}
}

function AjaxGetAsync(url,layer,sort,js,wait){
	var ajax = assegnaXMLHttpRequest();
	var r=Math.floor(Math.random()*10000)
	if(ajax) {
	
		if(wait != 0){
			document.getElementById('body').style.cursor='wait';
	
			layerY = (Math.ceil(document.getElementById(layer).offsetHeight/2))-9;
			waitText = '<div id="attendere" style="text-align:center;margin-top:'+layerY+'px;font-size:11px;">Attendere prego</div>'
			if(document.getElementById(layer).offsetHeight > 50) {
				layerY-=20;
				waitText='<div id="attendere" style="text-align:center;margin-top:'+layerY+'px;font-size:11px;"><img alt="Spinner" src="/img/aj-loader.gif" width="25" height="25"></div>'
			}
			document.getElementById(layer).innerHTML=waitText;
		}
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4){
				if (js == 1) {
					sethtml(layer,ajax.responseText);
				}
				else {
					document.getElementById(layer).innerHTML=ajax.responseText;
				}
				if (sort == 1) $("#SortTable").tablesorter();
				document.getElementById('body').style.cursor='default';
			}
		}
		ajax.open("get", url + "&r="+r, true);
 		ajax.send(null);
 	}
 	else{
 		alert('Attenzione! Ajax non inizializzato');
 	}
}

function LayerDisplay(layer,disp) {
	ddd = 'none';
	if (disp == 1) ddd = 'inline';
	document.getElementById(layer).style.display=ddd;
}

function IsLayerDisplay(layer,nodisp) {
	if (document.getElementById(layer).style.display == 'inline') {
		if (nodisp != 1) {
			LayerDisplay(layer,0);
			return false;
		}
		else return true;
	}
	else {
		if (nodisp != 1) {
			LayerDisplay(layer,1);
			return true;	
		}
		else return false;
	}
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function Check_Integer(fvalue) {
	var checkOK = "0123456789";
	var checkStr = fvalue;
	var allValid = true;
	var decPoints = 0;
	var allNum = "";
	for (i = 0;  i < checkStr.length;  i++)
	{
	ch = checkStr.charAt(i);
	for (j = 0;  j < checkOK.length;  j++)
	  if (ch == checkOK.charAt(j))
	    break;
	if (j == checkOK.length)
	{
		allValid = false;
		break;
	}
	allNum += ch;
	}
	return allValid;
}

function Check_Valuta(fvalue) {
	var checkOK = "0123456789,.";
	var checkStr = trim(fvalue);
	var allValid = true;
	var decPoints = 0;
	var allNum = "";
	for (i = 0;  i < checkStr.length;  i++)
	{
	ch = checkStr.charAt(i);
	for (j = 0;  j < checkOK.length;  j++)
	  if (ch == checkOK.charAt(j))
	    break;
	if (j == checkOK.length)
	{
		allValid = false;
		break;
	}
	allNum += ch;
	}
	return allValid;
}

function getMouseXY(e) {
if (IE) { // grab the x-y pos.s if browser is IE
	tempX = MouseX();
	tempY = MouseY();
}	
else {  // grab the x-y pos.s if browser is NS
  tempX = e.pageX;
  tempY = e.pageY;
}  
if (tempX < 0){tempX = 0;}
if (tempY < 0){tempY = 0;}  
return true;
}
function MouseY(e) {
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	}
	return posy;
}

function MouseX(e) {
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posx = e.pageX;
	}
	else if (e.clientX || e.clientY) 	{
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
	}
	return posx;
}

function window_open_bar(filename, x, y, target)
{
	windowops = eval("'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=" + x + ",height=" + y + "'");
	newwindow=window.open(filename, target, windowops);
	return;
}

function toggletable(postid,menuid) {
   var whichpost = document.getElementById(postid);

   if (whichpost.className=="tableshown") {
      whichpost.className="tablehidden";
      if (menuid != undefined) {
      	document.getElementById(menuid).innerHTML='[+]';
      }
   }
   else {
      whichpost.className="tableshown";
      if (menuid != undefined) {
      	document.getElementById(menuid).innerHTML='[-]';
      }
      
   }
}

function showtable() {
	var divs=document.getElementsByTagName("div");
	for(i=0;i<divs.length;i++){
	   if(divs[i].className=="tablehidden"){
	       divs[i].className ="tableshown";
	       document.getElementById("show_all").innerHTML='[-]';
	       }
	      else {
	  if(divs[i].className=="tableshown"){
	   		divs[i].className ="tablehidden";
	   		document.getElementById("show_all").innerHTML='[+]';
	   	}
	   }
   }
}


function over(id){
	document.getElementById('overdiv').style.left=tempX+100+'px';
	document.getElementById('overdiv').style.top=tempY-100+'px';
	document.getElementById('overdiv').style.display='inline';
	AjaxGetAsync('/getTrick.php?url=URL.asp?id='+id,'overcontent');
}
function out(){
	document.getElementById('overdiv').style.display='none';
	document.getElementById('overcontent').innerHTML='&nbsp;';
}

function Trick_Scheda(id){
/*	midY = tempY - 300;
	if(midY<=0)midY=(screen.height/2)-300;
	
	document.getElementById('link').style.left=(screen.width/2)-217+'px';
	document.getElementById('link').style.top=midY+'px';
	document.getElementById('link').style.display='inline';*/
	if(IsLayerDisplay('tr_'+id)){
		document.getElementById('tr_'+id).style.height='100px';
		document.getElementById('tr_'+id).innerHTML='&nbsp;';
		document.getElementById('trt_'+id).style.border='1px #000 solid';
		document.getElementById('trtr_'+id).className='trick_H';
		document.getElementById('trick_'+id).style.color='#000';
		AjaxGetAsync('/getTrick.php?url=LINK.asp?id='+id,'tr_'+id);
	}
	else{
		document.getElementById('trt_'+id).style.border='0';
		document.getElementById('trick_'+id).style.color='#3399FF';
		document.getElementById('trtr_'+id).className='trick';
	}
}
function Link_Vota(id,idlink,v){
	ret=AjaxGetReturn('/getTrick.php?url=TRICK_ACT.asp?act=link_vota|id='+idlink+'|voto='+v);
	if(ret!='OK'){
		alert(ret);
		return false;
	}
	AjaxGetAsync('/getTrick.php?url=LINK.asp?id='+id,'tr_'+id);
}
function Link_Commenti(id){
//	midY = tempY - 300;
//	if(midY<=0)midY=(screen.height/2)-300;
	
//	document.getElementById('link').style.left=(screen.width/2)-217+'px';
//	document.getElementById('link').style.top=tempY+'px';
//	document.getElementById('link').style.display='inline';

//	LayerDisplay('Commenti',1);
	if(IsLayerDisplay('ll_'+id)){
		AjaxGetAsync('/getTrick.php?url=LINK_COMMENTI.asp?id='+id,'ll_'+id);
		a=getCookie('autore');
		em=getCookie('email')
		if(a!=''){
			document.getElementById('_Autore').value=a;
			document.getElementById('_Autore').setAttribute('disabled','disabled');
			document.getElementById('_Email').value=em;
			document.getElementById('_Email').setAttribute('disabled','disabled');
		}
	}
}

function Link_Commenti_Add(id){
	a=document.getElementById('_Autore').value;
	if(a==''){alert('L\'Autore non può essere nullo');document.getElementById('_Autore').focus();return false;}
	em=document.getElementById('_Email').value;
	if(!emailCheck(em)){alert('Email non valida');document.getElementById('_Email').focus();return false;}
	c=document.getElementById('_Commento').value;
	if(c==''){alert('Il Commento non può essere nullo');document.getElementById('_Commento').focus();return false;}
	document.cookie = 'autore='+a+'|email='+em+'|; expires=Thu, 01-Jan-40 00:00:01 GMT; ';
	a=escape(a);
	c=escape(c);
	ret=AjaxGetReturn('/getTrick.php?url=TRICK_ACT.asp?act=linkcommento_ins|id='+id+'|aut='+a+'|email='+em+'|comm='+c);
	if(ret!='OK'){
		alert(ret);
		return false;
	}
	AjaxGetAsync('/getTrick.php?url=LINK_COMMENTI.asp?id='+id,'ll_'+id);
}

function Video_Commenti_Add(idy,id){
	b=document.getElementById('_Commento').value;
	if(b==''){alert('Il Commento non può essere nullo');document.getElementById('_Commento').focus();return false;}

	b = b.replace('\r\n','[BR]');
	b = b.replace('\r\n ','[BR]');
	b = b.replace('\n','[BR]');
	b = b.replace('\n ','[BR]');
	b = b.replace(/(\r\n)|(\n)/g,'[BR]');
	b = escape(b);

	ret=AjaxGetReturn('/getTrick.php?url=VIDEO_ACT.asp?act=commento_ins|id='+id+'|idy='+idy+'|comm='+b);
	if(ret!='OK'){
		alert(ret);
		return false;
	}
	window.location.reload();
}

function Video_Vota(id,v){
	ret=AjaxGetReturn('/getTrick.php?url=VIDEO_ACT.asp?act=vota|id='+id+'|voto='+v);
	if(ret!='OK'){
		alert(ret);
		return false;
	}
	window.location.reload();
}

function Video_CheckURL(v){
	ret=AjaxGetReturn('/getTrick.php?url=VIDEO_ACT.asp?act=urlCheck|url='+escape(v));
	if(ret!='OK'){
		alert(ret);
		return false;
	}
}

function Video_CheckTitolo(v){
	ret=AjaxGetReturn('/getTrick.php?url=VIDEO_ACT.asp?act=titoloCheck|tit='+escape(v));
	if(ret!='OK'){
		alert(ret);
		return false;
	}
	return true;
}

function Video_ADD(idy){
	url = document.getElementById('vURL').value;
	if(url==''){alert('URL non può essere nullo');return false;}
	tit = document.getElementById('vTitolo').value;
	if(tit==''){alert('Titolo non può essere nullo');return false;}
	b = document.getElementById('vDesc').value;
	if(b==''){alert('Descrizione non può essere nullo');return false;}
	
	b = b.replace('\r\n','[BR]');
	b = b.replace('\r\n ','[BR]');
	b = b.replace('\n','[BR]');
	b = b.replace('\n ','[BR]');
	b = b.replace(/(\r\n)|(\n)/g,'[BR]');
	b = escape(b);

	ret=AjaxGetReturn('/getTrick.php?url=VIDEO_ACT.asp?act=insert|idy='+idy+'|url='+url+'|tit='+escape(tit)+'|desc='+b);
	if(ret!='OK'){
		alert(ret);
		return false;
	}
	window.location.reload();
	
}

function Video_UpdData(idv,idy,vdata,ff){
	ret=AjaxGetReturn('/getTrick.php?url=VIDEO_ACT.asp?act=UpdData|idv='+idv+'|idy='+idy+'|vdata='+vdata);
	if(ret!='OK'){
		alert(ret);
		return false;
	}
	pulseGreen(ff);
}

function Video_UpdTitolo(idv,idy,vtit,ff){
	ret=AjaxGetReturn('/getTrick.php?url=VIDEO_ACT.asp?act=UpdTitolo|idv='+idv+'|idy='+idy+'|vtit='+escape(vtit));
	if(ret!='OK'){
		alert(ret);
		return false;
	}
	pulseGreen(ff);
}

function Video_UpdDesc(idv,idy,b,ff){
	b = b.replace('\r\n','[BR]');
	b = b.replace('\r\n ','[BR]');
	b = b.replace('\n','[BR]');
	b = b.replace('\n ','[BR]');
	b = b.replace(/(\r\n)|(\n)/g,'[BR]');
	b = escape(b);

	ret=AjaxGetReturn('/getTrick.php?url=VIDEO_ACT.asp?act=UpdDesc|idv='+idv+'|idy='+idy+'|vdesc='+b);
	if(ret!='OK'){
		alert(ret);
		return false;
	}
	pulseGreen(ff);
}



function Tag_ADD(idv,tag){
	if(tag==''){alert('TAG non può essere nullo');return false;}
	ret=AjaxGetReturn('/getTrick.php?url=VIDEO_ACT.asp?act=tagADD|tag='+tag);
	if(ret!='OK'){
		alert(ret);
		return false;
	}
	AjaxGetAsync('/getTrick.php?url=Video_ACT.asp?act=tagSELECT|idv='+idv,'tags');
}

function Video_Tag(idv,idtag,istag){
	ret=AjaxGetReturn('/getTrick.php?url=VIDEO_ACT.asp?act=VideoTag|idv='+idv+'|idtag='+idtag+'|istag='+istag);
	if(ret!='OK'){
		alert(ret);
		return false;
	}
}

function Profilo(idy){
	window.location.href='/yoer/'+idy;
}
function Yoer(){
	document.getElementById('body').style.cursor='wait';
	n=escape(document.getElementById('___Nickname').value);
	if(n==''){alert('Il Nickname non può essere nullo');document.getElementById('Nickname').focus();return false;}
	p=escape(document.getElementById('___Password').value);
	if(p==''){alert('La Password non può essere nullo');document.getElementById('Password').focus();return false;}
	em=document.getElementById('Email').value;
	if(!emailCheck(em)){alert('Email non valida');document.getElementById('Email').focus();return false;}
	c=escape(document.getElementById('Citta').value);
	if(c==''){alert('La Città non può essere nulla');document.getElementById('Citta').focus();return false;}

	if(document.getElementById('provincia').selectedIndex==0){alert('Seleziona la Provincia');document.getElementById('Provincia').focus();return false;}
	prv=document.getElementById('provincia').options[document.getElementById('provincia').selectedIndex].value;
	
	nom = escape(document.getElementById('Nome').value);
	cog = escape(document.getElementById('Cognome').value);

	ret=AjaxGetReturn('/getTrick.php?url=YOER_ACT.asp?act=ins|nick='+n+'|email='+em+'|citta='+c+'|prv='+prv+'|nome='+nom+'|cog='+cog+'|pwd='+p);
	if(ret!='OK'){
		alert(ret);
		return false;
	}
	alert('Grazie per esserti registrato');
	AjaxGetReturn('/cookie.php?l='+n+'&p='+p);
	window.location.href='profilo.php';
//	window.location.reload();
}

function Yoer_upd(id){
	n=escape(document.getElementById('_Nickname').value);
	if(n==''){alert('Il Nickname non può essere nullo');document.getElementById('_Nickname').focus();return false;}
	p=escape(document.getElementById('_Password').value);
	if(p==''){alert('La Password non può essere nullo');document.getElementById('_Password').focus();return false;}
	em=document.getElementById('_Email').value;
	if(!emailCheck(em)){alert('Email non valida');document.getElementById('_Email').focus();return false;}
	ind=escape(document.getElementById('_Indirizzo').value);
	c=escape(document.getElementById('_Citta').value);
	if(c==''){alert('La Città non può essere nulla');document.getElementById('_Citta').focus();return false;}

	tel=escape(document.getElementById('_Tel').value);
	cap=document.getElementById('_CAP').value;
	if(cap!=''){
		if(!Check_Integer(cap)){alert('Il CAP deve essere un numero intero');document.getElementById('_CAP').focus();return false;}
	}

	if(document.getElementById('_provincia').selectedIndex==0){alert('Seleziona la Provincia');document.getElementById('_provincia').focus();return false;}
	prv=document.getElementById('_provincia').options[document.getElementById('_provincia').selectedIndex].value;
	
	nom = escape(document.getElementById('_Nome').value);
	cog = escape(document.getElementById('_Cognome').value);
	b = document.getElementById('_Bio').value;
	b = b.replace('\r\n','[BR]');
	b = b.replace('\r\n ','[BR]');
	b = b.replace('\n','[BR]');
	b = b.replace('\n ','[BR]');
	b = b.replace(/(\r\n)|(\n)/g,'[BR]');
	b = escape(b);

	y = document.getElementById('_yoyo').value;
	y = y.replace('\r\n','[BR]');
	y = y.replace('\r\n ','[BR]');
	y = y.replace('\n','[BR]');
	y = y.replace('\n ','[BR]');
	y = y.replace(/(\r\n)|(\n)/g,'[BR]');
	y = escape(y);

	f = document.getElementById('_Forum').value;

	l1 = document.getElementById('_Link1').value;
	if(l1!='')if(Left(l1,4)!='http'){alert('Il link deve essere del tipo http://www.ecc.it');document.getElementById('_Link1').focus();return false;}
	dl1 = document.getElementById('_DescLink1').value;
	if(l1!='' && dl1==''){alert('La descrizione del link non può essere nulla');document.getElementById('_DescLink1').focus();return false;}

	l2 = document.getElementById('_Link2').value;
	if(l2!='')if(Left(l2,4)!='http'){alert('Il link deve essere del tipo http://www.ecc.it');document.getElementById('_Link2').focus();return false;}
	dl2 = document.getElementById('_DescLink2').value;
	if(l2!='' && dl2==''){alert('La descrizione del link non può essere nulla');document.getElementById('_DescLink2').focus();return false;}

	l3 = document.getElementById('_Link3').value;
	if(l3!='')if(Left(l3,4)!='http'){alert('Il link deve essere del tipo http://www.ecc.it');document.getElementById('_Link3').focus();return false;}
	dl3 = document.getElementById('_DescLink3').value;
	if(l3!='' && dl3==''){alert('La descrizione del link non può essere nulla');document.getElementById('_DescLink3').focus();return false;}

	bd = document.getElementById('_giorno').value+'/'+document.getElementById('_mese').value+'/'+document.getElementById('_anno').value;

	lv = document.getElementById('_livello').value;
	
	nl = document.getElementById('_NL').checked;
	cal = document.getElementById('_CAL').checked;
	map = document.getElementById('_MAP').checked;
	mex = document.getElementById('_MEX').checked;
	
	asp_str='/getTrick.php?url=YOER_ACT.asp?act=upd|id='+id+'|nick='+n+'|email='+em+'|citta='+c+'|prv='+prv+'|nome='+nom+'|cog='+cog+'|pwd='+p+'|bio='+b+'|yoyo='+y+'|for='+f+'|l1='+l1+'|dl1='+dl1+'|l2='+l2+'|dl2='+dl2+'|l3='+l3+'|dl3='+dl3+'|bd='+bd+'|lv='+lv+'|ind='+ind+'|nl='+nl+'|cal='+cal+'|map='+map+'|mex='+mex+'|cap='+cap+'|tel='+tel;

	ret=AjaxGetReturn(asp_str);
	if(ret!='OK'){
		alert(ret);
		return false;
	}
	alert('Profilo Aggiornato');
}

function Yoer_del(id){
	if(confirm('Sicuro?')){
		if(confirm('Sicuro sicuro sicuro ?')){
			n=escape(document.getElementById('_Nickname').value);
			p=escape(document.getElementById('_Password').value);
			ret=AjaxGetReturn('/getTrick.php?url=YOER_ACT.asp?act=del|id='+id+'|nick='+n+'|pwd='+p);
			if(ret=='OK'){
				alert('Cancellato');
				window.location.href='/';
			}
			else alert(ret);
		}
	}

}

function Yoer_pwd(id){
	n=escape(document.getElementById('_Nickname').value);
	p=escape(document.getElementById('_Password').value);
	p1=escape(document.getElementById('_newPWD').value);
	p2=escape(document.getElementById('_newPWD2').value);
	if(p1==''){alert('Le password non possono essere nulle');document.getElementById('_newPWD').focus();return false;}
	if(p1!=p2){alert('Le due password devono essere uguali');document.getElementById('_newPWD').focus();return false;}
	if(p1==p){alert('La nuova password deve essere diversa dalla vecchia');document.getElementById('_newPWD').focus();return false;}

	if(confirm('Sicuro?')){
		ret=AjaxGetReturn('/getTrick.php?url=YOER_ACT.asp?act=pwd|id='+id+'|nick='+n+'|pwd='+p+'|npwd1='+p1+'|npwd2='+p2);
		if(ret=='OK'){
			alert('Password cambiata');
			window.location.reload();
			}
		else alert(ret);
	}
}

function Nazionali_upd(id){
	n=escape(document.getElementById('_Nickname').value);
	p=escape(document.getElementById('_Password').value);

	nome=escape(document.getElementById('_Nome').value);
	if(nome==''){alert('Il Nome non può essere nullo');document.getElementById('_Nome').focus();return false;}
	cognome=escape(document.getElementById('_Cognome').value);
	if(cognome==''){alert('Il Cognnome non può essere nullo');document.getElementById('_Cognome').focus();return false;}
	ind=escape(document.getElementById('_Indirizzo').value);
	if(ind==''){alert('Indirizzo non può essere nullo');document.getElementById('_Indirizzo').focus();return false;}

	cap=document.getElementById('_CAP').value;
	if(cap==''){alert('Il CAP non può essere nullo');document.getElementById('_CAP').focus();return false;}
	if(!Check_Integer(cap)){alert('Il CAP deve essere un numero intero');document.getElementById('_CAP').focus();return false;}

	dataA=escape(document.getElementById('_DataArrivo').value);
	if(dataA==''){alert('La Data di Arrivo non può essere nulla');document.getElementById('_DataArrivo').focus();return false;}
	dataP=escape(document.getElementById('_DataPartenza').value);
	if(dataP==''){alert('La Data di Partenza non può essere nulla');document.getElementById('_DataPartenza').focus();return false;}

	mezzo=document.getElementById('_Mezzo').value;
	if(mezzo==0){alert('Devi indicare un mezzo');document.getElementById('_Mezzo').focus();return false;}
	
/*	posti=document.getElementById('_PostiAuto').value;
	if(posti=='')posti=0;
	if(!Check_Integer(posti)){alert('Posti auto deve essere un numero intero');document.getElementById('_PostiAuto').focus();return false;}*/
	posti=0;
	
	accomp=document.getElementById('_Accompagnatori').value;
	if(accomp=='')posti=0;
	if(!Check_Integer(accomp)){alert('Accompagnatori deve essere un numero intero');document.getElementById('_Accompagnatori').focus();return false;}

	//camera=document.getElementById('_Camera').value;
	//if(camera==0){alert('Scegli la sistemazione in Camera');document.getElementById('_Camera').focus();return false;}
	camera = 'no';
	
	a1=document.getElementById('_1A').checked;
	a1_liv=0;
	if(a1){
		a1_liv=document.getElementById('_Livello1A').value; 
		if(a1_liv==0){alert('Scegliere il livello 1A');document.getElementById('_Livello1A').focus();return false;}
	}
	x=document.getElementById('_X').checked;
	ap=document.getElementById('_AP').checked;
	
	if(!a1 && !x && !ap){if(!confirm('Non hai indicato nessuna gara. Sei sicuro?'))return false;}
	
	b=document.getElementById('_Note').value;
	b = b.replace('\r\n','[BR]');
	b = b.replace('\r\n ','[BR]');
	b = b.replace('\n','[BR]');
	b = b.replace('\n ','[BR]');
	b = b.replace(/(\r\n)|(\n)/g,'[BR]');
	note = escape(b);

	asp_str='/getTrick.php?url=Nazionali_ACT.asp?act=upd|id='+id+'|nick='+n+'|pwd='+p+'|nome='+nome+'|cognome='+cognome+'|ind='+ind+'|cap='+cap+'|dataA='+dataA+'|dataP='+dataP+'|mezzo='+mezzo+'|posti='+posti+'|accomp='+accomp+'|camera='+camera+'|a1='+a1+'|a1_liv='+a1_liv+'|x='+x+'|ap='+ap+'|note='+note;
	
	ret=AjaxGetReturn(asp_str);
	if(ret!='OK'){
		alert(ret);
		return false;
	}
	alert('Iscrizione avvenuta.');
	window.location.href='http://www.yoyomaniacs.com/contest2008/';
}

var idYoer=0;
function Nazionali(){
	if(idYoer==0){
		n=escape(document.getElementById('_Nickname').value);
		if(n==''){alert('Il Nickname non può essere nullo');document.getElementById('_Nickname').focus();return false;}
		p=escape(document.getElementById('_Password').value);
		if(p==''){alert('La Password non può essere nulla');document.getElementById('_Password').focus();return false;}
		em=document.getElementById('_Email').value;
		if(!emailCheck(em)){alert('Email non valida');document.getElementById('_Email').focus();return false;}
		c=escape(document.getElementById('_Citta').value);
		if(c==''){alert('La Città non può essere nulla');document.getElementById('_Citta').focus();return false;}
	
		if(document.getElementById('_provincia').selectedIndex==0){alert('Seleziona la Provincia');document.getElementById('_provincia').focus();return false;}
		prv=document.getElementById('_provincia').options[document.getElementById('_provincia').selectedIndex].value;
		
		nom = escape(document.getElementById('_Nome').value);
		if(nom==''){alert('Il Nome non può essere nullo');document.getElementById('_Nome').focus();return false;}
		cog = escape(document.getElementById('_Cognome').value);
		if(cog==''){alert('Il Cognome non può essere nullo');document.getElementById('_Cognome').focus();return false;}
	
		bd = document.getElementById('_giorno').value+'/'+document.getElementById('_mese').value+'/'+document.getElementById('_anno').value;
		if(bd=='0/0/0'){alert('La Data di Nascita non può essere nulla');document.getElementById('_giorno').focus();return false;}
	
		id=AjaxGetReturn('/getTrick.php?url=Nazionali_ACT.asp?act=ins|nick='+n+'|email='+em+'|citta='+c+'|prv='+prv+'|nome='+nom+'|cog='+cog+'|pwd='+p+'|bd='+bd);
		if(!Check_Integer(id)){
			alert(id);
			return false;
		}
		idYoer=id;
	}
	else id=idYoer;
	
	Nazionali_upd(id);
}

function Associato_upd(id,anno){
	n=escape(document.getElementById('_Nickname').value);
	p=escape(document.getElementById('_Password').value);

	nome=escape(document.getElementById('_Nome').value);
	if(nome==''){alert('Il Nome non può essere nullo');document.getElementById('_Nome').focus();return false;}
	cognome=escape(document.getElementById('_Cognome').value);
	if(cognome==''){alert('Il Cognnome non può essere nullo');document.getElementById('_Cognome').focus();return false;}
	ind=escape(document.getElementById('_Indirizzo').value);
	if(ind==''){alert('Indirizzo non può essere nullo');document.getElementById('_Indirizzo').focus();return false;}

	cap=document.getElementById('_CAP').value;
	if(cap==''){alert('Il CAP non può essere nullo');document.getElementById('_CAP').focus();return false;}
	if(!Check_Integer(cap)){alert('Il CAP deve essere un numero intero');document.getElementById('_CAP').focus();return false;}

	tessera='';
	quota=document.getElementById('Offerta').value;
	if(quota != ''){
		if(!Check_Valuta(quota)){alert('Cifra non valida');document.getElementById('Offerta').focus();return false;} 
		if(quota < 10){alert('L\'offerta minima è di 10 euro');document.getElementById('Offerta').focus();return false;}
		quota=parseInt(quota);
	}
	else quota=0;
	quota+=15;
	
	taglia='No';
	if(document.getElementById('T-Shirt').checked){
		if(document.getElementById('Taglia').selectedIndex==0){alert('Seleziona la Taglia');document.getElementById('Taglia').focus();return false;}
		taglia=document.getElementById('Taglia').options[document.getElementById('Taglia').selectedIndex].value;
		quota+=4.50;
	}
	else quota+=1.50;

//	if(document.getElementById('T-Shirt').checked){quota=document.getElementById('T-Shirt');}
	
	pagamento='';
	//if(document.getElementById('Naz08').checked)pagamento='Naz08';
	if(document.getElementById('Paypal').checked)pagamento='Paypal';
	if(document.getElementById('Bonifico').checked)pagamento='Bonifico';
	//if(document.getElementById('Contanti').checked)pagamento='Contanti';
	//if(document.getElementById('Vaglia').checked)pagamento='Vaglia';
	if(pagamento==''){alert('Scegli un tipo di pagamento');return false;}
	
	note=document.getElementById('Note').value;
	
	asp_str='/getTrick.php?url=Associato_ACT.asp?act=upd|idy='+id+'|nick='+n+'|pwd='+p+'|nome='+nome+'|cognome='+cognome+'|ind='+ind+'|cap='+cap+'|anno='+anno+'|quota='+quota+'|pagamento='+pagamento+'|nota='+note+'|taglia='+taglia;

	ret=AjaxGetReturn(asp_str);
	if(ret!='OK'){
		alert(ret);
		return false;
	}
	alert('Iscrizione avvenuta.\r\rRiceverai una mail con tutte le istruzioni');
	window.location.href='http://www.yoyomaniacs.com/';
}


function Associato(anno){
	if(idYoer==0){
		n=escape(document.getElementById('_Nickname').value);
		if(n==''){alert('Il Nickname non può essere nullo');document.getElementById('_Nickname').focus();return false;}
		p=escape(document.getElementById('_Password').value);
		if(p==''){alert('La Password non può essere nulla');document.getElementById('_Password').focus();return false;}
		em=document.getElementById('_Email').value;
		if(!emailCheck(em)){alert('Email non valida');document.getElementById('_Email').focus();return false;}
		c=escape(document.getElementById('_Citta').value);
		if(c==''){alert('La Città non può essere nulla');document.getElementById('_Citta').focus();return false;}
	
		if(document.getElementById('_Provincia').selectedIndex==0){alert('Seleziona la Provincia');document.getElementById('_Provincia').focus();return false;}
		prv=document.getElementById('_Provincia').options[document.getElementById('_Provincia').selectedIndex].value;
		
		nom = escape(document.getElementById('_Nome').value);
		if(nom==''){alert('Il Nome non può essere nullo');document.getElementById('_Nome').focus();return false;}
		cog = escape(document.getElementById('_Cognome').value);
		if(cog==''){alert('Il Cognome non può essere nullo');document.getElementById('_Cognome').focus();return false;}
		ind=escape(document.getElementById('_Indirizzo').value);
		if(ind==''){alert('Indirizzo non può essere nullo');document.getElementById('_Indirizzo').focus();return false;}

		cap=document.getElementById('_CAP').value;
	
		bd = document.getElementById('_giorno').value+'/'+document.getElementById('_mese').value+'/'+document.getElementById('_anno').value;
		if(bd=='0/0/0'){alert('La Data di Nascita non può essere nulla');document.getElementById('_giorno').focus();return false;}
	
		asp_str='/getTrick.php?url=Associato_ACT.asp?act=ins|nick='+n+'|email='+em+'|citta='+c+'|prv='+prv+'|nome='+nom+'|cog='+cog+'|pwd='+p+'|bd='+bd+'|ind='+ind+'|cap='+cap;

		id=AjaxGetReturn(asp_str);
		if(!Check_Integer(id)){
			alert(id);
			return false;
		}
		idYoer=id;
	}
	else id=idYoer;
	Associato_upd(id,anno);
}

function Registra(){
		n=escape(document.getElementById('_Nickname').value);
		if(n==''){alert('Il Nickname non può essere nullo');document.getElementById('_Nickname').focus();return false;}
		p=escape(document.getElementById('_Password').value);
		if(p==''){alert('La Password non può essere nulla');document.getElementById('_Password').focus();return false;}
		em=document.getElementById('_Email').value;
		if(!emailCheck(em)){alert('Email non valida');document.getElementById('_Email').focus();return false;}
		c=escape(document.getElementById('_Citta').value);
		if(c==''){alert('La Città non può essere nulla');document.getElementById('_Citta').focus();return false;}
	
		if(document.getElementById('_Provincia').selectedIndex==0){alert('Seleziona la Provincia');document.getElementById('_Provincia').focus();return false;}
		prv=document.getElementById('_Provincia').options[document.getElementById('_Provincia').selectedIndex].value;
		
		nom = escape(document.getElementById('_Nome').value);
		if(nom==''){alert('Il Nome non può essere nullo');document.getElementById('_Nome').focus();return false;}
		cog = escape(document.getElementById('_Cognome').value);
		if(cog==''){alert('Il Cognome non può essere nullo');document.getElementById('_Cognome').focus();return false;}
		ind=escape(document.getElementById('_Indirizzo').value);
		if(ind==''){alert('Indirizzo non può essere nullo');document.getElementById('_Indirizzo').focus();return false;}

		cap=document.getElementById('_CAP').value;
		if(cap==''){alert('Il CAP non può essere nullo');document.getElementById('_CAP').focus();return false;}
		if(!Check_Integer(cap)){alert('Il CAP deve essere un numero intero');document.getElementById('_CAP').focus();return false;}

	
		bd = document.getElementById('_giorno').value+'/'+document.getElementById('_mese').value+'/'+document.getElementById('_anno').value;
		if(bd=='0/0/0'){alert('La Data di Nascita non può essere nulla');document.getElementById('_giorno').focus();return false;}

		tel = escape(document.getElementById('_Tel').value);
		if(tel==''){alert('Il Telefono non può essere nullo (serve al corriere)');document.getElementById('_Tel').focus();return false;}

		asp_str='/getTrick.php?url=Shop_ACT.asp?act=Register|nick='+n+'|email='+em+'|citta='+c+'|prv='+prv+'|nome='+nom+'|cog='+cog+'|pwd='+p+'|bd='+bd+'|ind='+ind+'|cap='+cap+'|tel='+tel;

		if(!confirm('Sei sicuro?'))return false;
		
		ret=AjaxGetReturn(asp_str);
		if(ret!='OK'){
			alert(ret);
			return false;
		}
		alert('Registrato');
		if(AjaxGetReturn('/cookie.php?l='+n+'&p='+p)=='OK')window.location.reload();
		else alert('Errore cookie');
}

function Album_Crea(l,p,pers){
	t=escape(document.getElementById('Titolo').value);
	b = document.getElementById('Descrizione').value;
	b = b.replace('\r\n','[BR]');
	b = b.replace('\r\n ','[BR]');
	b = b.replace('\n','[BR]');
	b = b.replace('\n ','[BR]');
	b = b.replace(/(\r\n)|(\n)/g,'[BR]');
	b = escape(b);
	id=AjaxGetReturn('/getTrick.php?url=Album_ACT.asp?act=crea|t='+t+'|d='+b+'|pers='+pers);
	if(!Check_Integer(id)){alert(id);return false;}
	AjaxGetAsync('/getTrick.php?url=Album_FOTO.asp?id='+id+'|l='+l+'|p='+p,'workspace');
//	document.getElementById('workspace').innerHTML='<iframe src="/album_img.php?id='+id+'" border="0" frameborder="0" height="300" marginheight="1" marginwidth="1" name="img" scrolling="no" width="100%"></iframe>';
}

function Album_Foto(id,alb,l,p){
//	document.getElementById('overdiv').style.left=(screen.width/2)-400+'px';
//	document.getElementById('overdiv').style.top=document.body.scrollTop + document.documentElement.scrollTop+100+'px';
//	document.getElementById('overdiv').style.display='inline';
	AjaxGetAsync('/getTrick.php?url=FOTO.asp?id='+id+'|alb='+alb+'|l='+l+'|p='+p,'workspace');
//	document.getElementById('overcontent').innerHTML='<img src="/album/'+id+'.jpg" onclick="out()">';
}

function Album_Foto_Commento(id,alb){
	b = document.getElementById('Commento').value;
	b = b.replace('\r\n','[BR]');
	b = b.replace('\r\n ','[BR]');
	b = b.replace('\n','[BR]');
	b = b.replace('\n ','[BR]');
	b = b.replace(/(\r\n)|(\n)/g,'[BR]');
	b = escape(b);
	
	ret=AjaxGetReturn('/getTrick.php?url=Album_ACT.asp?act=fotodesc|id='+id+'|desc='+b);
	if(ret!='OK'){alert(ret);return false;}

	window.location.reload();
	//AjaxGetAsync('/getTrick.php?url=FOTO.asp?id='+id+'|alb='+alb,'overcontent');
}


function pulseGreen(field){
	field.style.backgroundColor='#ccff33';
	f=field;
	c='#fff';
	setTimeout('f.style.backgroundColor=c',1000);
}


function Album_Foto_Upd(id,desc,l,p,ff){
	ret=AjaxGetReturn('/getTrick.php?url=Album_ACT.asp?act=fotoupd|id='+id+'|desc='+desc);
	if(ret!='OK'){alert(ret);return false;}
	pulseGreen(ff);
}

function Album_Foto_Del(id,l,p,alb){
	ret=AjaxGetReturn('/getTrick.php?url=Album_ACT.asp?act=delpic|id='+id);
	if(ret!='OK'){alert(ret);return false;}

	ret=AjaxGetReturn('/album_img_x.php?pic='+id);
	if(ret!='OK'){alert(ret);return false;}

	AjaxGetAsync('/getTrick.php?url=Album_EDIT.asp?id='+alb,'workspace');	
}

function Album_Titolo_Upd(id,tit,l,p,ff){
	ret=AjaxGetReturn('/getTrick.php?url=Album_ACT.asp?act=titoloupd|id='+id+'|tit='+tit);
	if(ret!='OK'){alert(ret);return false;}
	pulseGreen(ff);
}

function Album_Desc_Upd(id,desc,l,p,ff){
	b = document.getElementById('Descrizione').value;
	b = b.replace('\r\n','[BR]');
	b = b.replace('\r\n ','[BR]');
	b = b.replace('\n','[BR]');
	b = b.replace('\n ','[BR]');
	b = b.replace(/(\r\n)|(\n)/g,'[BR]');
	b = escape(b);

	ret=AjaxGetReturn('/getTrick.php?url=Album_ACT.asp?act=descupd|id='+id+'|desc='+b);
	if(ret!='OK'){alert(ret);return false;}
	pulseGreen(ff);
}

function CarrelloADD(idart,idcli){
	ret=AjaxGetReturn('/getTrick.php?url=Shop_ACT.asp?act=carrelloADD|idYoer='+idcli+'|idArt='+idart);
	if(ret!='OK'){alert(ret);return false;}
//	AjaxGetAsync('/getTrick.php?url=Shop_ACT.asp?act=carrelloSEL|idYoer='+idcli,'cart');
	AjaxGetAsync('/getTrick.php?url=Shop_ACT.asp?act=minicart|idYoer='+idcli,'menuL');
}

function CarrelloDEL(idcli){
	if(!confirm('Sei sicuro?'))return false;
	ret=AjaxGetReturn('/getTrick.php?url=Shop_ACT.asp?act=carrelloDEL|idYoer='+idcli);
	if(ret!='OK'){alert(ret);return false;}
	alert('Carrello vuoto');
	window.location.href='/shop';
}

function CarrelloUPD(idcar,qt,ff){
	if(!Check_Integer(qt)){alert('Qta non valida');return false;}
	ret=AjaxGetReturn('/getTrick.php?url=Shop_ACT.asp?act=carrelloUPD|idcar='+idcar+'|qt='+qt);
	if(ret!='OK'){alert(ret);return false;}
	window.location.reload();
}

function Ordine(idcli){
	pagamento='';
	if(document.getElementById('Paypal').checked)pagamento='Paypal';
	if(document.getElementById('Bonifico').checked)pagamento='Bonifico';
	if(document.getElementById('Contanti').checked)pagamento='Contanti';
	if(pagamento==''){alert('Scegli un tipo di pagamento');return false;}

	b=document.getElementById('Note').value;
	b = b.replace('\r\n','[BR]');
	b = b.replace('\r\n ','[BR]');
	b = b.replace('\n','[BR]');
	b = b.replace('\n ','[BR]');
	b = b.replace(/(\r\n)|(\n)/g,'[BR]');
	note = escape(b);
	
	if(!confirm('Sei sicuro?'))return false;

	ret=AjaxGetReturn('/getTrick.php?url=Shop_ACT.asp?act=Ordine|idcli='+idcli+'|pag='+pagamento+'|note='+note);
	if(ret!='OK'){alert(ret);return false;}
	alert('Ordine ricevuto.\rRiceverai i dettagli via mail');
	window.location.href='/shop';
}
function shopUpdIndirizzo(ind,idy){
	if(ind==''){alert('Indirizzo non può essere nullo');document.getElementById('shopIND').focus();return false;}

	ret=AjaxGetReturn('/getTrick.php?url=Shop_ACT.asp?act=shopIND|ind='+ind+'|id='+idy);
	if(ret!='OK'){
		alert(ret);
		return false;
	}
	pulseGreen(document.getElementById('shopIND'));
}

function shopUpdCAP(cap,idy){
	if(cap==''){alert('Il CAP non può essere nullo');document.getElementById('shopCAP').focus();return false;}
	if(!Check_Integer(cap)){alert('Il CAP deve essere un numero intero');document.getElementById('shopCAP').focus();return false;}

	ret=AjaxGetReturn('/getTrick.php?url=Shop_ACT.asp?act=shopCAP|cap='+cap+'|id='+idy);
	if(ret!='OK'){
		alert(ret);
		return false;
	}
	pulseGreen(document.getElementById('shopCAP'));
}

function shopUpdTelefono(tel,idy){
	if(tel==''){alert('Telefono non può essere nullo');document.getElementById('shopTEL').focus();return false;}
	ret=AjaxGetReturn('/getTrick.php?url=Shop_ACT.asp?act=shopTEL|tel='+tel+'|id='+idy);
	if(ret!='OK'){
		alert(ret);
		return false;
	}
	pulseGreen(document.getElementById('shopTEL'));
}

function shopUpdNome(nn,idy){
	if(nn==''){alert('Il Nome non può essere nullo');document.getElementById('shopNOME').focus();return false;}
	ret=AjaxGetReturn('/getTrick.php?url=Shop_ACT.asp?act=shopNOME|nome='+nn+'|id='+idy);
	if(ret!='OK'){
		alert(ret);
		return false;
	}
	pulseGreen(document.getElementById('shopNOME'));
}

function shopUpdCognome(nn,idy){
	if(nn==''){alert('Il Cognome non può essere nullo');document.getElementById('shopCOGNOME').focus();return false;}
	ret=AjaxGetReturn('/getTrick.php?url=Shop_ACT.asp?act=shopCOGNOME|cognome='+nn+'|id='+idy);
	if(ret!='OK'){
		alert(ret);
		return false;
	}
	pulseGreen(document.getElementById('shopCOGNOME'));
}

function Calendario(idy,a){
	nome=document.getElementById('c_Nome').value;
	if(nome==''){alert('Nome non può essere nullo');document.getElementById('c_Nome').focus();return false;}

	desc=document.getElementById('c_Desc').value;
	if(desc==''){alert('Descrizione non può essere nullo');document.getElementById('c_Desc').focus();return false;}

	luogo=document.getElementById('c_Luogo').value;
	if(luogo==''){alert('Luogo non può essere nullo');document.getElementById('c_Luogo').focus();return false;}

	prv=document.getElementById('c_Prov').options[document.getElementById('c_Prov').selectedIndex].value;
	if(prv=='0'){alert('Seleziona una provincia');document.getElementById('c_Prov').focus();return false;}

	dal=document.getElementById('c_Dal').value;
	if(dal==''){alert('Dal non può essere nullo');document.getElementById('c_Dal').focus();return false;}

	al=document.getElementById('c_Al').value;
	if(al==''){alert('Al non può essere nullo');document.getElementById('c_Al').focus();return false;}
	
	tipo=document.getElementById('c_Tipo').options[document.getElementById('c_Tipo').selectedIndex].value;
	if(tipo=='0'){alert('Seleziona un tipo');document.getElementById('c_Tipo').focus();return false;}
	
	stato=document.getElementById('c_Stato').options[document.getElementById('c_Stato').selectedIndex].value;
	if(stato=='0'){alert('Seleziona uno stato');document.getElementById('c_Stato').focus();return false;}

	url=document.getElementById('c_URL').value;
	url=url.replace('&','^');

	b=desc;
	b = b.replace('\r\n','[BR]');
	b = b.replace('\r\n ','[BR]');
	b = b.replace('\n','[BR]');
	b = b.replace('\n ','[BR]');
	b = b.replace(/(\r\n)|(\n)/g,'[BR]');
	desc = escape(b);

	album=0;
	act='INSERT';
	if(a=='upd'){
		act='UPDATE';
		album=document.getElementById('c_Foto').value;
		if(!Check_Integer(album)){alert('Solo numeri interi');document.getElementById('c_Foto').focus();return false;}
	}
	
	if(!confirm('Sei sicuro?'))return false;
	ret=AjaxGetReturn('/getTrick.php?url=Calendario_ACT.asp?act='+act+'|idy='+idy+'|nome='+escape(nome)+'|desc='+desc+'|luogo='+luogo+'|prv='+prv+'|dal='+dal+'|al='+al+'|tipo='+tipo+'|stato='+stato+'|url='+url+'|album='+album);

	if(ret!='OK'){alert(ret);return false;}
	alert('Calendario aggiornato');
	if(a=='upd')window.location.href='calendario.php?id='+idy;
	else window.location.reload();
}

function CalendarioDEL(cal,idy){
	if(!confirm('Sei sicuro?'))return false;
	if(!confirm('Sicuro sicuro sicuro?'))return false;
	ret=AjaxGetReturn('/getTrick.php?url=Calendario_ACT.asp?act=DELETE|idy='+idy+'|cal='+cal);
	if(ret!='OK'){alert(ret);return false;}
	alert('Calendario aggiornato');
	window.location.href='calendario.php';
}

function CalendarioPartecipa(cal,idy){
	ret=AjaxGetReturn('/getTrick.php?url=Calendario_ACT.asp?act=partecipa|cal='+cal+'|id='+idy);
	if(ret!='OK'){
		alert(ret);
		return false;
	}
	window.location.reload();
}

function CalendarioPartecipaDEL(cal,idy){
	ret=AjaxGetReturn('/getTrick.php?url=Calendario_ACT.asp?act=partecipaDEL|cal='+cal+'|id='+idy);
	if(ret!='OK'){
		alert(ret);
		return false;
	}
	window.location.reload();
}

function Logout(){
	ret=AjaxGetReturn('/cookieDEL.php?a=1');
	window.location.href='/';
}

function Login(){
	l=escape(document.getElementById('Nickname').value);
	p=escape(document.getElementById('PWD').value);
	if(p=='' || l==''){alert('Inserire Login e Password');return false;}
	ret=AjaxGetReturn('/getTrick.php?url=IsLogin.asp?login='+l+'|pwd='+p);
		if(ret=='0'){
		alert('Login o Password errati');
		return false;
	}
	AjaxGetReturn('/cookie.php?l='+l+'&p='+p);window.location.reload();
}

var artTimer = 0;
function Articolo_Scheda_PopUp(img){
	//document.getElementById('Scheda_Articolo').style.top='205px';
	document.getElementById('Scheda_Articolo').style.left=(screen.width/2)-280+'px';
	i = '<img src="/img/shop/large/'+img+'" style="border:1px #ccc solid">';
	LayerDisplay('Scheda_Articolo',1);
	document.getElementById('Scheda_Articolo').innerHTML=i;
	//artTimer = setTimeout("LayerDisplay('Scheda_Articolo',1);document.getElementById('Scheda_Articolo').innerHTML=i;",100);
}

function Img_PopUp(img,ww){
	wi=400;
	if(ww)wi=ww;
	document.getElementById('Scheda_Articolo').style.top=tempY+30+'px';
	document.getElementById('Scheda_Articolo').style.left=tempX-wi+'px';
	i = '<img src="'+img+'" style="border:1px #ccc solid">';
	LayerDisplay('Scheda_Articolo',1);
	document.getElementById('Scheda_Articolo').innerHTML=i;
}

function Eventi(dd){
	AjaxGetAsync('/getTrick.php?url=YYM_LOG.asp?act=home&data='+dd,'eventi');
}

function MOTD(motd,idy){
	document.getElementById('body').style.cursor='wait';
	ret=AjaxGetReturn('/getTrick.php?url=MOTD_ACT.asp?act=INS|motd='+escape(motd)+'|id='+idy);
	if(ret!='OK'){alert(ret);return false;}
	window.location.reload();
}

function Invia_Password(){
	ppp=prompt('Recupero password', 'Email');
	if(!ppp)return false;
	alert(AjaxGetReturn('/getTrick.php?url=Yoers_Mail.asp?email='+ppp));
}

function Messaggi(m,y){
	if(m==''){alert('Il messaggio non può essere vuoto.');return false;}
	if(y=='0'){alert('Seleziona un destinatario.');return false;}
	m = m.replace('&','~');
	if(!confirm('Sicuro?'))return false;
	ret=AjaxGetReturn('/getTrick.php?url=Messaggi_ACT.asp?act=invia|idf='+y+'|mex='+escape(m));
	if(ret!='OK')alert(ret);
	else{
		alert('Messaggio inviato');
		window.location.reload();
	}
}

function ToBr(b){
	b = b.replace('\r\n','[BR]');
	b = b.replace('\r\n ','[BR]');
	b = b.replace('\n','[BR]');
	b = b.replace('\n ','[BR]');
	b = b.replace(/(\r\n)|(\n)/g,'[BR]');
	b = b.replace('&','|');
	b = escape(b);
	return b;
}

function getId(y){
	divs=document.getElementById('yoer').options;
	for(i=0;i<divs.length;i++){
		if(divs[i].value==y){document.getElementById('yoer').selectedIndex=i;return;}
	}
}

function getMexYoerId(y){
	ret = AjaxGetReturn('/getTrick.php?url=Messaggi_ACT.asp?act=search|y='+y)
	return ret;
}


function ToolTip(menX){
	if(tempX-menX <= 0) menX = 0;
	document.getElementById('BoxTooltip').style.left=tempX-menX+'px';
	document.getElementById('BoxTooltip').style.top=tempY+10+'px';
}