﻿function selectAllSimptoms(SELECT)
{ 
	i = 0;
    while(document.getElementById('bolest_simptom'+i)) {         
		 document.getElementById('bolest_simptom'+i).checked = SELECT;           
         i++;
    }
}

function selectAllLekarstvaSimptoms(SELECT)
{ 
	  i = 0;
      while(document.getElementById('lekarstvo_simptom'+i)) {         
		 document.getElementById('lekarstvo_simptom'+i).checked = SELECT;           
         i++;
      }
 
}


var defsize=16;
function newsFsize(inc){
	//var objText = document.getElementById("newsDiv");
	var objTextBody = document.getElementById("newsBodyDiv");
	var objTextComment = document.getElementById("readComments");
	defsize = defsize - (-inc);
	fsz=defsize;
	var nsz;
	nsz = defsize
	if(nsz<6){
		nsz = 6;
		defsize=6;
	}
	if(nsz>32){
		nsz = 32;
		defsize=32;
	}
	nsz=nsz+"px";
	
	//objText.style.fontSize = nsz;
	objTextBody.style.fontSize = nsz;
	objTextComment.style.fontSize = nsz;
}
function newsFsize_d(){
	defsize=16;
	//var objText = document.getElementById("newsDiv");
	var objTextBody = document.getElementById("newsBodyDiv");
	var objTextComment = document.getElementById("readComments");
	//objText.style.fontSize = "12px";
	objTextBody.style.fontSize = "16px";
	objTextComment.style.fontSize = "16px";
}




function postsFsize(inc){
	//var objText = document.getElementById("postDiv");
	var objTextBody = document.getElementById("postBodyDiv");
	var objTextComment = document.getElementById("readComments");
	defsize = defsize - (-inc);
	fsz=defsize;
	var nsz;
	nsz = defsize
	if(nsz<6){
		nsz = 6;
		defsize=6;
	}
	if(nsz>32){
		nsz = 32;
		defsize=32;
	}
	nsz=nsz+"px";
	
	//objText.style.fontSize = nsz;
	objTextBody.style.fontSize = nsz;
	objTextComment.style.fontSize = nsz;
}
function postsFsize_d(){
	defsize=16;
	//var objText = document.getElementById("postDiv");
	var objTextBody = document.getElementById("postBodyDiv");
	var objTextComment = document.getElementById("readComments");
	//objText.style.fontSize = "12px";
	objTextBody.style.fontSize = "16px";
	objTextComment.style.fontSize = "16px";
}




function hospitalsFsize(inc){
	//var objText = document.getElementById("hospitalDiv");
	var objTextBody = document.getElementById("hospitalBodyDiv");
	var objTextComment = document.getElementById("readComments");
	defsize = defsize - (-inc);
	fsz=defsize;
	var nsz;
	nsz = defsize
	if(nsz<6){
		nsz = 6;
		defsize=6;
	}
	if(nsz>32){
		nsz = 32;
		defsize=32;
	}
	nsz=nsz+"px";
	
	//objText.style.fontSize = nsz;
	objTextBody.style.fontSize = nsz;
	objTextComment.style.fontSize = nsz;
}
function hospitalsFsize_d(){
	defsize=16;
	//var objText = document.getElementById("hospitalDiv");
	var objTextBody = document.getElementById("hospitalBodyDiv");
	var objTextComment = document.getElementById("readComments");
	//objText.style.fontSize = "14px";
	objTextBody.style.fontSize = "16px";
	objTextComment.style.fontSize = "16px";
}






function doctorsFsize(inc){
	//var objText = document.getElementById("doctorDiv");
	var objTextBody = document.getElementById("doctorBodyDiv");
	var objTextComment = document.getElementById("readComments");
	defsize = defsize - (-inc);
	fsz=defsize;
	var nsz;
	nsz = defsize
	if(nsz<6){
		nsz = 6;
		defsize=6;
	}
	if(nsz>32){
		nsz = 32;
		defsize=32;
	}
	nsz=nsz+"px";
	
	//objText.style.fontSize = nsz;
	objTextBody.style.fontSize = nsz;
	objTextComment.style.fontSize = nsz;
}
function doctorsFsize_d(){
	defsize=16;
	//var objText = document.getElementById("doctorDiv");
	var objTextBody = document.getElementById("doctorBodyDiv");
	var objTextComment = document.getElementById("readComments");
	//objText.style.fontSize = "16px";
	objTextBody.style.fontSize = "16px";
	objTextComment.style.fontSize = "16px";
}





