function checkAll(field)
{
for (i = 0; i < document.frm.elements.length; i++){
	document.frm.elements[i].checked = true ;
}	
}

function uncheckAll(field)
{
for (i = 0; i < document.frm.elements.length; i++){
	document.frm.elements[i].checked = false ;
}
}


function submit_import_file()
{
if (document.frm.fnume.value.length > 0 ){
    document.frm.action.value="submit_import_file";
    document.frm.target = "";
    document.frm.submit();
}    
else{
	alert('Va rugam sa introduceti fisierul ce contine datele clientilor pe care doriti sa-i importati.');
}	

}	
function complete_import_file()
{
    document.frm.action.value="complete_import_file";
    document.frm.target = "";
    document.frm.submit();
}
	
function refresh_import_file()
{
    document.frm.action.value="refresh_import_file";
    document.frm.target = "";
    document.frm.submit();
}	
function move_col_up(pp)
{
    document.frm.action.value="move_col_up";
    document.frm.field.value = pp;
    document.frm.target = "";
    document.frm.submit();
}	
function move_col_down(pp)
{
    document.frm.action.value="move_col_down";
    document.frm.field.value = pp;
    document.frm.target = "";
    document.frm.submit();
}	
function aranjeaza_coloane()
{
    document.frm.action.value="aranjeaza_coloane";
    document.frm.target = "";
    document.frm.submit();
}	
function import_file()
{
    document.frm.action.value="import_file";
    document.frm.target = "";
    document.frm.submit();

}	


function welcome()
{
//window.location = "http://expedition.softhouse.ro/?action=welcome";
    document.frm.action.value="welcome";
    document.frm.target = "";
    document.frm.submit();
}

function settings()
{
//window.location = "http://expedition.softhouse.ro/?action=welcome";
    document.frm.action.value="settings";
    document.frm.target = "";
    document.frm.submit();
}
function submit_cpassword()
{
  if (document.frm.parola.value != document.frm.rparola.value ){
  	alert('Parola introdusa in cele doua campuri nu este identica. Va rugam sa introduceti din nou parola.');
  	return;
  }	
    document.frm.action.value="submit_cpassword";
    document.frm.target = "";
    document.frm.submit();
}	

function borderou()
{
//window.location = "http://expedition.softhouse.ro/?action=welcome";
    document.frm.action.value="borderou";
    document.frm.target = "";
    document.frm.submit();
}
function genereaza_borderou()
{
    document.frm.action.value="genereaza_borderou";
    document.frm.target = "_blank";
    document.frm.submit();
}

function submit_forget()
{
if (document.frm.email.value.length > 0 ){

    document.frm.action.value="submit_forget";
    document.frm.target = "";
    document.frm.submit();
}    
else{
	alert('Va rugam introduceti adresa de mail.');
}	
}

	
function sterge_comenzi()
{
	    var answer = confirm("Atentie! Sunteti sigur(a) ca doriti sa stergeti aceste comenzi?")
	    if (answer){
    document.frm.action.value="sterge_comenzi";
    document.frm.target = "";
    document.frm.submit();
     }
}	
	
function checkValoare(){
history.length = 0;
	if (document.frm.action.value == "formular"){
		if (document.frm.valoare.value.length > 0 ){
			convert_valoare()
		}	
	}	
}
	
function submit_register()
{
    document.frm.action.value="submit_register";
    document.frm.target = "";
    document.frm.submit();
}	
function optiuni()
{
//window.location = "http://expedition.softhouse.ro/?action=welcome";
    document.frm.action.value="optiuni";
    document.frm.target = "";
    document.frm.submit();
}
function submit_optiuni()
{
//window.location = "http://expedition.softhouse.ro/?action=welcome";
    document.frm.action.value="submit_optiuni";
    document.frm.target = "";
    document.frm.submit();
}


function logout()
{
//window.location = "http://expedition.softhouse.ro/?action=welcome";
    document.frm.action.value="logout";
    document.frm.target = "";
    document.frm.submit();
}

function clienti()
{
    document.frm.action.value="clienti";
    document.frm.target = "";
    document.frm.submit();
}
function clienti_filter(pp)
{
    document.frm.action.value="clienti";
    document.frm.filter.value = pp;
    document.frm.target = "";
    document.frm.submit();
}
function formular()
{
    document.frm.action.value="formular";
    document.frm.target = "";
    document.frm.submit();
}
function fill_formular(uuid)
{
    document.frm.action.value="formular";
    document.frm.uid.value=uuid;
    document.frm.target = "";
    document.frm.submit();
}	
function remove_client(uuid)
{
	    var answer = confirm("Atentie! Sunteti sigur(a) ca doriti sa stergeti acest client?")
	    if (answer){
    document.frm.action.value="remove_client";
    document.frm.uid.value=uuid;
    document.frm.target = "";
    document.frm.submit();
     }
     else{
     	var aa = 0;
     }	
}	

