function isString() {
	if (typeof arguments[0] == 'string') return true;
	if (typeof arguments[0] == 'object') {
		var criterion = arguments[0].constructor.toString().match(/string/i);
		return (criterion != null);  
	}
	
	return false;
}

// zjisti, jestli objekt v 1. parametru ma tridu s nazvem 2. parametru
function hasClass ( _object , _className ) {
	if ( isString( _object.className ) )
		if ( _object.className.search(_className) != -1 ) return true;

	return false;
}

// prida tridu str _className do objektu _object
function addClass ( _object , _className ) {
	if( !hasClass( _object, _className ) ) {
		_object.className += ' '+_className;
	}
}

// smaze tridu str _className z objektu _object
function removeClass ( _object , _className ) {
	_rexp = new RegExp ("\s?"+_className+"" , "i" );
	_object.className = _object.className.replace( _rexp , "" );
}

// vrati element nadrazeny elementu _object, ktery ma tridu _className
function getParentByClassName ( _object , _className ) {
	_parentModule = _object;
	while ( _parentModule.className.search (_className) == -1 ) {
		_parentModule = _parentModule.parentNode;
	}

	return _parentModule;
}

// vrati prvni element podrazeny elementu _object, ktery ma tridu _className
function getFirstChildByClassName ( _object , _className ) {
	_bodyId = 0;
	_continue = -1;
	do {
		_bodyId++;
		_target = _object.childNodes[ _bodyId ];
		if ( isString(_target.className) ) _continue = _target.className.search(_className);
	} while ( _continue == -1 );

	return _target;
}

// pridava/odebira objektu _object tridu "hover" (nebo _classNameArg) pri najeti/vyjeti mysi
function hover ( _object , _classNameArg ) {
	_className = _classNameArg || "hover";
	if ( hasClass ( _object , _className ) ) {
		removeClass ( _object , _className );
	} else
		addClass ( _object , _className );
}

// po focusu na input pole ho vymaze, v pripade ze obsahuje pouze default hodnotu. Po bluru ho zase naplni default hodnotou, pokud je prazdny
function inputFocus ( _object ) {
	if ( ( _object.value == _object.defaultValue ) ) {
		_object.value = '';
	}
	else { if ( _object.value == '' ) {
			_object.value = _object.defaultValue;
		}
	}
}

// ovladaci funkce k zalozkam
function showTab ( _object ) {
	_parent = getParentByClassName ( _object , 'tabBox' );
	_target = document.getElementById ( _object.id + 'Tab' );
	_test=0;

	_foldClass = 'tabFold';
	_tabIdSuffix = 'Tab';

	for ( i = 0 ; i < _parent.childNodes.length ; i++ ) {
		_this = _parent.childNodes[i];
		_test += _parent.childNodes[i].className+' ';
		if ( hasClass( _this , _foldClass ) ) {
			//document.getElementById( _this.id + 'Tab' ).style.display = 'none';
			removeClass( document.getElementById( _this.id + _tabIdSuffix ) , 'active' );
			removeClass( _this , 'active' );
		}
	}

	removeClass( _object , 'active' ); //at tam neni dvakrat? B
	addClass( _object , 'active' );
	addClass( _target , 'active' );
}

function showHide ( _objectID , _displayValueArg ) {
	_object = document.getElementById( _objectID );
	_displayValue = _displayValueArg || "inline";

	if( _object.style.display == 'none' || _object.style.display == '' ) {
		_object.style.display = 'inline';
	} else {
		_object.style.display = 'none';
	}
}

function chnapni(obj) {
	if (obj && ((obj.nextSibling.nodeType == 1 && obj.nextSibling.innerHTML) || obj.nextSibling.nodeType == 3)) {
		obj.nextSibling.style.display = "block";
		obj.nextSibling.style.zIndex = 100;
	}
}

function pustto(obj) {
	if (obj) {
		obj.nextSibling.style.display = "none";
		obj.nextSibling.style.zIndex = -1;
	}
}

function img_wnd_open( _object , _descriptionArg , _widthArg , _heightArg ) {
	_imgUrl = _object.href;
	_images = _object.getElementsByTagName( 'img' );
	if( _descriptionArg.value.match( /^.{2,}\s.{2,}/ ) ) {
		_description = _descriptionArg;
	} else {
		_description = _images[0].alt;
	}

	_imageFull = new Image();
	_imageFull.src = _imgUrl;

	_fullWidth = ( _imageFull.width > 0 ) ? _imageFull.width : 550;
	_fullHeight = ( _imageFull.height > 0 ) ? _imageFull.height : 550;

	_width = _widthArg || _fullWidth + 100;
	_height = _heightArg || _fullHeight + 150;

	if( _width > ( screen.width * 0.8 ) ) { _width = screen.width * 0.8; }
	if( _height > ( screen.height * 0.8 ) ) { _height = screen.height * 0.8; }

	window.open('/images/preview_image.php?img_url=' + _imgUrl + '&img_descr=' + _description , 'imgwnd', 'scrollbars = yes, menubar = no, toolbar = no, resizable = yes, status = no, width='+_width+', height='+_height);

	return false;
}

var itmp = new Image();

