var selectedList;
var availableList;

function delAttribute(){
   availableList = document.getElementById("spec1");
   selectedList = document.getElementById("spec2");
   
   var selIndex = selectedList.selectedIndex;
   if(selIndex < 0)
      return;
   var rstr = document.getElementById("spec").value;
   
     
   document.getElementById("spec").value=rstr.replace(','+selectedList.options.item(selIndex).value+',',',');
   
   availableList.appendChild(
      selectedList.options.item(selIndex))
   selectNone(selectedList,availableList);
   setSize(availableList,selectedList);
   
}

function addAttribute(){
   availableList = document.getElementById("spec1");
   selectedList = document.getElementById("spec2");

   var addIndex = availableList.selectedIndex;
   if(addIndex < 0)
      return;

   document.getElementById("spec").value=document.getElementById("spec").value+availableList.options.item(addIndex).value+',';      

   selectedList.appendChild( 
      availableList.options.item(addIndex));
   
      
   selectNone(selectedList,availableList);
   setSize(selectedList,availableList);
}



function listvk(){

  var link='';
  link='vklist.php?grad='+document.getElementById('grad').value+'&spec='+document.getElementById('spec').value;
  window.location.href=link;  
}

function workdays(id){
  idd=document.getElementById('vid').value;
  
  if (idd==0){
    document.getElementById('days').style.display="block";
    document.getElementById('odd').style.display="none";
  }else{
    document.getElementById('days').style.display="none";
    document.getElementById('odd').style.display="block";
  }  
    
    
    
    
}

