/* INICIALIZACE SKRIPTU */
jQuery.fn.initImages = function(i){
	jQuery.ajax({
		type: "GET",
		url: "/fotky/",
		dataType: "html",
		success: parseHtml
	});
}

function parseHtml(my_html) {

                var wrapper = jQuery(my_html);
                var objects = wrapper.find("#mainIn ul");

                objects.find("li").each(function() {
                    arrayOfImages.push(jQuery(this).children("img").attr("src"));
		})

		for(i=0;i<arrayOfImages.length;i++){
                    var elem = '';
                    elem = jQuery("<img src='" + arrayOfImages[i] + "' alt='' />")

                    jQuery("#coin-slider").append(elem)
		}

		jQuery("#coin-slider").coinslider({
                    width: 586, // width of slider panel
                    height: 205, // height of slider panel
                    delay: 10000, // delay between images in ms
                    opacity: 0.7, // opacity of title and navigation
                    titleSpeed: 500, // speed of title appereance in ms
                    effect: '', // random, swirl, rain, straight
                    navigation: true, // prev next and buttons
                    hoverPause: true, // pause on hover
                    links: false
                });

}

arrayOfImages = []
arrayOfImagesOrig = []

jQuery(document).ready(function(){

        jQuery(this).initImages();

	jQuery("img[hspace]").each(function(){
	   var space = jQuery(this).attr("hspace");
	   jQuery(this).css({"margin-left":space + "px" , "margin-right": space + "px"})
	})

	jQuery("img[vspace]").each(function(){
	   var space = jQuery(this).attr("vspace");
	   jQuery(this).css({"margin-top":space + "px" , "margin-bottom": space + "px"})
	})

	jQuery("#content :text, #content textarea").addClass("text_input");
	jQuery("#content :submit, #content :reset").addClass("submit_input")

	jQuery(".answerBar img").attr("src", "/img/poll-bar.png");

	jQuery("blockquote").each(function(){
		jQuery(this).children(":last").css({marginBottom: "0"})
	})

	jQuery("#nav ul:first > li:first").addClass("first");
	jQuery("#nav ul:first > li:last").addClass("last");
        jQuery("#nav ul:first > li > a").prepend("<span></span>");

	jQuery("#rbcSystemIdentifierLogo").after("<span id='text_overlay'></span>");

	/* nastaveni vysky obsahu dokumentu */
	/*column_height = jQuery(".leftBar").height() + 80;
	content_height = jQuery("#mainOut").height() + 285;

	jQuery("#wrapper").css({height: Math.max(column_height, content_height) + 100 + "px"});*/
	column_height = jQuery(".leftBar").height();
	content_height = jQuery("#mainOut").height();

	local_max = Math.max(column_height, content_height)
	if(column_height > content_height) { local_max += 180; }

	jQuery("#wrapper").css({height: local_max  + "px"});

})