function istoric(uuid)
{
    document.frm.action.value="istoric";
    document.frm.uid.value=uuid;
    document.frm.target = "";
    document.frm.submit();
}	

function getnote(uuid)
{
    document.frm.action.value="getnote";
    document.frm.uid.value=uuid;
    document.frm.target = "";
    document.frm.submit();
}

function setnote()
{
    document.frm.action.value="setnote";
    document.frm.target = "";
    document.frm.submit();
}


function save_data()
{
	    var answer = confirm("Atentie! Sunteti sigur(a) ca doriti sa salvati datele acestui client?")
	    if (answer){
	    	if ( document.frm.dest_nume.value != "" || document.frm.dprenume.value != "" ){
	    document.frm.action.value="save_data";
	    document.frm.target = "";
	    document.frm.submit();

	     }
	     else{
	     	alert('Va rugam introduceti numele si prenumele destinatarului!');
	     }	
     }
     else{
     	var aa = 0;
     }	
}	


function submit_newrate()
{
if ( !checkNumber(document.frm.client.value) ){
	alert('Va rugam introduceti numai cifre corespunzatoare CNP-ului sau Codului Fiscal al clientului!');
	return;
}
else{	
	    var answer = confirm("Atentie! Dupa ce apasati pe butonul Trimite nu mai puteti schimba aceasta evaluare.")
	    if (answer){
	
   document.frm.action.value="submit_newrate";
   document.frm.target = "";
   document.frm.submit();
     }
}     
}
function submit_checkrate()
{
if ( !checkNumber(document.frm.client.value) ){
	alert('Va rugam introduceti numai cifre corespunzatoare CNP-ului sau Codului Fiscal al clientului!');
	return;
}
else{	
	    var answer = confirm("Atentie! Prin apasarea butonului Trimite se vor lua creditele aferente acestei interogari.")
	    if (answer){
   document.frm.action.value="submit_checkrate";
   document.frm.target = "";
   document.frm.submit();
     }
}     
}

function checkNumber(str)
{
var checkOK = "0123456789";
var checkStr = str;
var allValid = true;
var allNum = "";
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++){
			if (ch == checkOK.charAt(j))
			break;
		}
		if (j == checkOK.length)
		{
			allValid = false;
			break;
		}
	}
return allValid;
}	


function loginer(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
	   document.frm.action.value="login";
	   document.frm.target = "";
	   document.frm.submit();
	   return false;
   }
}
function login()
{
	   document.frm.action.value="login";
	   document.frm.target = "";
	   document.frm.submit();
}	

function vcheckrate(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
//else return true;

if (keycode == 13)
   {
	    var answer = confirm("Atentie! Prin apasarea butonului Trimite se vor lua creditele aferente acestei interogari.")
	    if (answer){
		   document.frm.action.value="submit_checkrate";
		   document.frm.target = "";
		   document.frm.submit();
		   return false;
	    }
   }
}

function vnewrate(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
//else return true;

if (keycode == 13)
   {
	    var answer = confirm("Atentie! Dupa ce apasati pe butonul Trimite nu mai puteti schimba aceasta evaluare.")
	    if (answer){
	
	   document.frm.action.value="submit_newrate";
	   document.frm.target = "";
	   document.frm.submit();
     }
   }
}


function show_colet()
{
   document.frm.action.value="show_colet";
   document.frm.target = "_blank";
   document.frm.submit();
}

function statistics()
{
   document.frm.action.value="statistics";
   document.frm.target = "_blank";
   document.frm.submit();
}
function statistics1()
{
   document.frm.action.value="statistics1";
   document.frm.target = "_blank";
   document.frm.submit();
}
function statistics2()
{
   document.frm.action.value="statistics2";
   document.frm.target = "_blank";
   document.frm.submit();
}


function show_formularfata()
{
  if (document.frm.telefon.value != ''){
    if (validate_sms() == 1){
      alert('Numar de telefon incorect. Va rugam verificati si incercati din nou.');
      return;
    }
  }

  if (document.frm.codpostal.value == ''){
    alert('Posta Romana a introdus obligativitatea codului postal.\r\nVa rugam introduceti codul postal!');
    return;
  }
  if (document.frm.localitatea.value.toUpperCase() == 'BUCURESTI' && document.frm.ofpostal.value == ''){
    alert('Pentru municipiul Bucuresti Oficiul Postal este obligatoriu.');
    return;
  }
   document.frm.action.value="show_formularfata";
   document.frm.target = "_blank";
   document.frm.submit();
}
function show_formularspate()
{
  if (document.frm.codpostal.value == ''){
    alert('Posta Romana a introdus obligativitatea codului postal.\r\nVa rugam introduceti codul postal!');
    return;
  }
  if (document.frm.localitatea.value.toUpperCase() == 'BUCURESTI' && document.frm.ofpostal.value == ''){
    alert('Pentru municipiul Bucuresti Oficiul Postal este obligatoriu.');
    return;
  }
   document.frm.action.value="show_formularspate";
   document.frm.target = "_blank";
   document.frm.submit();
}