function bolestiFsize(inc){
	//var objText = document.getElementById("bolestiDiv");
	var objTextBody = document.getElementById("bolestiBodyDiv");
	var objTextComment = document.getElementById("readComments");
	defsize = defsize - (-inc);
	fsz=defsize;
	var nsz;
	nsz = defsize
	if(nsz<6){
		nsz = 6;
		defsize=6;
	}
	if(nsz>32){
		nsz = 32;
		defsize=32;
	}
	nsz=nsz+"px";
	
	//objText.style.fontSize = nsz;
	objTextBody.style.fontSize = nsz;
	objTextComment.style.fontSize = nsz;
}
function bolestiFsize_d(){
	defsize=16;
	//var objText = document.getElementById("bolestiDiv");
	var objTextBody = document.getElementById("bolestiBodyDiv");
	var objTextComment = document.getElementById("readComments");
	//objText.style.fontSize = "12px";
	objTextBody.style.fontSize = "16px";
	objTextComment.style.fontSize = "16px";
}





function lekarstvaFsize(inc){
	//var objText = document.getElementById("lekarstvaDiv");
	var objTextBody = document.getElementById("lekarstvaBodyDiv");
	var objTextComment = document.getElementById("readComments");
	defsize = defsize - (-inc);
	fsz=defsize;
	var nsz;
	nsz = defsize
	if(nsz<6){
		nsz = 6;
		defsize=6;
	}
	if(nsz>32){
		nsz = 32;
		defsize=32;
	}
	nsz=nsz+"px";
	
	//objText.style.fontSize = nsz;
	objTextBody.style.fontSize = nsz;
	objTextComment.style.fontSize = nsz;
}
function lekarstvaFsize_d(){
	defsize=16;
	//var objText = document.getElementById("lekarstvaDiv");
	var objTextBody = document.getElementById("lekarstvaBodyDiv");
	var objTextComment = document.getElementById("readComments");
	//objText.style.fontSize = "14px";
	objTextBody.style.fontSize = "16px";
	objTextComment.style.fontSize = "16px";
}




function questionFsize(inc){
	//var objText = document.getElementById("questionDiv");
	var objTextBody = document.getElementById("questionBodyDiv");
	var objTextComment = document.getElementById("readComments");
	defsize = defsize - (-inc);
	fsz=defsize;
	var nsz;
	nsz = defsize
	if(nsz<6){
		nsz = 6;
		defsize=6;
	}
	if(nsz>32){
		nsz = 32;
		defsize=32;
	}
	nsz=nsz+"px";
	
	//objText.style.fontSize = nsz;
	objTextBody.style.fontSize = nsz;
	objTextComment.style.fontSize = nsz;
}
function questionFsize_d(){
	defsize=16;
	//var objText = document.getElementById("questionDiv");
	var objTextBody = document.getElementById("questionBodyDiv");
	var objTextComment = document.getElementById("readComments");
	//objText.style.fontSize = "12px";
	objTextBody.style.fontSize = "16px";
	objTextComment.style.fontSize = "16px";
}



function getSelectedSimptoms () {
	var selObj = document.getElementById('bolest_simptom');
	var tolength = selObj.options.length;
	j = 0;
    slctd = new Array();
    for (var i = 0; i < tolength; i++) {
	   if (selObj.options[i].selected) {
	        slctd[j] = selObj.options[i].value;
	        j++
	    }     
   }

   if(slctd.length > 0)
      return slctd.join(",");
   else
      return "";
   
   
}

function getSelectedSimptoms_OLD(){
       i = 0;
       j = 0;
       slctd = new Array();
      while(document.getElementById('bolest_simptom'+i)) {
         if(document.getElementById('bolest_simptom'+i).checked) {
            slctd[j] = document.getElementById('bolest_simptom'+i).value;
            j++
         }
         i++;
      }

      if(slctd.length > 0)
         return slctd.join(",");
      else
         return "";
}


function getSelectedLekarstvaSimptoms_OLD(){
       i = 0;
       j = 0;
       slctd = new Array();
      while(document.getElementById('lekarstvo_simptom'+i)) {
         if(document.getElementById('lekarstvo_simptom'+i).checked) {
            slctd[j] = document.getElementById('lekarstvo_simptom'+i).value;
            j++
         }
         i++;
      }

      if(slctd.length > 0)
         return slctd.join(",");
      else
         return "";
}


function getSelectedLekarstvaSimptoms () {
	var selObj = document.getElementById('lekarstvo_simptom');
	var tolength = selObj.options.length;
	j = 0;
    slctd = new Array();
    for (var i = 0; i < tolength; i++) {
	   if (selObj.options[i].selected) {
	        slctd[j] = selObj.options[i].value;
	        j++
	    }     
   }

   if(slctd.length > 0)
      return slctd.join(",");
   else
      return "";
   
   
}



