//'** - JS admin v2.15.00 - **
var SelectFirst="Devi effettuare una selezione per procedere."//"You must make a choice to proceed"
var ConfirmExit="Confermi l'uscita?"//"Confirm action?"
var ConfirmAction="Sei sicuro?"//"Are you sure"
var jSelColor='#A6C1DC' //'#7DAEF7'
var jCCcolor='#fbedec' //'#D3E3FC'
var jSelCCcolor='#2B8049' //'#003366'
var jApp='lpweb'


//-----------------------------------	


function HideField(asel)
{
    setTimeout('document.getElementById(asel).style.visibility="hidden"',200);
//document.getElementById(asel).style.visibility="hidden";
}

function PrintForm(asel)
{
    show_loading();
    mw = 10;
    mx = 1
    mh = 100;
    my = 1
    if (my < 0)
        my = 0;
	
    var testo = "<html><head><title> </title>";
    testo +="<LINK REL='stylesheet' type='text/css' href='../css/form.css'>";
    testo +="</head>";
    testo += "<body onload='javascript:print()';><center>";
    testo += "<table width=\"100%\" border=\"0\"><tr><td>";
    testo += document.getElementById(asel).innerHTML+"</td></tr></table>";
    testo += "<script>setTimeout('window.close();\',700);</script>";
    testo += "</body></html>";
    var ident_finestra = window.open("","finestra_stampa","top=" + my + ",left=" + my + ",width=" + mw + ",height=" + mh);
    ident_finestra.document.open();
    ident_finestra.document.write(testo);
    ident_finestra.document.close();
    hide_loading();
}

function Selform(tname,asel,aselid,ascheda,apagerpt,apegemod)
{
    obj=eval("document.getElementById('"+tname+asel+"')")
    if (document.SelForm.SELLINE.value!="")
    {
        objold=eval("document.getElementById('"+tname+document.SelForm.SELLINE.value+"')")
        objold.style.background='transparent';
        objold.style.color='#000000';
    }
    obj.style.background=jSelColor;
    obj.style.color='#000000';
    document.SelForm.SELLINE.value=asel;
    document.SelForm.SELID.value=aselid;
    document.SelForm.FCOD.value=ascheda;
    document.SelForm.PAGERPT.value=apagerpt;
    document.SelForm.PAGEMOD.value=apegemod;
}

function Selval(tname,asel,aselid)
{
    obj=eval("document.getElementById('"+tname+asel+"')")
    if (document.SelForm.SELLINE.value!="")
    {
        objold=eval("document.getElementById('"+tname+document.SelForm.SELLINE.value+"')")
        objold.style.background='transparent';
        objold.style.color='#000000';
    }
    if (document.SelForm.SELLINE.value==asel)
    {
    //obj.style.background='#FFFFFF';
    //obj.style.color='#000000';
    //document.SelForm.SELLINE.value="";
    //document.SelForm.SELID.value="";
    }
    else
    {
        eval("document.getElementById('"+tname+asel+"').style.background='"+jSelColor+"'");
        eval("document.getElementById('"+tname+asel+"').style.color='#000000'");
        document.SelForm.SELLINE.value=asel;
        document.SelForm.SELID.value=aselid;
    }
}

function Selreturn(divname,tname,asel)
{
    if (asel!="")
    {
        objDiv=document.getElementById(divname);
        objRT=eval("document.getElementById('"+tname+asel+"')");

        if (objRT)
        {
            mdiv=objDiv.offsetHeight;
            mlinT=objRT.offsetTop;
            mlinH=objRT.offsetHeight;
            aScroll=mlinT+mlinH-mdiv+5;
            if (aScroll>0){
                objDiv.scrollTop=aScroll;
            }
            objRT.style.background=jSelColor;
            document.SelForm.SELLINE.value=asel;
            document.SelForm.SELID.value=asel;
        }
        else
        {
            document.SelForm.SELLINE.value="";
            document.SelForm.SELID.value="";
        }
    }
}