function convert_valoare()
{
  if (0+document.getElementById("valoare").value<20){document.getElementById("valoare").value=20;}
	document.getElementById("valoarec").value=convert(document.getElementById("valoare").value)
}	
function convert_ramburs()
{
	document.getElementById("rambursc").value=convert(document.getElementById("ramburs").value)
}	


function convert(cifre)
{
var val = "";
var result ="";
var vect = new Array(10);
var zect = new Array(3);
var i=0;
var j=0;
var grup=0;
var vl_mii = 0;
var t = "";
var zecimal = "";
var stZecimal = "";
var lenZec = "";
val = String(cifre);
if (val.indexOf('.') > -1){
	zecimal=Right(val,val.length-val.indexOf('.')-1);
	val=Left(val,val.indexOf('.'));
}	
if (val.indexOf(',') != -1){
	zecimal=Right(val,val.length-val.indexOf(',')-1);
	val=Left(val,val.indexOf(','));
}	
zecimal=Left(zecimal,2);
if (zecimal.length == 1){zecimal = zecimal + "0";}
lenZec = zecimal;
i = 0;
digits = val.length;
for (i=0;i<10;i++){
	vect[i]=0;
	if (i<3){zect[i]=0;}
}	
i=0;
while(val.length > 0){
t = Right(val, 1);
    val = Left(val, val.length - 1);
    vect[i] = parseInt(t,10);
    i = i + 1
}
i=0;
while (zecimal.length > 0){
	t=Right(zecimal,1);
	zecimal = Left(zecimal,zecimal.length -1);
	zect[i] = parseInt(t,10);
	i = i+1;
}	

i = 0
grup = 0

if (digits > 1){
    var vl = 0;
    vl = parseInt(String(vect[1]) + String(vect[0]),10);
    if (vl < 20) {
        result = letter(vl);
    }else{
        result = letter_zeci(vect[1]);
        if (letter(vect[0]) != "zero"){
            result = result + "si" + letter(vect[0]);
        }
    }
    if (digits > 2){
            if (result == "zero"){
                result = "";
            }
        result = letter_sute(vect[2]) + result;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        if (digits > 3){
            vl_mii = parseInt(String(vect[4]) + String(vect[3]),10)
            if (vl_mii < 20){
                mii = letterMii(vl_mii);
            }else{
                mii = letter_zeci(vect[4]);
                if (letter(vect[3]) != "zero"){
                mii = mii + "si" + letter(vect[3]);
                }
            }
            if (digits > 4){
            mii = letter_sute(vect[5]) + mii;
            }
                if (mii == "una"){
                    mii = mii + "mie";
                }else{
                    if (mii == "osutao"){
                    mii = "osutaunamii";
                    }else{
                    mii = mii + "mii";
                    }
                }
                result = mii + result;

        }
        }
        
        
    }
	
else{
    result = letter(vect[0]);
}

if (result == "unu"){
	result = "unleu";
}
else{
	result = result +"lei";
}	

if (lenZec != ""){
    var vl = 0;
    vl = parseInt(parseInt(String(zect[1]) + String(zect[0]),10));
    if (vl < 20) {
        stZecimal = letter(vl);
    }else{
        stZecimal = letter_zeci(zect[1]);
        if (letter(zect[0]) != "zero"){
            stZecimal = stZecimal + "si" + letter(zect[0]);
        }
    }    
if (stZecimal == "unu"){
	stZecimal = "siunban"
}	
else{
//	stZecimal = "si" +stZecimal + "bani";
	stZecimal = "si" +lenZec + "bani";
}	

result = result + stZecimal;
}


return result;
}

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}


function letter(u)
{
    switch(u){
        case 0:
            return "zero";
        case 1:
            return "unu";
        case 2:
            return "doi";
        case 3:
            return "trei";
        case 4:
            return "patru";
        case 5:
            return "cinci";
        case 6:
            return "sase";
        case 7:
            return "sapte";
        case 8:
            return "opt";
        case 9:
            return "noua";
        case 10:
            return "zece";
        case 11:
            return "unsprezece";
        case 12:
            return "doisprezece";
        case 13:
            return "treisprezece";
        case 14:
            return "paisprezece";
        case 15:
            return "cincisprezece";
        case 16:
            return "saisprezece";
        case 17:
            return "saptesprezece";
        case 18:
            return "optsprezece";
        case 19:
            return "nouasprezece";
    }    
}
function letter_zeci(u)
{
    switch(u){
        case 2:
            return "douazeci";
        case 3:
            return "treizeci";
        case 4:
            return "patruzeci";
        case 5:
            return "cincizeci";
        case 6:
            return "saizeci";
        case 7:
            return "saptezeci";
        case 8:
            return "optzeci";
        case 9:
            return "nouazeci";
    }
}

