
var ChrRetA=String.fromCharCode(13);var ChrRetB=String.fromCharCode(10);var ChrQuote=String.fromCharCode(34);var FormName=0;var IgnoreObjNotFound=false;function SetFocus(ObjName){document.forms[FormName].elements[ObjName].focus();}
function ValidateValue(S){if(S!=''){for(var ii=0;ii<S.length;ii++){switch(S.substring(ii,ii+1)){case"&":S=S.substring(0,ii)+"¸"+S.substring(ii+1);break;case"=":S=S.substring(0,ii)+"Þ"+S.substring(ii+1);break;case" ":S=S.substring(0,ii)+"¯"+S.substring(ii+1);break;case"#":S=S.substring(0,ii)+"þ"+S.substring(ii+1);break;}}}
return S;}
function UnValidateValue(S){for(ii=0;ii<S.length;ii++){switch(S.substring(ii,ii+1)){case"¸":S=S.substring(0,ii)+"&"+S.substring(ii+1);break;case"Þ":S=S.substring(0,ii)+"="+S.substring(ii+1);break;case"¯":S=S.substring(0,ii)+" "+S.substring(ii+1);break;case"þ":S=S.substring(0,ii)+"#"+S.substring(ii+1);break;}}
return S;}
function Refresh(Obj,ToAnchor){var Er=0;document.forms[FormName].elements["Obj"].value=Obj;var LastComma=-1;var ListSelValue="";var RememberList=document.forms[FormName].elements["HidRememberSel"].value+",";RememberList=RememberList.replace(" ","");var MemSelection=false;if(RememberList.length>2){for(var I=0;I<RememberList.length;I++){if(RememberList.substr(I,1)==","){SelName=RememberList.substring(LastComma+1,I);if(SelName.substr(0,1)=="&"){MemAllOptions=false;MemSelection=true;if(SelName.substr(1,1)=="+"){SelName=SelName.substr(2);var MemValue=true;}else{SelName=SelName.substr(1);var MemValue=false;}}else{if(SelName.substr(0,1)=="*"){SelName=SelName.substr(1);MemAllOptions=true;MemSelection=true;}else{MemSelection=false;MemAllOptions=false;}}
if(MemSelection==false){if(ListSelValue.length>0){ListSelValue=ListSelValue+"þ";}
ListSelValue=ListSelValue+SelName+"¯";for(var ii=0;ii<document.forms[FormName].elements[SelName].options.length;ii++){if(ListSelValue.substr(ListSelValue.length-1,1)!="¯"){ListSelValue=ListSelValue+"µ"+document.forms[FormName].elements[SelName].options[ii].value+"µ"+document.forms[FormName].elements[SelName].options[ii].text;}else{ListSelValue=ListSelValue+document.forms[FormName].elements[SelName].options[ii].value+"µ"+document.forms[FormName].elements[SelName].options[ii].text;}}}else if(MemAllOptions){var LstASelected="";if(document.forms[FormName].elements[SelName]){for(var ii=0;ii<document.forms[FormName].elements[SelName].options.length;ii++){if(LstASelected.length==0){LstASelected=document.forms[FormName].elements[SelName].options[ii].value+","+document.forms[FormName].elements[SelName].options[ii].text;}else{LstASelected=LstASelected+"æ"+document.forms[FormName].elements[SelName].options[ii].value+","+document.forms[FormName].elements[SelName].options[ii].text;}}}
AddRemember(SelName+"ASlctd",LstASelected);}else{var LstSelected="";if(!document.forms[FormName].elements[SelName]){ObjNotFound("Refresh",SelName);Er=2;}else{if(MemValue){for(var ii=0;ii<document.forms[FormName].elements[SelName].options.length;ii++){if(document.forms[FormName].elements[SelName].options[ii].selected){if(LstSelected.length==0){LstSelected=document.forms[FormName].elements[SelName].options[ii].value;}else{LstSelected=LstSelected+","+document.forms[FormName].elements[SelName].options[ii].value;}}}}else{for(var ii=0;ii<document.forms[FormName].elements[SelName].options.length;ii++){if(document.forms[FormName].elements[SelName].options[ii].selected){if(LstSelected.length==0){LstSelected=ii;}else{LstSelected=LstSelected+","+ii;}}else{ObjNotFound("Refresh",SelName+".options["+ii+"].selected");Er=3;}}}
AddRemember(SelName+"Slctd",LstSelected);}}
LastComma=I;}}
document.forms[FormName].elements["HidListSelValue"].value=ListSelValue;}
if(ToAnchor){ToAnchor="#"+ToAnchor;}else{var ToAnchor="";}
for(var I=0;I<document.forms[FormName].elements.length;I++){document.forms[FormName].elements[I].disabled=false;}
document.forms[FormName].action=document.forms[FormName].action+ToAnchor;document.forms[FormName].submit();}
function CheckCompulsory(){if((arguments.length==0)||(arguments.length%2==1)){return"CheckCompulsory: Numero errato di parametri.";}else{var FieldList="";for(var I=0;I<arguments.length;I+=2){if(ObjValueLength(arguments[I])==0){if(FieldList==""){FieldList=arguments[(I+1)]+"\n";}else{FieldList=FieldList+arguments[(I+1)]+"\n";}}}
return FieldList;}}
function Disable(ObjName){if(arguments.length>1)var D=arguments[1];else D=true;document.forms[FormName].elements[ObjName].disabled=D;}
function Enable(ObjName){document.forms[FormName].elements[ObjName].disabled=false;}
function ObjValueLength(ObjName){if(!document.forms[FormName].elements[ObjName].type){ObjNotFound("ObjValueLength",ObjName+".type");}
ObjType=document.forms[FormName].elements[ObjName].type;switch(ObjType){case"select-multiple":case"select-one":var SelIndex=document.forms[FormName].elements[ObjName].selectedIndex;if(SelIndex==-1){var Valore="";}else{var Valore=document.forms[FormName].elements[ObjName].options[SelIndex].value;}
break;case"text":case"textarea":case"password":case"hidden":case'file':var Valore=document.forms[FormName].elements[ObjName].value;break;case"checkbox":var Valore=document.forms[FormName].elements[ObjName].checked;break;case'button':case'image':case'option':case'reset':case'submit':break;default:for(var j=0;j<document.forms[FormName].elements[ObjName].length;j++){if(document.forms[FormName].elements[ObjName][j].checked==true){Valore=document.forms[FormName].elements[ObjName][j].value;}}
break;}
if(Valore==""){return 0;}else{return Valore.length;}}
function SetObj(ObjName,ObjVal){if(document.forms[FormName].elements[ObjName]){ObjType=document.forms[FormName].elements[ObjName].type;if(ObjType=="undefined"){ObjNotFound("SetObj",ObjName+".Type");}
switch(ObjType){case"select-multiple":case"select-one":OptionSel(ObjName,ObjVal);break;case"text":case"textarea":case"password":case"hidden":case'file':document.forms[FormName].elements[ObjName].value=ObjVal;break;case"checkbox":if((ObjVal==true)||(ObjVal==1)||(ObjVal=="true")||(ObjVal==document.forms[FormName].elements[ObjName].value)){document.forms[FormName].elements[ObjName].checked=true;}else{document.forms[FormName].elements[ObjName].checked=false;}
break;case'button':case'image':case'option':case'reset':case'submit':break;default:var ObjType=document.forms[FormName].elements[ObjName][0].type;if(ObjType=="radio"){for(i=0;i<document.forms[FormName].elements[ObjName].length;i++){if(document.forms[FormName].elements[ObjName][i]){if(document.forms[FormName].elements[ObjName][i].value==ObjVal){document.forms[FormName].elements[ObjName][i].checked="1";}}else{ObjNotFound("SetObj",ObjName+"["+i+"]");}}}
break;}}else{ObjNotFound("SetObj",ObjName);}}
function ObjValue(ObjName){if(window.location.hostname=="localhost"){if(!document.forms[FormName].elements[ObjName])alert("GESTFORM.ObjValue() ERROR: "+ObjName+" non trovato.");}
if(!document.forms[FormName].elements[ObjName].type){ObjType="radio";}else{ObjType=document.forms[FormName].elements[ObjName].type;}
switch(ObjType){case"select-multiple":case"select-one":var SelIndex=document.forms[FormName].elements[ObjName].selectedIndex;if(SelIndex==-1){var Valore="";}else{var Valore=document.forms[FormName].elements[ObjName].options[SelIndex].value;}
break;case"text":case"textarea":case"password":case"hidden":case'file':var Valore=document.forms[FormName].elements[ObjName].value;break;case"checkbox":if(document.forms[FormName].elements[ObjName].checked){var Valore=document.forms[FormName].elements[ObjName].value;}else{var Valore="";}
break;case'button':case'image':case'option':case'reset':case'submit':break;default:if(document.forms[FormName].elements[ObjName].length){for(var j=0;j<document.forms[FormName].elements[ObjName].length;j++){if(document.forms[FormName].elements[ObjName][j].checked==true){Valore=document.forms[FormName].elements[ObjName][j].value;}}}else{ObjNotFound("ObjValue",ObjName+".type");}
break;}
return Valore;}
function ObjText(ObjName){if(!document.forms[FormName].elements[ObjName].type){ObjType="radio";}else{ObjType=document.forms[FormName].elements[ObjName].type;}
switch(ObjType){case"select-multiple":case"select-one":var SelIndex=document.forms[FormName].elements[ObjName].selectedIndex;if(SelIndex==-1){var Valore="";}else{var Valore=document.forms[FormName].elements[ObjName].options[SelIndex].text;}
break;case"text":case"textarea":case"password":case"hidden":case'file':var Valore=document.forms[FormName].elements[ObjName].value;break;case"checkbox":var Valore=document.forms[FormName].elements[ObjName].checked;break;case'button':case'image':case'option':case'reset':case'submit':break;default:if(document.forms[FormName].elements[ObjName].length){for(var j=0;j<document.forms[FormName].elements[ObjName].length;j++){if(document.forms[FormName].elements[ObjName][j].checked==true){Valore=document.forms[FormName].elements[ObjName][j].value;}}}else{ObjNotFound("ObjText",ObjName+".type");}
break;}
return Valore;}
function SelectClear(SelectName){for(var j=document.forms[FormName].elements[SelectName].options.length-1;j>=0;j--){document.forms[FormName].elements[SelectName].options[j]=null;}}
function OptionSelected(SelectName,OptionValue){if(document.forms[FormName].elements[SelectName]){var S=document.forms[FormName].elements[SelectName];for(var j=0;j<S.length;j++){if(S.options[j].value==OptionValue){return S.options[j].selected;}}
return false;}else{ObjNotFound("OptionSel",SelectName+"."+OptionValue);}}
function OptionSel(SelectName,OptionValue){if(document.forms[FormName].elements[SelectName]){var S=document.forms[FormName].elements[SelectName];var Ritorna=false;for(var j=0;(j<S.length)&&(Ritorna==false);j++){if(S.options[j].value==OptionValue){Ritorna=true;}}
if(Ritorna==true){S.options[j-1].selected=true;}
return Ritorna;}else{ObjNotFound("OptionSel",SelectName+"."+OptionValue);return false;}}
function OptionSelIndex(SelectName,OptionIndex){if(document.forms[FormName].elements[SelectName].options[OptionIndex]){if(arguments.length==3){var v=arguments[2];}else{var v=true;}
document.forms[FormName].elements[SelectName].options[OptionIndex].selected=v;}}
function OptionDelete(SelectName,OptionValue){var Ritorna=false;if(!document.forms[FormName].elements[SelectName]){ObjNotFound("OptionDelete",SelectName+"."+OptionValue);}else{var S=document.forms[FormName].elements[SelectName];for(var j=0;(j<S.length)&&(Ritorna==false);j++){if(S.options[j].value==OptionValue){Ritorna=true;}}
if(Ritorna==true){S.options[j-1]=null;}}}
function OptionExist(SelectName,OptionValue){var Ritorna=false;if(!document.forms[FormName].elements[SelectName]){ObjNotFound("OptionExist",SelectName+"."+OptionValue);}else{var S=document.forms[FormName].elements[SelectName];for(var j=0;(j<S.length)&&(Ritorna==false);j++){if(S.options[j].value==OptionValue){Ritorna=true;}}}
return Ritorna;}
function OptionAdd(SelectName,OptionValue,OptionText){if(arguments.length>3){var arg4=arguments[3];}else{var arg4="";}
if(arguments.length>4){var arg5=arguments[4];}else{var arg5="";}
if(!document.forms[FormName].elements[SelectName]){ObjNotFound("OptionAdd",SelectName);}
var opt=new Option(OptionText,OptionValue,arg4,arg5);Index=document.forms[FormName].elements[SelectName].options.length;document.forms[FormName].elements[SelectName].options[Index]=opt;}
function BlockFormChr(ObjName,BlockedChrs){if(document.forms[FormName].elements[ObjName]){var Txt=document.forms[FormName].elements[ObjName].value;var S="";var Er=false;for(var J=0;J<Txt.length;J++){var Found=0;var Chr=Txt.substr(J,1);for(var I=0;(I<BlockedChrs.length)&&(Found=0);I++){if(BlockedChrs.substr(I,1)==Chr){Found=1;}}
if(Found==1){Er=true;}else{S=S+Chr;}}
if(Er)document.forms[FormName].elements[ObjName].value=S;}}
function AllowFormChr(ObjName,AllowedChrs){if(document.forms[FormName].elements[ObjName]){var Txt=document.forms[FormName].elements[ObjName].value;var S="";var Er=false;for(var J=0;J<Txt.length;J++){var Found=0;var Chr=Txt.substr(J,1);for(var I=0;I<AllowedChrs.length;I++){if(AllowedChrs.substr(I,1)==Chr){Found=1;}}
if(Found==1){S=S+Chr;}else{Er=true;}}
if(Er)document.forms[FormName].elements[ObjName].value=S;}}
function AddRemember(AddName,AddValue){if(!document.forms[FormName].elements["HidRemember"]){ObjNotFound("AddRemember","HidRemember");}
if(AddValue!=""){AddValue=ValidateValue(AddValue);}
var Remember=document.forms[FormName].elements["HidRemember"].value;if(Remember.length==0){Remember=AddName+"="+AddValue;}else{var SearchIn="&"+Remember;var Pos=SearchIn.search("&"+AddName+"=");if(Pos!=-1){if(Pos!=0){Pos--;Concat="&";}else{Concat="";}
for(I=Pos+1;(I<Remember.length)&&(Remember.substr(I,1)!="&");I++){}
if(Remember.substr(I,1)!="&"){PosAnd=-1;}else{PosAnd=I;}
if(PosAnd==-1){Remember=Remember.substr(0,Pos)+Concat+AddName+"="+AddValue;}else{Remember=Remember.substr(0,Pos)+Concat+AddName+"="+AddValue+Remember.substr(PosAnd);}}else{Remember=Remember+"&"+AddName+"="+AddValue;}}
document.forms[FormName].elements["HidRemember"].value=Remember;return Remember;}
function ReadRemember(VarName){if(!document.forms[FormName].elements["HidRemember"]){ObjNotFound("ReadRemember","HidRemember");}
var Remember=document.forms[FormName].elements["HidRemember"].value;var SearchIn="&"+Remember;var Pos=SearchIn.search("&"+VarName+"=");if(Pos!=-1){for(I=Pos+1;Remember.substr(I,1)!="=";I++){}
PosEq=I;for(I=Pos+1;(I<Remember.length)&&(Remember.substr(I,1)!="&");I++){}
if(Remember.substr(I,1)!="&"){PosAnd=-1;}else{PosAnd=I;}
if(PosAnd==-1){var Value=Remember.substr(PosEq+1);}else{var Value=Remember.substring(PosEq+1,PosAnd);}
Value=UnValidateValue(Value);return Value;}else{return"";}}
function ObjNotFound(FunctionName,ObjName){if(window.location.host=="localhost"&&!IgnoreObjNotFound){window.status="JS "+FunctionName+" Err: "+ObjName+" not found.";StatusBarScroll();}}