function Selformreturn(divname,tname,asel,aselid,ascheda,apagerpt,apegemod)
{
    if (asel!="")
    {
        objDiv=document.getElementById(divname);
        objRT=eval("document.getElementById('"+tname+asel+"')");

        if (objRT)
        {
            mdiv=objDiv.offsetHeight;
            mlinT=objRT.offsetTop;
            mlinH=objRT.offsetHeight;
            aScroll=mlinT+mlinH-mdiv+5;
            if (aScroll>0){
                objDiv.scrollTop=aScroll;
            }
            objRT.style.background=jSelColor;
            document.SelForm.SELLINE.value=asel;
            document.SelForm.SELID.value=aselid;
            document.SelForm.FCOD.value=ascheda;
            document.SelForm.PAGERPT.value=apagerpt;
            document.SelForm.PAGEMOD.value=apegemod;
        }
        else
        {
            document.SelForm.SELLINE.value="";
            document.SelForm.SELID.value="";
            document.SelForm.FCOD.value="";
            document.SelForm.PAGERPT.value="";
            document.SelForm.PAGEMOD.value="";
        }
    }
}


function CC(tname,asel)
{
    obj=eval("document.getElementById('"+tname+asel+"')")
    if (asel!=document.SelForm.SELLINE.value)
    {
        obj.style.background=jCCcolor;
        obj.style.color='#000000';
    }
    else
    {
        obj.style.background=jSelCCcolor;
        obj.style.color='#FFFFFF';
    }
}
function show_loading(){
    //DUMMY
}
function hide_loading(){
    //DUMMY
}
function DC(tname,asel)
{
    obj=eval("document.getElementById('"+tname+asel+"')")
    if (asel!=document.SelForm.SELLINE.value)
    {
        obj.style.background='transparent';
    }
    else
    {
        obj.style.background=jSelColor;
        obj.style.color='#000000';
    }
}

function Go(apage)
{
    show_loading()
    document.location.pathname=apage
}

function GoID(apage)
{
    var selid=document.SelForm.SELID.value
    if (selid!="")
    {
        show_loading()
        document.location.pathname=apage+selid
    }
    else
    {
        alert(SelectFirst)
    }
	
}

function GoSelid(apage)
{
    var selid=document.SelForm.SELID.value
    if (selid!="")
    {
        show_loading()
        document.location.pathname=apage+"SELID="+selid
    }
    else
    {
        alert(SelectFirst)
    }
	
}

function GoMainid(apage)
{
    var selid=document.SelForm.SELID.value
    if (selid!="")
    {
        show_loading()
        document.location.pathname=apage+"MAINID="+selid
    }
    else
    {
        alert(SelectFirst)
    }
	
}

function GoSelForm(apage)
{
    var selid=document.SelForm.SELID.value
    if (selid!="" && apage!="")
    {
        var ascheda=document.SelForm.FCOD.value
        destPage=apage+"FCOD="+ascheda
        var selid=document.SelForm.SELID.value
        if (selid!=''){
            destPage=destPage+"&SELID="+selid
            }
        show_loading()
        document.location.pathname=destPage;
    }
    else
    {
        alert(SelectFirst)
    }
		
}

function GoSelidConfirm(apage)
{
    var selid=document.SelForm.SELID.value
    if (selid!="")
    {
        var truthBeTold = window.confirm(ConfirmAction);
        if (truthBeTold)
        {
            show_loading()
            document.location.pathname=apage+"SELID="+selid
        }
    }
    else
    {
        alert(SelectFirst)
    }
}

function GoDelidConfirm(apage)
{
    var selid=document.SelForm.SELID.value
    if (selid!="")
    {
        var truthBeTold = window.confirm("Confermi l'eliminazione?");
        if (truthBeTold)
        {
            var truthBeTold2 = window.confirm("Attenzione, il record non potrà essere recuperato\nSei sicuro?");
            if (truthBeTold2)
            {
                show_loading()
                document.location.pathname=apage+"SELID="+selid
            }
        }
    }
    else
    {
        alert(SelectFirst)
    }
}

function GoPageConfirm(apage)
{
    var truthBeTold = window.confirm(ConfirmAction);
    if (truthBeTold)
    {
        show_loading()
        document.location.pathname=apage;
    }
}

function Annulla(apage)
{
    var truthBeTold = window.confirm(ConfirmExit);
    if (truthBeTold)
    {
        show_loading()
        document.location.pathname=apage;
    }
}

