

window.onscroll = function() {
    
    var winScroll = document.body.scrollTop || document.documentElement.scrollTop;
    var height = document.documentElement.scrollHeight - document.documentElement.clientHeight;
    var scrolled = (winScroll / height) * 100;
    document.getElementById("myBar").style.width = scrolled + "%";

    }

/*
    $(document).ready(function(){
        
        $("#nav_btn_img").click(function(){
            alert("Confirmed");
        });
    });
*/



/* side bar show/hide code */

document.getElementById("nav_btn_img").addEventListener("click", showHideNav);

let toggle = true;
function showHideNav() {
    if(toggle === true){
    openNav();
    toggle = false;
    } else {
    closeNav();
    toggle = true;
    }
}

/* Set the width of the side navigation to 250px and the left margin of the page content to 250px */
function openNav() {
  document.getElementById("mySidenav").style.width = "150px";
  document.getElementById("nav_btn_img").innerHTML = "&times; ";
  document.getElementById("main").style.marginLeft = "150px";
  document.getElementById("center").style.left = "4%";
  document.getElementById("center2").style.left = "2%";
  document.getElementById("nav_btn_img").style.left = "170px";
  
}

/* Set the width of the side navigation to 0 and the left margin of the page content to 0 */
function closeNav() {
  document.getElementById("mySidenav").style.width = "0";
  document.getElementById("nav_btn_img").innerHTML = "&#9776; ";
  document.getElementById("main").style.marginLeft = "0";
  document.getElementById("center").style.left = "-50%";
  document.getElementById("center2").style.left = "-50%";
  document.getElementById("nav_btn_img").style.left = "15px";
  
}
















/*

 var print1 = document.getElementById("print1");
    if(print1){

document.getElementById("print1").addEventListener("keyup", print11);
    }
    
    



  function print11() {
        // Create an IFrame.
        var iframe = document.createElement('iframe');  
        // Hide the IFrame.  
        iframe.style.visibility = "hidden"; 
        // Define the source.  
        iframe.src = "https://portal.starlight-airlines.com//accounting/invoices/2/";        
        // Add the IFrame to the web page.
        document.body.appendChild(iframe);  
        iframe.contentWindow.focus();       
        iframe.contentWindow.print(); // Print.
    }
*/





//filtertable sales list

/*
$( "#searchPerClientName" ).keyup(function() {
  searchClientFunction();
});


$( "#searchPerDescriptionName" ).keyup(function() {
  searchDescriptionFunction();
});

*/

/*
document.getElementById("searchPerClientName").onkeyup = function() {
    searchClientFunction();
    
};
*/

 var search1 = document.getElementById("searchPerClientName");
    if(search1){

document.getElementById("searchPerClientName").addEventListener("keyup", searchClientFunction);
    }
    
    
function searchClientFunction() {
  // Declare variables
  var input, filter, table, tr, td, i, txtValue;
  input = document.getElementById("searchPerClientName");
  filter = input.value.toUpperCase();
  table = document.getElementById("qtn_table");
  tr = table.getElementsByTagName("tr");

  // Loop through all table rows, and hide those who don't match the search query
  for (i = 0; i < tr.length; i++) {
    td = tr[i].getElementsByTagName("td")[2];
    if (td) {
      txtValue = td.textContent || td.innerText;
      if (txtValue.toUpperCase().indexOf(filter) > -1) {
        tr[i].style.display = "";
      } else {
        tr[i].style.display = "none";
      }
    }
  }
}



 var search2 = document.getElementById("searchPerDescriptionName");
    if(search2){
document.getElementById("searchPerDescriptionName").addEventListener("keyup", searchDescriptionFunction);
}



function searchDescriptionFunction() {
  // Declare variables
  var input, filter, table, tr, td, i, txtValue;
  input = document.getElementById("searchPerDescriptionName");
  filter = input.value.toUpperCase();
  table = document.getElementById("qtn_table");
  tr = table.getElementsByTagName("tr");

  // Loop through all table rows, and hide those who don't match the search query
  for (i = 0; i < tr.length; i++) {
    td = tr[i].getElementsByTagName("td")[3];
    if (td) {
      txtValue = td.textContent || td.innerText;
      if (txtValue.toUpperCase().indexOf(filter) > -1) {
        tr[i].style.display = "";
      } else {
        tr[i].style.display = "none";
      }
    }
  }
}






 var search3 = document.getElementById("searchPerRef");
    if(search3){
document.getElementById("searchPerRef").addEventListener("keyup", searchRefFunction);
}



function searchRefFunction() {
  // Declare variables
  var input, filter, table, tr, td, i, txtValue;
  input = document.getElementById("searchPerRef");
  filter = input.value.toUpperCase();
  table = document.getElementById("qtn_table");
  tr = table.getElementsByTagName("tr");

  // Loop through all table rows, and hide those who don't match the search query
  for (i = 0; i < tr.length; i++) {
    td = tr[i].getElementsByTagName("td")[4];
    if (td) {
      txtValue = td.textContent || td.innerText;
      if (txtValue.toUpperCase().indexOf(filter) > -1) {
        tr[i].style.display = "";
      } else {
        tr[i].style.display = "none";
      }
    }
  }
}



 var search31 = document.getElementById("searchDateRef");
    if(search31){
document.getElementById("searchDateRef").addEventListener("keyup", searchDateFunction);
}

