	    $(document).ready(function()
  	  {
				reinitall();

				/**
				 * Slideshow referencí
			   */
		   	$('#references .references-slideshow:gt(0)').css({opacity:0, display: 'none'});
		   	$('#references .references-slideshow:nth-child(1)').css({opacity:1, display: 'block'});
		    $('#references').mouseover(function() { reference_stop() }).mouseout(function() { reference_start() });
				$('#references .paging-center a.list').click(function() {
					reference_fadeto($(this).text());
					return false;
				});
				reference_start();

		    /*
				$('#references .references-slideshow:gt(0)').hide();
		    $('#references').mouseover(function() { reference_stop() }).mouseout(function() { reference_start() });
				reference_start();
				$('#references .paging-center a.list').click(function() {
					reference_fadeto($(this).text());
					return false;
				});
				*/

				$('#flash-header').flash({
			    src: '/swf/header.swf',
			    width: '100%',
			    height: 215,
			    wmode: 'transparent',
			    id:	'header_flash_obj',
			    scale: 'noscale',
				});
 	  	});
			
			function reinitall()
			{
				/**
				 * Menu
				 */
			 	/*
				$('ul#menu').superfish(
				{
					autoArrows: false
				});
				*/

				/**
				 * Inbox labely
			   */
  	  	var els = $('input[title],textarea[title]');
  	  	els.unbind();
  	  	els.each(function()
				{
					if ($(this).val() == '')
					{
						$(this).val($(this).attr('title'));
						$(this).addClass('inactive');
					}
  	  	});
				els.focus(function()
				{
					if ($(this).val() == $(this).attr('title'))
					{
						$(this).val('');
						$(this).removeClass('inactive');
					}
				});

				els.focusout(function()
				{
					if ($(this).val() == '')
					{
						$(this).val($(this).attr('title'));
						$(this).addClass('inactive');
					}
				});

				$('form').unbind();
				$('form').submit(function()
				{
	  	  	var els = $('input[title],textarea[title]');
	  	  	els.each(function()
					{
						if ($(this).val() == $(this).attr('title'))
							$(this).val('');
	  	  	});
				});

				/**
				 * Kontaktní formulář
			   */
				$('#cf_subject').unbind();
				$('#cf_subject').change(function() {
					cf_subject_change();
				});
				cf_subject_change();


				/**
				 * Slideshow produktů
			   */
		   	$('#product-slides .product:gt(0)').css({opacity:0, display: 'none'});
		   	$('#product-slides .product:nth-child(1)').css({opacity:1, display: 'block'});
		    $('#product-slides').mouseover(function() { product_stop() }).mouseout(function() { product_start() });
		    product_start();
/*
				var seli2 = window.setInterval(function () {
					if (seli && document.getElementById('header_flash_obj').clickBut)
					{
						document.getElementById('header_flash_obj').clickBut(seli);
						clearInterval(seli2);
					}//if
				}, 100);
*/
    	};//function

			function cf_subject_change()
			{
					if ($('#cf_subject').val() == 1)
					{
						$('#cf_checks').show();
					}
					else
					{
						$('#cf_checks').hide();
					}//if
			}//function

			var referenceslideshow = null;
			var referenceslideshow_pos = 1;

			function reference_next()
			{
				referenceslideshow = setTimeout(function() {
				    var m = $('#references .references-slideshow').size();
				    var oldpos = referenceslideshow_pos;
						referenceslideshow_pos += 1;
				    if (referenceslideshow_pos > m) {
				        referenceslideshow_pos = 1;
				    }
				    $('#references .references-slideshow').stop().css('display', 'none');
				    $("#references .references-slideshow:nth-child(" + (referenceslideshow_pos) + ")").css('display', 'block');
				    $("#references .references-slideshow:nth-child(" + (oldpos) + ")").css('display', 'block');
				    $("#references .references-slideshow:nth-child(" + (referenceslideshow_pos) + ")").animate({
				        opacity: 1
				    }, 1000);
				    $("#references .references-slideshow:nth-child(" + (oldpos) + ")").animate({
				        opacity: 0, display: 'none'
				    }, 1000);
				    //$("#references .references-slideshow:nth-child(" + (oldpos) + ")").css('display', 'none');

				    reference_next();
				}, 5000);
			}

			function reference_start()
			{
				//reference_stop();

				if (!referenceslideshow)
				{
					reference_next();
				}
			}//function

			function reference_stop()
			{
				clearInterval(referenceslideshow);
				referenceslideshow = null;
			}//function

			function reference_fadeto(index) {
				reference_stop();
				var fadein = $('#references');
				fadein.children().stop();
				$('#references .references-slideshow').css({opacity:0, display: 'none'});
				$('#references-slideshow-' + index).css({opacity:1, display: 'block'});
				$('#references').unbind();
			}//function



