// JavaScript Document
 
function novyokno( odkaz )
{
    try
	{
		var test;
		
		test = ! window.open( odkaz );
		return test;
	}
	
	catch (e)
	{
		alert( "Při otvírání nového okna došlo k vnitřní chybě JavaScriptu. Zkuste povolit otevírání nových oken nebo kontaktujte správce webu! Odkaz se otevře ve stávajícím okně" );
		return true;
	}
}


//************ FUNKCE PRO PRACI SE SELEKTEM ***************************************//
function selectSelOpt( obj, val )			
{	
	if( obj == null ) return false;
	
	for( var i = 0; i < obj.options.length; i++ )		
	{	
		if( obj.options[i].value == val )
		{
			obj.options[i].selected = true;
			break;
		}	
	}	
}

function selectDeleteOpt( obj )			
{	
	if( obj == null ) return false;
	
	for( var i = 0; i < obj.options.length; i++ )		
	{	
		if( obj.options[i].selected == true ) obj.options[i]=null;	
	}	
}
  	
function selectAddOpt( obj, value, text )  
{	
	if( obj == null ) return false;
	
	var no = new Option();	
		no.value = value;    
		no.text = text; 
	
	obj.options[obj.options.length] = no; 
}

// hleda shodu podle hodnoty value //
function selectExistsOpt( box, val )
{
	if( box == null ) return true;
	if( box.options == null ) return false;
	if( box.options.length == null ) return false;
	
	for( var i = 0; i < box.options.length; i++ )  	
	{ 
		if( box.options[i].value == val )
		{	
			return true;
			break;
		}    
	}	
	
	return false;
}


function selectCountOpt( box )
{
	var cnt = 0;
	
	if( box == null ) return cnt;
	if( box.options == null ) return cnt;
	if( box.options.length == null ) return cnt;
	
	for( var i = 0; i < box.options.length; i++ )  	
	{ 
		cnt++;  
	}	
	
	return cnt;
}

function selectMove( fbox, tbox )  
{	
	if( fbox == null ) return false;
	if( tbox == null ) return false;
	if( fbox.options == null ) return false;
	if( fbox.options.length == null ) return false;
	
	for( var i=0; i < fbox.options.length; i++ )  	
	{  
		if( fbox.options[i].selected && fbox.options[i].value != "" )  
		{   
			if( fbox.options[i].value == "0" ) continue;	
			
			if( selectExistsOpt( tbox, fbox.options[i].value ) == false )
			{
				var no = new Option();	
				no.value = fbox.options[i].value;    
				no.text = fbox.options[i].text; 
				tbox.options[tbox.options.length] = no; 
			}
		} 
	} 
}


function selectClear( box ) 
{ 	
	if( box == null ) return false;
	if( box.options == null ) return false;
	if( box.options.length == null ) return false;
	
	for( var i=0; i < box.options.length; i++ )  	
	{ 
		box.options[i]=null;	
		i--;    
	}	
}


function selectMove2( box ) 
{ 	
	if( box == null ) return false;
	if( box.options == null ) return false;
	if( box.options.length == null ) return false;
	
	for( var i=0; i < box.options.length; i++ )  	
	{ 
		if( box.options[i].selected && box.options[i].value != "" )  
		{	
			box.options[i]=null;	
			i--; 
		}   
	}	
}


function selectFind( box )  		
{ 	
	if( box == null ) return false;
	if( box.options == null ) return false;
	if( box.options.length == null ) return false;
	
	for( i=0; i < box.options.length; i++ )
	{		
		box.options[i].selected = true;
	} 
}


function selectUnFind( box )  		
{ 	
	if( box == null ) return false;
	if( box.options == null ) return false;
	if( box.options.length == null ) return false;
	
	for( i=0; i < box.options.length; i++ )
	{		
		box.options[i].selected = '';
	} 
}


function selectReturnOptionsAsString( box, odd )
{
	if( odd == null ) odd = ",";
	
	var out = "";
	var tmpodd = "";
	
	if( box == null ) return false;
	if( box.options == null ) return false;
	if( box.options.length == null ) return false;
	
	for( var i = 0; i < box.options.length; i++ )  	
	{ 
		out+= tmpodd+box.options[i].value;  
		tmpodd = odd;
	}	
	
	return out;
}


function selectIstEmpty( box )
{
	if( box == null ) return true;
	if( box.options == null ) return true;
	if( box.options.length == null ) return true;
	
	for( i=0; i<box.options.length; i++ )
	{		
		return false;
		break;
	} 
	
	return true;
}

function selectIsNotEmpty( box )
{
	return ! selectIstEmpty( box );
}
//************ KONEC FUNKCI PRO PRACI SE SELEKTEM *********************************//