$(function() {
	$("div#makeMeScrollable").smoothDivScroll({autoScroll: "onstart",
												autoScrollDirection: "backandforth",
												autoScrollStep: 1,
												autoScrollInterval: 15,
												startAtElementId: "startAtMe",
												visibleHotSpots: "always"});

});



 $(function() {
        $('#gallery a,a.light').lightBox();
 });
 






window.onload = function() {
    targetBlank();
}

function targetBlank() {
    var elements = getElementsByClass("target");

    for (var i = 0; i < elements.length; i++) {
        elements[i].onclick = function(e) {
            window.open(this.href);
            return preventDefaultAction(e);
        }
    }
}





$(document).ready(function()
{
		flashtop();
		getOpened();
		
		var n = 0, secondTerm;
		
		var arr = location.href.split( '#' );
	
		if ( typeof arr[1] == 'undefined' || arr[1] == null )
		{
			
			secondTerm = '';
		}
		else
		{
			showMore( arr[1] );
			
			secondTerm = arr[1];

		}
		
		$( 'h2.aktuality' ).each( function(){
			n++

			if ( n > 2 )
			{
				return;
			}
			else if ( $( this ).attr('id').replace( '_nadpis', '' ) != secondTerm )
			{
				showMore( $( this ).attr('id').replace( '_nadpis', '' ) );
			}
		} );
	
		

});


function getOpened()
{
	
}





//hudba na HP
function flashtop(){
	var vars = {};
	var params = {
 		allowScriptAccess: "sameDomain",
		align: "middle",
		wmode: "window",
		scale: "showall",
	  loop:"true",
	  play:"true",
	  quality:"high",
		menu: true
	};
	var attrs = {};
	swfobject.embedSWF('/files/flash/title.swf' , "anim_box", "680", "186", "8.0.0.0", vars, attrs, params);
	return false;

}



function preventDefaultAction(e) {
  if (e && e.preventDefault) {
      e.preventDefault;
  } else {
      window.event.returnValue = false;
  }
  return false;
}

// vrátí pole elementů nalezených podle class
function getElementsByClass( searchClass, domNode, tagName) {
                if (domNode == null) domNode = document;
                if (tagName == null) tagName = '*';

    var el = new Array();
                var tags = domNode.getElementsByTagName(tagName);
                var tcl = " "+searchClass+" ";

    for(i=0,j=0; i<tags.length; i++) {
                               var test = " " + tags[i].className + " ";
                               if (test.indexOf(tcl) != -1)
                                                el[j++] = tags[i];
                }

                return el;
}





$(document).ready(function(){

    /*
     *   levy pruh
     */

    var published = new Array();

    function recursion( from, usedArr ) {
            var value = from[Math.floor(Math.random()*from.length)];
            var used = false;
            for(i=0;i<usedArr.length;i++){
                if( usedArr[i] == value ) used = true;
            }
            if( ! used ) return value;
            else return recursion( from, usedArr );
    }



    for(i=0;i<published.length;i++){
      $('#box'+i+'').addClass( published[i] );
    }

    /*
     *  tlacitka
     */
     
     
    var params = location.href.split("#");

		if(params[1])
		{
				var id = params[1];

				document.getElementById(id+"Block").style.display="block";
				document.getElementById(id+"_vice").innerHTML = 'Méně';
		}

     
     
    $('.allHref').click(function(){
        showMore( $( this ).parent().attr('id') );
		
		return false;
    });
	
	$('.titHref').click(function(){
        showMore( $( this ).parent().attr( 'id' ).replace( '_nadpis', '' ) );
		
		return false;
    });
});

function showMore( id )
{
         var block = $( '#' + id + 'Block' ).css('display');
        $( '#' + id + 'Block' ).slideToggle();

        
        if(block == 'none')
				{
          $( '#'+id+"_vice").html( 'Méně' );
				}
				else
				{
          $( '#'+id+"_vice").html( 'Více' );
				}
}