/*
			var referenceslideshow = null;

			function reference_start()
			{
				reference_stop();
				var fadein = $('#references'); //.addClass('fadein-js');
				fadein.children().slice(1).hide();
				referenceslideshow = setInterval(function(){
					fadein.children().eq(0).fadeOut(1000)
					.next().fadeIn(1000)
					.end().appendTo(fadein);
				}, 5000);
			}//function

			function reference_stop()
			{
				clearInterval(referenceslideshow);
			}//function

			function reference_fadeto(index) {
				reference_stop();
				var fadein = $('#references');
				fadein.children().stop().hide();
				$('#references-slideshow-' + index).show();
				$('#references').unbind();
			}//function
*/

			var productslideshow = null;
			var productslideshow_pos = 1;

			function product_next()
			{
				productslideshow = setTimeout(function() {
				    var m = $('#product-slides .product').size();
				    var oldpos = productslideshow_pos;
						productslideshow_pos += 1;
				    if (productslideshow_pos > m) {
				        productslideshow_pos = 1;
				    }
				    $('#product-slides .product').stop().css('display', 'none');
				    $("#product-slides .product:nth-child(" + (productslideshow_pos) + ")").css('display', 'block');
				    $("#product-slides .product:nth-child(" + (oldpos) + ")").css('display', 'block');
				    $("#product-slides .product:nth-child(" + (productslideshow_pos) + ")").animate({
				        opacity: 1
				    }, 1000);
				    $("#product-slides .product:nth-child(" + (oldpos) + ")").animate({
				        opacity: 0, display: 'none'
				    }, 1000);

				    product_next();
				}, 5000);
			}

			function product_start()
			{
				//reference_stop();

				if (!productslideshow)
				{
					product_next();
				}
			}//function

			function product_stop()
			{
				clearInterval(productslideshow);
				productslideshow = null;
			}//function

			function product_fadenext() {
				product_stop();
				
		    var m = $('#product-slides .product').size();
				productslideshow_pos += 1;
		    if (productslideshow_pos > m) {
		        productslideshow_pos = 1;
		    }
		    $('#product-slides .product').stop().css({opacity:1, display: 'none'});
		    $("#product-slides .product:nth-child(" + (productslideshow_pos) + ")").show();
			}//function

			function product_fadeprev() {
				product_stop();
				
		    var m = $('#product-slides .product').size();
				productslideshow_pos -= 1;
		    if (productslideshow_pos < 1) {
		        productslideshow_pos = m;
		    }
		    $('#product-slides .product').stop().css({opacity:1, display: 'none'});
		    $("#product-slides .product:nth-child(" + (productslideshow_pos) + ")").show();
			}

/*
			var productlideshow = null;

			function product_start()
			{
				product_stop();
				var fadein = $('#product-slides'); //.addClass('fadein-js');
				fadein.children().slice(1).hide();
				productlideshow = setInterval(function(){
					fadein.children().eq(0).fadeOut(1000)
					.next().fadeIn(1000)
					.end().appendTo(fadein);
				}, 5000);
			}//function

			function product_stop()
			{
				clearInterval(productlideshow);
			}//function

			function product_fadenext() {
				product_stop();
				var el = $('#product-slides .product:visible').next();
				$('#product-slides').unbind();

				if (el.attr('id'))
				{
					$('#product-slides').children().stop().hide();
					el.show();
				}
				else
				{
					$('#product-slides').children().stop().hide();
					$('#product-slides').children().first().show();
				}//if
			}//function

			function product_fadeprev() {
				product_stop();
				var el = $('#product-slides .product:visible').prev();
				$('#product-slides').unbind();

				if (el.attr('id'))
				{
					$('#product-slides').children().stop().hide();
					el.show();
				}
				else
				{
					$('#product-slides').children().stop().hide();
					$('#product-slides').children().last().show();
				}//if
			}
*/