function selectselected (fromSelObj, toSelObj) {
var fromlength = fromSelObj.options.length;
var tolength = toSelObj.options.length;
for (var i = 0; i < fromlength; i++) {
if (fromSelObj.options[i].selected) {
// check if it doesn't already exists in the target
var exists = false;
for (var j = 0; j < tolength; j++) {
if (toSelObj.options[j].value == fromSelObj.options[i].value) {
exists = true;
}
}
if (!exists) { 
var newOption = new Option(fromSelObj.options[i].text, fromSelObj.options[i].value);
toSelObj.options.add(newOption, toSelObj.options.selectedIndex);
}
}
}

}

function removeselected (selObj) {
var tolength = selObj.options.length;
for (var i = 0; i < tolength; i++) {
if (selObj.options[i].selected) {
selObj.remove(i);
}
}
}

function selectall (fromSelObj, toSelObj) {
toSelObj.options.length = 0;
fromlength = fromSelObj.options.length;
for (var i = 0; i < fromlength; i++) {
toSelObj.options[toSelObj.options.length] = new Option(fromSelObj.options[i].text, fromSelObj.options[i].value) ;
}
}

function removeall (selObj) {
selObj.options.length = 0;
}


function move(selObj, direction) {
	var newindex = 0;
	var index = selObj.options.selectedIndex;
	if (index > -1) {
	switch(direction){
	case "up":
	newindex = (index>0)?index-1:0;break;
	case "down":
	newindex = (index<(selObj.options.length-1))?(index+1):index;break;
	case "top":
	newindex = 0;break;
	case "down":
	newindex = selObj.options.length-1;break;
	}
	var tempVal = selObj.options[newindex].value;
	var tempTxt = selObj.options[newindex].text;
	selObj.options[newindex].text = selObj.options[index].text
	selObj.options[newindex].value = selObj.options[index].value;
	selObj.options[index].text = tempTxt;
	selObj.options[index].value = tempVal;
	selObj.options[index].selected = false;
	selObj.options[newindex].selected = true;
	}
}
function selectAllOptions(SELECT_NAME)
{ 	  i = 0;
	  var tolength2 = SELECT_NAME.options.length;	  
	  for (var i = 0; i < tolength2; i++) {
		//  alert('vvs'+SELECT_NAME.options.length);
		  SELECT_NAME.options[i].selected = true; 
	  }      
}



function update_footer_overlay_div_Content(file_name)
{
	new Ajax.Updater('footer_overlay_div_Content', 'includes/tools/ajax_footer_overlay_load.php?file_name='+file_name, {
		  method: 'get',onSuccess: function() {
	                    //   new Effect.Opacity('SubCatsDiv', {duration: 1.0, from:0.3, to:1.0});
		  }
	});		
	
}

function set_active_region(str, id, is_city, txt_x, txt_y) {
	//alert(str);
	document.getElementById('choosed_from_map').value = str;
	document.searchform.map_str.value = str;
	document.getElementById('citiesOrRegions').value = (is_city) ? 1 : 2;
	document.getElementById('ctsRgnsID').value = id;
	document.getElementById('txt_x').value = txt_x;
	document.getElementById('txt_y').value = txt_y;
}



function getFastSearchAphorisms(aphorism_body)
{
	new Ajax.Updater('fastSearchDiv', 'includes/tools/Ajax_Fast_Search.php?pg_current=aphorisms&aphorism_body='+aphorism_body, {
	  method: 'get',onSuccess: function() {
                       new Effect.Opacity('fastSearchDiv', {duration: 1.0, from:0.3, to:1.0});
					
              }
	});										
}




function getFastSearchThemeOfWeek(theme_body)
{
	new Ajax.Updater('fastSearchDiv', 'includes/tools/Ajax_Fast_Search.php?pg_current=theme_of_week&theme_body='+theme_body, {
	  method: 'get',onSuccess: function() {
                       new Effect.Opacity('fastSearchDiv', {duration: 1.0, from:0.3, to:1.0});
					
              }
	});										
}



function getFastSearchPosts(post_category,post_body,fromDate,toDate)
{
	new Ajax.Updater('fastSearchDiv', 'includes/tools/Ajax_Fast_Search.php?pg_current=posts&post_category='+post_category+'&post_body='+post_body+'&fromDate='+fromDate+'&toDate='+toDate, {
	  method: 'get',onSuccess: function() {
                       new Effect.Opacity('fastSearchDiv', {duration: 1.0, from:0.3, to:1.0});
					
              }
	});										
}