function letter_sute(u)
{
    switch(u){
        case 0:
            return "";
        case 1:
            return "unasuta";
        case 2:
            return "douasute";
        case 3:
            return "treisute";
        case 4:
            return "patrusute";
        case 5:
            return "cincisute";
        case 6:
            return "sasesute";
        case 7:
            return "saptesute";
        case 8:
            return "optsute";
        case 9:
            return "nouasute";
    }
}


function letterMii(u){
    switch(u){
        case 0:
            return "o";
        case 1:
            return "una";
        case 2:
            return "doua";
        case 3:
            return "trei";
        case 4:
            return "patru";
        case 5:
            return "cinci";
        case 6:
            return "sase";
        case 7:
            return "sapte";
        case 8:
            return "opt";
        case 9:
            return "noua";
        case 10:
            return "zece";
        case 11:
            return "unsprezece";
        case 12:
            return "douasprezece";
        case 13:
            return "treisprezece";
        case 14:
            return "paisprezece";
        case 15:
            return "cincisprezece";
        case 16:
            return "saisprezece";
        case 17:
            return "saptesprezece";
        case 18:
            return "optsprezece";
        case 19:
            return "nouasprezece";
}
}

function letterMilioane(u){
    switch(u){
        case 0:
            return "un";
        case 1:
            return "un";
        case 2:
            return "doua";
        case 3:
            return "trei";
        case 4:
            return "patru";
        case 5:
            return "cinci";
        case 6:
            return "sase";
        case 7:
            return "sapte";
        case 8:
            return "opt";
        case 9:
            return "noua";
        case 10:
            return "zece";
        case 11:
            return "unsprezece";
        case 12:
            return "douasprezece";
        case 13:
            return "treisprezece";
        case 14:
            return "paisprezece";
        case 15:
            return "cincisprezece";
        case 16:
            return "saisprezece";
        case 17:
            return "saptesprezece";
        case 18:
            return "optsprezece";
        case 19:
            return "nouasprezece";
        
}
}



function contact_list()
{
//   document.getElementById('action').value="new_customer";
   document.frm.action.value="contact_list";
   document.frm.target = "";
   document.frm.submit();
}

function submit_update_customer()
{
//   document.getElementById('action').value="new_customer";
   document.frm.action.value="submit_update_customer";
   document.frm.target = "";
   document.frm.submit();
}

function submit_update_contract()
{
//   document.getElementById('action').value="new_customer";
   document.frm.action.value="submit_update_contract";
   document.frm.target = "";
   document.frm.submit();
}
function sms()
{
   document.frm.action.value="sms";
   document.frm.target = "";
   document.frm.submit();
}
function istoric_sms()
{
   document.frm.action.value="istoric_sms";
   document.frm.target = "_blank";
   document.frm.submit();
}
function submit_sms()
{
   document.frm.action.value="submit_sms";
   document.frm.target = "";
   document.frm.submit();
}

function validate_sms()
{
  var tel = document.frm.telefon.value;
  var cnt = tel.length;

  if (tel.substring(0,2) == "07"){
    if (tel.length == 10){
      return 0;
    }
    else{
      return 1;
    }
  }
  if (tel.substring(0,4) == "+407"){
    if (tel.length == 12){
      return 0;
    }
    else{
      return 1;
    }
  }
  if (tel.substring(0,5) == "00407"){
    if (tel.length == 13){
      return 0;
    }
    else{
      return 1;
    }
  }
  return 1;
}

function send_com_sms()
{
var cnt = 0;
for (i = 0; i < document.frm.elements.length; i++){
  if (document.frm.elements[i].checked == true){cnt++;}
}
if (cnt>document.frm.nrofsms.value){
  alert('Credite insuficiente. Pentru a putea trimite mesaje catre clientii dumneavoastra trebuie sa cumparati credite suplimantare. Contactati echipa SoftHouse la email buletine@softhouse.ro sau telefon 0724.381.946.');
}
else{
if (cnt>0){
var answer = confirm("Atentie! Sunteti sigur(a) ca doriti sa trimiteti sms-uri de instiintare catre toti clientii selectati?")
if (answer){
   document.frm.action.value="send_com_sms";
   document.frm.target = "";
   document.frm.submit();
}
}
else{
  alert('Nu este selectat nici un client pentru a trimite mesaj de instiintare.');
}
}

}

