
function $f(id) {
	return document.getElementById(id);
}

function show_big_img(file, height)
{
	if(!height) height=580;
	var width=560;
	var left=180;
	var top=100;

	wopener = window.open($f('server_www').value+'image/detail/?image='+file, 'image', 'toolbar=0,location=0,status=1,resizable=1,scrollbars=0,width='+ width +',height='+ height +',top='+ top +',left='+ left);
	wopener.focus();
	
	return wopener;	
}

function submenu(show, id)
{
	if(show)
	{
		$f('submenu_' + id).style.zIndex = '100';
		$f('submenu_' + id).style.display = 'block';
	}
	else
	{
		$f('submenu_' + id).style.zIndex = '10';
		$f('submenu_' + id).style.display = 'none';
	}
} 

function printPage() 
{
  window.print();
}

function slideSwitch() {
    var $active = $('#slideshow DIV.active');

    if ( $active.length == 0 ) $active = $('#slideshow DIV:last');

    // use this to pull the divs in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow DIV:first');

    // uncomment below to pull the divs randomly
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

var active_car_item = '';

$(function() {
	
	if($('.models_bar .model_item'))
	{
		$('.models_bar .model_item').mouseover( function(){
	
			 $(this).click( function() {
				 location.href = $("a:first", this).attr('href');
			 });
			 $("div:first", this).show();
			 $(this).addClass('model_item_over');
		});

		$('.models_bar .model_item').mouseout( function(){
			 $("div:first", this).hide();
			 $(this).removeClass('model_item_over');
		});
	}
	
	
	if($('.car_bar .car_item'))
	{
		$('.car_bar .car_item').mouseover( function(){
			if($("a:first", this).attr('href'))
			{
				$(this).click( function() {
				 location.href = $("a:first", this).attr('href'); 
				});
			}
			 $(this).addClass('car_item_over');
		});
	
		$('.car_bar .car_item').mouseout( function(){
			  $(this).removeClass('car_item_over');
		});
	}
	
	if($('#galerie_box'))
	{
		$('#galerie_box div').mouseover( function(){
			$(this).css("border", "1px solid #ff0000");
		});

		$('#galerie_box div').mouseout( function(){
			$(this).css("border", "1px solid #ababab");
		});
	}
	
	if($('#models_list'))
	{
		$('#models_list div').mouseover( function(){
			$(this).css("border-bottom", "5px solid #ff0000");
		});

		$('#models_list div').mouseout( function(){
			$(this).css("border-bottom", "5px solid #ffffff");
		});
	}
    //setInterval( "slideSwitch()", 5000 );
});

function menuShow(status, id, obj)
{
	if(!$f(id)) return null;


	if(status)
  {
    //$(obj).append('<div class="white-line"></div>');
    $(obj).children('.white-line').css('width', $(obj).width());
    $(obj).children('.white-line').css('display', 'block');
    $f(id).style.display = 'block';
  }
	else 
  {
    //$(obj).children('.white-line').remove();
    $(obj).children('.white-line').css('display', 'none');
    $f(id).style.display = 'none';
  }
}

function wOpen(obj) {
	window.open(obj.href,'WinTip','scrolling=yes,resizable=yes,status=yes,top=0,left=0');
} 


$(document).ready(function(){
	if($('#slideshow'))
	{
	  var currentPosition = 0;
	  var slideWidth = 205;
	  var slides = $('.slide');
	  var numberOfSlides = slides.length;

	  // Remove scrollbar in JS
	  $('#slidesContainer').css('overflow', 'hidden');

	  // Wrap all .slides with #slideInner div
	  slides
	    .wrapAll('<div id="slideInner"></div>')
	    // Float left to display horizontally, readjust .slides width
		.css({
	      'float' : 'left',
	      'width' : slideWidth
	    });

	  // Set #slideInner width equal to total width of all slides
	  $('#slideInner').css('width', slideWidth * numberOfSlides + 20 * numberOfSlides);

	  // Insert controls in the DOM
	  $('#slideshow')
	    .prepend('<span class="control" id="leftControl">Clicking moves left</span>')
	    .append('<span class="control" id="rightControl">Clicking moves right</span>');


	  // manageControls: Hides and Shows controls depending on currentPosition
	  function manageControls(position){
	    // Hide left arrow if position is first slide
		if(position==0){$('#leftControl').hide()} else{$('#leftControl').show()}
		// Hide right arrow if position is last slide
	    if(position==numberOfSlides-1){$('#rightControl').hide()} else{$('#rightControl').show()}
	  }	
	  
	  // Hide left arrow control on first load
	  manageControls(currentPosition);

	  // Create event listeners for .controls clicks
	  $('.control')
	    .bind('click', function(){
	    // Determine new position
		currentPosition = ($(this).attr('id')=='rightControl') ? currentPosition+1 : currentPosition-1;
	    
		// Hide / show controls
	    manageControls(currentPosition);
	    // Move slideInner using margin-left
	    $('#slideInner').animate({
	      'marginLeft' : slideWidth*(-currentPosition)
	    });
	  });
	}	
});

var kurs_day;
function changeCourse()
{
	if (kurs_day==5) kurs_day = 2;
	else kurs_day = 5;
	
	$f('kurs_graf').src='http://graf.kurzy.cz/grafy-kurzu-men/online_d.php?c=10&m1=EUR&m2=CZK&ndb='+kurs_day;
}

function doBlink() {
	  // Blink, Blink, Blink...
	  var blink = document.all.tags("blink")
	  for (var i=0; i < blink.length; i++)
	    blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : "" 
}

function startBlink() {
	  // Make sure it is IE4
	  if (document.all)
	    setInterval("doBlink()",700)
}
window.onload = startBlink;


