var changingCUR=false;

function set_defcur(cur){
changingCUR =true;
if (document.SWREG) {
    if (document.SWREG.CUR) {
         for (var i=0; i< document.SWREG.CUR.length; i++) {
             if (cur == document.SWREG.CUR.options[i].value) {
                 document.SWREG.CUR.selectedIndex = i
                 break
             }
         }
     }
}
changingCUR =false;
}

function set_currency(cur,url){
  if (!changingCUR){
   var newloc = url+'?CUR=' + cur;
if (document.images)
    location.replace(newloc);
else
    location = newloc;
    }
}
    function toggleexpand(){
     var table = document.getElementById("ordertable");
     var cells = table.getElementsByTagName("tr");
     for (var i = 0; i < cells.length; i++) {
      if (cells[i].className == "toggle")
         cells[i].style.display=( (cells[i].style.display=='none') ? '' : 'none');
         if (cells[i].style.display=='none') {
            var inps = cells[i].getElementsByTagName("input");
               for (var j = 0; j < inps.length; j++) {
                inps[j].value=''
               }
         }
     }
     }

   function isEmpty(){
     var table = document.getElementById("ordertable");
     var cells = table.getElementsByTagName("input");
     for (var i = 0; i < cells.length; i++) {
      if (cells[i].className == 'qty' || cells[i].className == 'pqty') {
        if (cells[i].style.display!='none' && cells[i].value !='' ) return false;
      }
    }
    return true;
   }

    function hasProd(){
     var table = document.getElementById("ordertable");
     var cells = table.getElementsByTagName("input");
     for (var i = 0; i < cells.length; i++) {
      if (cells[i].className == 'pqty') {
        if (cells[i].style.display!='none' && cells[i].value !='' ) return true;
      }
    }
    return false;
   }

function showwin (URL,winwidth,winheight){
window.open(URL,"_blank",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width='+winwidth+',height='+winheight);
}

   

function synchQty(inp){
  var S = inp.value.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
  if (S!=''){
     var table = document.getElementById("ordertable");
     var cells = table.getElementsByTagName("input");
     for (var i = 0; i < cells.length; i++) {
      if (cells[i]!=inp && (cells[i].className == 'pqty' || cells[i].className == 'qty') 
       && cells[i].value && (cells[i].value.replace(/^\s\s*/, '').replace(/\s\s*$/, '')!='')) {
        cells[i].value = S;
      }
 
  }
}
}