function send_cust_sms()
{
if (validate_sms() == 1){
  alert('Numar de telefon incorect. Va rugam verificati si incercati din nou.');
  return;
}
if (document.frm.nrofsms.value > 0){
if (document.frm.telefon.value != ''){
var cnt = 0;
var answer = confirm("Atentie! Sunteti sigur(a) ca doriti sa trimiteti acest mesaj?")
if (answer){
   document.frm.action.value="send_cust_sms";
   document.frm.target = "_blank";
   document.frm.submit();
}
}
else{
  alert('Nu ati completat telefonul clientului.');
}
}
else{
  alert('Pentru a putea trimite mesaje catre clientii dumneavoastra trebuie sa cumparati credite suplimantare. Contactati echipa SoftHouse la email buletine@softhouse.ro sau telefon 0724.381.946.');
}

}


function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
cntfield.value = maxlimit - field.value.length;
}


function submit_update_location()
{
   document.frm.action.value="submit_update_location";
   document.frm.target = "";
   document.frm.submit();
}	
function submit_new_location()
{
   document.frm.action.value="submit_new_location";
   document.frm.target = "";
   document.frm.submit();
}	


function customers(flt)
{
   document.frm.action.value="customers";
   document.frm.filter.value=flt;
   document.frm.page.value = "";
   document.frm.target = "";
   document.frm.submit();
}	

function calendar(flt)
{
   document.frm.action.value="calendar";
   document.frm.option.value=flt;
   document.frm.target = "";
   document.frm.submit();
}	


function search_customers()
{
   document.frm.action.value="customers";
   document.frm.target = "";
   document.frm.submit();
}	


function next_customer()
{
   document.frm.action.value="customers";
   document.frm.page.value = document.frm.page.value-0+1;
   document.frm.target = "";
   document.frm.submit();
}	
function prev_customer()
{
   document.frm.action.value="customers";
   document.frm.page.value = document.frm.page.value-0-1;
   document.frm.target = "";
   document.frm.submit();
}	

function next_contract()
{
   document.frm.action.value="contracts";
   document.frm.page.value = document.frm.page.value-0+1;
   document.frm.target = "";
   document.frm.submit();
}	
function prev_contract()
{
   document.frm.action.value="contracts";
   document.frm.page.value = document.frm.page.value-0-1;
   document.frm.target = "";
   document.frm.submit();
}


function contacts(flt)
{
   document.frm.action.value="contact_list";
   document.frm.filter.value=flt;
   document.frm.target = "";
   document.frm.submit();
}	


function edit_customer(id)
{
   document.frm.action.value="edit_customer";
   document.frm.cid.value=id;
   document.frm.target = "";
   document.frm.submit();
}	
function edit_servicerequest(id)
{
   document.frm.action.value="edit_servicerequest";
   document.frm.sid.value=id;
   document.frm.target = "";
   document.frm.submit();
}	

function edit_contract(id)
{
   document.frm.action.value="edit_contract";
   document.frm.contractid.value=id;
   document.frm.target = "";
   document.frm.submit();
}	


function edit_contact(id)
{
   document.frm.action.value="edit_contact";
   document.frm.cid.value=id;
   document.frm.target = "";
   document.frm.submit();
}	

function map()
{
var address;
address = document.frm.address.value+" "+document.frm.city.value+" CO "+document.frm.zip.value
window.open('http://mobile.emeet.ro/Code/Applications/web/index.cgi?action=map&address='+address);
}	



function remove_customer(id)
{
var answer = confirm("Are you sure you want to remove this customer?")
    if (answer){
   document.frm.action.value="remove_customer";
   document.frm.cid.value=id;
   document.frm.target = "";
   document.frm.submit();
    }
}	






function toggleDiv(id,flagit) {
if (flagit=="1"){
if (document.layers) document.layers[''+id+''].visibility = "show"
else if (document.all) document.all[''+id+''].style.visibility = "visible"
else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
}
else
if (flagit=="0"){
if (document.layers) document.layers[''+id+''].visibility = "hide"
else if (document.all) document.all[''+id+''].style.visibility = "hidden"
else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
}
}


var IE = document.all?true:false;
if (!IE)

document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
var tempX = 0;
var tempY = 0;
function getMouseXY(e) {
if (IE) {
tempX = event.clientX;
tempY = event.clientY;
}
else {
tempX = e.pageX;
tempY = e.pageY;
}
if (tempX < 0){tempX = 0;}
if (tempY < 0){tempY = 0;}

return true;
}


function showHelp(){
// alert('in here' + tempX);
document.getElementById('help').style.top=tempY;
document.getElementById('help').style.left=tempX;
document.getElementById('help').style.display="block";
}


function hideHelp(){
document.getElementById('help').style.display="none";
}


