function show_message(message) //Display message 
 {
if (message!=''){
  div=document.getElementById('message');
  div.innerHTML="<fieldset style='border: 1px solid #B2C9FF; padding:0 7 7 7;'><legend class='tah_11_5570B0' style='padding:5; color:#003399; font-weight:bold;'>Information</legend><span class='tah_11_5570B0'>"+message+'</span></fieldset>';

  div=document.getElementById('message_row');
  div.style.display='';  
  } else 
  {
    div=document.getElementById('message_row');
    div.style.display='none';       
  }
}


function Show_Hide(id){
element_id='children_'+id;
img_id='treeimg_'+id;
  if (document.getElementById(element_id).style.display=="")  {
  document.getElementById(element_id).style.display="none"; 
  document.getElementById(img_id).src='images/treestereonode.gif  ';
  }
  else
  
{  document.getElementById(element_id).style.display='';
  document.getElementById(img_id).src='images/treemononode.gif ';
  }
}


 function load_data(module) // LOAD MODULE
{
   var currentTime = new Date();
   document.getElementById('scr').innerHTML='&nbsp;<script></' + 'script>';
   var script = document.getElementById('scr').getElementsByTagName("script")[0];
   href=module+'?tm='+currentTime.getTime();     
   if (script.setAttribute) script.setAttribute('src', href); else script.src = href;
   show_message('Loading .... Please wait!');
 }

//	<------------------------------------------------ Функции для переноса элементов из одного списка в другой --------------------------------------------------------->

function cmpOptions(a, b) {				// Функция сравнения двух элементов массива (нужна при сортировке)
  if( a.text < b.text ) return -1;
  if( a.text > b.text ) return 1;
  return 0;
};

function SelectMoveRows(list1, list2) {			// Функция переноса выбранных элементов из list1 в list2
	var arr1 = new Array(), arr2 = new Array();	// Массивы, в которых будут размещены элементы списков после перестановки

	// Перебираем элементы первого списка (источника). Если элемент выделен, помещаем его в arr2, иначе - в arr1 (останется в первом списке)
	var obj, obj2, i;
	for(i=0; i<list1.length; ++i) {
		if (list1.options[i].selected) arr2[arr2.length] = new Option(list1.options[i].text, list1.options[i].value);
		else arr1[ arr1.length ] = new Option(list1.options[i].text, list1.options[i].value);
	}
	
	// Элементы из второго списка (приемника) копируем в arr2
	for(i=0;i<list2.length;++i) {
		arr2[arr2.length] = new Option(list2.options[i].text, list2.options[i].value);
	}
	
	arr2.sort(cmpOptions);					// Сортируем элементы приемника по возрастанию, используя функцию сравнения объектов.
	list2.length = list1.length = 0;		// Очищаем списки
	
	// Заполняем списки элементами из массивов
	for(i=0; i<arr1.length; i++) list1.options[list1.length] = arr1[i];
	for(i=0; i<arr2.length; i++) list2.options[list2.length] = arr2[i];
}

function SelectRemoveRows(SS1)		// Move selected Items from one select to another
{   if (SS1) {
    var SelID='';
    var SelText='';
    
    for (i=SS1.options.length - 1; i>=0; i--)
    {
        if (SS1.options[i].selected == true)
        {
           SS1.options[i]=null;
        }
    }
//    SelectSort(SS1);
  }
}

//	<------------------------------------------ конец блока функций для переноса элементов из одного списка в другой -------------------------------------------->


/*	____________________________    Устаревший блок функций для переноса элементов из одного списка в другой    ___________________________
function Old_SelectMoveRows(SS1,SS2)// Move selected Items from one select to another		
{   if (SS1&&SS2) {
    var SelID='';
    var SelText='';
    // Move rows from SS1 to SS2 from bottom to top
    for (i=SS1.options.length - 1; i>=0; i--)
    {
        if (SS1.options[i].selected == true)
        {
            SelID=SS1.options[i].value;
            SelText=SS1.options[i].text;
            var newRow = new Option(SelText,SelID);
            SS2.options[SS2.length]=newRow;
            SS1.options[i]=null;
        }
    }
    SelectSort(SS2);
  }
}

function SelectSort(SelList)// SORT SELECT LIST alphabetically 
{
    var ID='';
    var Text='';
    for (x=0; x < SelList.length - 1; x++)
    {
        for (y=x + 1; y < SelList.length; y++)
        {
            if (SelList[x].text > SelList[y].text)
            {
                // Swap rows
                ID=SelList[x].value;
                Text=SelList[x].text;
                SelList[x].value=SelList[y].value;
                SelList[x].text=SelList[y].text;
                SelList[y].value=ID;
                SelList[y].text=Text;
            }
        }
    }
}
___________________________________________________________________________________________________________________________    */

function SelectSelect(SelList)// SELECT ALL ITEMS IN THE MULTI LIST SELECT OBJECT
{  if (SelList)
    for (x=0; x < SelList.length; x++)
    { 
	  if (SelList.options[x]) SelList.options[x].selected=true;
    }
}
function get_URLKEY(src,dst)
{ 
  sr=_LATIN_SYMBOLS;
  rp=_LATIN_SYNONIMS;  
  
  news=new String(src);
  newstr=new String();
  news=news.toLowerCase();// convert string to lover case 
  
  for(i=0;i<news.length;i++) {
  	add=true; 
      for (j=0;j<sr.length;j++) if (news.charAt(i)==sr[j]) { newstr+=rp[j]; add=false;j=sr.length; }
        
        if (add) newstr+=news.charAt(i);
  }
  
  newstr=newstr.replace(/[^a-zA-Z0-9\-\s]/gi,"");  //delete all special characters 
  newstr=newstr.replace(/[\s]+/g," ");                   //replace consecutive spaces by one
  newstr=newstr.replace(/[\s]+/gi, "-");                //replace all spaces by dash 
  newstr=newstr.replace(/[^a-zA-Z0-9]$/gi,"");     //delete all special characters at the end of string
  newstr=newstr.replace(/^[^a-zA-Z0-9]/gi,"");   //delete all special characters at the beginning of string
  
  
  dst.value=newstr; 
}

function GetObject(obj_id)// GET OBJECT BY ID
{
    return document.getElementById(obj_id);
}

 
function Show_Hide_Element(element_id) // Show or Hide element
{
   el=document.getElementById(element_id);
   if (el.style.display=='') el.style.display='none';
   else el.style.display='';
}

function setVis(element_id,visible) {			// Show or Hide element
	el=document.getElementById(element_id);
	if(visible == null) visible = el.style.display
	el.style.display = (visible == '') ? 'none' : '';
}

function intoVal(value, mode) {
	mode = (mode != null) ? mode : '';
	switch(mode) {
		case "float": {
			value = ((value + '').replace(",",".")).match(/\-*\d+[.]?\d*/);
			if(value == null) return 0;
			 else return parseFloat(value);
			break;
		}
		default: {				// return integer as default
			value = (value + '').match(/\d+/);
			if(value == null) return 0;
			 else return parseInt(value);
			break;
		}
	} 
}

function in_array(the_needle, the_haystack){
	var the_hay = the_haystack.toString();
	if(the_hay == '') {return false;}
	var the_pattern = new RegExp(the_needle, 'g');
	var matched = the_pattern.test(the_haystack);
	return matched;
}