
// cookie 
//***********************************************************



function wc(nazwa_cookie)  // wartosci cookie
{ 

	
	var start = document.cookie.indexOf(nazwa_cookie)+ nazwa_cookie.length +1; 
	var stop = document.cookie.indexOf(";",start); 

	if (stop < 0) stop = document.cookie.length; 
	var wartosc = document.cookie.substring(start,stop);

	if ((wartosc == ',')||(wartosc == ';') )
	{
		 wartosc = '0';
	}
	
	return wartosc;
	

} 	
//***********************************************************
function uc(ncookie) //ustaw cookie
{
	ncookie = ncookie + '; path=/';
	document.cookie = ncookie;
}
// cookie - koniec
//***********************************************************
//***********************************************************


function wind(addr)
{
	window.open(addr,'','alidn=center,toolbar=no,status=yes,location=no,directories=no,resizable=yes,scrollbars=yes,width=700,height=400,menubar=no');
}
//***********************************************************
//***********************************************************

function window_ankieta(addr)
{
	window.open(addr,'','alidn=center,toolbar=yes,status=no,location=yes,directories=yes,resizable=yes,scrollbars=yes,menubar=yes');
}
//***********************************************************
function open_frame(frame,addr)
{
	r = new Date();
	window.open(addr+'?r='+r.getTime(),frame,'');
}


//***********************************************************
function refresh_menu(addr)
{
	window.open(addr,'menu','');
}

//***********************************************************
function refresh_komunikat(addr)
{
	window.open(addr,'komunikat','');
}

//***********************************************************
function reload($ref)
{
	//location.reload();
	location.replace($ref);
}

// js dla ihtml w php - koniec
//***********************************************************

function selected_val(_select)
{
	return _select.options[_select.selectedIndex].text;
}


//***********************************************************
function run_proc(_proc_id, _proc_val)
{
	r = new Date();
	window.open('proc.html?proc_id='+_proc_id+'&proc_val='+_proc_val+'&r='+r.getTime(),'proc','');

}

//***********************************************************
function del_option(_select,_ids)
{

	var i;
	if (_select.selectedIndex >= 0)
	{
		for (i = _select.selectedIndex; i < _select.length; i++ )
		{
			if (i == _select.length-1)
			{
				_select.options[i].text = '';
				_select.length--;
			}
			else
			{
				_select.options[i].text =  _select.options[i+1].text;
			}
			
		}
	}
}
//***********************************************************

function strip_id(_string)
{
	a = new Array(2);
	s = new String(_string);
	a = s.split('°');
	return a[1];
}
//***********************************************************

function strip_opis(_string)
{
	a = new Array(2);
	s = new String(_string);
	a = s.split('- ');
	return a[0];
}



//***********************************************************
function get_options (_from)
{
	var i,j,v;
	val_str = new String('')
	val_str = ';';
	for (i = 0; i < _from.length; i++)
	{
		if ((val_str.search(';'+strip_id(_from.options[i].text)+';')) < 0) // warunek odp. za spr. duplikatów
		{
				val_str = val_str +strip_id(_from.options[i].text)+';'; 
		}
	}
	return val_str;
}

//***********************************************************

function get_options_opis (_from)
{
	var i,j,v;
	val_str = new String('')
	val_str = ';';
	for (i = 0; i < _from.length; i++)
	{
		if ((val_str.search(';'+strip_opis(_from.options[i].text)+' - '+strip_id(_from.options[i].text)+';')) < 0) // warunek odp. za spr. duplikatów
		{
				val_str = val_str +strip_opis(_from.options[i].text)+' - '+strip_id(_from.options[i].text)+';'; 
		}
	}
	return val_str;

}

//***********************************************************

function add_option(_from,_to)
{
	var s;
	if ((_from.options[_from.selectedIndex].text != ' ') && (_from.selectedIndex >= 0))
	{
		s = _to.length;
		_to.options[_to.length] = Option(_from.options[_from.selectedIndex].text);
		_to.selectedIndex=s;
	}

}


//***********************************************************

function add_text_pozycja(_from,_to)
{
	var s;
	
		s = _to.length;
		if (s > 0)
		{
			s = (strip_id(_to.options[_to.length-1].text));
			
		}
		
		s++;
		_to.options[_to.length] = Option(s+'. '+_from.value+'                                                                           °'+(s));
		_to.selectedIndex=s;
	
}

function add_option_opis (_from,_to,_opis)
{
	var s;
	if ((_from.options[_from.selectedIndex].text != ' ') && _from.selectedIndex)
	{
		s = _to.length;
		_to.options[_to.length] = Option(_opis.value+' - '+_from.options[_from.selectedIndex].text);
		_to.selectedIndex=s;
	}
}

//***********************************************************
function up_option (_to)
{
	var id,wrk_id,wrk;
	if (_to.selectedIndex > 0)
	{
		if ((_to.options[_to.selectedIndex].text != ' ') && (_to.selectedIndex > 0))
		{
			id = _to.selectedIndex;
			wrk_id = _to.selectedIndex-1;
			wrk = _to.options[wrk_id];
			_to.options[wrk_id] = Option(_to.options[id].text);
			_to.options[id] = wrk;
			_to.selectedIndex = wrk_id;
		}
	}
}

function down_option (_to)
{
	var id,wrk_id,wrk;
	if ((_to.selectedIndex >= 0) && (_to.selectedIndex < _to.length))
	{
		if ((_to.options[_to.selectedIndex].text != ' '))
		{
			id = _to.selectedIndex;
			wrk_id = _to.selectedIndex+1;
			wrk = _to.options[wrk_id];
			_to.options[wrk_id] = Option(_to.options[id].text);
			_to.options[id] = wrk;
			_to.selectedIndex = wrk_id;
		}
	}
}


//***********************************************************

// js dla ihtml w php - koniec