function getContact(cust_id)
{
	var req = null; 
	
document.frm.contacts.options[0] = new Option("loading...","0");
	 
	if (window.XMLHttpRequest)
	{
	 	req = new XMLHttpRequest();
		if (req.overrideMimeType) 
		{
			req.overrideMimeType('text/xml');
		}
	} 
	else if (window.ActiveXObject) 
	{
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e)
		{
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	        	}
	
	
	req.onreadystatechange = function()
	{ 
//		document.ajax.dyn.value="Wait server...";
		if(req.readyState == 4)
		{
			if(req.status == 200)
			{
				fillContacts(req.responseText);
			}	
			else	
			{
				fillContacts("");
			}	
		} 
	}; 
	req.open("GET", "http://mobile.emeet.ro/Code/Applications/web/index.cgi?action=xml_contacts&cid="+document.frm.customer.value, true); 
	req.send(null); 	
}


function fillContacts(cnts)
{
var len, i;
var str = "aaa";
    len = document.frm.contacts.options.length - 1;
    for (i=0; i<len;i++)
    {
    	document.frm.contacts.options[0] = null;
    }	
str = ""+cnts;
var contacts_pair = str.split(";");
var conts;
for (i=0;i<contacts_pair.length-1;i++)
{
	var xx = ""+contacts_pair[i];
	conts = xx.split(",");
	document.frm.contacts.options[i] = new Option(conts[1],conts[0]);
}	
if (contacts_pair.length > 1){
document.frm.contacts.options[1].selected = true;
}	

}


function getLocation(cust_id)
{
	var req = null; 
	
document.frm.locations.options[0] = new Option("loading...","0");
	 
	if (window.XMLHttpRequest)
	{
	 	req = new XMLHttpRequest();
		if (req.overrideMimeType) 
		{
			req.overrideMimeType('text/xml');
		}
	} 
	else if (window.ActiveXObject) 
	{
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e)
		{
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	        	}
	
	
	req.onreadystatechange = function()
	{ 
//		document.ajax.dyn.value="Wait server...";
		if(req.readyState == 4)
		{
			if(req.status == 200)
			{
				fillLocations(req.responseText);
				fillBillto(req.responseText);
			}	
			else	
			{
				fillBillto("");
				fillLocations("");
			}	
		} 
	}; 
	req.open("GET", "http://mobile.emeet.ro/Code/Applications/web/index.cgi?action=xml_locations&cid="+document.frm.customer.value, true); 
	req.send(null); 	
}	

function getLocation1(cust_id)
{
	var req = null; 
	
document.frm.billto.options[0] = new Option("loading...","0");
	 
	if (window.XMLHttpRequest)
	{
	 	req = new XMLHttpRequest();
		if (req.overrideMimeType) 
		{
			req.overrideMimeType('text/xml');
		}
	} 
	else if (window.ActiveXObject) 
	{
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e)
		{
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	        	}
	
	
	req.onreadystatechange = function()
	{ 
//		document.ajax.dyn.value="Wait server...";
		if(req.readyState == 4)
		{
			if(req.status == 200)
			{
				fillBillto(req.responseText);
			}	
			else	
			{
				fillBillto("");
			}	
		} 
	}; 
	req.open("GET", "http://mobile.emeet.ro/Code/Applications/web/index.cgi?action=xml_locations&cid="+document.frm.customer.value, true); 
	req.send(null); 	
}	

function fillLocations(cnts)
{
var len, i;
var str = "aaa";
    len = document.frm.locations.options.length - 1;
    for (i=0; i<len;i++)
    {
    	document.frm.locations.options[0] = null;
    }	
str = ""+cnts;
var contacts_pair = str.split(";");
var conts;
for (i=0;i<contacts_pair.length-1;i++)
{
	var xx = ""+contacts_pair[i];
	conts = xx.split(",");
	document.frm.locations.options[i] = new Option(conts[1],conts[0]);
}	
if (contacts_pair.length > 1){
document.frm.locations.options[1].selected = true;
}	
}

function fillBillto(cnts)
{
var len, i;
var str = "aaa";
    len = document.frm.billto.options.length - 1;
    for (i=0; i<len;i++)
    {
    	document.frm.billto.options[0] = null;
    }	
str = ""+cnts;
var contacts_pair = str.split(";");
var conts;
for (i=0;i<contacts_pair.length-1;i++)
{
	var xx = ""+contacts_pair[i];
	conts = xx.split(",");
	document.frm.billto.options[i] = new Option(conts[1],conts[0]);
}	
if (contacts_pair.length > 1){
document.frm.billto.options[1].selected = true;
}	
}