String.prototype.splitCSV1 = function(sep) {
  for (var foo = this.split(sep = sep || "|"), x = foo.length - 1, tl; x >= 0; x--) {
    if (foo[x].replace(/"\s+$/, '"').charAt(foo[x].length - 1) == '"') {
      if ((tl = foo[x].replace(/^\s+"/, '"')).length > 1 && tl.charAt(0) == '"') {
        foo[x] = foo[x].replace(/^\s*"|"\s*$/g, '').replace(/""/g, '"');
      } else if (x) {
        foo.splice(x - 1, 2, [foo[x - 1], foo[x]].join(sep));
      } else foo = foo.shift().split(sep).concat(foo);
    } else foo[x].replace(/""/g, '"');
  } return foo;
};

String.prototype.splitCSV2 = function(sep) {
  for (var foo = this.split(sep = sep || ";"), x = foo.length - 1, tl; x >= 0; x--) {
    if (foo[x].replace(/"\s+$/, '"').charAt(foo[x].length - 1) == '"') {
      if ((tl = foo[x].replace(/^\s+"/, '"')).length > 1 && tl.charAt(0) == '"') {
        foo[x] = foo[x].replace(/^\s*"|"\s*$/g, '').replace(/""/g, '"');
      } else if (x) {
        foo.splice(x - 1, 2, [foo[x - 1], foo[x]].join(sep));
      } else foo = foo.shift().split(sep).concat(foo);
    } else foo[x].replace(/""/g, '"');
  } return foo;
};


function showcitylz(nlz){

  for(i=1;i<20;i++){
  if (typeof(document.getElementById("mcity"+i.toString())) != 'undefined' && document.getElementById("mcity"+i.toString()) != null)
  {
        document.getElementById("mcity"+i.toString()).style.visibility="hidden";
        document.getElementById(i.toString()).style.backgroundColor="white";
  }
  }

  if (typeof(document.getElementById("mcity"+nlz)) != 'undefined' && document.getElementById("mcity"+nlz) != null)
  {
        document.getElementById("mcity"+nlz).style.visibility="visible";
        document.getElementById(nlz).style.backgroundColor="#FFCC00";
        getlz(nlz);
  }
}

function rateProduct(rating,productID,ID)  {
		//remotos = new datosServidor;
		//nt = remotos.enviar('update.php?rating='+rating+'&productID='+productID);
		
		rating2 = (rating * 25);
		if (rating2==0){rating2=1} else{rating2=rating2-2};
		
	
		document.getElementById('current-rating'+ID).style.width = rating2+'px';
		document.getElementById('rating'+ID).value = rating;
		//document.getElementById('ratelinks').style.display = 'none';
		//document.getElementById('ratingtext').innerHTML = 'Thank you for your vote!';
		
	
		
}



function maps(){
cind=document.getElementById('citym').selectedIndex;	
cvalue=document.getElementById('citym').options[cind].value;

window.location='maps_'+cvalue;
}

function addsm(sm){
if (sm==1){
document.getElementById("mnenie").value=document.getElementById("mnenie").value+':)';
}

if (sm==2){
document.getElementById("mnenie").value=document.getElementById("mnenie").value+":'(";
}
if (sm==3){
document.getElementById("mnenie").value=document.getElementById("mnenie").value+':(';
}
if (sm==4){
document.getElementById("mnenie").value=document.getElementById("mnenie").value+':P';
}


}



function newpreview(sm){
if (sm.id=='file'){
document.getElementById(sm.id+"div").src=sm.value;	
}else{
document.getElementById(sm.id+"div").innerHTML=sm.value;

}
}


// holds an instance of XMLHttpRequest
var xmlHttp = createXmlHttpRequestObject();
// creates an XMLHttpRequest instance

function createXmlHttpRequestObject()
{
// will store the reference to the XMLHttpRequest object
var xmlHttp;
// this should work for all browsers except IE6 and older
try
{
// try to create XMLHttpRequest object
xmlHttp = new XMLHttpRequest();
}
catch(e)
{
// assume IE6 or older
var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
"MSXML2.XMLHTTP.5.0",
"MSXML2.XMLHTTP.4.0",
"MSXML2.XMLHTTP.3.0",
"MSXML2.XMLHTTP",
"Microsoft.XMLHTTP");
// try every prog id until one works
for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++)
{
try
{
// try to create XMLHttpRequest object
xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
}
catch (e) {}
}
}
// return the created object or display an error message
if (!xmlHttp)
alert("Error creating the XMLHttpRequest object.");
else
return xmlHttp;
}

function changevid(vl){
if (vl==0){
document.getElementById("uinl").style.display = 'none';
document.getElementById("divuinl").innerHTML='';
}else{
document.getElementById("uinl").style.display = 'block';
document.getElementById("divuinl").innerHTML='УИНЛ';
}

}


function checkuname(vl){
// only continue if xmlHttp isn't void
if (xmlHttp)
{
// try to connect to the server
try
{
// get the two values entered by the user
var uname = vl;

var params = "uname=" + vl;
// initiate the asynchronous HTTP request
xmlHttp.open("GET", "checkuser.php?" + params, true);
xmlHttp.onreadystatechange = handleRequestStateChange1;
xmlHttp.send(null);
}
// display the error in case of failure
catch (e)
{
alert("Can't connect to server:\n" + e.toString());
}
}
}
// function called when the state of the HTTP request changes
function handleRequestStateChange1()
{
// when readyState is 4, we are ready to read the server response
if (xmlHttp.readyState == 4)
{
// continue only if HTTP status is "OK"
if (xmlHttp.status == 200)
{
try
{
// do something with the response from the server
//handleServerResponse();
myDiv = document.getElementById("divuname");
myDiv.innerHTML = xmlHttp.responseText;

}
catch(e)
{
// display error message
alert("Error reading the response: " + e.toString());
}
}
else
{
// display status message
alert("There was a problem retrieving the data:\n" +
xmlHttp.statusText);
}
}



}







function checkemail(vl){
// only continue if xmlHttp isn't void
if (xmlHttp)
{
// try to connect to the server
try
{
// get the two values entered by the user
var uname = vl;

var params = "email=" + vl;
// initiate the asynchronous HTTP request
xmlHttp.open("GET", "checkemail.php?" + params, true);
xmlHttp.onreadystatechange = handleRequestStateChange2;
xmlHttp.send(null);
}
// display the error in case of failure
catch (e)
{
alert("Can't connect to server:\n" + e.toString());
}
}
}
// function called when the state of the HTTP request changes
function handleRequestStateChange2()
{
// when readyState is 4, we are ready to read the server response
if (xmlHttp.readyState == 4)
{
// continue only if HTTP status is "OK"
if (xmlHttp.status == 200)
{
try
{
// do something with the response from the server
//handleServerResponse();
myDiv = document.getElementById("divemail");
myDiv.innerHTML = xmlHttp.responseText;

}
catch(e)
{
// display error message
alert("Error reading the response: " + e.toString());
}
}
else
{
// display status message
alert("There was a problem retrieving the data:\n" +
xmlHttp.statusText);
}
}



}













// read a file from the server
function process()
{
// only continue if xmlHttp isn't void
if (xmlHttp)
{
// try to connect to the server
try
{
// get the two values entered by the user
var uname = document.getElementById("uname").value;
var pass = document.getElementById("pass").value;
//var secondNumber = document.getElementById("secondNumber").value;
// create the params string

var params = "uname=" + uname+"&pass="+pass;
// initiate the asynchronous HTTP request
xmlHttp.open("GET", "loginuser.php?" + params, true);
xmlHttp.onreadystatechange = handleRequestStateChange;
xmlHttp.send(null);
}
// display the error in case of failure
catch (e)
{
alert("Can't connect to server:\n" + e.toString());
}
}
}
// function called when the state of the HTTP request changes
function handleRequestStateChange()
{
// when readyState is 4, we are ready to read the server response
if (xmlHttp.readyState == 4)
{
// continue only if HTTP status is "OK"
if (xmlHttp.status == 200)
{

// do something with the response from the server
//handleServerResponse();
myDiv = document.getElementById("divlogin");
var login = xmlHttp.responseText;

if (login.search('Фамилия')>-1){
window.location.reload();
}else{
myDiv.innerHTML = xmlHttp.responseText;
}

var str=myDiv.innerHTML;
var pos=str.indexOf(">Профил</");
if (pos>=0)
{
  if (typeof(document.getElementById("L_MARK")) != 'undefined' && document.getElementById("L_MARK") != null)
  {
        document.getElementById("L_MARK").innerHTML='<input id="submit" type="submit" name="submit" value="Запис">';
        window.scrollTo(0,25);
  }

  if (typeof(document.getElementById("L_ADDLZ")) != 'undefined' && document.getElementById("L_ADDLZ") != null)
  {
        document.getElementById("L_ADDLZ").innerHTML='<input type="submit" value="Добави" style="width:145px">';
        window.scrollTo(0,25);
  }

  
  if (typeof(document.getElementById("newmark")) != 'undefined' && document.getElementById("newmark") != null)
  {
        document.getElementById("newmark").innerHTML='<input type="button" onclick="document.getElementById('+String.fromCharCode(39)+'rnd_container'+String.fromCharCode(39)+').style.display='+String.fromCharCode(39)+'block'+String.fromCharCode(39)+';"  style="font-weight:700" value="Ново оценяване"/>';
        window.scrollTo(0,25);
  }
}


}
else
{
// display status message
//alert("There was a problem retrieving the data:\n" +
//xmlHttp.statusText);
}
}
}
// handles the response received from the server
function handleServerResponse()
{
// retrieve the server's response packaged as an XML DOM object
var xmlResponse = xmlHttp.responseXML;
// catching potential errors with IE and Opera
if (!xmlResponse || !xmlResponse.documentElement)
throw("Invalid XML structure:\n" + xmlHttp.responseText);
// catching potential errors with Firefox
var rootNodeName = xmlResponse.documentElement.nodeName;
if (rootNodeName == "parsererror")
throw("Invalid XML structure:\n" + xmlHttp.responseText);
// getting the root element (the document element)
xmlRoot = xmlResponse.documentElement;
// testing that we received the XML document we expect
if (rootNodeName != "response" || !xmlRoot.firstChild)
throw("Invalid XML structure:\n" + xmlHttp.responseText);
// the value we need to display is the child of the root <response> element
responseText = xmlRoot.firstChild.data;
// display the user message
myDiv = document.getElementById("myDivElement");
myDiv.innerHTML = "Server says the answer is: " + responseText;
}



//search LZ


function searchlz()
{
// only continue if xmlHttp isn't void
if (xmlHttp)
{
// try to connect to the server
try
{
// get the two values entered by the user
var type = document.getElementById("typess").value;
var city = document.getElementById("citys").value;
var name = document.getElementById("names").value;
var adres = document.getElementById("adres").value;
//var secondNumber = document.getElementById("secondNumber").value;
// create the params string

var params = "T=" + type+"&C="+city+"&N="+name+"&A="+adres;
// initiate the asynchronous HTTP request
xmlHttp.open("GET", "searchlz.php?" + params, true);
xmlHttp.onreadystatechange = handleRequestStateChangelz;
xmlHttp.send(null);
}
// display the error in case of failure
catch (e)
{
alert("Can't connect to server:\n" + e.toString());
}
}
}
// function called when the state of the HTTP request changes
function handleRequestStateChangelz()
{
// when readyState is 4, we are ready to read the server response
if (xmlHttp.readyState == 4)
{
// continue only if HTTP status is "OK"
if (xmlHttp.status == 200)
{

// do something with the response from the server
//handleServerResponse();
myDiv = document.getElementById("searchrez");
myDiv.innerHTML = xmlHttp.responseText;

}
else
{
// display status message
//alert("There was a problem retrieving the data:\n" +
//xmlHttp.statusText);
}
}
}

function searchlekars()
{
// only continue if xmlHttp isn't void
if (xmlHttp)
{
// try to connect to the server
try
{
// get the two values entered by the user
var type = document.getElementById("typess").value;
var city = document.getElementById("citys").value;
var name = document.getElementById("names").value;
var adres = document.getElementById("adres").value;
//var secondNumber = document.getElementById("secondNumber").value;
// create the params string

var params = "T=" + type+"&C="+city+"&N="+name+"&A="+adres;
// initiate the asynchronous HTTP request

xmlHttp.open("GET", "searchlekars.php?" + params, true);
xmlHttp.onreadystatechange = handleRequestStateChangelekars;
xmlHttp.send(null);
}
// display the error in case of failure
catch (e)
{
alert("Can't connect to server:\n" + e.toString());
}
}
}
// function called when the state of the HTTP request changes
function handleRequestStateChangelekars()
{
// when readyState is 4, we are ready to read the server response
if (xmlHttp.readyState == 4)
{
// continue only if HTTP status is "OK"
if (xmlHttp.status == 200)
{

// do something with the response from the server
//handleServerResponse();
myDiv = document.getElementById("searchrez");
myDiv.innerHTML = xmlHttp.responseText;

}
else
{
// display status message
//alert("There was a problem retrieving the data:\n" +
//xmlHttp.statusText);
}
}
}



function getdrugs(drug)
{
// only continue if xmlHttp isn't void
if (xmlHttp)
{
// try to connect to the server
try
{
var type;

type=document.getElementById('types').selectedIndex;
type=document.getElementById('types').options[type].value;

var params = "drug=" + drug+"&type=" + type;
// initiate the asynchronous HTTP request
xmlHttp.open("GET", "searchdrugs.php?" + params, true);
xmlHttp.onreadystatechange = handleRequestStateChangedrug;
xmlHttp.send(null);
}
// display the error in case of failure
catch (e)
{
alert("Can't connect to server:\n" + e.toString());
}
}
}
// function called when the state of the HTTP request changes
function handleRequestStateChangedrug()
{
// when readyState is 4, we are ready to read the server response
if (xmlHttp.readyState == 4)
{
// continue only if HTTP status is "OK"
if (xmlHttp.status == 200)
{

// do something with the response from the server
//handleServerResponse();
myDiv = document.getElementById("drugs");
myDiv.innerHTML = xmlHttp.responseText;

}
else
{
// display status message
//alert("There was a problem retrieving the data:\n" +
//xmlHttp.statusText);
}
}
}

//klistlz
function getlz(type)
{
// only continue if xmlHttp isn't void
if (xmlHttp)
{
// try to connect to the server
try
{
var city=document.getElementById("mcity"+type.toString()).value;
var params = "t=" + type+"&c="+city;
// initiate the asynchronous HTTP request
xmlHttp.open("GET", "searchlzlist.php?" + params, true);
xmlHttp.onreadystatechange = handleRequestStateChangelz45;
xmlHttp.send(null);
}
// display the error in case of failure
catch (e)
{
alert("Can't connect to server:\n" + e.toString());
}
}
}
// function called when the state of the HTTP request changes
function handleRequestStateChangelz45()
{
// when readyState is 4, we are ready to read the server response
if (xmlHttp.readyState == 4)
{
// continue only if HTTP status is "OK"
if (xmlHttp.status == 200)
{

// do something with the response from the server
//handleServerResponse();
myDiv = document.getElementById("listlz");
myDiv.innerHTML = xmlHttp.responseText;

}
else
{
// display status message
//alert("There was a problem retrieving the data:\n" +
//xmlHttp.statusText);
}
}
}





















function locupd(l1,l2,id)
{
//var xmlHttp1 = createXmlHttpRequestObject();
// only continue if xmlHttp isn't void
if (xmlHttp)
{
// try to connect to the server
try
{

var params = "L1=" +l1+"&L2="+l2+"&ID="+id;
// initiate the asynchronous HTTP request
xmlHttp.open("GET", "loc_upd.php?" + params, true);

xmlHttp.onreadystatechange = handleRequestStateChangeloc;
xmlHttp.send(null);
}
// display the error in case of failure
catch (e)
{
alert("Can't connect to server:\n" + e.toString());
}
}
}
// function called when the state of the HTTP request changes
function handleRequestStateChangeloc()
{
// when readyState is 4, we are ready to read the server response
if (xmlHttp.readyState == 4)
{
// continue only if HTTP status is "OK"
if (xmlHttp.status == 200)
{
myDiv = document.getElementById("autoloc");
myDiv.innerHTML = myDiv.innerHTML+xmlHttp.responseText;
}
else
{
// display status message
//alert("There was a problem retrieving the data:\n" +
//xmlHttp.statusText);
}
}
}





function adresmap(adr)
{
//var xmlHttpT = createXmlHttpRequestObject();
// only continue if xmlHttp isn't void
if (xmlHttp)
{
// try to connect to the server
//try
//{
//alert(adr);
xmlHttp.abort();
xmlHttp.async = false;
xmlHttp.open('GET', 'http://google.com/');
//xmlHttp.onreadystatechange = handleRequestStateChangemap12;
xmlHttp.send(null);
//}
// display the error in case of failure
//catch (e)
//{
//alert("Can't connect to server:\n" + e.toString());
//}
}
}
// function called when the state of the HTTP request changes
function handleRequestStateChangemap12()
{

// when readyState is 4, we are ready to read the server response
if (xmlHttp.readyState == 4)
{
// continue only if HTTP status is "OK"
if (xmlHttp.status == 200)
{
alert(xmlHttp.responseText);
//myDiv = document.getElementById("autoloc");
//myDiv.innerHTML = myDiv.innerHTML+xmlHttp.responseText;

}
else
{
// display status message
//alert("There was a problem retrieving the data:\n" +
//xmlHttp.statusText);
}
}
}


var v_old;
var v_lekar;

// virtual kab
var v_oldname;

function handleRequestStatevirtualcab()
{

if (xmlHttp.readyState == 4)
{

if (xmlHttp.status == 200)
{
myDiv = document.getElementById("private_content");
myDiv.innerHTML = xmlHttp.responseText;

if (v_oldname=='ul_editdays'){
   if (document.getElementById('work_l1').value>0){
     initialize_vk(0,document.getElementById('work_l1').value,document.getElementById('work_l2').value);    
   
   }}
if (v_oldname=='ul_newdays'){
     initialize_vk(1,0,0);    
}

if (v_oldname=='ul_setup'){
uploadpicture_vk('ul_savesetuppic.php',v_lekar);
}
}
else
{
}
}
}

function virtualcab(name,params,lekar)
{
if (xmlHttp)
{
try
{
myDiv = document.getElementById("private_content");
v_oldname= name;
v_lekar=lekar;
myDiv.innerHTML = '<img style="margin-left:320px;margin-top:220px" src="images/wait.gif" width="64" height="44" />';


//alert(name + ".php"  + "?lekar="+ lekar + params);
xmlHttp.open("GET",name + ".php"  + "?lekar="+ lekar + params, true);
xmlHttp.onreadystatechange = handleRequestStatevirtualcab;
xmlHttp.send(null);
}
catch (e)
{
alert("Can't connect to server:\n" + e.toString());
}
}
}

var v_id;

function handleRequestStateSavecab()
{

if (xmlHttp.readyState == 4)
{

if (xmlHttp.status == 200)
{
//myDiv = document.getElementById("private_content");
//myDiv.innerHTML = xmlHttp.responseText;
virtualcab(v_old,'',v_lekar);
}
else
{
}
}
}

function savevirtualcab(name,old,id,lekar,param1,param2,param3,param4,param5,param6,file)
{
if (xmlHttp)
{
try
{
v_old=old;
v_lekar=lekar;
v_id=id;
params='';  
if ((name!='ul_saveworkdays')&&(name!='ul_savesetup')){  
if (document.getElementById(param1+id)!=null){
   vl=document.getElementById(param1+id).value;
   params=params+'&'+param1+'='+encodeURIComponent(vl); 
}
if (document.getElementById(param3+id)!=null){
   vl=document.getElementById(param3+id).value;
   params=params+'&'+param3+'='+encodeURIComponent(vl); 
}


if (param2!='FCK'){
if (document.getElementById(param2+id)!=null){
   vl=document.getElementById(param2+id).value;
   params=params+'&'+param2+'='+encodeURIComponent(vl); 
}}
else{
   vl=FCKeditorAPI.GetInstance('1').GetHTML(true);
   params=params+'&'+'source='+encodeURIComponent(vl);
   
}

if (document.getElementById(param4+id)!=null){
   vl=document.getElementById(param4+id).value;
   params=params+'&'+param4+'='+encodeURIComponent(vl); 
}
if (document.getElementById(param5+id)!=null){
   vl=document.getElementById(param5+id).value;
   params=params+'&'+param5+'='+encodeURIComponent(vl); 
}
if (document.getElementById(param6+id)!=null){
   vl=document.getElementById(param6+id).value;
   params=params+'&'+param6+'='+encodeURIComponent(vl); 
}

if (document.getElementById(file)!=null){
   v_file=document.getElementById(file).innerHTML;
   params=params+'&file='+encodeURIComponent(v_file);

}
}
else{

    var elms = document.getElementById('savedays').elements;
    for(var i = 0, maxI = elms.length; i < maxI; ++i) {
    
    var elm = elms[i];
        switch(elm.type) {
          case "text":params=params+'&'+elm.id+'='+encodeURIComponent(elm.value);break;
          case "hidden":params=params+'&'+elm.id+'='+encodeURIComponent(elm.value);break;
          case "textarea":params=params+'&'+elm.id+'='+encodeURIComponent(elm.value);break;
          case "radio":params=params+'&'+elm.id+'='+encodeURIComponent(elm.value);break;
          case "select-one":params=params+'&'+elm.id+'='+encodeURIComponent(elm.value);break;
          case "select-multiple":params=params+'&'+elm.id+'='+encodeURIComponent(elm.value);break;
          case "checkbox":params=params+'&'+elm.id+'='+elm.checked;break;
        }
    

    }    

}

params = "id="+ id + params;

xmlHttp.open("POST",name + ".php", true);

xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=windows-1251");
//xmlHttp.setRequestHeader("Accept-Charset", "windows-1251"); 
xmlHttp.setRequestHeader("Content-length", params.length);
xmlHttp.setRequestHeader("Connection", "close");

xmlHttp.onreadystatechange = handleRequestStateSavecab;
xmlHttp.send(params);



}
catch (e)
{
alert("Can't connect to server:\n" + e.toString());
}
}
}








function handleRequestStateDeletecab()
{

if (xmlHttp.readyState == 4)
{

if (xmlHttp.status == 200)
{
virtualcab(v_old,'',v_lekar);
}
else
{
}
}
}

function deletevirtualcab(name,old,id,lekar,temp)
{
if (xmlHttp)
{
try
{
v_old=old;
v_lekar=lekar;

xmlHttp.open("GET",name + ".php"  + "?id="+ id+'&file='+temp, true);
xmlHttp.onreadystatechange = handleRequestStateDeletecab;
xmlHttp.send(null);

}
catch (e)
{
alert("Can't connect to server:\n" + e.toString());
}
}
}









function handleRequestStateNewcab()
{

if (xmlHttp.readyState == 4)
{

if (xmlHttp.status == 200)
{
if (v_old==''){
myDiv = document.getElementById("private_content");
myDiv.innerHTML = xmlHttp.responseText;
}else{    
virtualcab(v_old,'',v_lekar);
}
}
else
{
}
}
}

function newvirtualcab(name,old,lekar,user,param1,param2,param3,param4,param5,param6,file)
{
if (xmlHttp)
{
try
{
v_old=old;
v_lekar=lekar;
params='';    
if (name!='ul_newsavedays'){
if (document.getElementById(param1+'0')!=null){
   vl=document.getElementById(param1+'0').value;
   params=params+'&'+param1+'='+encodeURIComponent(vl); 
}

if (param2!='FCK'){
if (document.getElementById(param2+'0')!=null){
   vl=document.getElementById(param2+'0').value;
   params=params+'&'+param2+'='+encodeURIComponent(vl); 
}}
else{
   vl=FCKeditorAPI.GetInstance('1').GetHTML(true);
   params=params+'&'+'source='+encodeURIComponent(vl);
   
}

if (document.getElementById(param3+'0')!=null){
   
   vl=document.getElementById(param3+'0').value;
   params=params+'&'+param3+'='+encodeURIComponent(vl); 
}
if (document.getElementById(param4+'0')!=null){
   vl=document.getElementById(param4+'0').value;
   params=params+'&'+param4+'='+encodeURIComponent(vl); 
}
if (document.getElementById(param5+'0')!=null){
   vl=document.getElementById(param5+'0').value;
   params=params+'&'+param5+'='+encodeURIComponent(vl); 
}
if (document.getElementById(param6+'0')!=null){
   vl=document.getElementById(param6+'0').value;
   params=params+'&'+param6+'='+encodeURIComponent(vl); 
}

if (document.getElementById(file)!=null){
   v_file=document.getElementById(file).innerHTML;
   params=params+'&file='+encodeURIComponent(v_file);

}

}
else{

    var elms = document.getElementById('savedays').elements;
    for(var i = 0, maxI = elms.length; i < maxI; ++i) {
    
    var elm = elms[i];
        switch(elm.type) {
          case "text":params=params+'&'+elm.id+'='+encodeURIComponent(elm.value);break;
          case "hidden":params=params+'&'+elm.id+'='+encodeURIComponent(elm.value);break;
          case "textarea":params=params+'&'+elm.id+'='+encodeURIComponent(elm.value);break;
          case "radio":params=params+'&'+elm.id+'='+encodeURIComponent(elm.value);break;
          case "select-one":params=params+'&'+elm.id+'='+encodeURIComponent(elm.value);break;
          case "select-multiple":params=params+'&'+elm.id+'='+encodeURIComponent(elm.value);break;
          case "checkbox":params=params+'&'+elm.id+'='+elm.checked;break;
        }
    

    }    

}


params = "lekar="+lekar+'&user='+user + params;



xmlHttp.open("POST",name + ".php", true);

xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;");
//xmlHttp.setRequestHeader("Accept-Charset", "windows-1251"); 
xmlHttp.setRequestHeader("Content-length", params.length);
xmlHttp.setRequestHeader("Connection", "close");

xmlHttp.onreadystatechange = handleRequestStateNewcab;

xmlHttp.send(params);



}
catch (e)
{
alert("Can't connect to server:\n" + e.toString());
}
}
}



function uploadfile(link){
    
    new AjaxUpload('#button3', {
		action: link, 
		name: 'userfile',
		onComplete : function(file){
			myDiv = document.getElementById("upfiles");
            myDiv.innerHTML = file;
            myDiv.style.color = "green";
            
            document.getElementById("clr").style.visibility="visible";
                       
		},
    	onSubmit : function(file , ext){
                if (ext && /^(doc|pdf|docx|DOC|PDF|DOCX)$/.test(ext)){
                    
                    myDiv = document.getElementById("upfiles");
                    myDiv.innerHTML = 'Качване на '+file;
                    myDiv.style.color = "darkorange";
				} else {					
		        	myDiv = document.getElementById("upfiles");
                    myDiv.innerHTML = 'Разрешени за качване са само файлове (DOC, PDF, DOCX)';
                    myDiv.style.color = "red";
					return false;				
				}		
			}
        	
	});     
  
}



function uploadpicture(link){
    
    new AjaxUpload('#button3', {
		action: link, 
		name: 'userfile',
		onComplete : function(file){
			myDiv = document.getElementById("upfiles");
            myDiv.innerHTML = file;
            myDiv.style.color = "green";
            
            document.getElementById("clr").style.visibility="visible";
                       
		},
    	onSubmit : function(file , ext){
                if (ext && /^(jpg|JPG)$/.test(ext)){
                    
                    myDiv = document.getElementById("upfiles");
                    myDiv.innerHTML = 'Качване на '+file;
                    myDiv.style.color = "darkorange";
				} else {					
		        	myDiv = document.getElementById("upfiles");
                    myDiv.innerHTML = 'Разрешени за качване са само файлове (JPG)';
                    myDiv.style.color = "red";
					return false;				
				}		
			}
        	
	});     
  
}

function uploadpicture_vk(link,lekar){
    
    new AjaxUpload('#button3', {
		action: link, 
		name: 'userfile',
		onComplete : function(file){
            alert('Снимката ще бъде одобрена с рамките на един ден.');
            virtualcab('ul_setup','',lekar);
            //document.getElementById("clr").style.visibility="visible";
                       
		},
    	onSubmit : function(file , ext){
                if (ext && /^(jpg|JPG)$/.test(ext)){
                    
                    myDiv = document.getElementById("upfiles");
                    //myDiv.innerHTML = 'Качване на '+file;
                    myDiv.style.color = "darkorange";
				} else {					
		        	myDiv = document.getElementById("upfiles");
                    //myDiv.innerHTML = 'Разрешени за качване са само файлове (JPG)';
                    myDiv.style.color = "red";
					return false;				
				}		
			}
        	
	});     
  
}


var v_replyid;

function post_reply_state()
{

if (xmlHttp.readyState == 4)
{

if (xmlHttp.status == 200)
{
myDiv = document.getElementById("reply_"+v_replyid);
myDiv.innerHTML = xmlHttp.responseText;
}
else
{
}
}
}

function post_reply(id)
{
if (xmlHttp)
{
try
{
    
myDiv = document.getElementById("cont_"+id);
myDiv.style.display="block";
    
v_replyid=id;
xmlHttp.open("GET","get_reply.php"  + "?id="+ id, true);
xmlHttp.onreadystatechange = post_reply_state;
xmlHttp.send(null);
}
catch (e)
{
//alert("Can't connect to server:\n" + e.toString());
}
}
}









function ins_reply_state()
{

if (xmlHttp.readyState == 4)
{

if (xmlHttp.status == 200)
{
    
post_reply(v_replyid);
}
else
{
}
}
}


function ins_reply(id)
{
if (xmlHttp)
{
try
{

var elms = document.getElementById('content'+id).value;
 



params = "id="+id+"&content="+encodeURIComponent(elms);
  
v_replyid=id;
xmlHttp.open("POST","ins_reply.php", true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;");
xmlHttp.onreadystatechange = ins_reply_state; 
xmlHttp.setRequestHeader("Content-length", params.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(params);
}
catch (e)
{
//alert("Can't connect to server:\n" + e.toString());
}
}
}