function getFastSearchDoctors(doctor_category,first_name,last_name,cityName,info,fromDate,toDate,picCheck)
{
	new Ajax.Updater('fastSearchDiv', 'includes/tools/Ajax_Fast_Search.php?pg_current=doctors&doctor_category='+doctor_category+'&first_name='+first_name+'&last_name='+last_name+'&cityName='+cityName+'&info='+info+'&fromDate='+fromDate+'&toDate='+toDate+'&picCheck='+picCheck, {
	  method: 'get',onSuccess: function() {
                       new Effect.Opacity('fastSearchDiv', {duration: 1.0, from:0.3, to:1.0});
					
              }
	});										
}


function getFastSearchHospitals(hospital_category,firm_name,cityName,description,fromDate,toDate,picCheck)
{
	new Ajax.Updater('fastSearchDiv', 'includes/tools/Ajax_Fast_Search.php?pg_current=hospitals&hospital_category='+hospital_category+'&firm_name='+firm_name+'&cityName='+cityName+'&description='+description+'&fromDate='+fromDate+'&toDate='+toDate+'&picCheck='+picCheck, {
	  method: 'get',onSuccess: function() {
                       new Effect.Opacity('fastSearchDiv', {duration: 1.0, from:0.3, to:1.0});
              }
	});	
	//alert($('fastSearchDiv').innerHTML);									
}
	
function getFastSearchBolesti(bolest_category,bolest_body,simptoms)
{
	new Ajax.Updater('fastSearchDiv', 'includes/tools/Ajax_Fast_Search.php?pg_current=bolesti&bolest_category='+bolest_category+'&bolest_body='+bolest_body+'&bolest_simptom='+simptoms, {
	  method: 'get',onSuccess: function() {
                       new Effect.Opacity('fastSearchDiv', {duration: 1.0, from:0.3, to:1.0});
					
              }
	});										
}

function getFastSearchLekarstva(lekarstvo_category,lekarstvo_body,simptoms)
{
	new Ajax.Updater('fastSearchDiv', 'includes/tools/Ajax_Fast_Search.php?pg_current=lekarstva&lekarstvo_category='+lekarstvo_category+'&lekarstvo_body='+lekarstvo_body+'&lekarstvo_simptom='+simptoms, {
	  method: 'get',onSuccess: function() {
                       new Effect.Opacity('fastSearchDiv', {duration: 1.0, from:0.3, to:1.0});
					
              }
	});										
}