function getContracts(cust_id)
{
	var req = null; 
	
document.frm.locations.options[0] = new Option("loading...","0");
	 
	if (window.XMLHttpRequest)
	{
	 	req = new XMLHttpRequest();
		if (req.overrideMimeType) 
		{
			req.overrideMimeType('text/xml');
		}
	} 
	else if (window.ActiveXObject) 
	{
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e)
		{
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	        	}
	
	
	req.onreadystatechange = function()
	{ 
//		document.ajax.dyn.value="Wait server...";
		if(req.readyState == 4)
		{
			if(req.status == 200)
			{
				fillContracts(req.responseText);
			}	
			else	
			{
				fillContracts("");
			}	
		} 
	}; 
	req.open("GET", "http://mobile.emeet.ro/Code/Applications/web/index.cgi?action=xml_contracts&cid="+document.frm.customer.value, true); 
	req.send(null); 	
}	

function fillContracts(cnts)
{
var len, i;
var str = "aaa";
    len = document.frm.contract.options.length - 1;
    for (i=0; i<len;i++)
    {
    	document.frm.contract.options[0] = null;
    }	
str = ""+cnts;
var contacts_pair = str.split(";");
var conts;
for (i=0;i<contacts_pair.length-1;i++)
{
	var xx = ""+contacts_pair[i];
	conts = xx.split(",");
	document.frm.contract.options[i] = new Option(conts[1],conts[0]);
}	
if (contacts_pair.length > 1){
document.frm.contract.options[1].selected = true;
}	
}


function ShowHiddenElements() {
	var chk;
// 	chk = $("chkAssignToMoreUsers");
// 	if (chk != null)
// 		if (chk.checked) {$('divAssignToMoreUsers').show()} else {$('divAssignToMoreUsers').hide()};
// 	
	chk = document.frm.chkScheduled;
	if (chk != null)
	{
	    if (chk.checked) {
	        document.getElementById("scheduled").style.visibility = "visible";
	        document.getElementById("scheduled").style.display = "";
	    } 
	    else {
	         document.getElementById("scheduled").style.visibility = "hidden";
	        document.getElementById("scheduled").style.display = "none";
	    }
	} 

	chk = document.frm.chkDueDate;
	if (chk != null)
	{
	    if (chk.checked) {
	        document.getElementById("dueDate").style.visibility = "visible";
	        document.getElementById("dueDate").style.display = "";
	    } 
	    else {
	         document.getElementById("dueDate").style.visibility = "hidden";
	        document.getElementById("dueDate").style.display = "none";
	    }
	} 

}


function updateTaxes()
{
var stot,tax, taxv, total;
var xx = 100;
    stot = document.frm.subtotal.value;
    tax = parseFloat(taxlist[document.frm.taxcode.value]);
    taxv = 1*stot*tax/100;
    total = 1*stot + 1*taxv;

    xx = 1*stot;
    document.frm.subtotal.value = xx.toFixed(2);
    document.frm.tax.value = taxv.toFixed(2);
    document.frm.total.value = total.toFixed(2);
}	



function handleBill()
{
	    if (document.frm.billto[1].checked) {
	        document.getElementById("otheraddress").style.visibility = "visible";
	        document.getElementById("otheraddress").style.display = "";
	    } 
	    else {
	         document.getElementById("otheraddress").style.visibility = "hidden";
	        document.getElementById("otheraddress").style.display = "none";
	    }
	    if (document.frm.billto[2].checked) {
	        document.getElementById("othercustomer").style.visibility = "visible";
	        document.getElementById("othercustomer").style.display = "";
	    } 
	    else {
	         document.getElementById("othercustomer").style.visibility = "hidden";
	        document.getElementById("othercustomer").style.display = "none";
	    }

}	



function follow(linkul,id)
{
   document.frm.action.value="follow";
   document.frm.linkul.value=linkul;
   document.frm.idul.value=id;
   document.frm.target = "_blank";
   //alert(document.frm.target);
   document.frm.submit();
   document.frm.target = "";
}

function help()
{
   document.getElementById('action').value="help";
   document.frm.target = "";
   document.frm.submit();
}
function inscrie()
{
   document.frm.action.value="inscrie";
   document.frm.target = "";
   document.frm.submit();
}


function contact()
{
   document.getElementById('action').value="contact";
   document.frm.target = "";
   document.frm.submit();
}

var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
function encode64(input) {
   if(input == '') return '';
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;

   do {
      chr1 = input.charCodeAt(i++);
      chr2 = input.charCodeAt(i++);
      chr3 = input.charCodeAt(i++);

      enc1 = chr1 >> 2;
      enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
      enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
      enc4 = chr3 & 63;

      if (isNaN(chr2)) {
         enc3 = enc4 = 64;
      } else if (isNaN(chr3)) {
         enc4 = 64;
      }

      output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) +
         keyStr.charAt(enc3) + keyStr.charAt(enc4);
   } while (i < input.length);

   return output;
}
function decode64(input) {
   if(input == '') return '';
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;

   // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
   input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

   do {
      enc1 = keyStr.indexOf(input.charAt(i++));
      enc2 = keyStr.indexOf(input.charAt(i++));
      enc3 = keyStr.indexOf(input.charAt(i++));
      enc4 = keyStr.indexOf(input.charAt(i++));

      chr1 = (enc1 << 2) | (enc2 >> 4);
      chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
      chr3 = ((enc3 & 3) << 6) | enc4;

      output = output + String.fromCharCode(chr1);

      if (enc3 != 64) {
         output = output + String.fromCharCode(chr2);
      }
      if (enc4 != 64) {
         output = output + String.fromCharCode(chr3);
      }
   } while (i < input.length);

   return output;
}


