<!--
//----------------------------------------------------------------------------------------------------------------
var last_img_id = null;
var last_img_src = null;
//----------------------------------------------------------------------------------------------------------------
function imgrel( _id, _src )
{
	if( last_img_id != null ) document.getElementById(last_img_id).src=last_img_src;
	
	var el = document.getElementById(_id);
	
	last_img_id = el.id;
	last_img_src = el.src;

	el.src=_src;
}

//----------------------------------------------------------------------------------------------------------------
function trim_field_value(form_name, field){
	var re = /( )*/;
	var the_form = document.forms[form_name];
	var the_value =  eval('the_form.' + field + '.value');
	var trim_value = the_value.replace(re, "");

	return trim_value;
}

function checkUsersForm(existingPass){
	var obj_form = document.forms['usersForm'];

	trim_name = trim_field_value('usersForm', 'f_username');	
	if (!trim_name){
		alert("Моля въведете потребителско име");
		obj_form.f_username.focus();
		return false;
	}
	
	trim_name = trim_field_value('usersForm', 'f_password');	
	if (existingPass != 0)
	{
		alert('Съществува потребител с тази парола. Моля, въведете нова');
		return false;
	} 
	
	if (!trim_name){
		alert("Моля въведете парола");
		obj_form.f_password.focus();
		return false;
	}
	
	
	
	if (obj_form.f_rights.selectedIndex == 0) {
		alert("Моля изберете права за достъп");
		obj_form.f_rights.focus();
		return false;
	}
	
}


//-------------------------------------------------------------
function checkSimplePageForm(){
	var obj_form = document.forms['simplePage'];

	trim_name = trim_field_value('simplePage', 'f_title');	
	if (!trim_name){
		alert("Моля въведете заглавие на страница");
		obj_form.f_title.focus();
		return false;
	}
	
}

//-------------------------------------------------------------
function checkNewsPageForm(){
	var obj_form = document.forms['newsPage'];

	trim_name = trim_field_value('newsPage', 'f_title');	
	if (!trim_name){
		alert("Моля въведете заглавие на страница");
		obj_form.f_title.focus();
		return false;
	}
}

//-------------------------------------------------------------
function checkDocsPageForm(){
	var obj_form = document.forms['docsPage'];

	trim_name = trim_field_value('docsPage', 'f_title');	
	if (!trim_name){
		alert("Моля въведете заглавие на страница");
		obj_form.f_title.focus();
		return false;
	}
}

//-------------------------------------------------------------
function checkTeamPageForm(){
	var obj_form = document.forms['teamPage'];

	trim_name = trim_field_value('teamPage', 'f_title');	
	if (!trim_name){
		alert("Моля въведете заглавие на страница");
		obj_form.f_title.focus();
		return false;
	}
}

//-------------------------------------------------------------
function checkNewsForm(){
	var obj_form = document.forms['news'];

	trim_name = trim_field_value('news', 'f_title');	
	if (!trim_name){
		alert("Моля въведете заглавие на новина");
		obj_form.f_title.focus();
		return false;
	}
}

//-------------------------------------------------------------
function checkDocsForm(){
	var obj_form = document.forms['docs'];

	trim_name = trim_field_value('docs', 'f_title');	
	if (!trim_name){
		alert("Моля въведете заглавие на документ");
		obj_form.f_title.focus();
		return false;
	}
}

//-------------------------------------------------------------
function checkTeamForm(){
	var obj_form = document.forms['team'];

	trim_name = trim_field_value('team', 'f_name');	
	if (!trim_name){
		alert("Моля въведете име на член на екипа");
		obj_form.f_name.focus();
		return false;
	}
}

//-------------------------------------------------------------
function checkLinksForm(){
	var obj_form = document.forms['links'];

	trim_name = trim_field_value('links', 'f_url');	
	if (!trim_name && (obj_form.f_link_to.selectedIndex == 0)){
		alert("Моля въведете външна връзка или изберете връзка към вътрешна страница");
		return false;
	}
	
	trim_name = trim_field_value('links', 'f_title');	
	if (!trim_name){
		alert("Моля въведете заглавие");
		obj_form.f_title.focus();
		return false;
	}
}

//-------------------------------------------------------------
function checkDateRange()
{
	var obj_form = document.forms['dateRange'];	
	
	trim_from_date = trim_field_value('dateRange', 'from_date');
	trim_to_date = trim_field_value('dateRange', 'to_date');
	f_date = new Date(trim_from_date);
	t_date = new Date(trim_to_date);
	
	if (f_date >= t_date)
	{
		alert("Моля, въведете в полето „ОТ” дата, която е по-рано от тази в полето „ДО”");
		obj_form.from_date.focus();
		return false;
	}
}

//-------------------------------------------------------------
function confirmDelete(){
	if (confirm('Сигурни ли сте, че искате да изтриете този запис?')){
		return true;
	} else {
		return false;
	}
}

//-------------------------------------------------------------
function confirmDeletePage(){
	if (confirm('Сигурни ли сте, че искате да изтриете тази страница?')){
		return true;
	} else {
		return false;
	}
}

//-------------------------------------------------------------
function confirmDeleteFile(){
	if (confirm('Сигурни ли сте, че искате да изтриете този файл?')){
		return true;
	} else {
		return false;
	}
}

//-------------------------------------------------------------
function move(dir){
  var temp = "";
  var tempValue="";
  var tempIndex = "";
  var sign = 0;
  if (dir == "down") sign = -1;
  if (dir == "up") sign = 1;
  var TheSelect = document.forms[0].select_member;
  if (TheSelect.value == "") {
	alert("Не сте избрали нито една връзка!");
	return false;
	}
  if ((TheSelect.selectedIndex == 0)& (dir == "up"))
  		alert("Избраната връзка е първа в списъка. Молиа изберете друга.");					
	else 
		if ((TheSelect.selectedIndex == (TheSelect.options.length-1))&(dir == "down"))
  			alert("Избраната връзка е последна в списъка. Молиа изберете друга.");	
		  else				
			{
			tempIndex = TheSelect.selectedIndex - sign;
			temp = TheSelect.options[tempIndex].text;
			tempValue = TheSelect.options[tempIndex].value;
			TheSelect.options[tempIndex].value =  TheSelect.options[TheSelect.selectedIndex].value;
			TheSelect.options[tempIndex].text = TheSelect.options[TheSelect.selectedIndex].text;
			TheSelect.options[tempIndex+sign].value = tempValue;
			TheSelect.options[tempIndex+sign].text = temp;
			TheSelect.selectedIndex =TheSelect.selectedIndex - sign;
		}
}


function create_hidden()
{

	var val_hidden = "";
	for (i=0; i<document.forms[0].select_member.length; i++)
		val_hidden += document.forms[0].select_member.options[i].value+", ";
		document.forms[0].order_c.value = val_hidden;
		
}

// -->

