function new_freecap() { // captcha image cuntion for form submission security
	// loads new freeCap image
	if(document.getElementById)
	{
		// extract image name from image source (i.e. cut off ?randomness)
		thesrc = document.getElementById("freecap").src;
		thesrc = thesrc.substring(0,thesrc.lastIndexOf(".")+4);
		// add ?(random) to prevent browser/isp caching
		document.getElementById("freecap").src = thesrc+"?"+Math.round(Math.random()*100000);
	} else {
		alert("Sorry, cannot autoreload freeCap image\nSubmit the form and a new freeCap will be loaded");
	}
}


var Spell_Win_Name;
var Work_Form_Name;
var Work_Field_Name;

function SpellCheck(form_name,field_name) 
{
  //четене на формата във променливата textform
  //ако формата се казва: proba 
  //а полето за проверка е: description_short
  //правилното използване трябва да бъде
  //var textform = self.document.proba.description_short.value;
  //var textform = self.document["proba"]["description_short"].value;
  
  var textform = self.document[form_name][field_name].value;
  
  //textform = "dfghfhfghfghfgh";
  //обратно записване в формата
  //self.document[form_name][field_name].value = "alabala i towa e";
  //съобщение
  //alert (textform);
  
  //open popup window and submit to spell_check.php ONLY
  //1. IF popup window is not open or popup window was closed
  //2. OR click comes from another form-field
  
  //otherwise spellcheck click just focus popup window
  
  if ( ! Spell_Win_Name || Spell_Win_Name.closed || (Work_Form_Name != form_name || Work_Field_Name != field_name))
  {
  Spell_Win_Name = win_pop('');
  if (Spell_Win_Name.focus) { Spell_Win_Name.focus(); }
  
  self.document.hidden_form.form_name.value = form_name; 	//w skritata forma se izpolzwa ime na pole form_name i field_name
  self.document.hidden_form.field_name.value = field_name;  	// koito nqmat nishto obshto s promrnliwite w tazi funkciq
  self.document.hidden_form.first_time_text.value = textform;
  self.document.hidden_form.submit();
  
  Work_Form_Name=form_name;
  Work_Field_Name=field_name;
  }
  else
  {
  if (Spell_Win_Name.focus) { Spell_Win_Name.focus(); }
  }

}

function win_pop(URL)
{	
   		winname=window.open(URL,'WIN','width=600,height=380,left=210,top=210,resizable=yes,scrollbars=yes,status=yes'); 
	return winname;
}