function getCustomerLocation(cust_id)
{
	var req = null; 
	
document.frm.bcustomerlocation.options[0] = new Option("loading...","0");
	 
	if (window.XMLHttpRequest)
	{
	 	req = new XMLHttpRequest();
		if (req.overrideMimeType) 
		{
			req.overrideMimeType('text/xml');
		}
	} 
	else if (window.ActiveXObject) 
	{
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e)
		{
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	        	}
	
	
	req.onreadystatechange = function()
	{ 
//		document.ajax.dyn.value="Wait server...";
		if(req.readyState == 4)
		{
			if(req.status == 200)
			{
				fillCustomerLocations(req.responseText);
			}	
			else	
			{
				fillCustomerLocations("");
			}	
		}
	}; 
	req.open("GET", "http://mobile.emeet.ro/Code/Applications/web/index.cgi?action=xml_locations&cid="+document.frm.bcustomer.value, true); 
	req.send(null); 	
}	

function fillCustomerLocations(cnts)
{
var len, i;
var str = "aaa";
document.all("locationdescription").innerHTML = "";
    len = document.frm.bcustomerlocation.options.length - 1;
    for (i=0; i<len;i++)
    {
    	document.frm.bcustomerlocation.options[0] = null;
    }	
str = ""+cnts;
var contacts_pair = str.split(";");
var conts;
for (i=0;i<contacts_pair.length-1;i++)
{
	var xx = ""+contacts_pair[i];
	conts = xx.split(",");
	document.frm.bcustomerlocation.options[i] = new Option(conts[1],conts[0]);
}	
if (contacts_pair.length > 1){
document.frm.bcustomerlocation.options[1].selected = true;
}	
getLocationDescription();
}


function getLocationDescription(cust_id)
{
	var req = null; 
	
//document.frm.bcustomerlocation.value = "";
	 
	if (window.XMLHttpRequest)
	{
	 	req = new XMLHttpRequest();
		if (req.overrideMimeType) 
		{
			req.overrideMimeType('text/xml');
		}
	} 
	else if (window.ActiveXObject) 
	{
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e)
		{
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	        	}
	
	
	req.onreadystatechange = function()
	{ 
//		document.ajax.dyn.value="Wait server...";
		if(req.readyState == 4)
		{
			if(req.status == 200)
			{
//				fillCustomerLocations(req.responseText);
				document.all("locationdescription").innerHTML = req.responseText;
			}	             
			else	
			{
//				fillCustomerLocations("");
				document.all("locationdescription").innerHTML = " ";
			}	
		} 
	}; 
	req.open("GET", "http://mobile.emeet.ro/Code/Applications/web/index.cgi?action=xml_getlocation&cid="+document.frm.bcustomerlocation.value, true); 
	req.send(null); 	
}	

function equipments()
{
   document.frm.action.value="equipments";
   document.frm.target = "";
   document.frm.submit();
}
function new_equipment()
{
//   document.getElementById('action').value="new_customer";
   document.frm.action.value="new_equipment";
   document.frm.target = "";
   document.frm.submit();
}

function submit_new_equipment()
{
//   document.getElementById('action').value="new_customer";
   document.frm.action.value="submit_new_equipment";
   document.frm.target = "";
   document.frm.submit();
}

function submit_update_equipment()
{
//   document.getElementById('action').value="new_customer";
   document.frm.action.value="submit_update_equipment";
   document.frm.target = "";
   document.frm.submit();
}

function edit_equipment(ccid)
{
   document.frm.action.value="edit_equipment";
   document.frm.lid.value = ccid;
   document.frm.target = "";
   document.frm.submit();
}

function import_customers()
{
//   document.getElementById('action').value="new_customer";
   document.frm.action.value="ic1";
   document.frm.target = "";
   document.frm.submit();
}

function submit_ic1()
{
   document.frm.action.value="ic2";
   document.frm.target = "";
   document.frm.submit();
}	

function submit_ic2()
{
   document.frm.action.value="ic3";
   document.frm.target = "";
   document.frm.submit();
}	

// 			window.onresize = function() { checkPage("ScrollBox",page_elements);}
// 			document.oncontextmenu = document.onselectstart = function () { return false; }
// 			window.onload = function () {
// 				checkPage("ScrollBox",page_elements);
// 				status = document.getElementById("status");
// 				createFileInput(path);
// 			}	