function HelpWin(page) {
    mw = 10;
    mh = 10;
    mx = (screen.width - 400) / 2;
    my = 100;
    if (my < 0)
        my = 0;
    wWin= window.open(page,jApp+"help","toolbar=no,left=" + mx + ",top=" + my + ",width=" + mw + ",height=" + mh + ",directories=no,status=no,scrollbars=no,resizable=no" + ",menubar=no,location=no,copyhistory=no");

    wWin.focus();
}

function noNumbers(e)
{
    if (e.which)
    {
        if(e.which==13)
            document.FrmSel.submit();
        else if(e.which!=46 && e.which!=8 && (e.which<48 || e.which>57))
            return false;
    }
    else if(e.keyCode)
    {
        if(e.keyCode==13)
            document.FrmSel.submit();
        else if(e.keyCode!=46 && e.keyCode!=8 && (e.keyCode<48 || e.keyCode>57))
            return false;
    }
    return true;
    alert(e.keyCode)
}

function PrevPage(){
    npage=document.FrmSel.PAG;
    cpage=document.FrmSel.CURPAG;
    if (npage.value==cpage.value){
        npage.value--;
    }
    GoPage();
}
function NextPage(){
    npage=document.FrmSel.PAG;
    cpage=document.FrmSel.CURPAG;
    if (npage.value==cpage.value){
        npage.value++;
    }
    GoPage();
}
function GoPage(){
    if (typeof(document.FrmSel.btnext) == "object"){
        document.FrmSel.btnext.disabled=true;
    }
    if (typeof(document.FrmSel.btprev) == "object"){
        document.FrmSel.btprev.disabled=true;
    }
    document.FrmSel.submit();
}
function SearchSubmit(){
    document.FrmSel.PAG.value=1;
    document.FrmSel.submit();
}

function loadtrial() {
    mw = 850;
    mx = (screen.width - mw) / 2;
    mh = 570;
    my = ((screen.height - 45) - mh) / 2;
    if (my < 0)
        my = 0;

    wadmin= window.open("menulogin.asp", jApp,"toolbar=no,left=" + mx + ",top=" + my + ",width=" + mw + ",height=" + mh + ",directories=no,status=no,scrollbars=no,resizable=no" + ",menubar=no,location=no,copyhistory=no");
    wadmin.focus();
}

function eraseListBox(atxt){
    var a= new Array()
    a=eraseListBox.arguments;
    for(var i=0; i<a.length; i++){
        opt=eval("document.AppForm."+a[i]+".options");
        while (opt.length > 0){
            opt[0]=null
            }
			
        aid=0
        aval="..."
        opt[0]=new Option(aval,aid)
    }
}

function loadsel(apage,adb,afld,adescr1,adescr2,atxt,atxtdat,afldfilter,avalfilter,afcod) {
    mw = 770;
    mh = 480;
    var wselver=document.AppForm.selver.value
    if (wselver!="open") {
        document.AppForm.selver.value="open";
        page=apage+"?TXT="+atxt+"&PAGE="+apage+"&DB="+adb+"&FLD="+afld+"&DESCR1="+adescr1+"&DESCR2="+adescr2+"&S="+atxtdat+"&FCOD="+afcod+"&FLDFILTER="+afldfilter+"&VALFILTER="+avalfilter
        //prompt("PROVA",page)
        if (window.showModelessDialog) {
            window.showModelessDialog(page,window,"status:no;resizable:no;center:yes;scroll:no;dialogWidth:"+mw+"px;dialogHeight:"+mh+"px;");
        //window.open(page, jApp+"ver","toolbar=no,directories=no,status=no,scrollbars=no,resizable=no" + ",menubar=no,location=no,copyhistory=no");
        //window.open(page)
        }
        else
        {

            mx = (screen.width - mw) / 2;
            my = ((screen.height - 45) - mh) / 2;
            if (my < 0)
                my = 0;
            upwin=window.open(page, jApp+"ver","toolbar=no,left=" + mx + ",top=" + my + ",width=" + mw + ",height=" + mh + ",directories=no,status=no,scrollbars=no,resizable=no,menubar=no,location=no,copyhistory=no");
        }
    }
}