function searchDateFunction() {
  // Declare variables
  var input, filter, table, tr, td, i, txtValue;
  input = document.getElementById("searchDateRef");
  filter = input.value.toUpperCase();
  table = document.getElementById("qtn_table");
  tr = table.getElementsByTagName("tr");

  // Loop through all table rows, and hide those who don't match the search query
  for (i = 0; i < tr.length; i++) {
    td = tr[i].getElementsByTagName("td")[5];
    if (td) {
      txtValue = td.textContent || td.innerText;
      if (txtValue.toUpperCase().indexOf(filter) > -1) {
        tr[i].style.display = "";
      } else {
        tr[i].style.display = "none";
      }
    }
  }
}






 var search4 = document.getElementById("searchPerJob");
    if(search4){
document.getElementById("searchPerJob").addEventListener("keyup", searchJobFunction);
}



function searchJobFunction() {
  // Declare variables
  var input, filter, table, tr, td, i, txtValue;
  input = document.getElementById("searchPerJob");
  filter = input.value.toUpperCase();
  table = document.getElementById("qtn_table");
  tr = table.getElementsByTagName("tr");

  // Loop through all table rows, and hide those who don't match the search query
  for (i = 0; i < tr.length; i++) {
    td = tr[i].getElementsByTagName("td")[6];
    if (td) {
      txtValue = td.textContent || td.innerText;
      if (txtValue.toUpperCase().indexOf(filter) > -1) {
        tr[i].style.display = "";
      } else {
        tr[i].style.display = "none";
      }
    }
  }
}





 var search5 = document.getElementById("searchPerInv");
    if(search5){
document.getElementById("searchPerInv").addEventListener("keyup", searchInvFunction);
}



function searchInvFunction() {
  // Declare variables
  var input, filter, table, tr, td, i, txtValue;
  input = document.getElementById("searchPerInv");
  filter = input.value.toUpperCase();
  table = document.getElementById("qtn_table");
  tr = table.getElementsByTagName("tr");

  // Loop through all table rows, and hide those who don't match the search query
  for (i = 0; i < tr.length; i++) {
    td = tr[i].getElementsByTagName("td")[7];
    if (td) {
      txtValue = td.textContent || td.innerText;
      if (txtValue.toUpperCase().indexOf(filter) > -1) {
        tr[i].style.display = "";
      } else {
        tr[i].style.display = "none";
      }
    }
  }
}




 var search6 = document.getElementById("searchPerPO");
    if(search6){
document.getElementById("searchPerPO").addEventListener("keyup", searchPoFunction);
}



function searchPoFunction() {
  // Declare variables
  var input, filter, table, tr, td, i, txtValue;
  input = document.getElementById("searchPerPO");
  filter = input.value.toUpperCase();
  table = document.getElementById("qtn_table");
  tr = table.getElementsByTagName("tr");

  // Loop through all table rows, and hide those who don't match the search query
  for (i = 0; i < tr.length; i++) {
    td = tr[i].getElementsByTagName("td")[8];
    if (td) {
      txtValue = td.textContent || td.innerText;
      if (txtValue.toUpperCase().indexOf(filter) > -1) {
        tr[i].style.display = "";
      } else {
        tr[i].style.display = "none";
      }
    }
  }
}




 var search7 = document.getElementById("searchPerDoc");
    if(search7){
document.getElementById("searchPerDoc").addEventListener("keyup", searchDocFunction);
}



function searchDocFunction() {
  // Declare variables
  var input, filter, table, tr, td, i, txtValue;
  input = document.getElementById("searchPerDoc");
  filter = input.value.toUpperCase();
  table = document.getElementById("qtn_table");
  tr = table.getElementsByTagName("tr");

  // Loop through all table rows, and hide those who don't match the search query
  for (i = 0; i < tr.length; i++) {
    td = tr[i].getElementsByTagName("td")[1];
    if (td) {
      txtValue = td.textContent || td.innerText;
      if (txtValue.toUpperCase().indexOf(filter) > -1) {
        tr[i].style.display = "";
      } else {
        tr[i].style.display = "none";
      }
    }
  }
}







 var search8 = document.getElementById("searchPerUser");
    if(search8){
document.getElementById("searchPerUser").addEventListener("keyup", searchUsrFunction);
}



function searchUsrFunction() {
  // Declare variables
  var input, filter, table, tr, td, i, txtValue;
  input = document.getElementById("searchPerUser");
  filter = input.value.toUpperCase();
  table = document.getElementById("qtn_table");
  tr = table.getElementsByTagName("tr");

  // Loop through all table rows, and hide those who don't match the search query
  for (i = 0; i < tr.length; i++) {
    td = tr[i].getElementsByTagName("td")[9];
    if (td) {
      txtValue = td.textContent || td.innerText;
      if (txtValue.toUpperCase().indexOf(filter) > -1) {
        tr[i].style.display = "";
      } else {
        tr[i].style.display = "none";
      }
    }
  }
}


















         // (A) ALERT


// (B) CONFIRM
function demoB () {
  if (confirm("Continue?")) { alert("Yes"); }
}

// (C) PROMPT
function demoC () {
  var name = prompt("Enter Your Name", "Jon");
  alert("Your name is "+name);
}