/***********************************************
* Textarea Maxlength script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

function ismaxlength(obj)
{
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
	if (obj.getAttribute && obj.value.length>mlength)
	obj.value=obj.value.substring(0,mlength)
}
      
function checkForCorrectDataAphorism() 
{
    theForm = document.searchform;
    
         
     if(theForm.aphorism_title.value.length == 0) {
       alert('Моля, въведете Автор/Източник на Афоризъма!');
       theForm.aphorism_title.value = "";
       theForm.aphorism_title.focus();
       return false;
    }
   
  

   if(theForm.aphorism_body.value.length == 0) {
       alert('Моля, въведете Текст на Афоризъма!');
       theForm.aphorism_body.value = "";
       theForm.aphorism_body.focus();
       return false;
    }

        
 }    

  
 
     
function checkForCorrectDataThemeOfWeek(theForm) 
{         
     if(theForm.theme_title.value.length == 0) {
       alert('Моля, въведете заглавие на Тема на Седмицата!');
       theForm.theme_title.value = "";
       theForm.theme_title.focus();
       return false;
    }
     

   var oEditor = FCKeditorAPI.GetInstance('theme_body');
	var contents = oEditor.GetXHTML(true);		

   if(contents.length < 25)  { //сложил съм 5 екстра символа защото май едитора добавя едно "<br />" автоматично към съдържанието
       alert('Моля, Въведете Текст на Тема на Седмицата!');
       theForm.theme_body.value = "";
       theForm.theme_body.focus();
       return false;
    }

        
 }    

  
function checkForCorrectDataPost() 
{
    theForm = document.searchform;
    
         
     if(theForm.post_title.value.length == 0) {
       alert('Моля, въведете Заглавие на Статията!');
       theForm.post_title.value = "";
       theForm.post_title.focus();
       return false;
    }
   
     
	 if(theForm.post_category.value == '-1' || theForm.post_category.value == '' )  {
        alert('Моля, изберете Категория на Статията!');
       theForm.post_category.options[0].selected = true;
        theForm.post_category.focus();
        return false;
   }
   
   
   var oEditor = FCKeditorAPI.GetInstance('post_body');
	var contents = oEditor.GetXHTML(true);		

   if(contents.length < 25)  { //сложил съм 5 екстра символа защото май едитора добавя едно "<br />" автоматично към съдържанието
       alert('Моля, Въведете Текст на Статията!');
       theForm.post_body.value = "";
       theForm.post_body.focus();
       return false;
    }


   if(theForm.post_source.value.length == 0) {
       alert('Моля, въведете Източник на Статията!');
       theForm.post_source.value = "";
       theForm.post_source.focus();
       return false;
    }

        
 }    


	
function checkForCorrectDataDoctor(theForm) 
{   
    
     if(theForm.doctor_category.value == '-1' || theForm.doctor_category.value == '' )  {
	         alert('Моля, изберете категория/специалност!');
	         theForm.doctor_category.value = "-1";
	         theForm.doctor_category.focus();
	         return false;
	       }

     if(theForm.first_name.value.length < 3) {
         alert('Моля, въведете Вашето име!');
         theForm.first_name.value = "";
         theForm.first_name.focus();
         return false;
      }

     if(theForm.last_name.value.length < 3) {
         alert('Моля, въведете Вашата фамилия!');
         theForm.last_name.value = "";
         theForm.last_name.focus();
         return false;
      }
     
	   
     if(theForm.username.value.length < 5) {
        alert('Моля, въведете потребителско име по-голямо от 5 символа!');
        theForm.username.value = "";
        theForm.username.focus();
        return false;
     }
   		var pars = 'type=doctor&username=' + theForm.username.value ;
   		new Ajax.Request('includes/tools/Ajax_Check_Unique_Username.php', {method: 'post',parameters: pars,
   			 onSuccess: function(transport) { 
   			 	
   			    if (transport.responseText.match(/exist/))
   			    {
   			    	alert('Избраното потребителско име е заето!Моля, въведете потребителско име!');
   			   		theForm.username.value = "";
                	theForm.username.focus();
                	return false;
   			    }
   			 }
   			
   			 	   		
   	   	}) ;
	   	
      if(theForm.password.value.length < 5) {
        alert('Моля, въведете парола (по-голяма от 4 символа)!');
        theForm.password.value = "";
        theForm.password.focus();
        return false;
     }
      if(theForm.password.value != theForm.password2.value) {
        alert('Двете пароли не съвпадат!');
        theForm.password2.value = "";
        theForm.password2.focus();
        return false;
     }
     
      if(theForm.phone.value.length == 0) {
        alert('Моля, въведете телефон за връзка!');
        theForm.phone.value = "";
        theForm.phone.focus();
        return false;
     }
     
   
     
    emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
	if (emailPattern.test(theForm.email.value)){
			
	}else {
		if(theForm.email.value != 'n/a' && theForm.email.value != 'няма')
		{
			alert('Моля, въведете коректен Е-мейл адрес!');
           	theForm.email.value = "";
           	theForm.email.focus();
			return (false);
		}
	}

	
      
    if(theForm.cityName.value.length == 0)  {
       alert('Моля, изберете населено място!');
       theForm.cityName.value = "";
       theForm.cityName.focus();
       return false;
    }
     
     if(theForm.address.value.length == 0)  {
        alert('Моля, посочете Вашия адрес (квартал, улица, номер, блок)!');
        theForm.address.value = "";
        theForm.address.focus();
        return false;
     }
     
       
    var oEditor = FCKeditorAPI.GetInstance('info');
	var contents = oEditor.GetXHTML(true);	

    if(contents.length < 25)  { //сложил съм 5 екстра символа защото май едитора добавя едно "<br />" автоматично към съдържанието
       alert('Моля, Въведете Текст на Описанието!');
       theForm.info.value = "";
       theForm.info.focus();
       return false;
	}


	if(theForm.verificationcode.value.length == 0)  
	{
		alert('Моля, въведете коректен код за сигурност!');
		theForm.verificationcode.value = "";
		theForm.verificationcode.focus();
		return false;
	}
      
        
}




function checkForCorrectDataHospital(theForm) 
{
	           	  
	if(theForm.hospital_category.value == '-1' || theForm.hospital_category.value == '' )  {
		alert('Моля, изберете категория на Вашата организация!');
		theForm.hospital_category.value = "-1";
		theForm.hospital_category.focus();
		return false;
	}
            
     if(theForm.firm_name.value.length < 5) {
        alert('Моля, въведете наименование на организацията!');
        theForm.firm_name.value = "";
        theForm.firm_name.focus();
        return false;
     }
     
	   	            
     if(theForm.username.value.length < 5) {
        alert('Моля, въведете потребителско име по-голямо от 5 символа!');
        theForm.username.value = "";
        theForm.username.focus();
        return false;
     }
     
     
 	var pars = 'type=hospital&username=' + theForm.username.value ;
		new Ajax.Request('includes/tools/Ajax_Check_Unique_Username.php', {method: 'post',parameters: pars,
			 onSuccess: function(transport) { 
			    if (transport.responseText.match(/exist/))
			    {
			    	alert('Избраното потребителско име е заето!Моля, въведете потребителско име!');
			   		theForm.username.value = "";
            	theForm.username.focus();
            	return false;
			    }
			 }
			
			 	   		
	   	}) ;
   	   	
     
      if(theForm.password.value.length < 5) {
        alert('Моля, въведете парола (по-голяма от 5 символа)!');
        theForm.password.value = "";
        theForm.password.focus();
        return false;
     }
     
     
      if(theForm.password.value != theForm.password2.value) {
        alert('Двете пароли не съвпадат!');
        theForm.password2.value = "";
        theForm.password2.focus();
        return false;
     }
     
     
          
      
     if(theForm.phone.value.length == 0) {
         alert('Моля, въведете телефон за връзка!');
         theForm.phone.value = "";
         theForm.phone.focus();
         return false;
      }
      
          
     
    
   emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
	if (emailPattern.test(theForm.email.value)){
			
	}else {
		if(theForm.email.value != 'n/a' && theForm.email.value != 'няма')
		{
			alert('Моля, въведете коректен Е-мейл адрес!');
           	theForm.email.value = "";
           	theForm.email.focus();
			return (false);
		}
	}
	
	if(theForm.manager.value.length == 0) {
         alert('Моля, въведете управител!');
         theForm.manager.value = "";
         theForm.manager.focus();
         return false;
      }
          
          
      if(theForm.cityName.value.length == 0)  {
         alert('Моля, изберете населено място!');
         theForm.cityName.value = "";
         theForm.cityName.focus();
         return false;
      }
     
     
     if(theForm.address.value.length == 0)  {
        alert('Моля, посочете адреса (град, община, квартал, улица, номер, блок) на Вашата организация!');
        theForm.address.value = "";
        theForm.address.focus();
        return false;
     }
     
   	var oEditor = FCKeditorAPI.GetInstance('description');
	var contents = oEditor.GetXHTML(true);	

    if(contents.length < 25)  { //сложил съм 5 екстра символа защото май едитора добавя едно "<br />" автоматично към съдържанието
       alert('Моля, Въведете Текст на Описанието!');
       theForm.description.value = "";
       theForm.description.focus();
       return false;
	}
	
	
	if(theForm.verificationcode.value.length == 0)  
	{
		alert('Моля, въведете коректен код за сигурност!');
		theForm.verificationcode.value = "";
		theForm.verificationcode.focus();
		return false;
	}
}



  
function checkForCorrectDataBolest(theForm) 
{
    //theForm = document.searchform;
    
         
     if(theForm.bolest_title.value.length == 0) {
       alert('Моля, въведете Наименование на Болеста!');
       theForm.bolest_title.value = "";
       theForm.bolest_title.focus();
       return false;
    }
   
   if(theForm.bolest_category.value == '-1' || theForm.bolest_category.value == '' )  {
         alert('Моля, изберете Категория на Болеста!');
         theForm.bolest_category.value = "-1";
         theForm.bolest_category.focus();
         return false;
   }
	 
  
   
   var oEditor = FCKeditorAPI.GetInstance('bolest_body');
	var contents = oEditor.GetXHTML(true);		

   if(contents.length < 25)  { //сложил съм 5 екстра символа защото май едитора добавя едно "<br />" автоматично към съдържанието
       alert('Моля, Въведете Текст на Описанието!');
       theForm.bolest_body.value = "";
       theForm.bolest_body.focus();
       return false;
    }


   if(theForm.bolest_source.value.length == 0) {
       alert('Моля, въведете Източник на Описанието!');
       theForm.bolest_source.value = "";
       theForm.bolest_source.focus();
       return false;
    }

        
 }    
 
 
function checkForCorrectDataLekarstvo(theForm) 
{
    //theForm = document.searchform;
    
         
     if(theForm.lekarstvo_title.value.length == 0) {
       alert('Моля, въведете Наименование на Лекарството!');
       theForm.lekarstvo_title.value = "";
       theForm.lekarstvo_title.focus();
       return false;
    }
   
   if(theForm.lekarstvo_category.value == '-1' || theForm.lekarstvo_category.value == '' )  {
         alert('Моля, изберете Категория на Лекарството!');
         theForm.lekarstvo_category.value = "-1";
         theForm.lekarstvo_category.focus();
         return false;
   }
	   
   
	var oEditor = FCKeditorAPI.GetInstance('lekarstvo_body');
	var contents = oEditor.GetXHTML(true);		

   if(contents.length < 25)  { //сложил съм 5 екстра символа защото май едитора добавя едно "<br />" автоматично към съдържанието
       alert('Моля, Въведете Текст на Описанието!');
       theForm.lekarstvo_body.value = "";
       theForm.lekarstvo_body.focus();
       return false;
    }


   if(theForm.lekarstvo_source.value.length == 0) {
       alert('Моля, въведете Източник на Описанието!');
       theForm.lekarstvo_source.value = "";
       theForm.lekarstvo_source.focus();
       return false;
    }

        
}

 


function checkForCorrectDataThemeOfWeek(theForm) 
{     
		
	if(theForm.theme_title.value.length < 5) {
		alert('Моля, въведете Наименование на Тема на Седмицата!');
		theForm.theme_title.value = "";
		theForm.theme_title.focus();
		return false;
	}
	
	
	var oEditor = FCKeditorAPI.GetInstance('theme_body');
	var contents = oEditor.GetXHTML(true);		
	
	if(contents.length < 25)  { //сложил съм 5 екстра символа защото май едитора добавя едно "<br />" автоматично към съдържанието
		alert('Моля, въведете текст на Тема на Седмицата!');
		theForm.theme_body.value = "";
		theForm.theme_body.focus();
		return false;
	}
}     


function setActiveThemeOfWeek(selObj) {
	new Ajax.Request('includes/tools/Ajax_set_Active_Theme_Of_Week.php', 
	{
		parameters: 'Active='+selObj.options[selObj.selectedIndex].value	  
	});

}



	function sendMailWhenEpayBg(price) {
		new Ajax.Updater('bulletinDiv', 'includes/tools/Ajax_sendMailWhenEpayBg.php?price=' +price, {
		  method: 'get',onSuccess: function() {
	          // $('suggestions').show();
		  }
		});				
	}
	
	


	function updateSimptomSelect(type,simptom,simpt_ID)
	{
		if(type == 'bolesti')
		{
			document.getElementById('ALL_SIMPTOMS').value = simpt_ID;
			document.getElementById('inputString').value = simptom;			
			selectselected(document.getElementById('ALL_SIMPTOMS'), document.getElementById('bolest_simptom'));
			selectAllOptions(document.getElementById('bolest_simptom'));
		}	
		else if(type == 'lekarstva')
		{
			document.getElementById('ALL_SIMPTOMS').value = simpt_ID;
			document.getElementById('inputString').value = simptom;				
			selectselected(document.getElementById('ALL_SIMPTOMS'), document.getElementById('lekarstvo_simptom'));
			selectAllOptions(document.getElementById('lekarstvo_simptom'));
		}	
		else if(type == 'home_page')
		{
			document.getElementById("bolest_simptom").value = simpt_ID;
			document.getElementById("inputString").value = simptom;				
			document.searchform.action ="разгледай-болести,характерен_симптом_"+simptom+".html"; 
			document.searchform.submit();
		}
		
	}


	 function insertUserForBulletin(mail_toSend) 
	  {
	 	 theForm = document.searchform;         

	 	emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
	 	if (emailPattern.test(theForm.mail_toSend.value))
	 	{
	 		new Ajax.Updater("bulletinDiv", "includes/tools/Ajax_Check_Insert_User_For_Bulletin.php?mail_toSend=" +mail_toSend , {
	 		  method: "get",onSuccess: function() {
	 	          // $("suggestions").show();
	 		  }
	 		});		
	 	}
	 	else 
	 	{			
	 		alert("Моля, въведете коректен Е-мейл адрес!");
	  		theForm.mail_toSend.value = "";
	  		theForm.mail_toSend.focus();
	 		return (false);			
	 	}
	 }

	 
	 
	 

	function checkForCorrectComment() {
	 	theForm = document.searchform;
	 
	  	if(theForm.verificationcode.value.length == 0)  {
		    alert('Моля, въведете коректен код за сигурност!');
		    theForm.verificationcode.value = "";
		    theForm.verificationcode.focus();
		    return false;
		 }
	 
	 
	  	if(theForm.comment_body.value.length == 0) {
		    alert('Моля, въведете Вашия коментар!');
		    theForm.comment_body.value = "";
		    theForm.comment_body.focus();
		    return false;
		 }
	}

	     

	    	
		function hidemsgArea()
		{
			setTimeout("$('suggestions').hide();", 5000);
		}
			
		
		function lookup(inputString) {
			if(inputString.length == 0) {
				// Hide the suggestion box.
				$('suggestions').hide();
			} else { 
				new Ajax.Updater('autoSuggestionsList', 'includes/tools/Ajax_autoComplete_Simptoms.php?queryString=' +inputString , {
					  method: 'get',onSuccess: function() {
				           $('suggestions').show();
					  }
				});					
			}
		} 
		
		function lookupLekarstva(inputString) {
			if(inputString.length == 0) {
				// Hide the suggestion box.
				$('suggestions').hide();
			} else { 
				new Ajax.Updater('autoSuggestionsList', 'includes/tools/Ajax_autoComplete_Lekarstva_Simptoms.php?queryString=' +inputString , {
					  method: 'get',onSuccess: function() {
				           $('suggestions').show();
					  }
				});					
			}
		} 
		
		function lookupHomePage(inputString) {
			if(inputString.length == 0) {
				// Hide the suggestion box.
				$('suggestions').hide();
			} else { 
				new Ajax.Updater('autoSuggestionsList', 'includes/tools/Ajax_autoComplete_Simptoms.php?pg_curr=home_page&queryString=' +inputString , {
					  method: 'get',onSuccess: function() {
				           $('suggestions').show();
					  }
				});					
			}
		} 
		
		function lookupLocation(inputString) 
		{
			if(inputString.length == 0) {
				// Hide the suggestion box.
				$('suggestions').hide();
			} else { 
				new Ajax.Updater('autoSuggestionsList', 'includes/tools/Ajax_autoComplete_iFrame_loc.php?queryString=' +inputString , {
					  method: 'get',onSuccess: function() {
				           $('suggestions').show();
					  }
				});					
			}
		} 
	
		
	   	function updateLocSelect(cityName,locID)
		{
			document.getElementById('cityName').value = locID;
			document.getElementById('inputString').value = cityName;										
		}

	
		function fill(thisValue) {
//			$('inputString').setValue(thisValue);
//			setTimeout("$('suggestions').hide();", 5000);
			$('inputString').setValue(''); //изчистваме полето за да се въведе следващия симптом
			
		}

		function slideBody(num)
		{				
			if (!($('textBody_'+num).visible()))
			{
				i = 0;
		      	while(document.getElementById('textBody_'+i)) 
		      	{	      		
		        	if ($('textBody_'+i).visible())
		        	{
		        		new Effect.BlindUp('textBody_'+i);	
		        	}
					i++;	      		
		      	}	
		      	new Effect.BlindDown('textBody_'+num);
				
			}
		}
		
		

	
	function next_previous(type,currentID)
	{
		if(currentID > 0)
		{
			if(type == 'posts')
			{
				new Ajax.Updater('next_previousDIV', 'includes/tools/Ajax_next_previous_posts.php?postID='+currentID, {
			  	method: 'get',onSuccess: function() {
		                  new Effect.Opacity('next_previousDIV', {duration: 1.0, from:0.3, to:1.0});
							
		            }
				});
			}
			if(type == 'bolesti')
			{
				new Ajax.Updater('next_previousDIV', 'includes/tools/Ajax_next_previous_bolesti.php?bolestID='+currentID, {
			  	method: 'get',onSuccess: function() {
		                  new Effect.Opacity('next_previousDIV', {duration: 1.0, from:0.3, to:1.0});
							
		            }
				});
			}
			if(type == 'lekarstva')
			{
				new Ajax.Updater('next_previousDIV', 'includes/tools/Ajax_next_previous_lekarstva.php?lekarstvoID='+currentID, {
			  	method: 'get',onSuccess: function() {
		                  new Effect.Opacity('next_previousDIV', {duration: 1.0, from:0.3, to:1.0});
							
		            }
				});
			}
			if(type == 'aphorisms')
			{
				new Ajax.Updater('next_previousDIV', 'includes/tools/Ajax_next_previous_aphorisms.php?aphorismID='+currentID, {
			  	method: 'get',onSuccess: function() {
		                  new Effect.Opacity('next_previousDIV', {duration: 1.0, from:0.3, to:1.0});
							
		            }
				});
			}
			
			
		}	
						
	}
	
	
	
	
function makeViewLog(type,ID) {
	
	var pars = 'type='+type+'&ID='+ID ;
	
   		new Ajax.Request('includes/tools/Ajax_make_view_log.php', {method: 'post',parameters: pars,
   			 onSuccess: function(transport) { 
   			 	
   			    //alert(transport.responseText);
   			 }
   			
   			 	   		
   	   	}) ;
   	   	
   	   	
}
