/**
 * @author Antonello Masini
 * copyright ©Antonello Masini 2010
 */
var mainpath='http://www.francescomoufotografo.com/';var strmail=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;var btnl=15;var countbtn=8;var idtimer=null;var vel=200;var trgt=null;var sldmnu=null;var cmenu=null;var mnul=0;var tmrmenu=null;var tmr=null;var isanim=true;var startpg=true;function ShowBtn(i){if(i>countbtn){clearTimeout(idtimer);if(typeof(window.GetParam)=='function'){GetParam(0);}
return;}
var btn=document.getElementById("btn"+i);if(btn==null){clearTimeout(idtimer);return;}
if(i==countbtn){btn.style.left="660px";btn.style.top="85px";btn.style.display="block";}else{btn.style.left=btnl+"px";btn.style.display="block";}
btnl+=98;i++;setTimeout("ShowBtn("+i+")",vel);}
function Trim(str,nospace){if(str==null||str=="")return"";if(str.substr(str.length-1,1)==" "){str=str.substr(0,str.length-1);}
if(str.substr(0,1)==" "){str=str.substr(1);}
if(nospace==true){while(str.indexOf(" ")!=-1){str=str.replace(" ","");}}
return str;}
function msgbox(titolo,testo,tipo,okfunction){if(okfunction==null)okfunction="";var para=document.createElement('div');para.id="dialogbox";var dialog=document.createElement('div');dialog.id="dialog";dialog.setAttribute("style","display:block;background-color:#fff;border:1px solid blue;z-index:200;")
var title=document.createElement('div');title.id="msgtitle";title.innerHTML=titolo;var content=document.createElement('div');content.id="msgcontent";content.className=tipo;content.innerHTML=testo;var btn=document.createElement('div');btn.className="msgbtn";btn.style.backgroundPositionY="-60px"
switch(tipo){case"info":case"exclam":btn.innerHTML='<button onclick="DestroyMessage();'+okfunction+';" onmousedown="this.style.backgroundPosition=\'0 -60px\';">Ok</button>';break;case"question":btn.innerHTML='<button  onclick="DestroyMessage();'+okfunction+';" onmousedown="this.style.backgroundPosition=\'0 -60px\';">Si</button>';btn.innerHTML+='<button onclick="DestroyMessage();" onmousedown="this.style.backgroundPosition=\'0 -60px\';">No</button>';}
document.body.appendChild(para);para.appendChild(dialog);dialog.appendChild(title);dialog.appendChild(content);dialog.appendChild(btn);dialog.style.left=(document.body.offsetWidth-dialog.offsetWidth)/2+"px";if(document.all){dialog.style.top=(document.documentElement.clientHeight-dialog.offsetHeight)/2+"px";}else{dialog.style.top=(window.innerHeight-dialog.offsetHeight)/2+"px";}}
function ShowMessage(rsp,tipo){if(rsp=="")return;msgbox("Informazioni",rsp,tipo);}
function DestroyMessage(){document.body.removeChild(document.getElementById("dialogbox"));}
function byPass(str){str=Trim(str);if(str.length==0)return"";var ret="";ret=str.substr(0,1);ret=ret.charCodeAt(0);if(str.length==1)return ret;for(var i=1;i<str.length;i++){ret+=";"+str.substr(i,1).charCodeAt(0);}
return ret;}
function UnbyPass(str){if(str.length==0){return null;}
var ret="";var mt=str.split(";");for(var i=0;i<mt.length;i++){ret+=String.fromCharCode(mt[i]);}
return ret;}
function TestMail(campo){var valore=Trim(campo.value,true);if(!valore.match(strmail)){msgbox("Dati errati","L'indirizzo e-mail digitato non &egrave; valido.","exclam");return false;}
if(valore.match(";")||valore.match(",")||valore.match(" ")){msgbox("Dati errati","L'indirizzo e-mail digitato non &egrave; valido.","exclam");return false;}
return true;}
function TestPassw(campo,nomsg){var valore=Trim(campo.value,true);if(valore.length==0){if(nomsg==null)msgbox("Dati Incompleti","Digitare la password","exclam");return false;}else if(valore.length<7){if(nomsg==null)msgbox("Dati Incoerenti","La password &egrave; troppo corta.<br />Il minimo consentito &egrave; 7 caratteri","exclam");return false;}else if(valore.length>30){if(nomsg==null)msgbox("Dati Incoerenti","La password &egrave; troppo lunga.<br />Il massimo consentito &egrave; 30 caratteri","exclam");return false;}else{return true;}}
function TestRepassw(pass,repass){var ret=false
if(!TestPassw(pass,true)){msgbox("Dati Incompleti","Digitare la password di accesso.","exclam");}else{var passw=pass.value;var repassw=repass.value;if(passw!=repassw){msgbox("Dati Incoerenti","La conferma della password &egrave; errata","exclam");}else{ret=true;}}
return ret;}
function TestOldPassw(campo){var ret=false
var valore=Trim(campo.value,true);if(valore==null||valore==""){msgbox("Dati Incompleti","Digitare la password di accesso.","exclam");}else if(valore.length<7){msgbox("Dati Incompleti","La password digitata &egrave; errata.","exclam");}else if(valore.length>30){msgbox("Dati Incompleti","La password digitata &egrave; errata.","exclam");}else{ret=true;}
return ret;}
function OpenMenu(trgt,start){if(sldmnu==null){sldmnu=document.getElementById(trgt);cmenu=trgt
document.getElementById("btnshowmenu").disabled=true;document.getElementById("btnshowalbum").disabled=true;document.getElementById("btnshowinfo").disabled=true;}else{if(sldmnu.id==trgt){tmrmenu=setInterval("CloseMenu()",20);return;}else if(trgt!=null){tmrmenu=setInterval('CloseMenu("'+trgt+'")',20);return;}}
if(sldmnu==null)return;mnul=sldmnu.offsetLeft;if(mnul>=0){clearInterval(tmrmenu);if(cmenu=="mainmenu"){document.getElementById("btnshowmenu").style.backgroundPosition="0 -35px";}else if(cmenu=="mnualbum"){document.getElementById("btnshowalbum").style.backgroundPosition="0 -25px";}else if(cmenu=="boxdesc"){document.getElementById("btnshowinfo").style.backgroundPosition="0 -19px";}
if(start==null){document.getElementById("btnshowmenu").disabled=false;document.getElementById("btnshowalbum").disabled=false;document.getElementById("btnshowinfo").disabled=false;}
return;}else if(mnul<=-200){tmrmenu=setInterval('OpenMenu(null,'+start+')',20);}
mnul+=10;sldmnu.style.left=mnul+"px";}
function CloseMenu(trgt){if(sldmnu.offsetLeft>-200){mnul=sldmnu.offsetLeft-10;sldmnu.style.left=mnul+"px";document.getElementById("btnshowmenu").disabled=true;document.getElementById("btnshowalbum").disabled=true;document.getElementById("btnshowinfo").disabled=true;}else{sldmnu=null;clearInterval(tmrmenu);if(cmenu=="mainmenu"){document.getElementById("btnshowmenu").style.backgroundPosition="0 0";}else if(cmenu=="mnualbum"){document.getElementById("btnshowalbum").style.backgroundPosition="0 0";}else if(cmenu=="mnualbum"){document.getElementById("btnshowinfo").style.backgroundPosition="0 0";}
if(trgt!=null){OpenMenu(trgt);}else{document.getElementById("btnshowmenu").disabled=false;document.getElementById("btnshowalbum").disabled=false;document.getElementById("btnshowinfo").disabled=false;}}}
function PresentaMenu(){OpenMenu("mnualbum");}
function AllowScan(){isanim=false;document.getElementById("ledscan").style.backgroundPosition="0px -19px";}
function SetAutoload(value,tm){if(value==true){tmr=setInterval("Autoload()",tm);}else{clearInterval(tmr);tmr=null;}}
function Autoload(){clearInterval(tmr);tmr=null;window.location.replace(""+mainpath+"lib/rndpg.php");}