function loadver(adb,afld,atxt,apage) {
    eval("var txtver=document.AppForm."+atxt+".value;")
    var txtver=txtver.replace(" ","")
    var txtver=txtver.replace("/","'/")
    if (txtver != "") {
        page=apage+"?DB="+adb+"&FLD="+afld+"&TXT="+atxt+"&TXTVER="+txtver
        if (window.showModelessDialog) {
            window.showModelessDialog(page,window,"status:no;resizable:no;center:yes;scroll:no;dialogWidth:200px;dialogHeight:30px;");
        //**TEST//window.open(page)
        }
        else
        {
            mw = 200;
            mx = (screen.width - mw) / 2;
            mh = 30;
            my = ((screen.height - 45) - mh) / 2;
            if (my < 0)
                my = 0;
            window.open(page, "ver","toolbar=no,left=" + mx + ",top=" + my + ",width=" + mw + ",height=" + mh + ",directories=no,status=no,scrollbars=no,resizable=no" + ",menubar=no,location=no,copyhistory=no");
            upwin.focus();
        }
		
		
    //
    } else {
        eval("document.AppForm."+atxt+".value='';")
        }
}

function loadfiles(apage,atxt) {
    mw = 770;
    mh = 480;
    var wselver=document.AppForm.selver.value
    if (wselver!="open") {
        document.AppForm.selver.value="open";
        page=apage+"?FLD="+atxt

        if (window.showModelessDialog) {
            window.showModelessDialog(page,window,"status:no;resizable:no;center:yes;scroll:no;dialogWidth:"+mw+"px;dialogHeight:"+mh+"px;");
        //window.open(page, jApp+"ver","toolbar=no,directories=no,status=no,scrollbars=no,resizable=no" + ",menubar=no,location=no,copyhistory=no");
        }
        else
        {

            mx = (screen.width - mw) / 2;
            my = ((screen.height - 45) - mh) / 2;
            if (my < 0)
                my = 0;
            upwin=window.open(page, jApp+"up","toolbar=no,left=" + mx + ",top=" + my + ",width=" + mw + ",height=" + mh + ",directories=no,status=no,scrollbars=no,resizable=no" + ",menubar=no,location=no,copyhistory=no");
            upwin.focus();
        }
    }
}

//**AJax***********************************************************************************
var xmlHttp;

function GetXmlHttpObject()
{
    var xmlHttp=null;
    try
    {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {
        // Internet Explorer
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}

function GetAJax(method,url,sync)
{
    xmlHttp.open(method,url,sync);
    xmlHttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
    xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");
    xmlHttp.send(null);
}


function checkUsing(adb,afld,afldid,atxt,atipo,apage)
{ 
    show_loading()
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    }

    eval("var txtver=document.AppForm."+atxt+".value;")
	
    if (txtver!=""){
        var aid=document.AppForm.SELID.value
        //var txtver=txtver.replace(" ","")
        //var txtver=txtver.replace("/","'/")
        var url=apage+"?DB="+adb+"&FLD="+afld+"&FLDID="+afldid+"&TXT="+atxt+"&TXTVER="+txtver+"&TIPO="+atipo+"&SELID="+aid;
        //prompt("PROVA",url)
        xmlHttp.onreadystatechange=function()
        {
            if (xmlHttp.readyState==4 && xmlHttp.status == 200)
            {
                var test=xmlHttp.responseText
                if (test.indexOf("</script>",0)!=-1) test=test.substring(test.lastIndexOf("</script>") + 9);
				
                if (test)
                {
                    obj=eval("document.AppForm."+atxt);
                    var checktxt=obj.value;
                    obj.value='';
                    if (eval("document.AppForm."+atxt+"_dat")){
                        objdat=eval("document.AppForm."+atxt+"_dat");
                        checktxt=objdat.value;
                        objdat.value='';
                        objdat.focus();
                    }else{
                        obj.focus();
                    }
                    alert(afld.toUpperCase()+' ('+checktxt+') utilizzato');
                }
            }
        }
    }
    GetAJax("GET",url,false)
    hide_loading()
}

function checkExist(adb,afld,atxt,atipo,apage)
{ 
    show_loading()
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    }

    eval("var txtver=document.AppForm."+atxt+".value;")
    if (txtver!=""){
        var aid=document.AppForm.SELID.value
        //var txtver=txtver.replace(" ","")
        //var txtver=txtver.replace("/","'/")
        var url=apage+"?DB="+adb+"&FLD="+afld+"&TXT="+atxt+"&TXTVER="+txtver+"&TIPO="+atipo+"&SELID="+aid;
        //prompt("PROVA",url)
        xmlHttp.onreadystatechange=function()
        {
            if (xmlHttp.readyState==4 && xmlHttp.status == 200)
            {
                var test=xmlHttp.responseText
                if (test.indexOf("</script>",0)!=-1) test=test.substring(test.lastIndexOf("</script>") + 9);
				
                if (test)
                {
                    obj=eval("document.AppForm."+atxt);
                    if(eval("document.AppForm."+atxt+"_id")){
                        objid=eval("document.AppForm."+atxt+"_id");
                        objid.value='';
                    }
                    checktxt=obj.value
                    obj.value='';
                    obj.focus();
                    alert(afld.toUpperCase()+' ('+checktxt+') non trovato');
                }
            }
        }
    }
    GetAJax("GET",url,false)
    hide_loading()
}

