function filtreaza(e,affected){
var oAffected=document.getElementById(affected);
if (e.value!=''){
			var pattern=eval('/'+e.value+'/i');
			for (i=0; i<oAffected.options.length; i++){
					if (pattern.test(oAffected.options[i].text)){ oAffected.options[i].selected=true; return true; }
					}
	}
	else
	oAffected.options[0].selected=true;
}

function enPriv(e,i){
if (e.checked==true)
    document.getElementById('enable'+i).disabled=false;
  else
    document.getElementById('enable'+i).disabled=true;
}

function checkAddInvForm(frm,invId){
err=0;

if (frm.invResp.selectedIndex==0){
    document.getElementById('invRespLine1').style.backgroundColor='#cc0000';
    document.getElementById('invRespLine1').style.color='#fff';
    document.getElementById('invRespLine2').style.backgroundColor='#cc0000';
    err=1;
    }
  else{
    document.getElementById('invRespLine1').style.backgroundColor='#fff';
    document.getElementById('invRespLine1').style.color='#000';
    document.getElementById('invRespLine2').style.backgroundColor='#fff';    
    }
if (frm.currency.selectedIndex==0){
    document.getElementById('currencyLine1').style.backgroundColor='#cc0000';
    document.getElementById('currencyLine1').style.color='#fff';
    document.getElementById('currencyLine2').style.backgroundColor='#cc0000';
    err=1;
    }
  else{
    document.getElementById('currencyLine1').style.backgroundColor='#fff';
    document.getElementById('currencyLine1').style.color='#000';
    document.getElementById('currencyLine2').style.backgroundColor='#fff';
    }

return (err==0?true:false);
}

function showLogin(area){
  switch(area){
    case 1:
        document.getElementById('loginBox').style.display='none';
        document.getElementById('recoverBox').style.display='block';
        break;
    case 2:
        document.getElementById('recoverBox').style.display='none';
        document.getElementById('loginBox').style.display='block';
        break;
    }
return false;
}

function showContracts(val){
ajax(0,'invoices_invoice_ajax_contracts.php','showContractsResp','idSup='+val);
}

function showContractsResp(tmp){
document.getElementById('contracts').innerHTML=tmp;
}

function onlyDigits(e){
var tmp=(window.event) ? event.keyCode : e.keyCode;
tmp=String.fromCharCode(tmp);
return (/[0-9]/.test(tmp)==true)?true:false;
}

function onlyFloat(e){
var tmp=(window.event) ? event.keyCode : e.keyCode;
tmp=String.fromCharCode(tmp);
return (/[0-9,]/.test(tmp)==true)?true:false;
}

function showFormStep(j){
for (i=1; i<=3; i++)
    document.getElementById('step'+i).style.display=(i==j?'block':'none');
}

function checkFormAwb(frm){
var err='';

if (frm.expNume.value=='')    err+='PAS1 - Va rugam completati campul nume expeditor!'+"\n";
if (frm.expAdresa.value=='')  err+='PAS1 - Va rugam completati campul adresa expeditor!'+"\n";
if (frm.expLoc.value=='')     err+='PAS1 - Va rugam completati campul localitate expeditor!'+"\n";
if (frm.expJudet.value=='' && frm.expJudet.value!='')  err+='PAS1 - Va rugam alegeti judet expeditor!'+"\n";

if (frm.destNume.value=='')    err+='PAS2 - Va rugam completati campul nume destinatar!'+"\n";
if (frm.destAdresa.value=='')  err+='PAS2 - Va rugam completati campul adresa destinatar!'+"\n";
if (frm.destLoc.value=='')     err+='PAS2 - Va rugam completati campul localitate destinatar!'+"\n";
if (frm.destJudet.value=='' && frm.destJudet.value!='')  err+='PAS2 - Va rugam alegeti campul judet destinatar!'+"\n";

var errPlataLa=0
for (i=0; i<frm.plataLa.length; i++) errPlataLa=(frm.plataLa[i].checked==1 || errPlataLa==1)?1:0;
if (errPlataLa==0) err+='PAS3 - Va rugam alegeti o valoare pentru campul Plata la!'+"\n";

var errPlataMod=0
for (i=0; i<frm.plataMod.length; i++) errPlataMod=(frm.plataMod[i].checked==1 || errPlataMod==1)?1:0;
if (errPlataMod==0) err+='PAS3 - Va rugam alegeti o valoare pentru campul Modalitate plata!'+"\n";

var errTrimitereTip=0
for (i=0; i<frm.trimitereTip.length; i++) errTrimitereTip=(frm.trimitereTip[i].checked==1 || errTrimitereTip==1)?1:0;
if (errTrimitereTip==0) err+='PAS3 - Va rugam alegeti o valoare pentru campul Tip trimitere!'+"\n";

if (frm.trimitereTip[1].checked==true && frm.kg.value=='') err+='PAS3 - Va rugam introduceti greutatea totala pentru coletele dvs!'+"\n";

/*
var errConfPrimire=0
for (i=0; i<frm.confPrimire.length; i++) errConfPrimire=(frm.confPrimire[i].checked==1 || errConfPrimire==1)?1:0;
if (errConfPrimire==0) err+='PAS3 - Va rugam alegeti o valoare pentru campul Confirmare primire!'+"\n";

var errRegimLivrare=0
for (i=0; i<frm.regimLivrare.length; i++) errRegimLivrare=(frm.regimLivrare[i].checked==1 || errRegimLivrare==1)?1:0;
if (errRegimLivrare==0) err+='PAS3 - Va rugam alegeti o valoare pentru campul Regim livrare!'+"\n";


var errContravaloare=0
for (i=0; i<frm.contravaloare.length; i++) errContravaloare=(frm.contravaloare[i].checked==1 || errContravaloare==1)?1:0;
if (errContravaloare==0) err+='PAS4 - Va rugam alegeti o valoare pentru campul Contravaloare servicii!'+"\n";


var errReturDoc=0
for (i=0; i<frm.returDoc.length; i++) errReturDoc=(frm.returDoc[i].checked==1 || errReturDoc==1)?1:0;
if (errReturDoc==0) err+='PAS3 - Va rugam alegeti o valoare pentru campul Retur documente!'+"\n";
*/

if (err=='') return true;
    else{
      alert(err);
      return false;
    }
}

function showRow(css,tmp){
var elem=document.getElementsByTagName('tr');
for (i in elem){
    if (elem[i].className==css)
        //alert(elem[i].className)
        elem[i].style.display=(tmp==0?'none':'block');
    }
}

function enableRow(id,state){
document.getElementById(id).disabled=(state==0?true:false);
}

function printAwb(idAwb){
window.open('clienti_print.php?idAwb='+idAwb,'imprimare','width=800,height=600,scrollbars=1,toolbar=0,adressbar=0,menubar=1,status=1');
return false;
}
