﻿// JScript File
function openwindow(url,top,left,width,height){
    window.open(url,'finestra','top='+ top +',left='+ left +',width='+ width +',height='+ height +',scrollbars=yes');
}
  
function openwindowproduct(url,top,left,width,height,nameCode,nameDescr){
    var urlpath=url + '?code=' + document.getElementById("" + nameCode + "").value +'&descr=' + document.getElementById("" + nameDescr + "").value+''
    window.open(urlpath,'finesta','top='+ top +',left='+ left +',width='+ width +',height='+ height +',scrollbars=yes');
}
 
function openwindowContact(url, top, left, width, height, code, nameCode, nameNome, nameTel, nameEmail){
    var urlpath = url + '?code=' + code + ''
    var urlpath = urlpath + '&nameCode=' + nameCode + ''
    var urlpath = urlpath + '&nameTel=' + nameTel + ''
    var urlpath = urlpath + '&nameEmail=' + nameEmail + ''
    var urlpath = urlpath + '&nameNome=' + nameNome + ''
    window.open(urlpath,'finesta','top='+ top +',left='+ left +',width='+ width +',height='+ height +',scrollbars=yes');
 } 
 
  function openwindowDestination(url, top, left, width, height,nameNome, nameInd, nameCap,nameCitta,nameProv,nameTel,nameFax,namePIVA,nameCF,nameEmail,nameStato,code){
    var urlpath = url + '?code=' + code + ''
    var urlpath = urlpath + '&nameNome=' + nameNome + ''
    var urlpath = urlpath + '&nameTel=' + nameTel + ''
    var urlpath = urlpath + '&nameFax=' + nameFax + ''
    var urlpath = urlpath + '&nameIndirizzo=' + nameInd + ''
    var urlpath = urlpath + '&nameCap=' + nameCap + ''
    var urlpath = urlpath + '&nameCitta=' + nameCitta + ''
    var urlpath = urlpath + '&nameProv=' + nameProv + ''
    var urlpath = urlpath + '&namePIVA=' + namePIVA + ''
    var urlpath = urlpath + '&nameCF=' + nameCF + ''
    var urlpath = urlpath + '&nameEmail=' + nameEmail + ''
    var urlpath = urlpath + '&nameStato=' + nameStato + ''
    window.open(urlpath,'finesta','top='+ top +',left='+ left +',width='+ width +',height='+ height +',scrollbars=yes');
 } 
 
function openDocument(filename){
    var urlpath= filename
    window.open(urlpath,'finesta','top=0,left=0,width=10,height=10,');
}

function clearValue(ValueName){
    document.getElementById("" + ValueName + "").value='';
}

function LBJS_ApriScheda(Codice,Url){
    LeftPosition = (screen.width) ? (screen.width-600)/2 : 0; 
    TopPosition = (screen.height) ? (screen.height-600)/2 : 0; 
    settings ='height=400,width=750,top='+TopPosition+',left='+LeftPosition+',scrollbars=yes' 
    win = window.open(Url + '?id=' + Codice + '','scheda',settings) 
    if(win.window.focus){ 
        win.window.focus(); 
    } 
}

 function CheckQuantity(control,testoerrore)
    {
        if (isNaN(control.value)) {
            alert(testoerrore);
            return false;
        }
        else {
            if (control.value <= 0) {
                alert(testoerrore);
                return false;
            }
            else {
                return true;
            }
        }
    }

function SelectAll(nome, check)
{
   for (var i = 0; i < document.forms(0).elements.length; i++) {
        var name = document.forms(0).elements(i).id
        if (name.indexOf(nome) > -1)
            document.forms(0).elements(i).checked = check;
    }
}

function SelectFather(nome, check)
{   var y = 0;
    if (check == true){
        for (var i = 0; i < document.forms(0).elements.length; i++) {
            var name = document.forms(0).elements(i).id
            if (name.indexOf(nome) > -1){
                y = y + 1;
                if (y==1){
                    document.forms(0).elements(i).checked = check;
                }            
            }
        }
    }else{
        var y = 0;
        var count = 0;
        var name1 = "";
         for (var i = 0; i < document.forms(0).elements.length; i++) {
            var name = document.forms(0).elements(i).id
            if (name.indexOf(nome) > -1){
                if (count==0){
                    name1 = document.forms(0).elements(i).id;   
                }
                count=count+1;
                if (document.forms(0).elements(i).checked == true){
                    y = y + 1;
                }
            }
        }
        if (y==1){
            document.getElementById(name1).checked=false;
        }
    }
}

function CheckCheckboxChecked (control, errorMessage)
{
    if (document.forms(0).elements(control).checked == true) {
        return true;
    }
    else {
        alert (errorMessage);
        return false;
    }
}

function ismaxlength(obj,length){
    if (obj.getAttribute && obj.value.length>length){
        obj.value=obj.value.substring(0,length)
    }
}