function loadlistbox(adb,afld,atxt,asel)
{
    show_loading()
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    }

    var url="loaddat.asp?DB="+adb+"&FLD="+afld+"&SELID="+asel;
    //prompt("link",url)
    xmlHttp.onreadystatechange=function()
    {
        if (xmlHttp.readyState==4 && xmlHttp.status == 200)
        {
            var test=xmlHttp.responseText
            if (test.indexOf("</script>",0)!=-1) test=test.substring(test.lastIndexOf("</script>") + 9);
            eval("test=new Array("+test+")")
            var count=0
            opt=eval("document.AppForm."+atxt+".options");
            while (opt.length > 0){
                opt[0]=null
                }

            for (i=0;i<test.length;i+=2){
                aid=test[i]
                aval=test[i+1]
                opt[count]=new Option(aval,aid)
                count++
            }
        }
    }
    GetAJax("GET",url,false)
    hide_loading()
}

function XMLloadlistbox(adb,afld,atxt,asel)
{
    show_loading()
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    }

    var url="loaddatxml.asp?DB="+adb+"&FLD="+afld+"&SELID="+asel;

    xmlHttp.onreadystatechange=function()
    {
        if (xmlHttp.readyState==4 && xmlHttp.status == 200)
        {
			
            var xmlDoc=xmlHttp.responseXML.documentElement;

            var aid
            var aval

            opt=eval("document.AppForm."+atxt+".options");
            while (opt.length > 0){
                opt[0]=null
                }
            xmlRecCount=xmlDoc.getElementsByTagName("id").length

            for (i=0;i<xmlRecCount;i++){
                aid=xmlDoc.getElementsByTagName("id")[i].childNodes[0].nodeValue
                aval=xmlDoc.getElementsByTagName("descrizione")[i].childNodes[0].nodeValue
                opt[i]=new Option(aval,aid)
            }
        }
    }
    GetAJax("GET",url,false)
    hide_loading()
}

//Librerie custom-----------------------------------------------------------------

function checkCodice(atxt,aval,apage)
{ 
    show_loading()
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    }

    eval("var txtver=document.AppForm."+atxt+".value;")
    if (txtver!=""){
        //parte temporanea da rimuovuere dopo la demo
        eval("var tmptxt=document.AppForm."+atxt+";")
        if(tmptxt.name=="txt_codice_kit"){
            tmptest=tmptxt.value.replace(/\D/g, '');
            tmptxt.value=tmptest;
            aval=tmptest;
        }
		
        //end parte temporanea
        var aid=document.AppForm.SELID.value
        var url=apage+"?VAL="+aval
        //prompt("PROVA",url)
        xmlHttp.onreadystatechange=function()
        {
            if (xmlHttp.readyState==4 && xmlHttp.status == 200)
            {
                var test=xmlHttp.responseText
                if (test.indexOf("</script>",0)!=-1) test=test.substring(test.lastIndexOf("</script>") + 9);
				
                if (test!="")
                {
                    obj=eval("document.AppForm."+atxt);
                    obj.value='';
                    obj.focus();
                    alert(test);
                }
            }
        }
    }
    GetAJax("GET",url,false)
    hide_loading()
}


