/*
============================================================
Capturing The Mouse Position in IE4-6 & NS4-6
(C) 2000 www.CodeLifter.com
Free for all users, but leave in this  header
*/

// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false;

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0;
var tempY = 0;

// Main function to retrieve mouse x-y pos.s

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft;
    tempY = event.clientY + document.body.scrollTop;
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX;
    tempY = e.pageY;
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0;}
  if (tempY < 0){tempY = 0;}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  return true;
}

/* End mouse capture script */

function timeout_programare()
{
	setTimeout('document.getElementById(\'hfinal\').focus()',800);
}

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
} 

function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(id, millisec) {
    //if an element is invisible, make it visible, else make it ivisible
    if(document.getElementById(id).style.opacity == 0) {
        opacity(id, 0, 100, millisec);
    } else {
        opacity(id, 100, 0, millisec);
    }
} 

function enlarge(id, heightStart, heightEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;
	document.getElementById(id).style.height="0px";

    //determine the direction for the blending, if start and end are the same nothing happens
    if(heightStart > heightEnd) {
        for(i = heightStart; i >= heightEnd; i--) {
            setTimeout("changeSize(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(heightStart < heightEnd) {
        for(i = heightStart; i <= heightEnd; i++)
            {
            setTimeout("changeSize(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
	document.getElementById(id).style.display="block";
} 

function changeSize(height, id) {
    var object = document.getElementById(id).style;
    object.height=height+"px";
}

function expand(id) {
   var x=document.getElementById(id);
   if (x.style.display == 'none') x.style.display="block";
	else { x.style.display="none";  }
}

function IsEmpty(aTextField) {
   if ((aTextField.length==0) ||
   (aTextField==null)) {
      return true;
   }
   else { return false; }
}	

function noletter(id)
{
	document.getElementsByName(id)[0].value = document.getElementsByName(id)[0].value.replace(/[^\d]/g, ''); 
}

function nonumbers(id)
{
	document.getElementsByName(id)[0].value = document.getElementsByName(id)[0].value.replace(/[(0-9)]/g, ''); 
}

function change_class(name)
{
document.getElementsByName(name)[0].setAttribute("class", "input"); document.getElementsByName(name)[0].setAttribute("className", "input");
}

function di_tab(name)
{
document.getElementById(name).setAttribute("class", "ui-tabs-disabled"); document.getElementById(name).setAttribute("className", "ui-tabs-disabled");
}

function en_tab(name)
{
document.getElementById(name).setAttribute("class", ""); document.getElementById(name).setAttribute("className", "");
}

function validarecnp(string)
{
	run_get('validarecnp', 'cnp@', string+'@', 'infodreapta');
}

function set_red_class(name)
{
document.getElementsByName(name)[0].setAttribute("class", "error_field"); document.getElementsByName(name)[0].setAttribute("className", "error_field");
}

function check_empty(field,returnare)
{
f=document.getElementsByName(field)[0].value;
if(IsEmpty(f)) { alert ("Nu ai completat campul <"+returnare+">"); document.getElementsByName(field)[0].setAttribute("class", "error_field"); document.getElementsByName(field)[0].setAttribute("className", "error_field"); document.getElementsByName(field)[0].focus(); return false; } else { return true; }
}

function validare_cont_nou()
{ 
if(!check_empty('nume','Nume')) { $('#container-1 ul').tabsClick(1); $('#container-2 ul').tabsClick(1); return false };
if(!check_empty('prenume','Prenume')) { $('#container-1 ul').tabsClick(1); $('#container-2 ul').tabsClick(1); return false };
if(!check_empty('serie','Serie şi numar act')) { $('#container-1 ul').tabsClick(1); $('#container-2 ul').tabsClick(1); return false };
//if(!check_empty('telefon_fix','Telefon fix')) { $('#container-1 ul').tabsClick(1); $('#container-2 ul').tabsClick(1); return false };
//if(!check_empty('telefon_mobil','Telefon mobil')) { $('#container-1 ul').tabsClick(1); $('#container-2 ul').tabsClick(1); return false };
//if(!check_empty('loc_de_munca','Loc de munca')) { $('#container-1 ul').tabsClick(1); $('#container-2 ul').tabsClick(1); return false };
/*
if(!check_empty('numeartera','Nume artera')) { $('#container-1 ul').tabsClick(1); $('#container-2 ul').tabsClick(2); return false };
if(!check_empty('numar','Numar')) { $('#container-1 ul').tabsClick(1); $('#container-2 ul').tabsClick(2); return false };
if(!check_empty('bloc','Bloc')) { $('#container-1 ul').tabsClick(1); $('#container-2 ul').tabsClick(2); return false };
if(!check_empty('scara','Scara')) { $('#container-1 ul').tabsClick(1); $('#container-2 ul').tabsClick(2); return false };
if(!check_empty('etaj','Etaj')) { $('#container-1 ul').tabsClick(1); $('#container-2 ul').tabsClick(2); return false };
if(!check_empty('ap','Apartament')) { $('#container-1 ul').tabsClick(1); $('#container-2 ul').tabsClick(2); return false };
if(!check_empty('numeartera2','Nume artera')) { $('#container-1 ul').tabsClick(1); $('#container-2 ul').tabsClick(3); return false };
if(!check_empty('numar2','Numar')) { $('#container-1 ul').tabsClick(1); $('#container-2 ul').tabsClick(3); return false };
if(!check_empty('bloc2','Bloc')) { $('#container-1 ul').tabsClick(1); $('#container-2 ul').tabsClick(3); return false };
if(!check_empty('scara2','Scara')) { $('#container-1 ul').tabsClick(1); $('#container-2 ul').tabsClick(3); return false };
if(!check_empty('etaj2','Etaj')) { $('#container-1 ul').tabsClick(1); $('#container-2 ul').tabsClick(3); return false };
if(!check_empty('ap2','Apartament')) { $('#container-1 ul').tabsClick(1); $('#container-2 ul').tabsClick(3); return false };
*/
if(!check_empty('hloc','Localitate')) { $('#container-1 ul').tabsClick(1); $('#container-2 ul').tabsClick(3); return false };
if(!check_empty('hloc2','Localitate')) { $('#container-1 ul').tabsClick(1); $('#container-2 ul').tabsClick(4); return false };

//if(!check_empty('cetatenie','Cetatenie')) { $('#container-1 ul').tabsClick(1); $('#container-2 ul').tabsClick(1); return false };
if(!check_empty('username','Nume utilizator')) { $('#container-1 ul').tabsClick(4); return false };
//if(!check_empty('password','Parola')) { $('#container-1 ul').tabsClick(4); return false };
//if(!check_empty('password2','Reintroduceti parola')) { $('#container-1 ul').tabsClick(4); return false };

var test_sel = document.getElementById('sel2');
if(test_sel != null)
	updatehid('sel2','hid');

var drepturi_speciale = document.getElementsByName('drepturi_speciale')[0];
var nivel_confiden = document.getElementsByName('nivel_confiden')[0];
	
if(drepturi_speciale != null)
	if(drepturi_speciale.value==1) { var special=confirm("S-a retinut acordul de drepturi speciale?");  var raspuns1=1; var tiparit1=1; }
if(nivel_confiden != null)
	if(nivel_confiden.value!=2) { var confiden=confirm("S-a retinut acordul de confidentialitate ?"); var raspuns2=1; var tiparit2=1; }
if(drepturi_speciale != null)
	if(drepturi_speciale.value==0) { var raspuns1=1; var tiparit1=0; }
if(nivel_confiden != null)
	if(nivel_confiden.value==2) { var raspuns2=1; var tiparit2=0; }
var cod=document.getElementsByName('username')[0].value;

if((drepturi_speciale != null && raspuns1 == 1) || drepturi_speciale == null)
	if(raspuns2==1)
		{ 
			var sel2_length = 0;
			if(test_sel != null)
				sel2_length = test_sel.length;
			run_get('validare_cont_nou', 'nume@prenume@cnp@sel2@special@tiparit1@confiden@tiparit2@cod', document.getElementsByName('nume')[0].value+'@'+document.getElementsByName('prenume')[0].value+'@'+document.getElementsByName('cnp')[0].value+'@'+sel2_length+'@'+special+'@'+tiparit1+'@'+confiden+'@'+tiparit2+'@'+cod, 'infodreapta');
		}

}

function validare_modificare_cont()
{
//if(!check_empty('cnp','CNP')) { return false };
//if(!check_empty('nume','Nume')) { return false };
//if(!check_empty('prenume','Prenume')) { return false };
//if(!check_empty('serie','Serie')) { return false };

//if(!check_empty('telefon_fix','Telefon fix')) { return false };
//if(!check_empty('telefon_mobil','Telefon mobil')) { return false };
//if(!check_empty('loc_de_munca','Loc de munca')) { return false };

//if(!check_empty('numeartera','Nume artera')) { return false };
//if(!check_empty('numar','Numar')) { return false };
//if(!check_empty('bloc','Bloc')) { return false };
//if(!check_empty('scara','Scara')) { return false };
//if(!check_empty('etaj','Etaj')) { return false };
//if(!check_empty('ap','Apartament')) { return false };
//if(!check_empty('numeartera2','Nume artera')) { return false };
//if(!check_empty('numar2','Numar')) { return false };
//if(!check_empty('bloc2','Bloc')) { return false };
//if(!check_empty('scara2','Scara')) { return false };
//if(!check_empty('etaj2','Etaj')) { return false };
//if(!check_empty('ap2','Apartament')) { return false };

//if(!check_empty('cetatenie','Cetatenie')) { return false };
//if(!check_empty('username','Nume utilizator')) { return false };

updatehid('sel2','hid');
 
if(document.getElementsByName('drepturi_speciale')[0].value==1) { var special=confirm("S-a reţinut acordul de drepturi speciale?");  var raspuns1=1; var tiparit1=1; }
if(document.getElementsByName('nivel_confiden')[0].value!=2) { var confiden=confirm("S-a reţinut acordul de confidenţialitate ?"); var raspuns2=1; var tiparit2=1; }
if(document.getElementsByName('drepturi_speciale')[0].value==0) { var raspuns1=1; var tiparit1=0; }
if(document.getElementsByName('nivel_confiden')[0].value==2) { var raspuns2=1; var tiparit2=0; }
var id_user=document.getElementsByName('uid')[0].value;

if(document.getElementsByName('idfy')[0].value=='check') { var idfy=confirm("Pacientul necunoscut a fost identificat?"); if(idfy==1) document.getElementsByName('idfy')[0].value="ok"; }
if(document.getElementsByName('idfynn')[0].value=='check') { var idfynn=confirm("Pacientul nou-nascut a fost identificat?"); if(idfynn==1) document.getElementsByName('idfynn')[0].value="ok"; }
if(raspuns1==1 && raspuns2==1) 
	run_get('modificare_cont', 'password@password2@nume@prenume@cnp@sel2@special@tiparit1@confiden@tiparit2@uid', document.getElementsByName('password')[0].value+'@'+document.getElementsByName('password2')[0].value+'@'+document.getElementsByName('nume')[0].value+'@'+document.getElementsByName('prenume')[0].value+'@'+document.getElementsByName('cnp')[0].value+'@'+document.getElementById('sel2').length+'@'+special+'@'+tiparit1+'@'+confiden+'@'+tiparit2+'@'+id_user, 'infodreapta');

}


//functii ptr multiple select list
var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);

function addOption(theSel, theText, theValue)
{
  var newOpt = new Option(theText, theValue);
  var selLength = document.getElementById(theSel).length;
  document.getElementById(theSel).options[selLength] = newOpt;
}

function deleteOption(theSel, theIndex)
{ 
  var selLength = theSel.length;
  if(selLength>0)
  {
    theSel.options[theIndex] = null;
  }
}

function deleteOption2(theSel)
{ 
  var selLength = theSel.length;
   for(i=selLength-1; i>=0; i--)
  {
    if(theSel.options[i].selected)
    {
      run_get('modificare_rol', 'numerolsters@i', theSel.options[i].value+'@'+i, 'infodreapta');	
    }
  }
}

function deleteOption3(theSel)
{ 
  var selLength = theSel.length;
   for(i=selLength-1; i>=0; i--)
  {
    if(theSel.options[i].selected)
    {
      run_get('modificare_drept', 'numedreptsters', theSel.options[i].value, 'infodreapta');
      deleteOption(theSel, i);	
    }
  }
}

function deleteAllOptions(theSel)
{ 
  var selLength = theSel.length;
   for(i=selLength-1; i>=0; i--)
  {
      deleteOption(theSel, i);
  }
}

function deleteOptionCas(theSel)
{ 
  var selLength = theSel.length;
   for(i=selLength-1; i>=0; i--)
  {
    if(theSel.options[i].selected)
    {
      run_get('modificare_cas', 'mode@id@i', 'del@'+theSel.options[i].value+'@'+i, 'infodreapta');	
    }
  }
}

function moveOptions(theSelFrom, theSelTo)
{
  
  var selLength = theSelFrom.length;
  var selectedText = new Array();
  var selectedValues = new Array();
  var selectedCount = 0;
  
  var i;
  
  // Find the selected Options in reverse order
  // and delete them from the 'from' Select.
  for(i=selLength-1; i>=0; i--)
  {
    if(theSelFrom.options[i].selected)
    {
      selectedText[selectedCount] = theSelFrom.options[i].text;
      selectedValues[selectedCount] = theSelFrom.options[i].value;
      deleteOption(theSelFrom, i);
      selectedCount++;
    }
  }
  
  // Add the selected text/values in reverse order.
  // This will add the Options to the 'to' Select
  // in the same order as they were in the 'from' Select.
  for(i=selectedCount-1; i>=0; i--)
  {
    addOption(theSelTo, selectedText[i], selectedValues[i]);
	updatehid('sel2','hid');
	run_get('roluri_implicite','mode@iduri','drepturi_speciale@'+document.getElementById('hid').value,'infodreapta');
  }
  
  if(NS4) history.go(0);
}

function updatehid(id,hid)
{
  var s=document.getElementById(id);
  var h=document.getElementById(hid);
  var aux;
  for(i=0; i<=s.length-1; i++)
  {
    if(i!=s.length-1) { aux=aux+s.options[i].value+","; } else { aux=aux+s.options[i].value; }
  }
  h.value=aux;

}

function focusfield()
{
 return document.getElementById('focus').focus();
}

function succes(text)
{
 return "<p><font color=green>"+text+"</font></p>";
}

function warn(text)
{
 return "<p><font color=blue>"+text+"</font></p>";
}

function error(text)
{
 return "<p><font color=red>"+text+"</font></p>";
}

function capsDetect( e ) {
  //if the browser did not pass event information to the handler,
  //check in window.event
  if( !e ) { e = window.event; } if( !e ) { return; }
  //what (case sensitive in good browsers) key was pressed
  //this uses all three techniques for checking, just in case
  var theKey = 0;
  if( e.which ) { theKey = e.which; } //Netscape 4+, etc.
  else if( e.keyCode ) { theKey = e.keyCode; } //Internet Explorer, etc.
  else if( e.charCode ) { theKey = e.charCode } //Gecko - probably not needed
  //was the shift key was pressed
  var theShift = false;
  if( e.shiftKey ) { theShift = e.shiftKey; } //Internet Explorer, etc.
  else if( e.modifiers ) { //Netscape 4
    //check the third bit of the modifiers value (says if SHIFT is pressed)
    if( e.modifiers & 4 ) { //bitwise AND
      theShift = true;
    }
  }
  //if upper case, check if shift is not pressed
  if( theKey > 64 && theKey < 91 && !theShift ) {
  document.getElementById('mesaj').innerHTML=warn('Atentie, aveti tasta Caps Lock activata!');  
  }
  //daca scrie litere meci, sa dispara warnul
  if( theKey > 96 && theKey < 123 ) {
  document.getElementById('mesaj').innerHTML="";
  }
  //if lower case, check if shift is pressed
  else if( theKey > 96 && theKey < 123 && theShift ) {
  document.getElementById('mesaj').innerHTML=warn('Atentie, aveti tasta Caps Lock activata!');  
  }
}

function switch_button_values(byName,val1,val2) {
var nume=document.getElementsByName(byName)[0];
if(nume.value==val1) nume.value=val2; else nume.value=val1;
}

function copyfromto(fromdivname, todivname) {
	document.getElementsByName(todivname)[0].value=document.getElementsByName(fromdivname)[0].value;
}

function copyfromto_select(fromdivname, todivname) {
	document.getElementsByName(todivname)[0].selectedIndex=document.getElementsByName(fromdivname)[0].selectedIndex;
}

function setemptydivbyname(divname) {
	document.getElementsByName(divname)[0].value='';
}

function setemptydivbyname_select(divname) {
	document.getElementsByName(divname)[0].selectedIndex='0';
}

function copyfromadresalegala() {
	var checkb=document.getElementById('acceasiadresa');
	if(checkb.checked==true)
		{
		copyfromto('codpostal','codpostal2');
		copyfromto('numeartera','numeartera2');
		copyfromto('numar','numar2');
		copyfromto('bloc','bloc2');
		copyfromto('scara','scara2');
		copyfromto('etaj','etaj2');
		copyfromto('ap','ap2');
		copyfromto_select('artera', 'artera2');
		copyfromto('localitate', 'localitate2');
		copyfromto('localitate', 'localitate2');
		copyfromto('hloc', 'hloc2');
		run_get_noexec('updater','mode@key@idlocalitate','updatejudet@'+document.getElementsByName('localitate2')[0].value+'@'+document.getElementsByName('hloc')[0].value,'judet2');
		setTimeout("copyfromto_select('judet', 'judet2');", 2000);
		}
	else
		{
		setemptydivbyname('codpostal2');
		setemptydivbyname('numeartera2');
		setemptydivbyname('numar2');
		setemptydivbyname('bloc2');
		setemptydivbyname('scara2');
		setemptydivbyname('etaj2');
		setemptydivbyname('ap2');
		setemptydivbyname_select('artera2');
		setemptydivbyname_select('judet2');
		setemptydivbyname('localitate2');
		setemptydivbyname('hloc2');
		}
}

function ierarhieup() {
	if(document.getElementsByName('roluri')[0].selectedIndex-1>=0)
	{
	var aux=document.getElementsByName('roluri')[0][document.getElementsByName('roluri')[0].selectedIndex].value;
	var auxname=document.getElementsByName('roluri')[0][document.getElementsByName('roluri')[0].selectedIndex].innerHTML;
	document.getElementsByName('roluri')[0][document.getElementsByName('roluri')[0].selectedIndex].value=document.getElementsByName('roluri')[0][document.getElementsByName('roluri')[0].selectedIndex-1].value;
	document.getElementsByName('roluri')[0][document.getElementsByName('roluri')[0].selectedIndex].innerHTML=document.getElementsByName('roluri')[0][document.getElementsByName('roluri')[0].selectedIndex-1].innerHTML;
	document.getElementsByName('roluri')[0][document.getElementsByName('roluri')[0].selectedIndex-1].value=aux;
	document.getElementsByName('roluri')[0][document.getElementsByName('roluri')[0].selectedIndex-1].innerHTML=auxname;
	document.getElementsByName('roluri')[0].selectedIndex=	document.getElementsByName('roluri')[0].selectedIndex-1;
	updatehid('rols','hid');
	run_get('modificare_ierarhie', 'roluri', document.getElementById('hid').value, 'infodreapta');
	}
}

function ierarhiedown() {
	if(document.getElementsByName('roluri')[0].selectedIndex!='undefined')
	{
	var aux=document.getElementsByName('roluri')[0][document.getElementsByName('roluri')[0].selectedIndex].value;
	var auxname=document.getElementsByName('roluri')[0][document.getElementsByName('roluri')[0].selectedIndex].innerHTML;
	document.getElementsByName('roluri')[0][document.getElementsByName('roluri')[0].selectedIndex].value=document.getElementsByName('roluri')[0][document.getElementsByName('roluri')[0].selectedIndex+1].value;
	document.getElementsByName('roluri')[0][document.getElementsByName('roluri')[0].selectedIndex].innerHTML=document.getElementsByName('roluri')[0][document.getElementsByName('roluri')[0].selectedIndex+1].innerHTML;
	document.getElementsByName('roluri')[0][document.getElementsByName('roluri')[0].selectedIndex+1].value=aux;
	document.getElementsByName('roluri')[0][document.getElementsByName('roluri')[0].selectedIndex+1].innerHTML=auxname;
	document.getElementsByName('roluri')[0].selectedIndex=	document.getElementsByName('roluri')[0].selectedIndex+1;
	updatehid('rols','hid');
	run_get('modificare_ierarhie', 'roluri', document.getElementById('hid').value, 'infodreapta');
	}
}

function liveeditpopup(elem,titlu,ajaxauxvar) {
	var instanta=document.getElementById('livepopup');
	if(instanta==null) {
	popdiv=document.createElement('div');
	header=document.createElement('h3');
	header.innerHTML=titlu.toUpperCase()+' | <a href="javascript: void(0);" onClick="closeliveeditpopup();"><img src="images/cross.png" border="0" align="absmiddle" /></a>';
	header.setAttribute('style','border:solid 1px rgb(220,220,220); color:rgb(80,80,80); background-color:rgb(220,220,220);');
	header.align="right";
	content=document.createElement('div');
	content.setAttribute('id','livepopupcontent');
	content.setAttribute('style','margin: 5px 5px 5px 5px;');
	content.innerHTML='<br /><br /><br /><br />';
	var y=elem.offsetTop;
	var x=elem.offsetLeft;
	y=y-50;
	x=x+15;
	var att="left: "+x+"px; top: "+y+"px;";
	popdiv.setAttribute('id','livepopup');
	popdiv.setAttribute('class','contactform');
	popdiv.setAttribute('className','contactform');
	popdiv.setAttribute('style','z-index: 999; padding: 0; position: absolute; '+att);
	popdiv.style.opacity = 0;
	document.body.appendChild(popdiv);
	popdiv.appendChild(header); popdiv.appendChild(content);
	run_get_noexec('liveeditpopupcontentgenerator', 'contentfor@ajaxauxvar', titlu+'@'+ajaxauxvar, 'livepopupcontent');
	opacity('livepopup', 0, 100, 400); }
}

function closeliveeditpopup() {
	var instanta=document.getElementById('livepopup');
	if(instanta!=null) {
	opacity('livepopup', 100, 0, 400);
	setTimeout('document.body.removeChild(document.getElementById(\'livepopup\'));',500);
	}
}

function livesearchpopup(keyword) {
	var instanta=document.getElementById('livesearchpopup');
	var e=document.getElementsByName('search')[0];
	if(instanta==null) {
	sdiv=document.createElement('div');
	sheader=document.createElement('h4');
	sheader.innerHTML='Rezultatele cautarii pentru <i>'+keyword+'</i>:';
	sheader.setAttribute('style','border:solid 1px rgb(220,220,220); color:rgb(80,80,80); background-color:rgb(220,220,220);');
	scontent=document.createElement('div');
	scontent.setAttribute('id','livesearchpopupcontent');
	scontent.setAttribute('style','margin: 5px 5px 5px 5px;');
	scontent.innerHTML='<br /><br />';
	var y=e.offsetTop;
	var x=e.offsetLeft;
	x=x-78;
	y=y+2;
	var att="left: "+x+"px; top: "+y+"px;";
	sdiv.setAttribute('id','livesearchpopup');
	sdiv.setAttribute('class','contactform');
	sdiv.setAttribute('className','contactform');
	sdiv.setAttribute('style','z-index: 999; width: 250px; padding: 0; position: absolute; '+att);
	sdiv.style.opacity = 0;
	document.body.appendChild(sdiv);
	sdiv.appendChild(sheader); sdiv.appendChild(scontent);
	opacity('livesearchpopup', 0, 100, 400); }
	sheader.innerHTML='Rezultatele cautarii pentru <i>'+keyword+'</i>:';
	run_get_noexec('livesearch', 'keyword', keyword, 'livesearchpopupcontent');
}

function closelivesearchpopup() {
	var instanta=document.getElementById('livesearchpopup');
	if(instanta!=null) {
	opacity('livesearchpopup', 100, 0, 400);
	setTimeout('document.body.removeChild(document.getElementById(\'livesearchpopup\'));', 500);
	}
}

function livesearchlocalitate(keyword,field,hfield,jfield) {
	var instanta=document.getElementById('livesearchlocalitate');
	var e=field;
	if(instanta==null) {
	sdiv=document.createElement('div');
	scontent=document.createElement('div');
	scontent.setAttribute('id','livesearchlocalitatecontent');
	scontent.innerHTML='<br /><br />';
	var y=e.offsetTop;
	var x=e.offsetLeft;
	x=x-6;
	y=y+126;
	var att="left: "+x+"px; top: "+y+"px;";
	sdiv.setAttribute('id','livesearchlocalitate');
	sdiv.setAttribute('class','contactform');
	sdiv.setAttribute('className','contactform');
	sdiv.setAttribute('style','z-index: 999; width: 144px; height: 70px; padding: 0; position: absolute; overflow: auto; '+att);
	sdiv.style.opacity = 0;
	document.body.appendChild(sdiv);
	sdiv.appendChild(scontent);
	opacity('livesearchlocalitate', 0, 100, 400); }
	run_get_noexec('livesearchlocalitate', 'keyword@fieldname@hfield@jfield', keyword+'@'+e.name+'@'+hfield+'@'+jfield, 'livesearchlocalitatecontent');
}

function livesearchlocalitate2(keyword,field,hfield,jfield) {
	var instanta=document.getElementById('livesearchlocalitate');
	var e=field;
	if(instanta==null) {
	sdiv=document.createElement('div');
	scontent=document.createElement('div');
	scontent.setAttribute('id','livesearchlocalitatecontent');
	scontent.innerHTML='<br /><br />';
	var y=e.offsetTop;
	var x=e.offsetLeft;
	x=x+326-80;
	y=y+388;
	var att="left: "+x+"px; top: "+y+"px;";
	sdiv.setAttribute('id','livesearchlocalitate');
	sdiv.setAttribute('class','contactform');
	sdiv.setAttribute('className','contactform');
	sdiv.setAttribute('style','z-index: 999; width: 144px; height: 70px; padding: 0; position: absolute; overflow: auto; '+att);
	sdiv.style.opacity = 0;
	document.body.appendChild(sdiv);
	sdiv.appendChild(scontent);
	opacity('livesearchlocalitate', 0, 100, 400); }
	run_get_noexec('livesearchlocalitate', 'keyword@fieldname@hfield@jfield', keyword+'@'+e.name+'@'+hfield+'@'+jfield, 'livesearchlocalitatecontent');
}

function livesearchlocalitate_edit(keyword,field,hfield,jfield) {
	var instanta=document.getElementById('livesearchlocalitate');
	var e=field;
	if(instanta==null) {
	sdiv=document.createElement('div');
	scontent=document.createElement('div');
	scontent.setAttribute('id','livesearchlocalitatecontent');
	scontent.innerHTML='<br /><br />';
	var y=e.offsetTop;
	var x=e.offsetLeft;
	x=x+326-97;
	y=y+320;
	var att="left: "+x+"px; top: "+y+"px;";
	sdiv.setAttribute('id','livesearchlocalitate');
	sdiv.setAttribute('class','contactform');
	sdiv.setAttribute('className','contactform');
	sdiv.setAttribute('style','z-index: 999; width: 144px; height: 70px; padding: 0; position: absolute; overflow: auto; '+att);
	sdiv.style.opacity = 0;
	document.body.appendChild(sdiv);
	sdiv.appendChild(scontent);
	opacity('livesearchlocalitate', 0, 100, 400); }
	run_get_noexec('livesearchlocalitate', 'keyword@fieldname@hfield@jfield', keyword+'@'+e.name+'@'+hfield+'@'+jfield, 'livesearchlocalitatecontent');
}

function closelivesearchlocalitate() {
	var instanta=document.getElementById('livesearchlocalitate');
	if(instanta!=null) {
	opacity('livesearchlocalitate', 100, 0, 400);
	setTimeout('document.body.removeChild(document.getElementById(\'livesearchlocalitate\'));', 500);
	}
}

function livesearchprocedura(keyword,field) {
	var instanta=document.getElementById('livesearchprocedura');
	var e=field;
	if(instanta==null) {
	sdiv=document.createElement('div');
	scontent=document.createElement('div');
	scontent.setAttribute('id','livesearchproceduracontent');
	scontent.innerHTML='<br /><br />';
	var y=getOffsetTop(e);//e.offsetTop;
	var x=getOffsetLeft(e);//e.offsetLeft;
	x=x-8;
	y=y+0;
	var att="left: "+x+"px; top: "+y+"px;";
	sdiv.setAttribute('id','livesearchprocedura');
	sdiv.setAttribute('class','contactform');
	sdiv.setAttribute('className','contactform');
	sdiv.setAttribute('style','z-index: 999; width: 144px; height: 70px; padding: 0; position: absolute; overflow: auto; '+att);
	sdiv.style.opacity = 0;
	document.body.appendChild(sdiv);
	sdiv.appendChild(scontent);
	opacity('livesearchprocedura', 0, 100, 400); }
	run_get_noexec('livesearchprocedura', 'keyword@fieldname', keyword+'@'+e.name, 'livesearchproceduracontent');
}

function closelivesearchprocedura() {
	var instanta=document.getElementById('livesearchprocedura');
	if(instanta!=null) {
	opacity('livesearchprocedura', 100, 0, 400);
	setTimeout('document.body.removeChild(document.getElementById(\'livesearchprocedura\'));', 500);
	}
}

function livesearch(keyword,field) {
	var instanta=document.getElementById('livesearch');
	var e=field;
	width=e.clientWidth;
	if(instanta==null) {
	sdiv=document.createElement('div');
	scontent=document.createElement('div');
	scontent.setAttribute('id','livesearchcontent');
	scontent.innerHTML='';
	var y=getOffsetTop(e);//e.offsetTop;
	var x=getOffsetLeft(e);//e.offsetLeft;
	x=x-8;
	y=y+0;
	var att="left: "+x+"px; top: "+y+"px;";
	sdiv.setAttribute('id','livesearch');
	sdiv.setAttribute('class','contactform');
	sdiv.setAttribute('className','contactform');
	sdiv.setAttribute('style','z-index: 999; width: '+width+'px; height: 70px; padding: 0; position: absolute; overflow: auto; '+att);
	sdiv.style.opacity = 0;
	document.body.appendChild(sdiv);
	sdiv.appendChild(scontent);
	opacity('livesearch', 0, 100, 400); }
	run_get_noexec('livesearch', 'keyword@fieldname@mode', keyword+'@'+e.name+'@'+e.name, 'livesearchcontent');
}

function closelivesearch() {
	var instanta=document.getElementById('livesearch');
	if(instanta!=null) {
	opacity('livesearch', 100, 0, 400);
	setTimeout('document.body.removeChild(document.getElementById(\'livesearch\'));', 500);
	}
}

function livesearchproc(keyword,field) {
	var instanta=document.getElementById('livesearchproc');
	var e=field;
	if(instanta==null) {
	sdiv=document.createElement('div');
	scontent=document.createElement('div');
	scontent.setAttribute('id','livesearchcontent');
	scontent.innerHTML='';
	var y=getOffsetTop(e);//e.offsetTop;
	var x=getOffsetLeft(e);//e.offsetLeft;
	x=x-8;
	y=y+0;
	var att="left: "+x+"px; top: "+y+"px;";
	sdiv.setAttribute('id','livesearchproc');
	sdiv.setAttribute('class','contactform');
	sdiv.setAttribute('className','contactform');
	sdiv.setAttribute('style','z-index: 999; height: 70px; padding: 0; position: absolute; overflow: auto; '+att);
	sdiv.style.opacity = 0;
	document.body.appendChild(sdiv);
	sdiv.appendChild(scontent);
	opacity('livesearchproc', 0, 100, 400); }
	run_get_noexec('livesearchproc', 'keyword@fieldname@mode', keyword+'@'+e.name+'@'+e.name, 'livesearchcontent');
}

function closelivesearchproc() {
	var instanta=document.getElementById('livesearchproc');
	if(instanta!=null) {
	opacity('livesearch', 100, 0, 400);
	setTimeout('document.body.removeChild(document.getElementById(\'livesearchproc\'));', 500);
	}
}

function console() {
	var instanta=document.getElementById('console');
	if(instanta==null) {
	sdiv=document.createElement('div');
	scontent=document.createElement('div');
	scontent.setAttribute('id','consolecontent');
	scontent.setAttribute('style','width: 100%; height:278px; overflow: auto; color:#ffffff; font-family: Verdana; padding:1px 1px 1px 1px;');
	scl=document.createElement('div');
	scl.setAttribute('id','consolecl');
	scl.setAttribute('style','margin-left: 1px; width: 100%; height: 22px; color: #ffffff; font-family: Verdana; font-weight: bold;');
	scl.innerHTML='<input type="text" name="cl" style="width: 99%" />';
	var scrollTop = window.pageYOffset || document.documentElement.scrollTop || 0;
	var py=document.body.offsetHeight;
	var y=py/2+scrollTop-150;
	var x=document.body.offsetWidth/2-250;
	var att="left: "+x+"px; top: "+y+"px;";
	sdiv.setAttribute('id','console');
	sdiv.setAttribute('style','z-index: 999; background-color:#000000; color:#ffffff; font-family:Verdana; border:2px #666666 solid; width: 500px; height: 300px; padding: 0; position: absolute; '+att);
	sdiv.style.opacity = 0;
	document.body.appendChild(sdiv);
	sdiv.appendChild(scontent);
	sdiv.appendChild(scl);
	opacity('console', 0, 80, 600); }
	document.getElementsByName('cl')[0].focus();
	document.getElementsByName('cl')[0].onkeyup=KeyCheck2;
}

function closeconsole() {
	var instanta=document.getElementById('console');
	if(instanta!=null) {
	opacity('console', 80, 0, 600);
	setTimeout('document.body.removeChild(document.getElementById(\'console\'));', 600);
	}
}

function nexttablink(tabid) {
	document.getElementById('nexttablinkffs1').innerHTML='<a href="javascript:void(0);" onClick="$(\'#container-1\').tabs(\'select\', '+tabid+')\">Continuare...</a>';
	document.getElementById('nexttablinkffs2').innerHTML='<a href="javascript:void(0);" onClick="$(\'#container-1\').tabs(\'select\', '+tabid+')\">Continuare...</a>';
}

function atribuire_procedura(obj,uid) {
	x=obj.parentNode.parentNode.parentNode.insertRow(obj.parentNode.parentNode.sectionRowIndex+1); 
	y=x.insertCell(0); 
	z=x.insertCell(1);
	z.setAttribute('class', 'nume');
	z.setAttribute('className', 'nume');
	a=x.insertCell(2);
	a.setAttribute('class', 'nume');
	a.setAttribute('className', 'nume');
	y.innerHTML='<p><label for="proceduri" class="left2">Nume procedură:</label><input type="text" size="20" name="proceduri" onKeyDown="change_class(\'proceduri\');" onKeyUp="change_class(\'proceduri\'); livesearchprocedura(this.value, this);" onBlur="closelivesearchprocedura();" /></p>';
	z.innerHTML='<a href="javascript:void(0);" onClick="if(document.getElementsByName(\'hid\')[0].value!=\'\') run_get(\'modificareprocedurama\', \'mode@cod1@cod2\', \'adaugare@'+uid+'@\'+document.getElementsByName(\'hid\')[0].value, \'infodreapta\');"><img src="images/accept.png" border="0" alt="" /></a><input type="hidden" name="hid" />';
	a.innerHTML='<a href="javascript:void(0);" onClick="this.parentNode.parentNode.parentNode.deleteRow(this.parentNode.parentNode.sectionRowIndex);"><img src="images/cross.png" border="0" alt="" /></a>';
}

function stergere_procedura(obj,uid,idproc) {
	obj.parentNode.parentNode.parentNode.deleteRow(obj.parentNode.parentNode.sectionRowIndex);
	run_get('modificareprocedurama', 'mode@cod1@cod2', 'stergere@'+uid+'@'+idproc, 'infodreapta');
}

function getOffsetTop(el)
{
var ot = el.offsetTop;
while ( ( el = el.offsetParent ) != null )
{
ot += el.offsetTop;
}
return ot;
}

function getOffsetLeft(el)
{
var ol = el.offsetLeft;
while ( ( el = el.offsetParent ) != null )
{
ol += el.offsetLeft;
}
return ol;
}

function atribuire_procedura_unitate(obj,uid) {
	x=obj.parentNode.parentNode.parentNode.insertRow(obj.parentNode.parentNode.sectionRowIndex+1); 
	y=x.insertCell(0); 
	z=x.insertCell(1);
	z.setAttribute('class', 'nume');
	z.setAttribute('className', 'nume');
	a=x.insertCell(2);
	a.setAttribute('class', 'nume');
	a.setAttribute('className', 'nume');
	y.innerHTML='<p><label for="proceduri" class="left2">Nume procedură:</label><input type="text" size="20" name="proceduri" onKeyDown="change_class(\'proceduri\');" onKeyUp="change_class(\'proceduri\'); livesearchprocedura_unitate(this.value, this);" onBlur="closelivesearchprocedura_unitate();" /></p>';
	z.innerHTML='<a href="javascript:void(0);" onClick="if(document.getElementsByName(\'hid\')[0].value!=\'\') run_get(\'modificareprocedurau\', \'mode@cod1@cod2\', \'adaugare@'+uid+'@\'+document.getElementsByName(\'hid\')[0].value, \'infodreapta\');"><img src="images/accept.png" border="0" alt="" /></a><input type="hidden" name="hid" />';
	a.innerHTML='<a href="javascript:void(0);" onClick="this.parentNode.parentNode.parentNode.deleteRow(this.parentNode.parentNode.sectionRowIndex);"><img src="images/cross.png" border="0" alt="" /></a>';
}

function stergere_procedura_unitate(obj,uid,idproc) {
	obj.parentNode.parentNode.parentNode.deleteRow(obj.parentNode.parentNode.sectionRowIndex);
	run_get('modificareprocedurau', 'mode@cod1@cod2', 'stergere@'+uid+'@'+idproc, 'infodreapta');
}

function livesearchprocedura_unitate(keyword,field) {
	var instanta=document.getElementById('livesearchprocedura_unitate');
	var e=field;
	if(instanta==null) {
	sdiv=document.createElement('div');
	scontent=document.createElement('div');
	scontent.setAttribute('id','livesearchprocedura_unitatecontent');
	scontent.innerHTML='<br /><br />';
	var y=getOffsetTop(e);//e.offsetTop;
	var x=getOffsetLeft(e);//e.offsetLeft;
	x=x-8;
	y=y+0;
	var att="left: "+x+"px; top: "+y+"px;";
	sdiv.setAttribute('id','livesearchprocedura_unitate');
	sdiv.setAttribute('class','contactform');
	sdiv.setAttribute('className','contactform');
	sdiv.setAttribute('style','z-index: 999; width: 144px; height: 70px; padding: 0; position: absolute; overflow: auto; '+att);
	sdiv.style.opacity = 0;
	document.body.appendChild(sdiv);
	sdiv.appendChild(scontent);
	opacity('livesearchprocedura_unitate', 0, 100, 400); }
	run_get_noexec('livesearchprocedura_unitate', 'keyword@fieldname', keyword+'@'+e.name, 'livesearchprocedura_unitatecontent');
}

function closelivesearchprocedura_unitate() {
	var instanta=document.getElementById('livesearchprocedura_unitate');
	if(instanta!=null) {
	opacity('livesearchprocedura_unitate', 100, 0, 400);
	setTimeout('document.body.removeChild(document.getElementById(\'livesearchprocedura_unitate\'));', 500);
	}
}

function adauga_rezultat() {
	var lastinputid=0;
	var lastinput=document.getElementsByTagName('input');
	for(i=0;i<lastinput.length;i++) {
	if(lastinput[i].type=='text' && lastinput[i].name.split('z')[0]=='numere')
		{
		lastinputid=i;
		}
	}
	var lastid=lastinput[lastinputid].name.split('numerez')[1];
	lastid++;
	lastcid=1;
	document.getElementById('alabala').innerHTML+='<div><p><label for="rez'+lastid+'" class="left3"><u>Rezultat '+lastid+'</u></label><div class="delete"><a href="javascript:void(0);" onClick="delete_rez('+lastid+')"><img src="images/delete.png" alt="" border="0" /></a></div>\n<p><label for="numerez'+lastid+'" class="left3">Nume rezultat:</label>\n<input type="text" size="20" name="numerez'+lastid+'" id="numerez'+lastid+'" onKeyDown="change_class(\'numerez'+lastid+'\');" onKeyUp="change_class(\'numerez'+lastid+'\');" /></p>\n<p><label for="umrez'+lastid+'" class="left3">Unitate de masură:</label>\n<input type="text" size="20" name="umrez'+lastid+'" id="umrez'+lastid+'" onKeyDown="change_class(\'umrez'+lastid+'\');" onKeyUp="change_class(\'umrez'+lastid+'\');" />\n<p><label for="costrez'+lastid+'" class="left3">Cost:</label>\n<input type="text" size="20" name="costrez'+lastid+'" id="costrez'+lastid+'" onKeyDown="change_class(\'costrez'+lastid+'\');" onKeyUp="change_class(\'costrez'+lastid+'\');" /></p></div>';  
	document.getElementById('alabala2').innerHTML+='<fieldset id="conditiirez'+lastid+'"><legend>&nbsp;CONDIŢII PENTRU REZULTATUL '+lastid+'&nbsp;</legend><div id="alabalarez'+lastid+'"><p><label for="cond'+lastcid+'rez'+lastid+'" class="left3"><u>Condiţie '+lastcid+'</u></label></p>\n<!--[if IE]>&nbsp;<br /><br /><![endif]-->\n<p><label for="" class="left3">Nume condiţie:</label><input type="text" size="20" name="numecond'+lastcid+'rez'+lastid+'" id="numecond'+lastcid+'rez'+lastid+'" onKeyDown="change_class(\'numecond'+lastcid+'rez'+lastid+'\');" onKeyUp="change_class(\'numecond'+lastcid+'rez'+lastid+'\');" /></p><p><label for="valcond'+lastcid+'rez'+lastid+'" class="left3">Valoare:</label><input type="text" size="20" name="valcond'+lastcid+'rez'+lastid+'" id="valcond'+lastcid+'rez'+lastid+'" onKeyDown="change_class(\'valcond'+lastcid+'rez'+lastid+'\');" onKeyUp="change_class(\'valcond'+lastcid+'rez'+lastid+'\');" /></p></div><div class="buton"><a href="javascript:void(0);" onClick="adauga_conditie(\'rez'+lastid+'\');" class="link">Adaugă incă o condiţie</a></div></fieldset>';
	document.getElementsByName('nrrez')[0].value=parseFloat(document.getElementsByName('nrrez')[0].value)+1;
}

function delete_rez(rezid) {
	var l=document.getElementsByTagName('u');
	for(i=0;i<l.length;i++)
	{
		if(l[i].innerHTML=='Rezultat '+rezid)
			{
			l[i].parentNode.parentNode.parentNode.parentNode.removeChild(l[i].parentNode.parentNode.parentNode);
			}
	}
	var x=document.getElementById('conditiirez'+rezid);
	x.parentNode.removeChild(x);
}

function adauga_conditie(rez) {
	var lastinputid=0;
	var rezid=rez.split('rez')[1];
	var lastinput=document.getElementsByTagName('input');
	for(i=0;i<lastinput.length;i++) {
	if(lastinput[i].type=='text' && lastinput[i].name.split('d')[0]=='numecon' && lastinput[i].name.split('numecond')[1].split('rez')[1]==rezid)
		{
		lastinputid=i;
		}
	}
	var lastid=lastinput[lastinputid].name.split('numecond')[1].split('rez')[0];
	lastid++;
	document.getElementById('alabalarez'+rezid).innerHTML+='<p><label for="cond'+lastid+'rez'+rezid+'" class="left3"><u>Condiţie '+lastid+'</u></label></p>\n<!--[if IE]>&nbsp;<br /><br /><![endif]-->\n<p><label for="numecond'+lastid+'rez'+rezid+'" class="left3">Nume condiţie:</label><input type="text" size="20" name="numecond'+lastid+'rez'+rezid+'" id="numecond'+lastid+'rez'+rezid+'" onKeyDown="change_class(\'numecond'+lastid+'rez'+rezid+'\');" onKeyUp="change_class(\'numecond'+lastid+'rez'+rezid+'\');" /></p>\n<p><label for="valcond'+lastid+'rez'+rezid+'" class="left3">Valoare:</label><input type="text" size="20" name="valcond'+lastid+'rez'+rezid+'" id="valcond'+lastid+'rez'+rezid+'" onKeyDown="change_class(\'valcond'+lastid+'rez'+rezid+'\');" onKeyUp="change_class(\'valcond'+lastid+'rez'+rezid+'\');" /></p>';  
}

function adauga_specialitate() {
/*
	var lastinputid=0;
	var lastinput=document.getElementsByTagName('select');
	for(i=0;i<lastinput.length;i++) {
	if(lastinput[i].name.split('c')[0]=='spe')
		{
		lastinputid=i;
		}
	}
	var lastid=lastinput[lastinputid].name.split('spec')[1];
*/
	var nospec=document.getElementById('nospec');
	if(nospec.value!="undefined") nospec.style.display='none';
	var lastid=document.getElementsByName('nrspecialitati')[0].value;
	lastid++;
	run_get('addspecialitate', 'numar@', lastid +'@', 'infodreapta');
	
	//document.getElementById('specialitati').innerHTML+=	'<p><label for="spec'+lastid+'" class="left2">Specialitate '+lastid+':</label>\n<select name="spec'+lastid+'" style="width:130px;"> \n </select> \n <label for="gradprofesional'+lastid+'">Grad profesional:</label>\n<select name="gradprofesional'+lastid+'" style="width:130px;">\n</select></p>';
	document.getElementsByName('nrspecialitati')[0].value=parseFloat(document.getElementsByName('nrspecialitati')[0].value)+1;
	if(document.getElementsByName('nrspecialitati')[0].value=='3') document.getElementById('buton').innerHTML='';
}

function delete_spec(rezid) {
	var l=document.getElementsByTagName('label');
	for(i=0;i<l.length;i++)
	{
		if(l[i].innerHTML=='Specialitate '+rezid+':')
			{
			l[i].parentNode.parentNode.removeChild(l[i].parentNode);
			}
	}
	document.getElementsByName('nrspecialitati')[0].value=parseFloat(document.getElementsByName('nrspecialitati')[0].value)-1;
	if(document.getElementsByName('nrspecialitati')[0].value==0)
		{
		var nospec=document.getElementById('nospec');
		if(nospec.value!="undefined") nospec.style.display='block';
		}
	if(document.getElementsByName('nrspecialitati')[0].value!='3') document.getElementById('buton').innerHTML='<a href="javascript:void(0);" onClick="adauga_specialitate();" class="link">Adaugă incă o specialitate</a>';
}

function adaugare_program_entitate(obj,uid) {
	x=obj.parentNode.parentNode.parentNode.insertRow(obj.parentNode.parentNode.sectionRowIndex+1); 
	y=x.insertCell(0); 
	z=x.insertCell(1);
	z.setAttribute('class', 'nume');
	z.setAttribute('className', 'nume');
	a=x.insertCell(2);
	a.setAttribute('class', 'nume');
	a.setAttribute('className', 'nume');
	l=x.insertCell(3);
	l.setAttribute('class', 'nume');
	l.setAttribute('className', 'nume');
	y.innerHTML='<p><label for="zile" class="left2">Zile:</label><input type="text" size="20" name="zile" onKeyDown="change_class(\'zile\');" onKeyUp="change_class(\'zile\');" /></p>';
	z.innerHTML='<p><label for="ore" class="left2">Ore:</label><input type="text" size="20" name="ore" onKeyDown="change_class(\'ore\');" onKeyUp="change_class(\'ore\');" /></p>';
	a.innerHTML='<a href="javascript:void(0);" onClick="run_get(\'modificareprograme\', \'mode@cod1@zile@ore\', \'adaugare@'+uid+'@\'+document.getElementsByName(\'zile\')[0].value+\'@\'+document.getElementsByName(\'ore\')[0].value, \'infodreapta\');"><img src="images/accept.png" border="0" alt="" /></a>';
	l.innerHTML='<a href="javascript:void(0);" onClick="this.parentNode.parentNode.parentNode.deleteRow(this.parentNode.parentNode.sectionRowIndex);"><img src="images/cross.png" border="0" alt="" /></a>';
}

function stergere_program_entitate(obj,uid,ident) {
	obj.parentNode.parentNode.parentNode.deleteRow(obj.parentNode.parentNode.sectionRowIndex);
	run_get('modificareprograme', 'mode@cod1@cod2', 'stergere@'+uid+'@'+ident, 'infodreapta');
}

function adaugare_post_de_lucru(obj,uid) {
	x=obj.parentNode.parentNode.parentNode.insertRow(obj.parentNode.parentNode.sectionRowIndex+1); 
	y=x.insertCell(0); 
	z=x.insertCell(1);
	z.setAttribute('class', 'nume');
	z.setAttribute('className', 'nume');
	n=x.insertCell(2);
	n.setAttribute('class', 'nume');
	n.setAttribute('className', 'nume');
	a=x.insertCell(3);
	a.setAttribute('class', 'nume');
	a.setAttribute('className', 'nume');
	l=x.insertCell(4);
	l.setAttribute('class', 'nume');
	l.setAttribute('className', 'nume');
	y.innerHTML='<p><label for="zile" class="left2">Nume:</label><input type="text" size="20" name="nume" onKeyDown="change_class(\'nume\');" onKeyUp="change_class(\'nume\');" /></p>';
	z.innerHTML='<p><label for="ipl" class="left2">IP local:</label><input type="text" size="20" name="ipl" onKeyDown="change_class(\'ipl\');" onKeyUp="change_class(\'ipl\');" /><br /><label for="ipp" class="left2">IP public:</label><input type="text" size="20" name="ipp" onKeyDown="change_class(\'ipp\');" onKeyUp="change_class(\'ipp\');" /></p>';
	n.innerHTML='<p><label for="pi" class="left2">Pagină<br />implicită:</label>'+getAjax('modificareposturidelucru', 'mode', 'getpages')+'</p>';
	a.innerHTML='<a href="javascript:void(0);" onClick="run_get(\'modificareposturidelucru\', \'mode@eid@nume@ipl@ipp@pi\', \'adaugare@'+uid+'@\'+document.getElementsByName(\'nume\')[0].value+\'@\'+document.getElementsByName(\'ipl\')[0].value+\'@\'+document.getElementsByName(\'ipp\')[0].value+\'@\'+document.getElementsByName(\'pi\')[0].value, \'infodreapta\');"><img src="images/accept.png" border="0" alt="" /></a>';
	l.innerHTML='<a href="javascript:void(0);" onClick="this.parentNode.parentNode.parentNode.deleteRow(this.parentNode.parentNode.sectionRowIndex);"><img src="images/cross.png" border="0" alt="" /></a>';
}

function stergere_post_de_lucru(obj,uid,eid) {
	obj.parentNode.parentNode.parentNode.deleteRow(obj.parentNode.parentNode.sectionRowIndex);
	run_get('modificareposturidelucru', 'mode@cod1@eid', 'stergere@'+uid+'@'+eid, 'infodreapta');
}

function adaugare_registru_entitate(obj,eid) {
	x=obj.parentNode.parentNode.parentNode.insertRow(obj.parentNode.parentNode.sectionRowIndex+1); 
	y=x.insertCell(0); 
	z=x.insertCell(1);
	z.setAttribute('class', 'nume');
	z.setAttribute('className', 'nume');
	a=x.insertCell(2);
	a.setAttribute('class', 'nume');
	a.setAttribute('className', 'nume');
	l=x.insertCell(3);
	l.setAttribute('class', 'nume');
	l.setAttribute('className', 'nume');
	y.innerHTML='<p><label for="zile" class="left2">Nume:</label><input type="text" size="20" name="nume" /></p>';
	z.innerHTML='<p><label for="ore" class="left2">Nr. registru:</label><input type="text" size="20" name="nr" /></p>';
	a.innerHTML='<a href="javascript:void(0);" onClick="run_get(\'modificare_entitati\', \'mode@eid@nume@nr\', \'adaugare_registru@'+eid+'@\'+document.getElementsByName(\'nume\')[0].value+\'@\'+document.getElementsByName(\'nr\')[0].value, \'infodreapta\');"><img src="images/accept.png" border="0" alt="" /></a>';
	l.innerHTML='<a href="javascript:void(0);" onClick="this.parentNode.parentNode.parentNode.deleteRow(this.parentNode.parentNode.sectionRowIndex);"><img src="images/cross.png" border="0" alt="" /></a>';
}

function stergere_registru_entitate(obj,eid,idreg) {
	obj.parentNode.parentNode.parentNode.deleteRow(obj.parentNode.parentNode.sectionRowIndex);
	run_get('modificare_entitati', 'mode@idreg@eid', 'stergere_registru@'+idreg+'@'+eid, 'infodreapta');
}

function editare_registru_entitate(obj,eid,idreg) {
	x=obj.parentNode.parentNode.parentNode.insertRow(obj.parentNode.parentNode.sectionRowIndex+1); 
	y=x.insertCell(0); 
	z=x.insertCell(1);
	z.setAttribute('class', 'nume');
	z.setAttribute('className', 'nume');
	a=x.insertCell(2);
	a.setAttribute('class', 'nume');
	a.setAttribute('className', 'nume');
	l=x.insertCell(3);
	l.setAttribute('class', 'nume');
	l.setAttribute('className', 'nume');
	run_get('modificare_entitati', 'mode@eid@idreg', 'return_edit_form@'+eid+'@'+idreg, 'infodreapta');
}

function livesearchent(keyword,field) {
	var instanta=document.getElementById('livesearchent');
	var e=field;
	if(instanta==null) {
	sdiv=document.createElement('div');
	scontent=document.createElement('div');
	scontent.setAttribute('id','livesearchentcontent');
	scontent.innerHTML='<br /><br />';
	var y=getOffsetTop(e);//e.offsetTop;
	var x=getOffsetLeft(e);//e.offsetLeft;
	x=x-8;
	y=y+0;
	var att="left: "+x+"px; top: "+y+"px;";
	sdiv.setAttribute('id','livesearchent');
	sdiv.setAttribute('class','contactform');
	sdiv.setAttribute('className','contactform');
	sdiv.setAttribute('style','z-index: 999; width: 144px; height: 70px; padding: 0; position: absolute; overflow: auto; '+att);
	sdiv.style.opacity = 0;
	document.body.appendChild(sdiv);
	sdiv.appendChild(scontent);
	opacity('livesearchent', 0, 100, 400); }
	run_get_noexec('livesearchent', 'keyword@fieldname', keyword+'@'+e.name, 'livesearchentcontent');
}

function closelivesearchent() {
	var instanta=document.getElementById('livesearchent');
	if(instanta!=null) {
	opacity('livesearchent', 100, 0, 400);
	setTimeout('document.body.removeChild(document.getElementById(\'livesearchent\'));', 500);
	}
}

function adaugare_program_medic(obj,uid) {
	x=obj.parentNode.parentNode.parentNode.insertRow(obj.parentNode.parentNode.sectionRowIndex+1); 
	y=x.insertCell(0); 
	z=x.insertCell(1);
    k=x.insertCell(2);
	z.setAttribute('class', 'nume');
	z.setAttribute('className', 'nume');
	k.setAttribute('class', 'nume');
	k.setAttribute('className', 'nume');
	a=x.insertCell(3);
	a.setAttribute('class', 'nume');
	a.setAttribute('className', 'nume');
	l=x.insertCell(4);
	l.setAttribute('class', 'nume');
	l.setAttribute('className', 'nume');
	y.innerHTML='<p><label for="zile" class="left2">Zile:</label><input type="text" size="20" name="zile" onKeyDown="change_class(\'zile\');" onKeyUp="change_class(\'zile\');" /></p>';
	z.innerHTML='<p><label for="ore" class="left2">Ore:</label><input type="text" size="20" name="ore" onKeyDown="change_class(\'ore\');" onKeyUp="change_class(\'ore\');" /></p>';
	k.innerHTML='<input type="hidden" name="hid" /><p><label for="ent" class="left2">Entitate:</label><input type="text" size="20" name="ent" onKeyDown="change_class(\'ent\');" onKeyUp="change_class(\'ent\'); livesearchent(this.value, this);" onBlur="closelivesearchent();" /></p>';
	a.innerHTML='';
	l.innerHTML='<a href="javascript:void(0);" onClick="run_get(\'modificareprogramm\', \'mode@cod1@zile@ore@ent\', \'adaugare@'+uid+'@\'+document.getElementsByName(\'zile\')[0].value+\'@\'+document.getElementsByName(\'ore\')[0].value+\'@\'+document.getElementsByName(\'hid\')[0].value, \'infodreapta\');"><img src="images/accept.png" border="0" alt="" /></a><br /><a href="javascript:void(0);" onClick="this.parentNode.parentNode.parentNode.deleteRow(this.parentNode.parentNode.sectionRowIndex);"><img src="images/cross.png" border="0" alt="" /></a>';
}

function stergere_program_medic(obj,uid,ident) {
	obj.parentNode.parentNode.parentNode.deleteRow(obj.parentNode.parentNode.sectionRowIndex);
	run_get('modificareprogramm', 'mode@cod1@cod2', 'stergere@'+uid+'@'+ident, 'infodreapta');
}

function livesearchproceduraprogramare(keyword,field) {
	var instanta=document.getElementById('livesearchprocedura');
	var e=field;
	if(instanta==null) {
	sdiv=document.createElement('div');
	scontent=document.createElement('div');
	scontent.setAttribute('id','livesearchproceduracontent');
	scontent.innerHTML='<br /><br />';
	var y=getOffsetTop(e);//e.offsetTop;
	var x=getOffsetLeft(e);//e.offsetLeft;
	x=x-8;
	y=y+0;
	var att="left: "+x+"px; top: "+y+"px;";
	sdiv.setAttribute('id','livesearchprocedura');
	sdiv.setAttribute('class','contactform');
	sdiv.setAttribute('className','contactform');
	sdiv.setAttribute('style','z-index: 999; width: 144px; height: 70px; padding: 0; position: absolute; overflow: auto; '+att);
	sdiv.style.opacity = 0;
	document.body.appendChild(sdiv);
	sdiv.appendChild(scontent);
	opacity('livesearchprocedura', 0, 100, 400); }
	run_get_noexec('livesearchproceduraprogramare', 'keyword@fieldname', keyword+'@'+e.name, 'livesearchproceduracontent');
}

function closelivesearchproceduraprogramare() {
	var instanta=document.getElementById('livesearchprocedura');
	if(instanta!=null) {
	opacity('livesearchprocedura', 100, 0, 400);
	setTimeout('document.body.removeChild(document.getElementById(\'livesearchprocedura\'));', 500);
	}
}

function livesearchproceduracabinet(keyword,field) {
	var instanta=document.getElementById('livesearchprocedura');
	var e=field;
	if(instanta==null) {
	sdiv=document.createElement('div');
	scontent=document.createElement('div');
	scontent.setAttribute('id','livesearchproceduracontent');
	scontent.innerHTML='<br /><br />';
	var y=getOffsetTop(e);//e.offsetTop;
	var x=getOffsetLeft(e);//e.offsetLeft;
	x=x-8;
	y=y+0;
	var att="left: "+x+"px; top: "+y+"px;";
	sdiv.setAttribute('id','livesearchprocedura');
	sdiv.setAttribute('class','contactform');
	sdiv.setAttribute('className','contactform');
	sdiv.setAttribute('style','z-index: 999; height: 70px; min-width:144px; padding: 0; position: absolute; overflow: auto; '+att);
	sdiv.style.opacity = 0;
	document.body.appendChild(sdiv);
	sdiv.appendChild(scontent);
	opacity('livesearchprocedura', 0, 100, 400); }
	run_get_noexec('livesearchproceduracabinet', 'keyword@fieldname', keyword+'@'+e.name, 'livesearchproceduracontent');
}

function closelivesearchproceduracabinet() {
	var instanta=document.getElementById('livesearchprocedura');
	if(instanta!=null) {
	opacity('livesearchprocedura', 100, 0, 400);
	setTimeout('document.body.removeChild(document.getElementById(\'livesearchprocedura\'));', 500);
	}
}

function livesearchproceduraalias(keyword,field,hname) {
	var instanta=document.getElementById('livesearchproceduraalias');
	var e=field;
	if(instanta==null) {
	sdiv=document.createElement('div');
	scontent=document.createElement('div');
	scontent.setAttribute('id','livesearchproceduraaliascontent');
	scontent.innerHTML='<br /><br />';
	var y=getOffsetTop(e);//e.offsetTop;
	var x=getOffsetLeft(e);//e.offsetLeft;
	x=x-8;
	y=y+0;
	var att="left: "+x+"px; top: "+y+"px;";
	sdiv.setAttribute('id','livesearchproceduraalias');
	sdiv.setAttribute('class','contactform');
	sdiv.setAttribute('className','contactform');
	sdiv.setAttribute('style','z-index: 999; width: 144px; height: 70px; padding: 0; position: absolute; overflow: auto; '+att);
	sdiv.style.opacity = 0;
	document.body.appendChild(sdiv);
	sdiv.appendChild(scontent);
	opacity('livesearchproceduraalias', 0, 100, 400); }
	run_get_noexec('livesearchproceduraalias', 'keyword@fieldname@hname', keyword+'@'+e.name+'@'+hname, 'livesearchproceduraaliascontent');
}

function closelivesearchproceduraalias() {
	var instanta=document.getElementById('livesearchproceduraalias');
	if(instanta!=null) {
	opacity('livesearchproceduraalias', 100, 0, 400);
	setTimeout('document.body.removeChild(document.getElementById(\'livesearchproceduraalias\'));', 500);
	}
}

function livesearchprocedurarecomandare(keyword,field) {
	var instanta=document.getElementById('livesearchprocedura');
	var e=field;
	if(instanta==null) {
	sdiv=document.createElement('div');
	scontent=document.createElement('div');
	scontent.setAttribute('id','livesearchproceduracontent');
	scontent.innerHTML='<br /><br />';
	var y=getOffsetTop(e);//e.offsetTop;
	var x=getOffsetLeft(e);//e.offsetLeft;
	x=x-8;
	y=y+0;
	var att="left: "+x+"px; top: "+y+"px;";
	sdiv.setAttribute('id','livesearchprocedura');
	sdiv.setAttribute('class','contactform');
	sdiv.setAttribute('className','contactform');
	sdiv.setAttribute('style','z-index: 999; min-width: 144px; height: 70px; padding: 0; position: absolute; overflow: auto; '+att);
	sdiv.style.opacity = 0;
	document.body.appendChild(sdiv);
	sdiv.appendChild(scontent);
	opacity('livesearchprocedura', 0, 100, 400); }
	run_get_noexec('livesearchprocedurarecomandare', 'keyword@fieldname', keyword+'@'+e.name, 'livesearchproceduracontent');
}

function closelivesearchprocedurarecomandare() {
	var instanta=document.getElementById('livesearchprocedura');
	if(instanta!=null) {
	opacity('livesearchprocedura', 100, 0, 400);
	setTimeout('document.body.removeChild(document.getElementById(\'livesearchprocedura\'));', 500);
	}
}

function livesearchprocedurafiu(keyword,field) {
	var instanta=document.getElementById('livesearchprocedura');
	var e=field;
	if(instanta==null) {
	sdiv=document.createElement('div');
	scontent=document.createElement('div');
	scontent.setAttribute('id','livesearchproceduracontent');
	scontent.innerHTML='<br /><br />';
	var y=getOffsetTop(e);//e.offsetTop;
	var x=getOffsetLeft(e);//e.offsetLeft;
	x=x-8;
	y=y+0;
	var att="left: "+x+"px; top: "+y+"px;";
	sdiv.setAttribute('id','livesearchprocedura');
	sdiv.setAttribute('class','contactform');
	sdiv.setAttribute('className','contactform');
	sdiv.setAttribute('style','z-index: 999; width: 144px; height: 70px; padding: 0; position: absolute; overflow: auto; '+att);
	sdiv.style.opacity = 0;
	document.body.appendChild(sdiv);
	sdiv.appendChild(scontent);
	opacity('livesearchprocedura', 0, 100, 400); }
	run_get_noexec('livesearchprocedurafiu', 'keyword@fieldname', keyword+'@'+e.name, 'livesearchproceduracontent');
}

function closelivesearchprocedurafiu() {
	var instanta=document.getElementById('livesearchprocedura');
	if(instanta!=null) {
	opacity('livesearchprocedura', 100, 0, 400);
	setTimeout('document.body.removeChild(document.getElementById(\'livesearchprocedura\'));', 500);
	}
}

function livesearchdiagnostice(keyword,field) {
	var instanta=document.getElementById('livesearchdiagnostic');
	var e=field;
	if(instanta==null) {
	sdiv=document.createElement('div');
	scontent=document.createElement('div');
	scontent.setAttribute('id','livesearchdiagnosticcontent');
	scontent.innerHTML='<br /><br />';
	var y=getOffsetTop(e);//e.offsetTop;
	var x=getOffsetLeft(e);//e.offsetLeft;
	x=x-8;
	y=y+0;
	var att="left: "+x+"px; top: "+y+"px;";
	sdiv.setAttribute('id','livesearchdiagnostic');
	sdiv.setAttribute('class','contactform');
	sdiv.setAttribute('className','contactform');
	sdiv.setAttribute('style','z-index: 999; height: 70px; padding: 0; position: absolute; overflow: auto; '+att);
	sdiv.style.opacity = 0;
	document.body.appendChild(sdiv);
	sdiv.appendChild(scontent);
	opacity('livesearchdiagnostic', 0, 100, 400); }
	run_get_noexec('livesearchdiagnostice', 'keyword@fieldname', keyword+'@'+e.name, 'livesearchdiagnosticcontent');
}

function closelivesearchdiagnostice() {
	var instanta=document.getElementById('livesearchdiagnostic');
	if(instanta!=null) {
	opacity('livesearchdiagnostic', 100, 0, 400);
	setTimeout('document.body.removeChild(document.getElementById(\'livesearchdiagnostic\'));', 500);
	}
}

function livesearchunitateprogramare(keyword,field) {
	var instanta=document.getElementById('livesearchunitate');
	var e=field;
	if(instanta==null) {
	sdiv=document.createElement('div');
	scontent=document.createElement('div');
	scontent.setAttribute('id','livesearchunitatecontent');
	scontent.innerHTML='<br /><br />';
	var y=getOffsetTop(e);//e.offsetTop;
	var x=getOffsetLeft(e);//e.offsetLeft;
	x=x-8;
	y=y+0;
	var att="left: "+x+"px; top: "+y+"px;";
	sdiv.setAttribute('id','livesearchunitate');
	sdiv.setAttribute('class','contactform');
	sdiv.setAttribute('className','contactform');
	sdiv.setAttribute('style','z-index: 999; width: 144px; height: 70px; padding: 0; position: absolute; overflow: auto; '+att);
	sdiv.style.opacity = 0;
	document.body.appendChild(sdiv);
	sdiv.appendChild(scontent);
	opacity('livesearchunitate', 0, 100, 400); }
	run_get_noexec('livesearchunitateprogramare', 'keyword@fieldname', keyword+'@'+e.name, 'livesearchunitatecontent');
}

function closelivesearchunitateprogramare() {
	var instanta=document.getElementById('livesearchunitate');
	if(instanta!=null) {
	opacity('livesearchunitate', 100, 0, 400);
	setTimeout('document.body.removeChild(document.getElementById(\'livesearchunitate\'));', 500);
	}
}

function livesearchmedicprogramare(keyword,field) {
	var instanta=document.getElementById('livesearchmedic');
	var e=field;
	if(instanta==null) {
	sdiv=document.createElement('div');
	scontent=document.createElement('div');
	scontent.setAttribute('id','livesearchmediccontent');
	scontent.innerHTML='<br /><br />';
	var y=getOffsetTop(e);//e.offsetTop;
	var x=getOffsetLeft(e);//e.offsetLeft;
	x=x-8;
	y=y+0;
	var att="left: "+x+"px; top: "+y+"px;";
	sdiv.setAttribute('id','livesearchmedic');
	sdiv.setAttribute('class','contactform');
	sdiv.setAttribute('className','contactform');
	sdiv.setAttribute('style','z-index: 999; width: 144px; height: 70px; padding: 0; position: absolute; overflow: auto; '+att);
	sdiv.style.opacity = 0;
	document.body.appendChild(sdiv);
	sdiv.appendChild(scontent);
	opacity('livesearchmedic', 0, 100, 400); }
	run_get_noexec('livesearchmedicprogramare', 'keyword@fieldname', keyword+'@'+e.name, 'livesearchmediccontent');
}

function closelivesearchmedicprogramare() {
	var instanta=document.getElementById('livesearchmedic');
	if(instanta!=null) {
	opacity('livesearchmedic', 100, 0, 400);
	setTimeout('document.body.removeChild(document.getElementById(\'livesearchmedic\'));', 500);
	}
}

function livesearchmediccabinet(keyword,field) {
	var instanta=document.getElementById('livesearchmediccabinet');
	var e=field;
	if(instanta==null) {
	sdiv=document.createElement('div');
	scontent=document.createElement('div');
	scontent.setAttribute('id','livesearchmediccabinetcontent');
	scontent.innerHTML='<br /><br />';
	var y=getOffsetTop(e);//e.offsetTop;
	var x=getOffsetLeft(e);//e.offsetLeft;
	x=x-8;
	y=y+0;
	var att="left: "+x+"px; top: "+y+"px;";
	sdiv.setAttribute('id','livesearchmediccabinet');
	sdiv.setAttribute('class','contactform');
	sdiv.setAttribute('className','contactform');
	sdiv.setAttribute('style','z-index: 999; width: 144px; height: 70px; padding: 0; position: absolute; overflow: auto; '+att);
	sdiv.style.opacity = 0;
	document.body.appendChild(sdiv);
	sdiv.appendChild(scontent);
	opacity('livesearchmediccabinet', 0, 100, 400); }
	run_get_noexec('livesearchmediccabinet', 'keyword@fieldname', keyword+'@'+e.name, 'livesearchmediccabinetcontent');
}

function closelivesearchmediccabinet() {
	var instanta=document.getElementById('livesearchmediccabinet');
	if(instanta!=null) {
	opacity('livesearchmediccabinet', 100, 0, 400);
	setTimeout('document.body.removeChild(document.getElementById(\'livesearchmediccabinet\'));', 500);
	}
}

function livesearchmedicrezcabinet(keyword,field) {
	var instanta=document.getElementById('livesearchmedicrezcabinet');
	var e=field;
	if(instanta==null) {
	sdiv=document.createElement('div');
	scontent=document.createElement('div');
	scontent.setAttribute('id','livesearchmedicrezcabinetcontent');
	scontent.innerHTML='<br /><br />';
	var y=getOffsetTop(e);//e.offsetTop;
	var x=getOffsetLeft(e);//e.offsetLeft;
	x=x-8;
	y=y+0;
	var att="left: "+x+"px; top: "+y+"px;";
	sdiv.setAttribute('id','livesearchmedicrezcabinet');
	sdiv.setAttribute('class','contactform');
	sdiv.setAttribute('className','contactform');
	sdiv.setAttribute('style','z-index: 999; width: 144px; height: 70px; padding: 0; position: absolute; overflow: auto; '+att);
	sdiv.style.opacity = 0;
	document.body.appendChild(sdiv);
	sdiv.appendChild(scontent);
	opacity('livesearchmedicrezcabinet', 0, 100, 400); }
	run_get_noexec('livesearchmedicrezcabinet', 'keyword@fieldname', keyword+'@'+e.name, 'livesearchmedicrezcabinetcontent');
}

function closelivesearchmedicrezcabinet() {
	var instanta=document.getElementById('livesearchmedicrezcabinet');
	if(instanta!=null) {
	opacity('livesearchmedicrezcabinet', 100, 0, 400);
	setTimeout('document.body.removeChild(document.getElementById(\'livesearchmedicrezcabinet\'));', 500);
	}
}

function change_medic_cabient(pid) {
	newmed=document.getElementsByName('idmednou')[0].value;
	if(newmed!=null && !IsEmpty(newmed) && newmed!=0)
	{
	run_get('modificare_medic_cabinet','mid@pid',newmed+'@'+pid,'infodreapta');
	}
	else
	{
	document.getElementById('infodreapta').innerHTML=warn('Nu ai ales niciun medic pentru schimbare');
	document.getElementById('medales').innerHTML='<input type="text" size="1" style="width:2px;" readonly="readonly" class="hidden" />Medic: <font color=\"red\"><b>Nu a fost ales</b></font> ';
	}
}

function change_medicrez_cabient(pid) {
	newmed=document.getElementsByName('idmedreznou')[0].value;
	if(newmed!=null && !IsEmpty(newmed) && newmed!=0)
	{
	run_get('modificare_medicrez_cabinet','mrid@pid',newmed+'@'+pid,'infodreapta');
	}
	else
	{
	document.getElementById('infodreapta').innerHTML=warn('Nu ai ales niciun medic rezident pentru schimbare');
	document.getElementById('medrezales').innerHTML='<input type="text" size="1" style="width:2px;" readonly="readonly" class="hidden" />Medic rezident: <font color=\"red\"><b>Nu a fost ales</b></font> ';
	}
}

function generare_calendar_programari(obj) {
		var iduriproceduri=document.getElementById('filtre').getElementsByTagName("input");
		var procstring='';
		var umedstring='';
		var medstring='';		
		for(i=0;i<iduriproceduri.length;i++)
			{
				if((iduriproceduri[i].type=="hidden") && (iduriproceduri[i].name=="procedura"))
					{
						procstring+=iduriproceduri[i].value+',';
					}
				if((iduriproceduri[i].type=="hidden") && (iduriproceduri[i].name=="unitate"))
					{
						umedstring+=iduriproceduri[i].value+',';
					}
				if((iduriproceduri[i].type=="hidden") && (iduriproceduri[i].name=="medic"))
					{
						medstring+=iduriproceduri[i].value+',';
					}
			}
		run_get_noexec('modificare_programare', 'mode@procstring@umedstring@medstring@data', 'gencalendarprocedura@'+procstring+'@'+umedstring+'@'+medstring+'@'+obj, 'calendar');
}

function generare_formular(val) {
	run_get_noexec('modificare_programare','mode@criteriu','genform@'+val,'formular_programare');
}

function form_obiect(val,id_proc,id_cond) {
	//run_get_noexec('add_proceduri','mode@obiect','form_obiect@'+val,'step2');
	
	document.getElementById('parent').options.length = 0;
	document.getElementById('parent_fiu').options.length = 0;
	document.getElementById('parent_cond').options.length = 0;
	document.getElementById('parent_proc_cond').options.length = 0;
	document.getElementById('parent_cond_dom').options.length = 0;
	//addOption('parent', '', 'NULL');
	
	if(val=='NULL') { document.getElementById('step2-proc').style.display='block';
					  document.getElementById('step2-procfiu').style.display='none';
					  document.getElementById('step2-cond').style.display='none';
					  document.getElementById('step2-dom').style.display='none';
					  addOption('parent', '', 'NULL');
					}
					
	if(val=='proc') { document.getElementById('step2-proc').style.display='block';
					  document.getElementById('step2-procfiu').style.display='none';
					  document.getElementById('step2-cond').style.display='none';
					  document.getElementById('step2-dom').style.display='none';
					  var lastinput=document.getElementsByTagName('li');
					  for(i=0;i<lastinput.length;i++) {
					  if(lastinput[i].class=='proc' || lastinput[i].className=='proc')
						if(lastinput[i].id.split('-')[0]=='node'+id_proc)
						{
						var nume=lastinput[i].id.split('-')[1];
						}	
					  }
					  addOption('parent', nume, id_proc);
					  //addOptionsProc('parent','');
					}
					
	if(val=='procfiu')	{ document.getElementById('step2-proc').style.display='none'
						  document.getElementById('step2-procfiu').style.display='block';
					      document.getElementById('step2-cond').style.display='none';
					      document.getElementById('step2-dom').style.display='none';
						  var lastinput=document.getElementsByTagName('li');
					  for(i=0;i<lastinput.length;i++) {
					  if(lastinput[i].class=='proc' || lastinput[i].className=='proc')
						if(lastinput[i].id.split('-')[0]=='node'+id_proc)
						{
						var nume=lastinput[i].id.split('-')[1];
						}	
					  }
					  addOption('parent_fiu', nume, id_proc);
						}
					
	if(val=='cond') { document.getElementById('step2-proc').style.display='none'
					  document.getElementById('step2-procfiu').style.display='none';
					  document.getElementById('step2-cond').style.display='block';
					  document.getElementById('step2-dom').style.display='none';
					  //addOptionsProc('parent_proc_cond','parent_cond');
					  var lastinput=document.getElementsByTagName('li');
					  for(i=0;i<lastinput.length;i++) {
					  if(lastinput[i].id.split('-')[0]=='node'+id_cond)
						{
						if(lastinput[i].class=='cond' || lastinput[i].className=='cond')
							{ 
							  addOption('parent_cond', lastinput[i].id.split('-')[1], id_cond);
							  document.getElementById('ppc').style.display='none';
							  document.getElementById('pc').style.display='block';
							  addOption('parent_proc_cond', '', 'NULL');
							  break;
							}
						if(lastinput[i].class=='proc' || lastinput[i].className=='proc')
							{ 
							  addOption('parent_proc_cond', lastinput[i].id.split('-')[1], id_cond); 
							  document.getElementById('pc').style.display='none';
							  document.getElementById('ppc').style.display='block';
							  addOption('parent_cond', '', 'NULL');
							  break;
							}
						}	
					  }	
					  
					}
					
	if(val=='dom') {  document.getElementById('step2-proc').style.display='none'
					  document.getElementById('step2-procfiu').style.display='none';
					  document.getElementById('step2-cond').style.display='none';
					  document.getElementById('step2-dom').style.display='block';
					  //addOptionsProc('','parent_cond_dom');
					  var lastinput=document.getElementsByTagName('li');
					  for(i=0;i<lastinput.length;i++) {
					  if(lastinput[i].id.split('-')[0]=='node'+id_cond)
						{
						var nume=lastinput[i].id.split('-')[1];
						}	
					  }	
					  addOption('parent_cond_dom', nume, id_cond);
					}
					

/*	
	var lastinput=document.getElementsByTagName('li');
	for(i=0;i<lastinput.length;i++) {
	if(lastinput[i].class=='proc' || lastinput[i].className=='proc')
		{
			//var newOpt = new Option(lastinput[i].id.split('-')[1], lastinput[i].id.split('-')[0]);
			//var selLength = document.getElementById('parent').length;
			//document.getElementById('parent').options[selLength] = newOpt;
			addOption('parent', lastinput[i].id.split('-')[1], lastinput[i].id.split('-')[0]);
		}
	if(lastinput[i].class=='cond' || lastinput[i].className=='cond')
		{
			var newOpt = new Option(lastinput[i].id.split('-')[1], lastinput[i].id.split('-')[0]);
			var selLength = document.getElementById('parent_cond').length;
			document.getElementById('parent_cond').options[selLength] = newOpt;
		}
	}
*/
}

function form_obiect2(val,id_proc,id_cond) { //PENTRU EDITARE PROCEDURI
	//run_get_noexec('add_proceduri','mode@obiect','form_obiect@'+val,'step2');
	
	document.getElementById('parent').options.length = 0;
	document.getElementById('parent_cond').options.length = 0;
	document.getElementById('parent_proc_cond').options.length = 0;
	document.getElementById('parent_cond_dom').options.length = 0;
	//addOption('parent', '', 'NULL');
	
	if(val=='NULL') { document.getElementById('step2-proc').style.display='block';
					  document.getElementById('step2-cond').style.display='none';
					  document.getElementById('step2-dom').style.display='none';
					  addOption('parent', '', 'NULL');
					}
					
	if(val=='proc') { document.getElementById('step2-proc').style.display='block';
					  document.getElementById('step2-cond').style.display='none';
					  document.getElementById('step2-dom').style.display='none';
					  var lastinput=document.getElementsByTagName('li');
					  for(i=0;i<lastinput.length;i++) {
					  if(lastinput[i].class=='proc' || lastinput[i].className=='proc')
						if(lastinput[i].id.split('-')[0]=='node'+id_proc)
						{
						var nume=lastinput[i].id.split('-')[1];
						}	
					  }
					  addOption('parent', nume, id_proc);
					  //addOptionsProc('parent','');
					}
					
	if(val=='cond') { document.getElementById('step2-proc').style.display='none'
					  document.getElementById('step2-cond').style.display='block';
					  document.getElementById('step2-dom').style.display='none';
					  //addOptionsProc('parent_proc_cond','parent_cond');
					  var lastinput=document.getElementsByTagName('li');
					  for(i=0;i<lastinput.length;i++) {
					  if(lastinput[i].id.split('-')[0]=='node'+id_cond)
						{
						if(lastinput[i].class=='cond' || lastinput[i].className=='cond')
							{ 
							  addOption('parent_cond', lastinput[i].id.split('-')[1], id_cond);
							  document.getElementById('ppc').style.display='none';
							  document.getElementById('pc').style.display='block';
							  addOption('parent_proc_cond', '', 'NULL');
							  break;
							}
						if(lastinput[i].class=='proc' || lastinput[i].className=='proc')
							{ 
							  addOption('parent_proc_cond', lastinput[i].id.split('-')[1], id_cond); 
							  document.getElementById('pc').style.display='none';
							  document.getElementById('ppc').style.display='block';
							  addOption('parent_cond', '', 'NULL');
							  break;
							}
						}	
					  }	
					  
					}
					
	if(val=='dom') { document.getElementById('step2-proc').style.display='none'
					  document.getElementById('step2-cond').style.display='none';
					  document.getElementById('step2-dom').style.display='block';
					  //addOptionsProc('','parent_cond_dom');
					  var lastinput=document.getElementsByTagName('li');
					  for(i=0;i<lastinput.length;i++) {
					  if(lastinput[i].id.split('-')[0]=='node'+id_cond)
						{
						var nume=lastinput[i].id.split('-')[1];
						}	
					  }	
					  addOption('parent_cond_dom', nume, id_cond);
					}
					

/*	
	var lastinput=document.getElementsByTagName('li');
	for(i=0;i<lastinput.length;i++) {
	if(lastinput[i].class=='proc' || lastinput[i].className=='proc')
		{
			//var newOpt = new Option(lastinput[i].id.split('-')[1], lastinput[i].id.split('-')[0]);
			//var selLength = document.getElementById('parent').length;
			//document.getElementById('parent').options[selLength] = newOpt;
			addOption('parent', lastinput[i].id.split('-')[1], lastinput[i].id.split('-')[0]);
		}
	if(lastinput[i].class=='cond' || lastinput[i].className=='cond')
		{
			var newOpt = new Option(lastinput[i].id.split('-')[1], lastinput[i].id.split('-')[0]);
			var selLength = document.getElementById('parent_cond').length;
			document.getElementById('parent_cond').options[selLength] = newOpt;
		}
	}
*/
}

function addOptionsProc(selProc,selCond) {
	var lastinput=document.getElementsByTagName('li');
	for(i=0;i<lastinput.length;i++) {
	if(selProc!='') if(lastinput[i].class=='proc' || lastinput[i].className=='proc')
		{
			addOption(selProc, lastinput[i].id.split('-')[1], lastinput[i].id.split('-')[0]);
		}
	if(selCond!='') if(lastinput[i].class=='cond' || lastinput[i].className=='cond')
		{
			addOption(selCond, lastinput[i].id.split('-')[1], lastinput[i].id.split('-')[0]);
		}
	}
}

function add_proc(pid) {
	var denumire=document.getElementsByName('denumire')[0].value;
	//alert(parseInt(pid));
	var um=document.getElementsByName('um')[0].value;
	var cost=document.getElementsByName('cost')[0].value;
	var parinte=document.getElementById('parent').options[document.getElementById('parent').selectedIndex].value;
	var cod=document.getElementsByName('cod')[0].value;
	if(check_proc()==1) run_get('add_proceduri','mode@denumire@um@cost@parinte@cod@pid','add_proc@'+denumire+'@'+um+'@'+cost+'@'+parinte+'@'+cod+'@'+parseInt(pid),'infodreapta');
	else document.getElementById('infodreapta').innerHTML=error("Numele procedurii nu este completat!");
	//run_get('add_proceduri','mode','get_id_proc','infodreapta');
	//window.location="index.php?page=6_adaugare_proceduri&id="+id_proc;
}

function add_proc_fiu(pid) {
	var fiu=document.getElementsByName('idproc_fiu')[0].value;
	var parinte=document.getElementById('parent_fiu').options[document.getElementById('parent_fiu').selectedIndex].value;
	//alert(denumire+' '+parinte);
	run_get('add_proceduri','mode@fiu@parinte@pid','add_proc_fiu@'+fiu+'@'+parinte+'@'+parseInt(pid),'infodreapta');
}

function add_cond(pid) {
	var nume=document.getElementsByName('nume')[0].value;
	var proc_parinte=document.getElementById('parent_proc_cond').options[document.getElementById('parent_proc_cond').selectedIndex].value;
	var cond_parinte=document.getElementById('parent_cond').options[document.getElementById('parent_cond').selectedIndex].value;
	if(check_cond()==1) run_get('add_proceduri','mode@nume@proc@cond@pid','add_cond@'+nume+'@'+proc_parinte+'@'+cond_parinte+'@'+parseInt(pid),'infodreapta');
	if(check_cond()==-1) document.getElementById('infodreapta').innerHTML=error("Numele condiţiei nu este completat!");
	if(check_cond()==0) document.getElementById('infodreapta').innerHTML=error("Condiţia poate depinde ori de o procedură, ori de o altă condiţie!");
	//run_get('add_proceduri','mode','get_id_proc','infodreapta');
	//window.location="index.php?page=6_adaugare_proceduri&id="+id_proc;
}

function add_dom_valori(pid) {
	if (document.getElementById('parent_cond_dom').options.length == 0)
	{
		document.getElementById('infodreapta').innerHTML=error("Nu este definită nicio condiţie căreia să-i putem atribui domeniul de valori!");
		return;
	}
	var val=document.getElementsByName('val')[0].value;
	var operator=document.getElementById('operator').options[document.getElementById('operator').selectedIndex].value;
	var cond_parinte=document.getElementById('parent_cond_dom').options[document.getElementById('parent_cond_dom').selectedIndex].value;
	if(check_dom()==1) run_get('add_proceduri','mode@val@operator@cond@pid','add_dom_valori@'+val+'@'+operator+'@'+cond_parinte+'@'+parseInt(pid),'infodreapta');
	else document.getElementById('infodreapta').innerHTML=error("Nu s-a completat campul \"valoare\"!");
	//run_get('add_proceduri','mode','get_id_proc','infodreapta');
	//window.location="index.php?page=6_adaugare_proceduri&id="+id_proc;
}

//add elemente la editare
function add_proc2(pid) {
	var denumire=document.getElementsByName('denumire')[0].value;
	//alert(parseInt(pid));
	var um=document.getElementsByName('um')[0].value;
	var cost=document.getElementsByName('cost')[0].value;
	var parinte=document.getElementById('parent').options[document.getElementById('parent').selectedIndex].value;
	var cod=document.getElementsByName('cod')[0].value;
	if(check_proc()==1) run_get('edit_proceduri','mode@denumire@um@cost@parinte@cod@pid','add_proc@'+denumire+'@'+um+'@'+cost+'@'+parinte+'@'+cod+'@'+parseInt(pid),'infodreapta');
	else document.getElementById('infodreapta').innerHTML=error("Numele procedurii nu este completat!");
	//run_get('add_proceduri','mode','get_id_proc','infodreapta');
	//window.location="index.php?page=6_adaugare_proceduri&id="+id_proc;
}

function add_cond2(pid) {
	var nume=document.getElementsByName('nume')[0].value;
	var proc_parinte=document.getElementById('parent_proc_cond').options[document.getElementById('parent_proc_cond').selectedIndex].value;
	var cond_parinte=document.getElementById('parent_cond').options[document.getElementById('parent_cond').selectedIndex].value;
	if(check_cond()==1) run_get('edit_proceduri','mode@nume@proc@cond@pid','add_cond@'+nume+'@'+proc_parinte+'@'+cond_parinte+'@'+parseInt(pid),'infodreapta');
	if(check_cond()==-1) document.getElementById('infodreapta').innerHTML=error("Numele condiţiei nu este completat!");
	if(check_cond()==0) document.getElementById('infodreapta').innerHTML=error("Condiţia poate depinde ori de o procedură, ori de o altă condiţie!");
	//run_get('add_proceduri','mode','get_id_proc','infodreapta');
	//window.location="index.php?page=6_adaugare_proceduri&id="+id_proc;
}

function add_dom_valori2(pid) {
	if (document.getElementById('parent_cond_dom').options.length == 0)
	{
		document.getElementById('infodreapta').innerHTML=error("Nu este definită nicio condiţie căreia să-i putem atribui domeniul de valori!");
		return;
	}
	var val=document.getElementsByName('val')[0].value;
	var operator=document.getElementById('operator').options[document.getElementById('operator').selectedIndex].value;
	var cond_parinte=document.getElementById('parent_cond_dom').options[document.getElementById('parent_cond_dom').selectedIndex].value;
	if(check_dom()==1) run_get('edit_proceduri','mode@val@operator@cond@pid','add_dom_valori@'+val+'@'+operator+'@'+cond_parinte+'@'+parseInt(pid),'infodreapta');
	else document.getElementById('infodreapta').innerHTML=error("Nu s-a completat campul \"valoare\"!");
	//run_get('add_proceduri','mode','get_id_proc','infodreapta');
	//window.location="index.php?page=6_adaugare_proceduri&id="+id_proc;
}

function check_proc() {
	var nume=document.getElementsByName('denumire')[0].value;
	if(nume=='') return 0;
	else return 1;
}

function check_cond() {
	var proc=document.getElementById('parent_proc_cond').options[document.getElementById('parent_proc_cond').selectedIndex].value;
	var cond=document.getElementById('parent_cond').options[document.getElementById('parent_cond').selectedIndex].value;
	var nume=document.getElementsByName('nume')[0].value;
	if(proc=="NULL" && cond=="NULL") return 0;
	if(nume=='') return -1;
	if((proc=="NULL" && cond!="NULL") || (proc!="NULL" && cond=="NULL")) return 1;
}

function check_dom() {
	var val=document.getElementsByName('val')[0].value;
	if(val=='') return 0;
	else return 1;
}

function getore(uid,zi) {
	run_get_noexec('modificare_programare','mode@uid@zi','gentimeline@'+uid+'@'+zi,'ore');
}

function show_ora(id,field) {
	var instanta=document.getElementById('popora');
	var e=field;
	if(instanta==null) {
	sdiv=document.createElement('div');
	scontent=document.createElement('div');
	scontent.setAttribute('id','poporacontent');
	scontent.innerHTML=Math.floor(id/60)+':'+id%60;
	var y=getOffsetTop(e);//e.offsetTop;
	var x=getOffsetLeft(e);//e.offsetLeft;
	x=x-8;
	y=y+10;
	var att="left: "+x+"px; top: "+y+"px;";
	sdiv.setAttribute('id','popora');
	sdiv.setAttribute('class','contactform');
	sdiv.setAttribute('className','contactform');
	sdiv.setAttribute('style','z-index: 999; width: 40px; height: 10px; padding: 0; position: absolute; overflow: auto; '+att);
	sdiv.style.opacity = 0;
	document.body.appendChild(sdiv);
	sdiv.appendChild(scontent);
	opacity('popora', 0, 100, 400); }
}

function closeshow_ora() {
	var instanta=document.getElementById('popora');
	if(instanta!=null) {
	opacity('popora', 100, 0, 400);
	setTimeout('document.body.removeChild(document.getElementById(\'popora\'));', 500);
	}
}

function finalizare_programare(ent,zi,ora) {
	document.getElementById('final').innerHTML='<p id="um"></p><p id="ent"></p><p>Procedură: '+document.getElementsByName('proceduri')[0].value+'</p><p><label>Zi: </label>'+zi+'</p><p><label>Oră: </label>'+Math.floor(ora/60)+':'+ora%60+'</p>';
	run_get('modificare_programare','mode@eid','getinfo@'+ent,'infodreapta');
}

function livesearchatestat(keyword,field) {
	document.getElementById('hid').value='';
	var instanta=document.getElementById('livesearchatestat');
	var e=field;
	if(instanta==null) {
	sdiv=document.createElement('div');
	scontent=document.createElement('div');
	scontent.setAttribute('id','livesearchatestatcontent');
	scontent.innerHTML='<br /><br />';
	var y=getOffsetTop(e);//e.offsetTop;
	var x=getOffsetLeft(e);//e.offsetLeft;
	x=x-8;
	y=y+0;
	var att="left: "+x+"px; top: "+y+"px;";
	sdiv.setAttribute('id','livesearchatestat');
	sdiv.setAttribute('class','contactform');
	sdiv.setAttribute('className','contactform');
	sdiv.setAttribute('style','z-index: 999; width: 144px; height: 70px; padding: 0; position: absolute; overflow: auto; '+att);
	sdiv.style.opacity = 0;
	document.body.appendChild(sdiv);
	sdiv.appendChild(scontent);
	opacity('livesearchatestat', 0, 100, 400); }
	run_get_noexec('livesearchatestat', 'keyword@fieldname', keyword+'@'+e.name, 'livesearchatestatcontent');
}

function closelivesearchatestat() {
	var instanta=document.getElementById('livesearchatestat');
	if(instanta!=null) {
	opacity('livesearchatestat', 100, 0, 400);
	setTimeout('document.body.removeChild(document.getElementById(\'livesearchatestat\'));', 500);
	}
}

	function livesearchepicriza(keyword,field) {
		document.getElementById('hid').value='';
		var instanta=document.getElementById('livesearchepicriza');
		var e=field;
		if(instanta==null) {
		sdiv=document.createElement('div');
		scontent=document.createElement('div');
		scontent.setAttribute('id','livesearchepicrizacontent');
		scontent.innerHTML='<br /><br />';
		var y=getOffsetTop(e);//e.offsetTop;
		var x=getOffsetLeft(e);//e.offsetLeft;
		x=x-8;
		y=y+77;
		var att="left: "+x+"px; top: "+y+"px;";
		sdiv.setAttribute('id','livesearchepicriza');
		sdiv.setAttribute('class','contactform');
		sdiv.setAttribute('className','contactform');
		sdiv.setAttribute('style','z-index: 999; width: 600px; height: 70px; padding: 0; position: absolute; overflow: auto; '+att);
		sdiv.style.opacity = 0;
		document.body.appendChild(sdiv);
		sdiv.appendChild(scontent);
		opacity('livesearchepicriza', 0, 100, 400); }
		run_get_noexec('livesearchepicriza', 'keyword@fieldname', keyword+'@'+e.name, 'livesearchepicrizacontent');
	}

	function closelivesearchepicriza() {
		var instanta=document.getElementById('livesearchepicriza');
		if(instanta!=null) {
		opacity('livesearchepicriza', 100, 0, 400);
		setTimeout('document.body.removeChild(document.getElementById(\'livesearchepicriza\'));', 500);
		}
	}

function adauga_atestat() {
	var boole=0;
	var x=document.getElementsByName('atestat')[0].value;
	if (x!='') {
	if (document.getElementById('atestate').length>0) {
	for(i=0;i<document.getElementById('atestate').length;i++)
	{
	if(document.getElementById('atestate').options[i].innerHTML==x) boole=1;
	}
	}
	if (boole==0) {
	var ida=document.getElementById('hid').value;
	if (ida!='') { addOption('atestate', document.getElementsByName('atestat')[0].value, ida); document.getElementsByName('atestat')[0].value=''; }
	else { run_get('modificare_atestat','mode@nume','adaugare@'+document.getElementsByName('atestat')[0].value,'infodreapta'); }
	}
	else
	{
	document.getElementById('infodreapta').innerHTML=warn('Acest atestat este deja atribuit');
	}
	}
	else
	{
	document.getElementById('infodreapta').innerHTML=warn('Nu aţi introdus niciun atestat');
	}
	
}

function adauga_filtru(tip, id, nume) {
	if(IsEmpty(id))
	{
	document.getElementById('infodreapta').innerHTML=warn("Nu aţi ales niciun filtru din baza de date");
	}
	else
	{
	switch(tip) {
	case "procedura":
	document.getElementsByName('idfproc')[0].value='';
	document.getElementsByName('proceduri')[0].value='';
	fnou=document.createElement('li');
	fnou.setAttribute('name','filtru');
	fnou.setAttribute('class','filter');
	fnou.style.height="20px"; fnou.style.display="inline";
	fnou.innerHTML='<input type="hidden" name="'+tip+'" value="'+id+'" /><a href="javascript:void(0);" onClick="scoate_filtru(this.parentNode);"><font color="orange">'+nume+'</font> <font color="red">x</font></a>';
	document.getElementById('filtre').appendChild(fnou);
	generare_calendar_programari("");
	document.getElementById('infodreapta').innerHTML=succes("Filtrul a fost adaugat cu succes");
	break;
	
	case "unitate":
	document.getElementsByName('idfumed')[0].value='';
	document.getElementsByName('unitate')[0].value='';
	fnou=document.createElement('li');
	fnou.setAttribute('name','filtru');
	fnou.setAttribute('class','filter');
	fnou.style.height="20px"; fnou.style.display="inline";
	fnou.innerHTML='<input type="hidden" name="'+tip+'" value="'+id+'" /><a href="javascript:void(0);" onClick="scoate_filtru(this.parentNode);"><font color="blue">'+nume+'</font> <font color="red">x</font></a>';
	document.getElementById('filtre').appendChild(fnou);
	generare_calendar_programari("");
	document.getElementById('infodreapta').innerHTML=succes("Filtrul a fost adaugat cu succes");
	break;
	
	case "medic":
	var vladimirbalan=0;
	var cescfabregas=document.getElementById('filtre').getElementsByTagName('input');
	for(i=0;i<cescfabregas.length;i++) {
		if(cescfabregas[i].name=='medic')
			{
			vladimirbalan=1;
			}
	}
	if(vladimirbalan==0)
	{
	document.getElementsByName('idfmed')[0].value='';
	document.getElementsByName('medic')[0].value='';
	fnou=document.createElement('li');
	fnou.setAttribute('name','filtru');
	fnou.setAttribute('class','filter');
	fnou.style.height="20px"; fnou.style.display="inline";
	fnou.innerHTML='<input type="hidden" name="'+tip+'" value="'+id+'" /><a href="javascript:void(0);" onClick="scoate_filtru(this.parentNode);"><font color="green">'+nume+'</font> <font color="red">x</font></a>';
	document.getElementById('filtre').appendChild(fnou);
	generare_calendar_programari("");
	document.getElementById('infodreapta').innerHTML=succes("Filtrul a fost adaugat cu succes");
	}
	else
	{
	document.getElementById('infodreapta').innerHTML=warn("Un filtru de tip medic este deja adăugat. Nu se poate adăuga mai mult de un filtru de tip medic");
	}
	break;	
	}
	document.getElementById('filtre').parentNode.style.display="block"; document.getElementById('calendar').parentNode.style.display="block";
	}
}

function scoate_filtru(obj) {
	obj.parentNode.removeChild(obj);
	generare_calendar_programari("");
	if(document.getElementById('filtre').getElementsByTagName('input').length==0) { document.getElementById('filtre').parentNode.style.display="none"; document.getElementById('calendar').parentNode.style.display="none"; }
}

function gen_calendar(obj) {
	document.getElementsByName('proceduri')[0].value='';
    //run_get_noexec('updater','mode@data','data@'+obj+'','calendar');
	generare_calendar_programari(obj);
}

function preprogramare(idutilizator) {
	run_get('updater','mode','updatecacheprogramari','infodreapta');
	var comenzi=new Array(); 			
	var a=0;
	var elemente=document.getElementById('calendar').getElementsByTagName('div');
	var content=document.createElement('div');
	for(i=0;i<elemente.length;i++) {
		if(elemente[i].style.backgroundColor=='lightgreen')
			{
			var q=elemente[i].getElementsByTagName('input');
			if(q[0].type=='hidden')
			{
			var nou=document.createElement('input');
			nou.setAttribute('type','hidden');
			nou.setAttribute('value',q[0].value);
			content.appendChild(nou);
			var pum=document.createElement('p');
			pum.setAttribute('id',i);
			content.appendChild(pum);
			//comenzi[a]="setTimeout(\"run_get('modificare_programare','mode@uid@zi@ora@data@idproc@med@id@idutilizator','getinfo@"+q[0].value+"@"+i+"@"+idutilizator+"','infodreapta')\","+589*(a+1)+");";
			comenzi[a]="run_get('modificare_programare','mode@uid@zi@ora@data@idproc@med@id@idutilizator','getinfo@"+q[0].value+"@"+i+"@"+idutilizator+"','infodreapta');";
			a++;
			}
			}
	}
	document.getElementById('final').innerHTML=content.innerHTML;
	for(j=0;j<a;j++) { 
	eval(comenzi[j]);
	}
	if(a==0)
	{
	document.getElementById('infodreapta').innerHTML=warn("Nu ai realizat nicio selecţie cu privire la data/ora/locaţia progrămarii");
	}
	else
	{
	document.getElementById('final').innerHTML+="<br /><input type=\"button\" class=\"button5\" onClick=\"finalizareprogramare();\" value=\"Programează\" />";
	document.getElementById('final').parentNode.style.display="block";
	}
}

function finalizareprogramare() {
	run_get('modificare_programare','mode','finalizare','infodreapta');
	document.getElementById('final').innerHTML='';
}

function progrshowinfo(obj,strr) {
	var instanta=document.getElementById('calendarpopup');
	if(instanta==null) {
	sdiv=document.createElement('div');
	sheader=document.createElement('h4');
	sheader.innerHTML='Detalii:<br />';
	sheader.setAttribute('style','border:solid 1px rgb(220,220,220); color:rgb(80,80,80); background-color:rgb(220,220,220);');
	scontent=document.createElement('div');
	scontent.setAttribute('id','calendarpopupcontent');
	scontent.setAttribute('style','margin: 5px 5px 5px 5px;');
	scontent.innerHTML='<br /><br />';
	var y=tempY;
	var x=tempX;
	x=x+5;
	y=y-15
	var att="left: "+x+"px; top: "+y+"px;";
	sdiv.setAttribute('id','calendarpopup');
	sdiv.setAttribute('class','contactform');
	sdiv.setAttribute('className','contactform');
	sdiv.setAttribute('style','z-index: 999; width: 250px; padding: 0; position: absolute; '+att);
	sdiv.style.opacity = 0;
	document.body.appendChild(sdiv);
	sdiv.appendChild(sheader); sdiv.appendChild(scontent);
	//opacity('calendarpopup', 0, 100, 300); }
	}
	sheader.innerHTML='Detalii:<br />';
	run_get_noexec('modificare_programare', 'culo@mode@uid@zi@ora@data@idproc@med', obj.style.backgroundColor+'@infos@'+strr, 'calendarpopupcontent');
	sdiv.style.opacity = 100;
}

function closecalendarpopup() {
	var instanta=document.getElementById('calendarpopup');
	if(instanta!=null) {
	//opacity('calendarpopup', 100, 0, 300);
	//setTimeout('document.body.removeChild(document.getElementById(\'calendarpopup\'));', 400);
	document.body.removeChild(document.getElementById('calendarpopup'));
	}
}

function achitare(id,rand) {
	run_get('modificare_programare','mode@id','achitare@'+id,'infodreapta');
	run_get_noexec('updater', 'mode', 'lista_facturi_platite', 'lista_platite');
	if(rand!='NULL') rand.parentNode.parentNode.parentNode.removeChild(rand.parentNode.parentNode);
}

function achitare2(id) {
	run_get('modificare_programare','mode@id','achitare@'+id,'infodreapta');
	run_get_noexec('updater', 'mode', 'lista_facturi_platite', 'lista_platite');
}

function validare_programare(id,rand) {
	run_get('modificare_programare','mode@id','validare@'+id,'infodreapta');
	if(rand!='NU')
	{
	rand.parentNode.parentNode.parentNode.removeChild(rand.parentNode.parentNode);
	}
}

function validare_programare2(id,rand,codparafa,codparafa2,diagtrimitere) {
	var radioGrp = document.getElementsByName('tipsolicitare');
	for(i=0; i < radioGrp.length; i++)
		{
		if (radioGrp[i].checked == true) 
			{
			var tipsolicitare = radioGrp[i].value;
			}
		}
	var medic=document.getElementById('medic1').value;
	var medic2=document.getElementById('medic2').value;
	run_get('modificare_programare','mode@id@tipsolicitare@codparafa@codparafa2@medic@medic2@diagtrimitere','validare2@'+id+'@'+tipsolicitare+'@'+codparafa+'@'+codparafa2+'@'+medic+'@'+medic2+'@'+diagtrimitere,'infodreapta');
	rand.parentNode.parentNode.parentNode.parentNode.removeChild(rand.parentNode.parentNode.parentNode);
	document.getElementById('ftrimitere').style.display='none';
	document.getElementById('cod1').value='';
	document.getElementById('cod2').value='';
	document.getElementById('medic1').value='';
	document.getElementById('medic2').value='';
	document.getElementById('diagtrimitere').value='';
}

function validare_programare2p(id,rand,codparafa,codparafa2,diagtrimitere) {
	var radioGrp = document.getElementsByName('tipsolicitarep');
	for(i=0; i < radioGrp.length; i++)
		{
		if (radioGrp[i].checked == true) 
			{
			var tipsolicitare = radioGrp[i].value;
			}
		}
	var medic=document.getElementById('medic1p').value;
	var medic2=document.getElementById('medic2p').value;
	run_get('modificare_programare','mode@id@tipsolicitare@codparafa@codparafa2@medic@medic2@diagtrimitere','validare2@'+id+'@'+tipsolicitare+'@'+codparafa+'@'+codparafa2+'@'+medic+'@'+medic2+'@'+diagtrimitere,'infodreapta');
	rand.parentNode.parentNode.parentNode.parentNode.removeChild(rand.parentNode.parentNode.parentNode);
	document.getElementById('ftrimiterep').style.display='none';
	document.getElementById('cod1p').value='';
	document.getElementById('cod2p').value='';
	document.getElementById('medic1p').value='';
	document.getElementById('medic2p').value='';
	document.getElementById('diagtrimiterep').value='';
}

function intrare_programare(id,rand) {
	nufacerefresh = true;
	clearTimeout(refr);
	if (confirm("Sunteti sigur(a) ca vreti sa introduceti pacientul in cabinet?")) {
		run_get('modificare_programare','mode@id','intrare@'+id,'infodreapta');
		rand.parentNode.parentNode.parentNode.removeChild(rand.parentNode.parentNode);
	} else {
		nufacerefresh = false;
		refresh('index.php?page=5_lista_asteptari', 10)
	}
}

function intrareretrshowdataora(id) {
	var instanta=document.getElementById('dataora');
	if(instanta==null) {
	sdiv=document.createElement('div');
	sheader=document.createElement('h4');
	sheader.innerHTML='Data si ora consultului:<br />';
	sheader.setAttribute('style','border:solid 1px rgb(220,220,220); color:rgb(80,80,80); background-color:rgb(220,220,220);');
	scontent=document.createElement('div');
	scontent.setAttribute('id','dataorapopupcontent');
	scontent.setAttribute('style','margin: 5px 5px 5px 5px;');
	scontent.innerHTML='Data: <input style="font-size:11px" type="button" name="datai" id="datai" /><br />Ora: <input style="font-size:11px; width:40px;" type="text" name="orai" value="08:00" /> <a href="javascript:void(0);" onClick="javascript:intrare_programare_retroactiva('+id+');"><img src="images/accept.png" alt="Intrare retroactiva" title="Intrare retroactiva" border="0" class="center" /></a> <a href="javascript:void(0);" onClick="javascript:closeintrareretrshowdataora();"><img src="images/cross.png" alt="Inchide" title="Inchide" border="0" class="center" /></a><br />';
	var y=tempY;
	var x=tempX;
	x=x-245;
	y=y-35;
	var att="left: "+x+"px; top: "+y+"px;";
	sdiv.setAttribute('id','dataora');
	sdiv.setAttribute('class','contactform');
	sdiv.setAttribute('className','contactform');
	sdiv.setAttribute('style','z-index: 3; width: 250px; padding: 0; position: absolute; '+att);
	sdiv.style.opacity = 0;
	document.body.appendChild(sdiv);
	sdiv.appendChild(sheader); sdiv.appendChild(scontent);
	opacity('dataora', 0, 100, 300); 
	new vlaDatePicker('datai', { separator: '.', style: 'adobe_cs3', offset: { x: -200 }, format: 'd.m.y', ieTransitionColor: '' });
	new vlaDatePicker('orai', { prefillDate: { day: '-'} , separator: '.', style: 'adobe_cs3', offset: { x: -200 }, format: 'd.m.y', ieTransitionColor: '' });
	}
}

function intrareretrshowdataora2(id,eid) {
	var instanta=document.getElementById('dataora');
	if(instanta==null) {
	sdiv=document.createElement('div');
	sheader=document.createElement('h4');
	sheader.innerHTML='Data si ora consultului:<br />';
	sheader.setAttribute('style','border:solid 1px rgb(220,220,220); color:rgb(80,80,80); background-color:rgb(220,220,220);');
	scontent=document.createElement('div');
	scontent.setAttribute('id','dataorapopupcontent');
	scontent.setAttribute('style','margin: 5px 5px 5px 5px;');
	scontent.innerHTML='Data: <input style="font-size:11px" type="button" name="datai" id="datai" /><br />Ora: <input style="font-size:11px; width:40px;" type="text" name="orai" value="08:00" /> <a href="javascript:void(0);" onClick="javascript:intrare_internat_retroactiva('+id+','+eid+');"><img src="images/accept.png" alt="Intrare retroactiva" title="Intrare retroactiva" border="0" class="center" /></a> <a href="javascript:void(0);" onClick="javascript:closeintrareretrshowdataora2();"><img src="images/cross.png" alt="Inchide" title="Inchide" border="0" class="center" /></a><br />';
	var y=tempY;
	var x=tempX;
	x=x-245;
	y=y-35;
	var att="left: "+x+"px; top: "+y+"px;";
	sdiv.setAttribute('id','dataora');
	sdiv.setAttribute('class','contactform');
	sdiv.setAttribute('className','contactform');
	sdiv.setAttribute('style','z-index: 3; width: 250px; padding: 0; position: absolute; '+att);
	sdiv.style.opacity = 0;
	document.body.appendChild(sdiv);
	sdiv.appendChild(sheader); sdiv.appendChild(scontent);
	opacity('dataora', 0, 100, 300); 
	new vlaDatePicker('datai', { separator: '.', style: 'adobe_cs3', offset: { x: -200 }, format: 'd.m.y', ieTransitionColor: '' });
	new vlaDatePicker('orai', { prefillDate: { day: '-'} , separator: '.', style: 'adobe_cs3', offset: { x: -200 }, format: 'd.m.y', ieTransitionColor: '' });
	}
}

function intrareretrshowdataora_nounascut(id,eid,uid) {
	var instanta=document.getElementById('dataora');
	if(instanta==null) {
	sdiv=document.createElement('div');
	sheader=document.createElement('h4');
	sheader.innerHTML='Data si ora consultului:<br />';
	sheader.setAttribute('style','border:solid 1px rgb(220,220,220); color:rgb(80,80,80); background-color:rgb(220,220,220);');
	scontent=document.createElement('div');
	scontent.setAttribute('id','dataorapopupcontent');
	scontent.setAttribute('style','margin: 5px 5px 5px 5px;');
	scontent.innerHTML='Data: <input style="font-size:11px" type="button" name="datai" id="datai" /><br />Ora: <input style="font-size:11px; width:40px;" type="text" name="orai" value="08:00" /> <a href="javascript:void(0);" onClick="javascript:intrare_nounascut_retroactiva(\''+id+'\','+eid+','+uid+');"><img src="images/accept.png" alt="Intrare retroactiva" title="Intrare retroactiva" border="0" class="center" /></a> <a href="javascript:void(0);" onClick="javascript:closeintrareretrshowdataora_nounascut();"><img src="images/cross.png" alt="Inchide" title="Inchide" border="0" class="center" /></a><br />';
	var y=tempY;
	var x=tempX;
	x=x-245;
	y=y-35;
	var att="left: "+x+"px; top: "+y+"px;";
	sdiv.setAttribute('id','dataora');
	sdiv.setAttribute('class','contactform');
	sdiv.setAttribute('className','contactform');
	sdiv.setAttribute('style','z-index: 3; width: 250px; padding: 0; position: absolute; '+att);
	sdiv.style.opacity = 0;
	document.body.appendChild(sdiv);
	sdiv.appendChild(sheader); sdiv.appendChild(scontent);
	opacity('dataora', 0, 100, 300); 
	new vlaDatePicker('datai', { separator: '.', style: 'adobe_cs3', offset: { x: -200 }, format: 'd.m.y', ieTransitionColor: '' });
	new vlaDatePicker('orai', { prefillDate: { day: '-'} , separator: '.', style: 'adobe_cs3', offset: { x: -200 }, format: 'd.m.y', ieTransitionColor: '' });
	}
}

function closeintrareretrshowdataora() {
	var instanta=document.getElementById('dataora');
	if(instanta!=null) {
	opacity('dataora', 100, 0, 300);
	setTimeout('document.body.removeChild(document.getElementById(\'dataora\'));', 400);
	nufacerefresh=false;
	refr=setTimeout("location.reload();", (10*1000));
	//document.body.removeChild(document.getElementById('calendarpopup'));
	}
}

function closeintrareretrshowdataora2() {
	var instanta=document.getElementById('dataora');
	if(instanta!=null) {
	opacity('dataora', 100, 0, 300);
	setTimeout('document.body.removeChild(document.getElementById(\'dataora\'));', 400);
	//nufacerefresh=false;
	//refr=setTimeout("location.reload();", (10*1000));
	//document.body.removeChild(document.getElementById('calendarpopup'));
	}
}

function closeintrareretrshowdataora_nounascut() {
	var instanta=document.getElementById('dataora');
	if(instanta!=null) {
	opacity('dataora', 100, 0, 300);
	setTimeout('document.body.removeChild(document.getElementById(\'dataora\'));', 400);
	//nufacerefresh=false;
	//refr=setTimeout("location.reload();", (10*1000));
	//document.body.removeChild(document.getElementById('calendarpopup'));
	}
}

var dataoracheck=false;

function dataoraicheck() {
var datai=document.getElementsByName('datai');
var orai=document.getElementsByName('orai');
if(String(datai[0])!='undefined') dataoracheck=true;
}

function intrare_programare_retroactiva(id,rand) {
	dataoraicheck();
	if(dataoracheck==false)
	{
	nufacerefresh=true;
	clearTimeout(refr);
	intrareretrshowdataora(id);
	}
	else
	{
	var datai=document.getElementsByName('datai');
	var orai=document.getElementsByName('orai');
	run_get('modificare_programare','mode@id@data@ora','intrareretroactiva@'+id+'@'+datai[0].value+'@'+orai[0].value,'infodreapta');
	closeintrareretrshowdataora();
	dataoracheck=false;
	rand.parentNode.parentNode.parentNode.removeChild(rand.parentNode.parentNode);
	}
}

function intrare_internat_retroactiva(id,eid) {
	dataoraicheck();
	if(dataoracheck==false)
	{
	intrareretrshowdataora2(id,eid);
	}
	else
	{
	var datai=document.getElementsByName('datai');
	var orai=document.getElementsByName('orai');
	run_get('modificare_programare','mode@id@eid@data@ora','intrareretroactivainternat@'+id+'@'+eid+'@'+datai[0].value+'@'+orai[0].value,'infodreapta');
	closeintrareretrshowdataora2();
	dataoracheck=false;
	}
}

/*function swLiveRetro() {
	nufacerefresh=false;
	clearTimeout(refr);
	refr=setTimeout("location.reload()", 20*1000);
	var sw=document.getElementById('live');
	var swtext=document.getElementById('swtext');
	if(sw!=null)
	{
	sw.id='retro';
	sw.innerHTML='';
	swtext.innerHTML='Schimba in intrare in timp real'
	}
	else
	{
	sw=document.getElementById('retro');
	sw.id='live';
	sw.innerHTML='<a href="javascript:void(0);" onClick="javascript:intrare_programare('+id+',\''+this+'\');"><img src="images/accept.png" alt="Intrare" title="Intrare" border="0" class="center2" /></a>';
	swtext.innerHTML='Schimba in intrare retroactiva'
	}
}
*/

function swLiveRetro() {
	run_get('modificare_programare','mode','swliveretro','infodreapta');	
}

function intrare_internat(id,eid) {
	run_get('modificare_programare','mode@id@eid','intrare_internat@'+id+'@'+eid,'infodreapta');
}

function intrare_nounascut(id,eid,uid) {
	run_get('modificare_programare','mode@id@eid@uid','intrare_nounascut@'+id+'@'+eid+'@'+uid,'infodreapta');
}

function intrare_nounascut_retroactiva(id,eid,uid) {
	dataoraicheck();
	if(dataoracheck==false)
	{
	intrareretrshowdataora_nounascut(id,eid,uid);
	}
	else
	{
	var datai=document.getElementsByName('datai');
	var orai=document.getElementsByName('orai');
	run_get('modificare_programare','mode@id@eid@uid@data@ora','intrareretroactivanounascut@'+id+'@'+eid+'@'+uid+'@'+datai[0].value+'@'+orai[0].value,'infodreapta');
	closeintrareretrshowdataora_nounascut();
	dataoracheck=false;
	}
}

function iesire_cabinet(id,eid) {
	run_get('modificare_programare','mode@id@eid','iesire@'+id+'@'+eid,'infodreapta');
}

/*
<p><label for="rez1" class="left3"><u>Rezultat 1</u></label></p>
				<!--[if IE]>&nbsp;<![endif]-->
				<p><label for="numerez1" class="left3">Nume rezultat:</label>
				   <input type="text" size="20" name="numerez1" id="numerez1" onKeyDown="change_class('numerez1');" onKeyUp="change_class('numerez1');" /></p>
				<p><label for="umrez1" class="left3">Unitate de masură:</label>
				   <input type="text" size="20" name="umrez1" id="umrez1" onKeyDown="change_class('umrez1');" onKeyUp="change_class('umrez1');" /></p>
				<p><label for="costrez1" class="left3">Cost:</label>
				   <input type="text" size="20" name="costrez1" id="costrez1" onKeyDown="change_class('costrez1');" onKeyUp="change_class('costrez1');" /></p>
*/

function add_proc_cabinet(idprog)
{
	check=document.getElementsByName('idproc')[0].value;
	if(check!='' && !IsEmpty(check) && check!=0)
	{	//verificam daca s-a selectat vreo procedura
	
		var rezultat=getAjax('proceduri','mode@pid','are_copii@'+document.getElementsByName('idproc')[0].value);
		if(rezultat!="OK")
		{ //verificam daca procedura este pachet de proceduri
		
			if(rezultat=="nastere")
			{
				run_get('proceduri','mode@pid@idprog','nastere@'+document.getElementsByName('idproc')[0].value+'@'+idprog,'infodreapta');
			}
			else
			{
				document.getElementById('procs').innerHTML += '<div style=\'background-color: #ffffff; border: 1px #cccccc solid; margin-bottom: 4px;\'><input type="checkbox" name="proc[]" onClick="this.parentNode.parentNode.removeChild(this.parentNode);" value="'+document.getElementsByName('idproc')[0].value+'" checked=checked /> '+document.getElementsByName('proceduri')[0].value+'<div id="rez'+document.getElementsByName('idproc')[0].value+'"></div><input type="button" value="Salvează rezultat" onClick="save_rezultat(\''+document.getElementsByName('idproc')[0].value+'\', \''+idprog+'\');" style="margin:2px 0 4px 5px;" class="button5" /></div>'; 
				document.getElementsByName('proceduri')[0].value='';
				run_get_noexec('updater','mode@pid','updaterezproccab@'+document.getElementsByName('idproc')[0].value,'rez'+document.getElementsByName('idproc')[0].value);
				document.getElementsByName('idproc')[0].value='';
				document.getElementById('infodreapta').innerHTML=succes('Procedura a fost adăugată cu succes');
			}
		}
		else
		{
		run_get('proceduri','mode@pid@idprog','rezultate_copii@'+document.getElementsByName('idproc')[0].value+'@'+idprog,'infodreapta');
		}
	}
	else
	{
	document.getElementById('infodreapta').innerHTML=warn('Nu aţi ales nicio procedură');
	}
}

function add_proc_cabinet_recomandare(rand,idprog)
{
	rand.parentNode.parentNode.parentNode.removeChild(rand.parentNode.parentNode);
	run_get('proceduri','mode@idprog','recomandat2incurs@'+idprog,'infodreapta');
}

function save_rezultat(pid, idprog)
{
	var check=getAjax('updater','mode@pid','getmedicprog@'+idprog);
	if(parseInt(check)==0) { alert("Nu aţi ales niciun medic pentru acest consult. Vă rugăm alegeţi unul pentru a putea salva rezultatele procedurilor efectuate."); }
	else
	{
	var iddiag=document.getElementsByName('iddiagnosticf'+pid)[0];
	if(iddiag!=null && iddiag!='undefined') iddiag=iddiag.value;
	
	var diagnostic=document.getElementsByName('diagnostic'+pid)[0];
	if(diagnostic!=null && diagnostic!='undefined') diagnostic=diagnostic.value;
	
	var precizariiddiagnostic=document.getElementsByName('precizariiddiagnostic'+pid)[0];
	if(precizariiddiagnostic!=null && precizariiddiagnostic!='undefined') precizariiddiagnostic=precizariiddiagnostic.value;
	
	var rezultat=document.getElementsByName('rezultat'+pid)[0];
	if(rezultat!=null && rezultat!='undefined') rezultat=rezultat.value;
		
	var valnum=document.getElementsByName('valnum'+pid)[0];
	if(valnum!=null && valnum!='undefined') valnum=valnum.value;
	
	var listval=document.getElementsByName('listval'+pid)[0];
	if(listval!=null && listval!='undefined') listval=listval.value;
	
	var text=document.getElementsByName('text'+pid)[0];
	if(text!=null && text!='undefined') text=text.value;
	
	var observatii=document.getElementsByName('observatii'+pid)[0];
	if(observatii!=null && observatii!='undefined') observatii=observatii.value;
	
	//alert(rezultat+' '+iddiag+' '+diagnostic+' '+precizariiddiagnostic+' '+valnum+' '+listval+' '+text+' '+admin);
	run_get('proceduri','mode@pid@idprog@iddiag@diagnostic@precizari@rezultat@valnum@listval@text@observatii','save_rezultat@'+pid+'@'+idprog+'@'+iddiag+'@'+diagnostic+'@'+precizariiddiagnostic+'@'+rezultat+'@'+valnum+'@'+listval+'@'+text+'@'+observatii,'infodreapta');
	element=document.getElementById('rez'+pid);
	element.parentNode.parentNode.removeChild(element.parentNode);
	}
}

function anulare_procedura(rezid) {
	if (confirm('Sunteti sigur ca doriti sa anulati procedura?'))
		run_get('updater', 'mode@rezid', 'updateanulareproc@'+rezid, 'infodreapta');
}

function save_rezultat_nastere(pid, idprog)
{
	var nr_copii=document.getElementsByName('rezultat'+pid)[0].value;
	run_get('proceduri', 'mode@pid@idprog@nr_copii', 'save_rezultat_nastere@'+pid+'@'+idprog+'@'+nr_copii, 'infodreapta');
	element=document.getElementById('rez'+pid);
	element.parentNode.parentNode.removeChild(element.parentNode);
}

function resetare_parola(id)
{
	run_get('updater', 'mode@id', 'resetpass@'+id, 'infodreapta');
}

function programare_prezentare(pid, uid)
{
	document.getElementsByName('idfproc')[0].value='';
	document.getElementsByName('proceduri')[0].value='';
	run_get('modificare_programare','mode@pid@uid','prezentare@'+pid+'@'+uid,'infodreapta');
}

function validare_prezentare()
{
	var radioGrp = document.getElementsByName('tipsolicitare');
	for(i=0; i < radioGrp.length; i++)
		{
		if (radioGrp[i].checked == true) 
			{
			var tipsolicitare = radioGrp[i].value;
			}
		}

	var pid=document.getElementsByName('idfproc')[0].value;
	var uid=document.getElementById('idut').value;
	var codparafa=document.getElementById('cod1').value;
	var medic=document.getElementById('medic1').value;
	var medic2=document.getElementById('medic2').value;
	var codparafa2=document.getElementById('cod2').value;
	var diagtrimitere=document.getElementById('diagtrimitere').value;
	var entitate_trimitere=document.getElementsByName('entitate_trimitere')[0].value;
	var medic_prezentare=document.getElementsByName('idmednou')[0].value;
	var sterge_programare=document.getElementsByName('prin_recomandare')[0].value;
	
	//alert(medic_prezentare);
	run_get('modificare_programare','mode@sterge_programare@pid@uid@tipsolicitare@codparafa@codparafa2@medic@medic2@diagtrimitere@medic_prezentare@eid','validare_prezentare@'+sterge_programare+'@'+pid+'@'+uid+'@'+tipsolicitare+'@'+codparafa+'@'+codparafa2+'@'+medic+'@'+medic2+'@'+diagtrimitere+'@'+medic_prezentare+'@'+entitate_trimitere,'infodreapta');
}

function validare_prezentare_si_intrare() {
		var radioGrp = document.getElementsByName('tipsolicitare');
	for(i=0; i < radioGrp.length; i++)
		{
		if (radioGrp[i].checked == true) 
			{
			var tipsolicitare = radioGrp[i].value;
			}
		}

	var pid=document.getElementsByName('idfproc')[0].value;
	var uid=document.getElementById('idut').value;
	var codparafa=document.getElementById('cod1').value;
	var medic=document.getElementById('medic1').value;
	var medic2=document.getElementById('medic2').value;
	var codparafa2=document.getElementById('cod2').value;
	var diagtrimitere=document.getElementById('diagtrimitere').value;
	var entitate_trimitere=document.getElementsByName('entitate_trimitere')[0].value;
	var medic_prezentare=document.getElementsByName('idmednou')[0].value;
	var sterge_programare=document.getElementsByName('prin_recomandare')[0].value;
	
	//alert(medic_prezentare);
	run_get('modificare_programare','mode@sterge_programare@pid@uid@tipsolicitare@codparafa@codparafa2@medic@medic2@diagtrimitere@medic_prezentare@eid','validare_prezentare_intrare@'+sterge_programare+'@'+pid+'@'+uid+'@'+tipsolicitare+'@'+codparafa+'@'+codparafa2+'@'+medic+'@'+medic2+'@'+diagtrimitere+'@'+medic_prezentare+'@'+entitate_trimitere,'infodreapta');
}

function recomandare(uid,idprog)
{
	pid=document.getElementsByName('idproc_recomand')[0].value;
	pname=document.getElementsByName('proceduri_recomandare')[0].value;
	interval=document.getElementsByName('interval')[0].value;
	tip_interval=document.getElementsByName('tip_interval')[0].value;
	interval2=document.getElementsByName('interval2')[0].value;
	tip_interval2=document.getElementsByName('tip_interval2')[0].value;
	mentiuni=document.getElementsByName('mentiuni')[0].value;
	
	run_get('modificare_programare','mode@uid@pid@pname@interval@tip_interval@interval2@tip_interval2@idprog@mentiuni','recomandare@'+uid+'@'+pid+'@'+pname+'@'+interval+'@'+tip_interval+'@'+interval2+'@'+tip_interval2+'@'+idprog+'@'+mentiuni,'infodreapta');
}

function lsbox(el, key, content, contentparent, todo)
{
	if(key==13 || key==38 || key==40)
	{
	var ct=document.getElementById(content);
	if(ct!=null)
	{
	switch(key)
	{
		case 40:
		var c=ct.getElementsByTagName('p');
		i=0; aux=0;
		while(i<c.length && aux==0)
		{
			if(c[i].name=='sel')
			{
				if(i==c.length-1) { aux=1; }
				else {
				c[i].style.backgroundColor='rgb(240,240,240)';
				c[i].name='notsel';
				c[i+1].style.backgroundColor='rgb(137,170,214)';
				c[i+1].name='sel';
				aux=1;
				if(i>1 && i%5==0) document.getElementById(contentparent).scrollTop=document.getElementById(contentparent).scrollTop+70;
				}
			}
		i++;
		}
		if(aux==0) { c[0].name='sel'; c[0].style.backgroundColor='rgb(137,170,214)'; }
		break;
		
		case 38:
		var c=ct.getElementsByTagName('p');
		i=0; aux=0;
		while(i<c.length && aux==0)
		{
			if(c[i].name=='sel')
			{
				c[i].style.backgroundColor='rgb(240,240,240)';
				c[i].name='notsel';
				c[i-1].style.backgroundColor='rgb(137,170,214)';
				c[i-1].name='sel';
				aux=1;
				if(i>1 && i%5==0) document.getElementById('livesearchprocedura').scrollTop=document.getElementById('livesearchprocedura').scrollTop-70;
			}
		i++;
		}
		if(aux==0) { c[0].name='sel'; c[0].style.backgroundColor='rgb(137,170,214)'; }
		break;
		
		case 13:
		var c=ct.getElementsByTagName('p');
		i=0; aux=0;
		while(i<c.length && aux==0)
		{
			if(c[i].name=='sel')
			{
				eval(c[i].getAttribute("onClick"));
				el.blur();
				aux=1;
			}
		i++;
		}
		break;
	}
	}
	}
	else
	{
	eval(todo);
	}
}

function show_log(filtre1, valorifiltre1) 
{
run_get_noexec('livelog',filtre1, valorifiltre1,'logtable');
setTimeout("show_log('"+filtre+"', '"+valorifiltre+"')", 2500);
}

function swapCheck(checkBox)
	{
	var inputs = document.getElementsByTagName('input');
	for (var i = 0; i < inputs.length; i++)
        {
			if (inputs[i].type == 'checkbox' && inputs[i].name.split('u')[1]=='gical')
				if(inputs[i].id!=checkBox.id) if(checkBox.checked==true) inputs[i].checked = false;
																		 else document.getElementById('chirurgical').checked=true;
		}
	}
	
function swapCheck2(checkBox)
	{
	var inputs = document.getElementsByTagName('input');
	for (var i = 0; i < inputs.length; i++)
        {
			if (inputs[i].type == 'checkbox' && inputs[i].name.split('s')[0]!='tip')
				if(inputs[i].id!=checkBox.id)
					 {
						inputs[i].checked = false;
						document.getElementById('poza'+inputs[i].id).style.display='block';
					 }
				else {
						document.getElementById('idprogramare').value=checkBox.id;
						document.getElementById('poza'+checkBox.id).style.display='none';
					 }
		}
	if(checkBox.checked==false) document.getElementById('poza'+checkBox.id).style.display='block';
	}
	
function swapCheck2p(checkBox)
	{
	var inputs = document.getElementsByTagName('input');
	for (var i = 0; i < inputs.length; i++)
        {
			if (inputs[i].type == 'checkbox' && inputs[i].name.split('s')[0]!='tip')
				if(inputs[i].id!=checkBox.id)
					 {
						inputs[i].checked = false;
						document.getElementById('poza'+inputs[i].id).style.display='block';
					 }
				else {
						document.getElementById('idprogramarep').value=checkBox.id;
						document.getElementById('poza'+checkBox.id+'p').style.display='none';
					 }
		}
	if(checkBox.checked==false) document.getElementById('poza'+checkBox.id+'p').style.display='block';
	}
	
function trimitere()
{
	var elemente=document.getElementsByTagName('input');
	var obj=document.getElementById('ftrimitere');
	var j=0;
	for(i=0;i<elemente.length;i++)
	{
		if(elemente[i].checked==true && elemente[i].type=='checkbox') j++;
	}
	if(j==1)
	{
	obj.style.display='block';
	}
	if(j==0) obj.style.display='none';
}

function trimiterep()
{
	var elemente=document.getElementsByTagName('input');
	var obj=document.getElementById('ftrimiterep');
	var j=0;
	for(i=0;i<elemente.length;i++)
	{
		if(elemente[i].checked==true && elemente[i].type=='checkbox') j++;
	}
	if(j==1)
	{
	obj.style.display='block';
	}
	if(j==0) obj.style.display='none';
}

function addlog(action, file)
{
	run_get('modificare_log', 'action@file', action+'@'+file, 'infodreapta');
}

function toggle(ele)
{
	var getin=document.getElementsByName(ele)[0].parentNode.parentNode.getElementsByTagName('input');
	for(i=0;i<getin.length;i++)
	{
		if(getin[i].type=='text')
		{ 
			if(getin[i].disabled) getin[i].removeAttribute("disabled");
			else getin[i].setAttribute("disabled","disabled");
		}
	}
}

function gen_diag_input(el, hid)
{
var instanta=document.getElementById('precizari'+hid);
if(el.value!='')
{
if(instanta==null || instanta=='undefined')
{
var nou=document.createElement('input');
nou.setAttribute('name','precizari'+hid);
nou.setAttribute('id','precizari'+hid);
nou.setAttribute('type','text');
nou.setAttribute('size','35');
nou.setAttribute("onKeyUp","livesearchdiagnosticerad(this.value, this, document.getElementsByName('"+hid+"')[0].value); diag_check2('"+hid.split('iddiagnostic')[1]+"')");
nou.setAttribute("onblur","closelivesearchdiagnosticerad();");
nou.style.opacity = 0;
el.parentNode.appendChild(nou);
opacity('precizari'+hid, 0, 100, 600);
}
}
else
{
if(instanta!=null) { opacity('precizari'+hid, 100, 0, 600); setTimeout("document.getElementById('precizari"+hid+"').parentNode.removeChild(document.getElementById('precizari"+hid+"'));", 610); }
}
}

function gen_diag_cod(hid, val)
{
var instanta=document.getElementById('cod'+hid);
if(instanta==null || instanta=='undefined')
{
var nou=document.createElement('input');
nou.setAttribute('name','cod'+hid);
nou.setAttribute('id','cod'+hid);
nou.setAttribute('type','text');
nou.setAttribute('value','Cod: '+val);
nou.setAttribute('DISABLED',"DISABLED");
nou.style.opacity = 0;
asf='diagnostic'+hid;
document.getElementsByName(asf)[0].parentNode.appendChild(nou);
opacity('cod'+hid, 0, 100, 600);
}
}

function livesearchdiagnosticerad(keyword,field,val) {
	var instanta=document.getElementById('livesearchdiagnosticrad');
	var e=field;
	if(instanta==null) {
	sdiv=document.createElement('div');
	scontent=document.createElement('div');
	scontent.setAttribute('id','livesearchdiagnosticradcontent');
	scontent.innerHTML='<br /><br />';
	var y=getOffsetTop(e);//e.offsetTop;
	var x=getOffsetLeft(e);//e.offsetLeft;
	x=x-8;
	y=y+0;
	var att="left: "+x+"px; top: "+y+"px;";
	sdiv.setAttribute('id','livesearchdiagnosticrad');
	sdiv.setAttribute('class','contactform');
	sdiv.setAttribute('className','contactform');
	sdiv.setAttribute('style','z-index: 999; height: 70px; padding: 0; position: absolute; overflow: auto; '+att);
	sdiv.style.opacity = 0;
	document.body.appendChild(sdiv);
	sdiv.appendChild(scontent);
	opacity('livesearchdiagnosticrad', 0, 100, 400); }
	run_get_noexec('livesearchdiagnosticerad', 'keyword@fieldname@val', keyword+'@'+e.name+'@'+val, 'livesearchdiagnosticradcontent');
}

function closelivesearchdiagnosticerad() {
	var instanta=document.getElementById('livesearchdiagnosticrad');
	if(instanta!=null) {
	opacity('livesearchdiagnosticrad', 100, 0, 400);
	setTimeout('document.body.removeChild(document.getElementById(\'livesearchdiagnosticrad\'));', 500);
	}
}

function diag_check1(pid)
{
document.getElementsByName('iddiagnostic'+pid)[0].value='';
document.getElementsByName('iddiagnosticf'+pid)[0].value='';
var ins1=document.getElementsByName('precizariiddiagnostic'+pid)[0];
if(ins1!=null)
{
ins1.value='';
}
var ins2=document.getElementsByName('cod'+pid)[0];
if(ins2!=null) 
{
ins2.parentNode.removeChild(ins2);
}
}

function diag_check2(pid)
{
document.getElementsByName('iddiagnosticf'+pid)[0].value='';
var ins2=document.getElementsByName('cod'+pid)[0];
if(ins2!=null) 
{
ins2.parentNode.removeChild(ins2);
}
}

function save_mod_diag(tip, val, did)
{
switch(tip)
{
case "n":
run_get_noexec('updater', 'mode@val@did', 'updatediagn@'+val+'@'+did, 'infodreapta');
break;

case "p":
run_get_noexec('updater', 'mode@val@did', 'updatediagp@'+val+'@'+did, 'infodreapta');
break;

case "c":
run_get_noexec('updater', 'mode@val@did', 'updatediagc@'+val+'@'+did, 'infodreapta');
break;
}
}

function save_mod_alias(tip, val, did)
{
switch(tip)
{
case "n":
run_get_noexec('updater', 'mode@val@did', 'updatealiasn@'+val+'@'+did, 'infodreapta');
break;

case "p":
run_get_noexec('updater', 'mode@val@did', 'updatealiasp@'+val+'@'+did, 'infodreapta');
break;

case "c":
run_get_noexec('updater', 'mode@val@did', 'updatealiasc@'+val+'@'+did, 'infodreapta');
break;
}
}

function block_diag(el, did)
{
run_get_noexec('updater', 'mode@did', 'updatediagblock@'+did, 'blocate');
el.parentNode.parentNode.parentNode.removeChild(el.parentNode.parentNode);
}

function accept_diag(el, did)
{
run_get_noexec('updater', 'mode@did', 'updatediagaccept@'+did, 'validate');
el.parentNode.parentNode.parentNode.removeChild(el.parentNode.parentNode);
}

function block_alias(el, did)
{
run_get_noexec('updater', 'mode@did', 'updatealiasblock@'+did, 'blocate');
el.parentNode.parentNode.parentNode.removeChild(el.parentNode.parentNode);
}

function accept_alias(el, did)
{
run_get_noexec('updater', 'mode@did', 'updatealiasaccept@'+did, 'validate');
el.parentNode.parentNode.parentNode.removeChild(el.parentNode.parentNode);
}

function codparafa2medic(camp, dest)
{
var raspuns=getAjax('codparafa2medic', 'val', camp.value);
if(raspuns!=null && raspuns!='undefined' && raspuns != '')
{
dest.value=raspuns;
}
}

function medic2codparafa(camp, dest)
{
var raspuns=getAjax('medic2codparafa', 'val', camp.value);
if(raspuns!=null && raspuns!='undefined' && raspuns != '')
{
dest.value=raspuns;
}
}

function add_um()
{
var nume=document.getElementsByName('denumire')[0].value;
var nr_reg_com=document.getElementsByName('nr_reg_com')[0].value;
var sediu=document.getElementsByName('sediu')[0].value;
var localitate=document.getElementsByName('hloc')[0].value;
var judet=document.getElementsByName('judet')[0].value;
var cont=document.getElementsByName('cont')[0].value;
var banca=document.getElementsByName('bank')[0].value;

run_get('admin_um','mode@nume@nr_reg_com@sediu@localitate@judet@cont@banca','add@'+nume+'@'+nr_reg_com+'@'+sediu+'@'+localitate+'@'+judet+'@'+cont+'@'+banca,'infodreapta');
}

function edit_um()
{
var nume=document.getElementsByName('denumire')[0].value;
var nr_reg_com=document.getElementsByName('nr_reg_com')[0].value;
var sediu=document.getElementsByName('sediu')[0].value;
var localitate=document.getElementsByName('hloc')[0].value;
var judet=document.getElementsByName('judet')[0].value;
var cont=document.getElementsByName('cont')[0].value;
var banca=document.getElementsByName('bank')[0].value;
var uid=document.getElementsByName('uid')[0].value;

run_get('admin_um','mode@nume@nr_reg_com@sediu@localitate@judet@cont@banca@uid','edit@'+nume+'@'+nr_reg_com+'@'+sediu+'@'+localitate+'@'+judet+'@'+cont+'@'+banca+'@'+uid,'infodreapta');

}

function MyAddress(IP)
{
var ip=IP;
var ipn=ip.split(" ");
if(ipn.length>1)
{
document.getElementById('ipl').value=ipn[1];
}
else
{
document.getElementById('ipl').value=IP;
}
}

function MyAddress2(IP)
{
document.getElementById('ipl').value=IP;
}

function save_cas(pid)
{
var decont=document.getElementById('decontat'+pid).value;
var coplata=document.getElementById('coplata'+pid).value;
var cas=document.getElementsByName('id_cas')[0].value;
run_get('proceduri','mode@pid@cas@decont@coplata','save_cas@'+pid+'@'+cas+'@'+decont+'@'+coplata,'infodreapta');
}

function detalii_programare(idprog)
{
//alert(idprog);
run_get_noexec('detalii_receptie','mode@idprog','programare@'+idprog,'detalii_in');
//expand('detalii');
document.getElementById('detalii').style.display='block';
}

function detalii_pacient(idpacient)
{
run_get_noexec('detalii_receptie','mode@idpacient','pacient@'+idpacient,'detalii_in');
document.getElementById('detalii').style.display='block';
}

function save_serii(eid)
{
	serie=document.getElementsByName('serie')[0].value;
	serie2=document.getElementsByName('serie2')[0].value;
	run_get('modificare_entitati', 'mode@eid@serie@serie2', 'save_serii@'+eid+'@'+serie+'@'+serie2, 'infodreapta');
}

function save_nrpaturi(eid)
{
	nrpaturi_cont=document.getElementsByName('nrpaturi_cont')[0].value;
	nrpaturi_zi=document.getElementsByName('nrpaturi_zi')[0].value;
	run_get('modificare_entitati', 'mode@eid@nrpaturi_cont@nrpaturi_zi', 'save_nrpaturi@'+eid+'@'+nrpaturi_cont+'@'+nrpaturi_zi, 'infodreapta');
}

function schimba_varianta(page)
{
	run_get('modificare_varianta', 'page@', page+'@', 'infodreapta');
}

function popupWindow(url, width, height) {
	window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width='+width+',height='+height+',screenX=150,screenY=150,top=150,left=150')
}

function popupWindow_scroll(url, width, height) {
	window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+width+',height='+height+',screenX=150,screenY=150,top=150,left=150')
}

function popup_layer(url, cwidth, cheight) {
	window.scrollTo(0,0);
	var div = document.createElement('div');
	div.setAttribute('id','popup_layer');
	div.setAttribute('class','contactform');
	div.setAttribute('className','contactform');

	var divheader = document.createElement('div');
	divheader.setAttribute('style','display: block; margin:0; padding:10px 0 0 0; text-align:right; width:100%; height:40px; position:relative; right:20px;');
	divheader.innerHTML = '<a href="javascript:void(0);" onClick="popup_layer_close();"><img src="style/close.png" alt="" title="" border="0" /></a>';

	var divcontent = document.createElement('div');
	divcontent.setAttribute('id','popup_layer_content');
	divcontent.setAttribute('style','display: block; margin:0; padding:0; text-align:center; width:100%; height:100%;');
	divcontent.innerHTML = '<iframe allowtransparency="true" frameborder="0" id="popup_content" name="popup_content" scrolling="auto" src="'+url+'" style="min-width:550px; width:'+cwidth+'px; height:'+cheight+'px;"></iframe>';
	
	div.appendChild(divheader);
	div.appendChild(divcontent);

	var height = document.body.offsetHeight;
	div.setAttribute('style','display: block; position: absolute; top: 0pt; left: 0pt; z-index: 90; width: 100%; height: '+height+'px; margin:0; padding:0 0 0 0; background:url("style/overlay.png") repeat; border:0;');

	document.body.appendChild(div);
}

function popup_layer_closeandopen(url, cwidth, cheight) {
	parent.window.scrollTo(0,0);
	parent.document.getElementById('popup_layer_content').innerHTML = '<iframe allowtransparency="true" frameborder="0" id="popup_content" name="popup_content" scrolling="auto" src="'+url+'" style="min-width:550px; width:'+cwidth+'px; height:'+cheight+'px;"></iframe>';
	//alert(parent.document.getElementById('popup_content').parentNode.id);
}

function popup_layer_close() {
	document.body.removeChild(document.getElementById('popup_layer'));
}

function popup_layer_close_frompopup() {
	parent.document.body.removeChild(parent.document.getElementById('popup_layer'));
}

function interneaza(idpacient,idprog)
{ //legatura catre detalii ptr internare
	//popupWindow_scroll('internare.php?idprog='+idprog+'&id='+idpacient,500,300);
	popup_layer('internare.php?idprog='+idprog+'&id='+idpacient, '', '500');
}

function internare()
{ //actiunea de internare propriu-zisa
	var entitati=document.getElementsByName('locatie');
	var pacient=document.getElementsByName('pacient')[0].value;
	var data=document.getElementsByName('data')[0].value;
	var idprog=document.getElementById('idprog').value;
	var entitate='undefined';
	for(i=0;i<entitati.length;i++)
		{
			if(entitati[i].checked) entitate=entitati[i].value;
		}
	var internare_de_zi=document.getElementsByName('internarezi')[0];
	if(internare_de_zi.checked) internare_de_zi=internare_de_zi.value;
								else internare_de_zi='0';
	if(entitate=='undefined') alert('Nu aţi selectat nicio entitate!');
		else run_get('internari', 'mode@entitate@pacient@data@internarezi@idprog', 'internare@'+entitate+'@'+pacient+'@'+data+'@'+internare_de_zi+'@'+idprog, 'infodreapta2');
}

function externare()
{
	document.getElementById('stare_externare').style.display="block";
}

function externeaza(idpacient,idprog)
{
	//popupWindow_scroll('dompdf/printing_template.php?raport=foaieobs&id='+idpacient+'&idprog='+idprog, '820', '960');
	var stare=document.getElementsByName('stare')[0].value;
	run_get('internari','mode@idpacient@idprog@stare','externare@'+idpacient+'@'+idprog+'@'+stare,'infodreapta');
	popup_layer('externare.php?idprog='+idprog+'&id='+idpacient+'&stare='+stare, '820', '700');
}

function transfer(idprog,idpacient)
{
	popupWindow_scroll('transfer.php?idprog='+idprog+'&id='+idpacient,500,300);
}

function transfer_intern(pacient)
{
	var entitati=document.getElementsByName('locatie');
	var pacient=document.getElementsByName('pacient')[0].value;
	var data=document.getElementsByName('data')[0].value;
	var idprog=document.getElementById('idprog').value;
	var entitate='undefined';
	for(i=0;i<entitati.length;i++)
		{
			if(entitati[i].checked) entitate=entitati[i].value;
		}
	if(entitate=='undefined') alert('Nu aţi selectat nicio entitate!');
		else run_get('internari', 'mode@entitate@pacient@data@idprog', 'transfer_intern@'+entitate+'@'+pacient+'@'+data+'@'+idprog, 'infodreapta');
}

function check_acord()
{
if(document.getElementsByName('email')[0].value=='') { document.getElementById('printare_acord').style.display='none'; } else { document.getElementById('printare_acord').style.display='block'; }
}

function check_acord2()
{
if(document.getElementsByName('email')[0].value=='') 
	{
		document.getElementById('nivel_confiden').style.display='none';
		document.getElementsByName('nivel_confiden')[0].value='2';
		document.getElementById('printare_acord').style.display='none';
	}
else document.getElementById('nivel_confiden').style.display='block';
/*
var acord=document.getElementsByName('acord')[0];
if(document.getElementsByName('email')[0].value=='') {acord.checked=false; document.getElementById('printare_acord').style.display='none'; }
if(acord.checked==true) document.getElementById('printare_acord').style.display='block';
else  document.getElementById('printare_acord').style.display='none';
*/
}

function set_nivel_confiden(value)
{
	document.getElementsByName('nivel_confiden')[0].value=value;
}

function print_acord()
{
	var tip_acord=document.getElementsByName('nivel_confiden')[0].value;
	var cnp=document.getElementsByName('cnp')[0].value;
	var nume=document.getElementsByName('nume')[0].value;
	var prenume=document.getElementsByName('prenume')[0].value;
	var serie=document.getElementsByName('serie')[0].value;
	var email=document.getElementsByName('email')[0].value;
	var uid=document.getElementsByName('id_operator')[0].value;
	var cod=document.getElementsByName('username')[0].value;
	popupWindow_scroll('dompdf/printing_template.php?raport=formular'+tip_acord+'&nume='+nume+'&prenume='+prenume+'&cnp='+cnp+'&serie='+serie+'&email='+email+'&uid='+uid+'&cod='+cod, '820', '960');
}

function print_acord2()
{
	var cnp=document.getElementsByName('cnp')[0].value;
	var nume=document.getElementsByName('nume')[0].value;
	var prenume=document.getElementsByName('prenume')[0].value;
	var serie=document.getElementsByName('serie')[0].value;
	var email=document.getElementsByName('email')[0].value;
	var uid=document.getElementsByName('id_operator')[0].value;
	var cod=document.getElementsByName('username')[0].value;
	popupWindow_scroll('dompdf/printing_template.php?raport=formular5&nume='+nume+'&prenume='+prenume+'&cnp='+cnp+'&serie='+serie+'&email='+email+'&uid='+uid+'&cod='+cod, '820', '960');
}

function adaugare_imprimanta(obj) {
	var imprimante=getAjaxResponse('imprimante', 'mode@', 'get_imprimante_select@', obj);
	var x=obj.parentNode.parentNode.parentNode.insertRow(obj.parentNode.parentNode.sectionRowIndex); 
	var y=x.insertCell(0); 
	var z=x.insertCell(1);
	z.setAttribute('class', 'center');
	z.setAttribute('className', 'center');
	var a=x.insertCell(2);
	a.setAttribute('class', 'center');
	a.setAttribute('className', 'center');
	var l=x.insertCell(3);
	l.setAttribute('class', 'center');
	l.setAttribute('className', 'center');
	y.innerHTML='<input type="text" name="denumire" size="30" />';
	z.innerHTML=imprimante;
	a.innerHTML='<textarea name="observatii"></textarea>';
	l.innerHTML='<a href="javascript:void(0);" onClick="run_get(\'imprimante\', \'mode@denumire@cod@observatii\', \'adaugare_imprimanta@\'+document.getElementsByName(\'denumire\')[0].value+\'@\'+document.getElementsByName(\'cod\')[0].value+\'@\'+document.getElementsByName(\'observatii\')[0].value, \'infodreapta\');"><img src="images/tick.png" border="0" alt="" /></a>&nbsp;&nbsp;&nbsp;';
	l.innerHTML+='<a href="javascript:void(0);" onClick="this.parentNode.parentNode.parentNode.deleteRow(this.parentNode.parentNode.sectionRowIndex);"><img src="images/cross.png" border="0" alt="Anulează" title="Anulează" /></a>';
}

function stergere_imprimanta(obj,id,nume) {
	if (confirm("Sunteţi sigur că vreţi să ştergeţi imprimanta logică '"+nume+"'?")==true)
	{
	obj.parentNode.parentNode.parentNode.deleteRow(obj.parentNode.parentNode.sectionRowIndex);
	run_get('imprimante', 'mode@id', 'stergere_imprimanta@'+id, 'infodreapta');
	}
}

function editare_imprimanta(obj,id) {
	run_get('imprimante', 'mode@id', 'form_edit_imprimanta@'+id, 'infodreapta');
}

function setare_imprimanta_implicita(id) {
	run_get('imprimante', 'mode@id_postlucru', 'setare_imprimanta_implicita@'+id, 'infodreapta');
}

function salvare_imprimanta_implicita(id_postlucru, id_imprimanta) {
	run_get('imprimante', 'mode@id_postlucru@id_imprimanta', 'salvare_imprimanta_implicita@'+id_postlucru+'@'+document.getElementsByName(id_imprimanta)[0].value, 'infodreapta');
}

function schimbare_imprimanta_implicita(id) {
	run_get('imprimante', 'mode@id_postlucru', 'schimbare_imprimanta_implicita@'+id, 'infodreapta');
}

function dezactivare_imprimanta_implicita(id) {
	run_get('imprimante', 'mode@id_postlucru', 'dezactivare_imprimanta_implicita@'+id, 'infodreapta');
}

function adaugare_proba(obj) {
	x=obj.parentNode.parentNode.parentNode.insertRow(obj.parentNode.parentNode.sectionRowIndex); 
	y=x.insertCell(0); 
	z=x.insertCell(1);
	z.setAttribute('class', 'center');
	z.setAttribute('className', 'center');
	a=x.insertCell(2);
	a.setAttribute('class', 'center');
	a.setAttribute('className', 'center');
	l=x.insertCell(3);
	l.setAttribute('class', 'center');
	l.setAttribute('className', 'center');
	y.innerHTML='<input type="text" name="nume" />';
	z.innerHTML='<input type="text" name="cod" />';
	a.innerHTML='<input type="text" name="observatii" />';
	l.innerHTML='<a href="javascript:void(0);" onClick="run_get(\'laborator\', \'mode@nume@cod@observatii\', \'adaugare_proba@\'+document.getElementsByName(\'nume\')[0].value+\'@\'+document.getElementsByName(\'cod\')[0].value+\'@\'+document.getElementsByName(\'observatii\')[0].value, \'infodreapta\');"><img src="images/tick.png" border="0" alt="" /></a>&nbsp;&nbsp;&nbsp;';
	l.innerHTML+='<a href="javascript:void(0);" onClick="this.parentNode.parentNode.parentNode.deleteRow(this.parentNode.parentNode.sectionRowIndex);"><img src="images/cross.png" border="0" alt="Anulează" title="Anulează" /></a>';
}

function stergere_proba(obj,id,nume) {
	if (confirm("Sunteţi sigur că vreţi să ştergeţi proba '"+nume+"'?")==true)
	{
	obj.parentNode.parentNode.parentNode.deleteRow(obj.parentNode.parentNode.sectionRowIndex);
	run_get('laborator', 'mode@id', 'stergere_proba@'+id, 'infodreapta');
	}
}

function editare_proba(obj,id) {
	run_get('laborator', 'mode@id', 'form_edit_proba@'+id, 'infodreapta');
}


function adaugare_recipient(obj) {
	x=obj.parentNode.parentNode.parentNode.insertRow(obj.parentNode.parentNode.sectionRowIndex); 
	y=x.insertCell(0); 
	z=x.insertCell(1);
	z.setAttribute('class', 'center');
	z.setAttribute('className', 'center');
	a=x.insertCell(2);
	a.setAttribute('class', 'center');
	a.setAttribute('className', 'center');
	l=x.insertCell(3);
	l.setAttribute('class', 'center');
	l.setAttribute('className', 'center');
	y.innerHTML='<input type="text" name="nume" />';
	z.innerHTML='<input type="text" name="cod" />';
	a.innerHTML='<input type="text" name="observatii" />';
	l.innerHTML='<a href="javascript:void(0);" onClick="run_get(\'laborator\', \'mode@nume@cod@observatii\', \'adaugare_recipient@\'+document.getElementsByName(\'nume\')[0].value+\'@\'+document.getElementsByName(\'cod\')[0].value+\'@\'+document.getElementsByName(\'observatii\')[0].value, \'infodreapta\');"><img src="images/tick.png" border="0" alt="" /></a>&nbsp;&nbsp;&nbsp;';
	l.innerHTML+='<a href="javascript:void(0);" onClick="this.parentNode.parentNode.parentNode.deleteRow(this.parentNode.parentNode.sectionRowIndex);"><img src="images/cross.png" border="0" alt="Anulează" title="Anulează" /></a>';
}

function stergere_recipient(obj,id,nume) {
	if (confirm("Sunteţi sigur că vreţi să ştergeţi recipientul '"+nume+"'?")==true)
	{
	obj.parentNode.parentNode.parentNode.deleteRow(obj.parentNode.parentNode.sectionRowIndex);
	run_get('laborator', 'mode@id', 'stergere_recipient@'+id, 'infodreapta');
	}
}

function editare_recipient(obj,id) {
	run_get('laborator', 'mode@id', 'form_edit_recipient@'+id, 'infodreapta');
}

function preleveaza(id_pacient,id_prog) {
	popupWindow('prelevare.php?id='+id_pacient+'&idprog='+id_prog);
}

function prelevare() {
	run_get('prelevari','mode@','detalii@','infodreapta');
}

function prelevari_istoric(id_pacient,idprog)
{
	run_get('prelevari','mode@id_pacient@idprog','istoric@'+id_pacient+'@'+idprog,'infodreapta');
}

function add_proc_prelevare(id_pacient,idprog)
{
	var pid=document.getElementsByName('idproc')[0].value;
	run_get('prelevari','mode@pid@id_pacient@idprog','add_proc@'+pid+'@'+id_pacient+'@'+idprog,'infodreapta');
}

function legatura_nec(idnec) {
	run_get('legatura_nec', 'idnec', idnec, 'infodreapta');
	document.getElementById('legatura').setAttribute("style","display: block;");
}

function adauga_legatura(idnec, idleg) {
	run_get('legatura_nec', 'idnec@idleg', idnec+'@'+idleg, 'infodreapta');
}

function schedule_add(dela, panala) {
getAjax('updater', 'mode@dela@panala', 'schedule@'+dela+'@'+panala);
run_get_noexec('updater','mode','scheduleactual','actual');
}

function schedule_delete() {
getAjax('updater', 'mode@dela@panala', 'scheduledelete@ @ ');
run_get_noexec('updater','mode','scheduleactual','actual');
}


function adaugare_task(obj) {
	x=obj.parentNode.parentNode.parentNode.insertRow(obj.parentNode.parentNode.sectionRowIndex); 
	zxc=x.insertCell(0);
	asd=x.insertCell(1);
	y=x.insertCell(2); 
	z=x.insertCell(3);
	k=x.insertCell(4);
	q=x.insertCell(5);
	w=x.insertCell(6);
	e=x.insertCell(7);
	s=x.insertCell(8);
	t=x.insertCell(9);
	r=x.insertCell(10);
	z.setAttribute('class', 'center');
	z.setAttribute('className', 'center');
	k.setAttribute('class', 'center');
	k.setAttribute('className', 'center');
		q.setAttribute('class', 'center');
	q.setAttribute('className', 'center');
		w.setAttribute('class', 'center');
	w.setAttribute('className', 'center');
		e.setAttribute('class', 'center');
	e.setAttribute('className', 'center');
		r.setAttribute('class', 'center');
	r.setAttribute('className', 'center');
	asd.innerHTML='<input type="text" name="capitol" style="width:45px" />';
	y.innerHTML='<textarea name="text" cols="10" style="width:200px;" rows="5"></textarea>';
	z.innerHTML='<select name="urgenta"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option></select>';
	k.innerHTML='<select name="complexitate"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option></select>';
	q.innerHTML='<select name="impact"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option></select>';
	w.innerHTML='<input type="text" style="width:70px" name="incepere" />';
	e.innerHTML='<input type="text" style="width:70px" name="termen" />';
	s.innerHTML='<input type="text" style="width:70px" name="responsabil" />';
	t.innerHTML='<textarea name="observatii" cols="10" style="width:150px;" rows="5"></textarea>';
	r.innerHTML='<a href="javascript:void(0);" onClick="run_get(\'administrare_aplicatie\', \'mode@capitol@text@urgenta@complexitate@impact@incepere@termen@responsabil@observatii\', \'adaugare_task@\'+document.getElementsByName(\'capitol\')[0].value+\'@\'+document.getElementsByName(\'text\')[0].value+\'@\'+document.getElementsByName(\'urgenta\')[0].value+\'@\'+document.getElementsByName(\'complexitate\')[0].value+\'@\'+document.getElementsByName(\'impact\')[0].value+\'@\'+document.getElementsByName(\'incepere\')[0].value+\'@\'+document.getElementsByName(\'termen\')[0].value+\'@\'+document.getElementsByName(\'responsabil\')[0].value+\'@\'+document.getElementsByName(\'observatii\')[0].value, \'infodreapta\');"><img src="images/tick.png" border="0" alt="" /></a>&nbsp;&nbsp;&nbsp;';
	r.innerHTML+='<a href="javascript:void(0);" onClick="this.parentNode.parentNode.parentNode.deleteRow(this.parentNode.parentNode.sectionRowIndex);"><img src="images/cross.png" border="0" alt="Anulează" title="Anulează" /></a>';
}

function stergere_task(obj,id) {
	if (confirm("Sunteţi sigur că vreţi să ştergeţi acest task?")==true)
	{
	obj.parentNode.parentNode.parentNode.deleteRow(obj.parentNode.parentNode.sectionRowIndex);
	run_get('administrare_aplicatie', 'mode@id', 'stergere_task@'+id, 'infodreapta');
	}
}

function editare_task(obj,id) {
	run_get('administrare_aplicatie', 'mode@id', 'form_edit_task@'+id, 'infodreapta');
}

function finalizare_task(obj,id) {
	if (confirm("Sunteţi sigur că task-ul a fost finalizat?")==true)
	{
	//obj.parentNode.parentNode.parentNode.deleteRow(obj.parentNode.parentNode.sectionRowIndex);
	obj.parentNode.parentNode.bgColor='#92fe9f';
	actiuni=obj.parentNode;
	actiuni.innerHTML='<a href="javascript:void(0);" onClick="editare_task(this,\''+id+'\');"><img src="images/editare_cont.png" alt="Editare probă" title="Editare task" border="0" /></a>&nbsp;&nbsp;';
	actiuni.innerHTML+='<a href="javascript:void(0);" onClick="stergere_task(this,\''+id+'\');"><img src="images/delete.png" title="Şterge task" alt="Şterge task" border="0" /></a>';
	run_get('administrare_aplicatie', 'mode@id', 'finalizare_task@'+id, 'infodreapta');
	}
}

function add_apartinator(uid) {
	document.getElementsByName('numeapartinator')[0].value=getAjax('updater','mode@uid','numeapartinator@'+uid);
	document.getElementsByName('apartinator')[0].value=uid;
	$('#container-1 ul').tabsClick(6);
}

function refresh(page, interval) {
refr=setTimeout("location.href='"+page+"';", (interval*1000))
}

function disable_refresh() {
	
}

function retine_acord(obj,id)
{
	obj.setAttribute('disabled', 'disabled');
	run_get('updater','mode@id','retine_acord@'+id,'infodreapta');
}

function consult_curent(bifa)
{
if(bifa.checked==true) { var afiseaza=0; }
else { var afiseaza=1; }

	var obj=document.getElementsByTagName('tr');
	for(i=0;i<obj.length;i++)
		{
			if((obj[i].className=='ascunde' || obj[i].class=='ascunde') && afiseaza==0) obj[i].style.display='none';
			if((obj[i].className=='ascunde' || obj[i].class=='ascunde') && afiseaza==1) obj[i].style.display='';
		}
}

function finalizare_consultatie()
{
	var idprog=document.getElementsByName('idprog')[0].value;
	run_get('validare_consultatie','mod@idprog','validare@'+idprog,'infodreapta');
}

function adaugare_element(obj) {
	x=obj.parentNode.parentNode.parentNode.insertRow(obj.parentNode.parentNode.sectionRowIndex); 
	y=x.insertCell(0); 
	l=x.insertCell(1);
	l.setAttribute('class', 'center');
	l.setAttribute('className', 'center');
	y.innerHTML='<input type="text" name="nume" />';
	l.innerHTML='<a href="javascript:void(0);" onClick="run_get(\'liste_simple\', \'mode@nume\', \'adaugare_element@\'+document.getElementsByName(\'nume\')[0].value, \'infodreapta\');"><img src="images/tick.png" border="0" alt="" /></a>&nbsp;&nbsp;&nbsp;';
	l.innerHTML+='<a href="javascript:void(0);" onClick="this.parentNode.parentNode.parentNode.deleteRow(this.parentNode.parentNode.sectionRowIndex);"><img src="images/cross.png" border="0" alt="Anulează" title="Anulează" /></a>';
}

function stergere_element(obj,id,nume) {
	if (confirm("Sunteţi sigur că vreţi să ştergeţi specialitatea '"+nume+"'?")==true)
	{
	obj.parentNode.parentNode.parentNode.deleteRow(obj.parentNode.parentNode.sectionRowIndex);
	run_get('liste_simple', 'mode@id', 'stergere_element@'+id, 'infodreapta');
	}
}

function editare_element(obj,id) {
	run_get('liste_simple', 'mode@id', 'form_edit_element@'+id, 'infodreapta');
}

function hidethis(el, bool) {
	var BbiTza=0;
	var divs = document.getElementsByTagName("div");
	for(var i = 0; i < divs.length;i++) {
		if(divs[i].getAttribute('class') == "main-subcontent") {
			if(divs[i].style.display!="none") { BbiTza=1; divs[i].style.display="none"; } 
			else { divs[i].style.display="block"; BbiTza=0; }
		} 

		if(divs[i].getAttribute('class') == "main-content") {
			if(BbiTza==1) { divs[i].style.marginRight="0px"; }
			else { divs[i].style.marginRight="215px"; }
		}
	}
	if(BbiTza==1) { document.getElementById('hidethis').innerHTML='<a href="javascript:void(0);" onClick="hidethis(this, \'1\');" title="Arată bara ascunsă"><img src="images/application_side_contract.png" border="0" alt="" /></a>'; } else { document.getElementById('hidethis').innerHTML='<a href="javascript:void(0);" onClick="hidethis(this, \'1\');" title="Ascunde bara pentru mai mult spaţiu"><img src="images/application_side_expand.png" border="0" alt="" /></a>'; }
	if(bool == 1)
		run_get_noexec('updater','mode@bbitza','hide_right_panel@'+BbiTza,'infodreapta');
}

function closeEditare() {
document.body.removeChild(document.getElementById('edit_layer'));
}

function editare_documentatie(id) {
	var instanta=document.getElementById('edit_layer');
	if(instanta==null || instanta=='undefined' || instanta=='') {
		var edit_layer=document.createElement('div');
	
		edit_layer.setAttribute('class','edit_layer');
		edit_layer.setAttribute('id','edit_layer');
		edit_layer.setAttribute('className','edit_layer');
		edit_layer.innerHTML="<div class=\"body\"><div class=\"cont\" id=\"editare\"></div></div><div class=\"foot\"><a onClick=\"closeEditare();\" href=\"#\"></a></div>";
		document.body.appendChild(edit_layer);
		run_post_noexec('administrare_aplicatie', 'mode@id', 'editare_documentatie@'+id, 'editare');
	}
}

function closeEditare2() {
document.body.removeChild(document.getElementById('edit_layer2'));
}

function editare_referinta(id) {
	var instanta=document.getElementById('edit_layer2');
	if(instanta==null || instanta=='undefined' || instanta=='') {
		var edit_layer=document.createElement('div');
	
		edit_layer.setAttribute('class','edit_layer2');
		edit_layer.setAttribute('id','edit_layer2');
		edit_layer.setAttribute('className','edit_layer2');
		edit_layer.innerHTML="<div class=\"body\"><div class=\"cont\" id=\"editare\"></div></div><div class=\"foot\"><a onClick=\"closeEditare2();\" href=\"#\"></a></div>";
		document.body.appendChild(edit_layer);
		run_post_noexec('administrare_aplicatie', 'mode@id', 'editare_referinta@'+id, 'editare');
	}
}

function selectAll(ctrl) {
	var obj=document.getElementsByTagName('input');
	for(var i=0;i<obj.length;i++)
		{
			if(obj[i].type=="checkbox" && obj[i].className=="task")
				if(ctrl.checked==true)
					obj[i].checked=true;
				else
					obj[i].checked=false;
		}
}

function setAsSticky() {
	var obj=document.getElementsByTagName('input');
	var taskuri='';
	var j=0;
	for(var i=0;i<obj.length;i++)
		{
			if(obj[i].type=="checkbox" && obj[i].className=="task" && obj[i].checked==true) {
				taskuri+=obj[i].id.split('task')[1]+'.';
				j++;
			}
		}
	if(j!=0)
		run_get('administrare_aplicatie', 'mode@taskuri', 'setAsSticky@'+taskuri, 'infodreapta');
	else
		alert('Nu aţi selectat niciun task!');
}

function DisableSticky() {
	var obj=document.getElementsByTagName('input');
	var taskuri='';
	var j=0;
	for(var i=0;i<obj.length;i++)
		{
			if(obj[i].type=="checkbox" && obj[i].className=="task" && obj[i].checked==true) {
				taskuri+=obj[i].id.split('task')[1]+'.';
				j++;
			}
		}
	if(j!=0)
		run_get('administrare_aplicatie', 'mode@taskuri', 'DisableSticky@'+taskuri, 'infodreapta');
	else
		alert('Nu aţi selectat niciun task!');
}

function check(id, select) {
	var obj = document.getElementsByTagName('input');
	var rez = '';
	for (var i = 0; i < obj.length; i++) {
		if (obj[i].type == "checkbox" && obj[i].className.split(' ')[0] == "nivel_acces") {
			if (obj[i].id.split('.')[obj[i].id.split('.').length-1] == id.split('.')[id.split('.').length-1]) {
				if(select == 0) {
					obj[i].checked = obj[i].checked ? false : true;
				}
			}
			else {
				var aux = obj[i].id.split(id)[1];
				if (aux != undefined)
					obj[i].checked = document.getElementById(id).checked ? true : false;
			}
			if (obj[i].checked) {
				if (rez != '')
					rez += '!';
				rez += obj[i].id.split('.')[obj[i].id.split('.').length-1];
			}
		}
	}
	document.getElementsByName('rez_nivel_acces')[0].value = rez;
}

function checkrp(cb, eid) {
	var obj = document.getElementsByTagName('input');
	for (var i = 0; i < obj.length; i++) {
		if (obj[i].name == 'node'+eid) {
			if (cb == '[object HTMLSpanElement]') {
				obj[i].checked = obj[i].checked ? false : true;
			}
		}
		if (obj[i].id.split('.')[0] == eid) {
			obj[i].checked = document.getElementsByName('node'+eid)[0].checked;
			checkrp(obj[i],obj[i].id.split('.')[1]);
		}
	}
	if (!$('#pas3').is(':visible')) $('#pas3').show();
}

function meniu_posturi_lucru() {
	expand('nivel_acces');
}

function schimba_post_lucru(id_postlucru) {
	run_get('updater', 'mode@id_postlucru', 'schimba_post_lucru@'+id_postlucru, 'infodreapta');
}

function vizualizare_fisa(id_pacient) {
	if (confirm("Sunteti sigur(a) ca vreti sa consultati fisa pacientului?"))
		run_get('modificare_programare', 'mode@id_pacient', 'vizualizare_fisa@'+id_pacient, 'infodreapta');
}

function meniu_roluri() {
	expand('meniu_roluri');
}

function schimba_rol(id_rol) {
	run_get('updater', 'mode@id_rol', 'schimba_rol@'+id_rol, 'infodreapta');
}

function howToPrint(raport, cod, id_postlucru)
{
	var document = createPDF(raport, cod);
	var avem = getAjax('imprimante', 'mode@id_postlucru', 'avem_imprimanta_implicita@'+id_postlucru, 'infodreapta');
	if(avem == "da") {
		printare(document);
	}
	else {
		print();
	}
}

function createPDF(formular, cod_persoana)
{
	var fisierPDF = getAjax('createPDF', 'mode@formular@cod_persoana', 'creazaPDF@'+formular+'@'+cod_persoana);
	return fisierPDF;
}

Function.prototype.defaults = function()
{
  var _f = this;
  var _a = Array(_f.length-arguments.length).concat(
    Array.prototype.slice.apply(arguments));
  return function()
  {
    return _f.apply(_f, Array.prototype.slice.apply(arguments).concat(
      _a.slice(arguments.length, _a.length)));
  }
}

var printare = function(documentName,copiesNumber,orientation,mediaSizeName)
{
	run_get_noexec('printare', 'documentName@copiesNumber@orientation@mediaSizeName', documentName+'@'+copiesNumber+'@'+orientation+'@'+mediaSizeName, 'infodreapta');
}.defaults('','2','portrait','iso-a4');