// JScript source code

$(document).ready(function () {
	
	if ($('#nav').is('ul'))
	{
		$('#nav').droppy({speed: 100});
	}
	
    if ($('#hmi1').is('div'))
    {
	    $('#hmi1').click(function(e){changeImage(e)});
	    $('#hmi2').click(function(e){changeImage(e)});
	    $('#hmi3').click(function(e){changeImage(e)});
	    
	    $('#header-content').attr('class','o1');
	    $('#hmi1').attr('class','t2');
	    $('#hmi2').attr('class','t3');
	    $('#hmi3').attr('class','t4');
	
	    $('#header-content').data('cur',1);
	    $('#hmi1').data('cur',2);
	    $('#hmi2').data('cur',3);
	    $('#hmi3').data('cur',4);
    }
	
	$('#logo').css("display","none");
	$('#hmi1').css("display","none");
	$('#hmi2').css("display","none");
	$('#hmi3').css("display","none");
    if ($('#predajkv').is('div'))
    {
    	$('#predajkv').css("display","none");
    }
    else
    {
    	$('#header-content').css("display","none");
    }
	$('#nav').css("display","none");
    	
    $('#blind').fadeOut('fast',function() {
        if ($('#predajkv').is('div'))
        {
            $('#nav').fadeIn(600, function() {
                $('#hmi1').fadeIn(400);
                $('#hmi2').fadeIn(800);
                $('#hmi3').fadeIn(1200);
            });
        	$('#predajkv').fadeIn(800);
            $('#logo').fadeIn(600);
        }
        else
        {
	        $('#header-content').toggle(600, function() {
	            $('#logo').fadeIn(600);
	            $('#nav').fadeIn(600, function() {
	                $('#hmi1').fadeIn(400);
	                $('#hmi2').fadeIn(800);
	                $('#hmi3').fadeIn(1200);
	            });
		    });
        }
    });
});

function changeImage(e)
{
    $('#hmi3').fadeOut(200);
    $('#hmi2').fadeOut(400);
    $('#hmi1').fadeOut(600, function() {
        $('#nav').hide();
        $('#header-content').toggle(400, function() {
            var n=$('#'+e.target.id).data('cur');
            var o=$('#header-content').data('cur');
            
            $('#'+e.target.id).attr('class','t'+o);
            $('#header-content').attr('class','o'+n);
            $('#'+e.target.id).data('cur',o);
            $('#header-content').data('cur',n);
            
            $('#header-content').toggle(600, function() {
                $('#nav').fadeIn(600);
                $('#hmi1').fadeIn(200);
                $('#hmi2').fadeIn(800);
                $('#hmi3').fadeIn(1200);
            });
        });
    });
}


$(document).ready(function(){
	
	if(jQuery().prettyPhoto) 
	{
		$("a[rel^='prettyPhoto']").prettyPhoto({theme: 'dark_rounded',allowresize: true,animationSpeed: 'fast'});
	}
	
	if(jQuery().editable)
	{
		$(".editable_texy").editable("?do=saveTexy", { 
		    indicator : "<img src='/images/indicator.gif'>",
		    loadurl   : "?do=loadTexy",
		    loadtype  : "post",
		    type      : "autogrow",
		    rows      : "auto",
		    submit    : "OK",
		    cancel    : "",
		    tooltip   : "Click to edit..."
		});
		
		$(".editable_text").editable("?do=saveText", { 
		    indicator : "<img src='/images/indicator.gif'>",
		    loadurl   : "?do=loadText",
		    loadtype  : "post",
		    type      : "text",
		    width     : 200,
		    submit    : "OK",
		    cancel    : "",
		    tooltip   : "Click to edit..."
		});
	}
	
	if(jQuery().autogrow)
	{
		$("TEXTAREA").autogrow({
			maxHeight: 500,
			minHeight: 30,
			lineHeight: 16
		});	
	}
	
	$('input.datepicker').datepicker();
	
	if ($("div.flash-messages").is('div'))
	{
		$("div.flash-messages").livequery(function () {
			var el = $(this);
			setTimeout(function () {
				el.animate({"opacity": 0}, 2000);
				el.slideUp();
			}, 3000);
		});
	}
});


