$(function(){

	$("body").addClass("ready");

	$("#mobile-bar").click(function(){
		if($(this).hasClass("shown")){
			$('#mobile-bar, #mobile-drop').removeClass("shown");
		} else {
			$('#mobile-bar, #mobile-drop').addClass("shown");
		}

		return false;
	});

	$(".header-close").click(
		function(){
			$('#mobile-bar, #mobile-drop').removeClass('shown');
			return false;
		}
	);
});

var BLOGPOST = {},
HOMEPAGE = {};

HOMEPAGE.init = function(){
	$("#slider1 > div:first").addClass("selected").fadeIn();

	$("#paginate-slider1 .prev").click(function(){
		var me = $("#slider1 > .selected");
		var n = me.prev();
		if(n.length < 1){
			n = $("#slider1 > div:last");
		}
		me.removeClass('selected').fadeOut();
		n.addClass('selected').fadeIn();

		return false;
	});
	$("#paginate-slider1 .next").click(function(){
		var me = $("#slider1 > .selected");
		var n = me.next();
		if(n.length < 1){
			n = $("#slider1 > div:first");
		}
		me.removeClass('selected').fadeOut();
		n.addClass('selected').fadeIn();

		return false;
	});

};

BLOGPOST.init = function(blog_name,blog_link){

	setTimeout(function(){
		if($('.facebook-box .fb_share_no_count').length){
			$('.fb_share_no_count').removeClass("fb_share_no_count");
			$('.fb_share_count_inner').html("0");
		}
	},750);

	window.LINKBOXSTYLE = 'small';

	var new_blog_item = SHARETHIS.addEntry({
		title: blog_name,
		url: blog_link
	});
	new_blog_item.attachButton(document.getElementById("ck_sharethis"));
	new_blog_item.attachButton(document.getElementById("ck_sharethis2"));

	if(!window.mobile_device_on){
		$(window).bind("resize",BLOGPOST.checkWindowResize);
		$(window).bind("scroll",BLOGPOST.checkWindowResize);
		BLOGPOST.checkWindowResize();
	}

	$("#ck_sharethis2").bind('mouseenter',function(){
		setTimeout(function(){
			if( $("#stwrapper").offset().top < ( $(window).scrollTop() + 100 ) ){
				$("#stwrapper").css( "top",$(window).scrollTop() + 100 );
			} else if( $("#stwrapper").offset().top > ( $(window).scrollTop() + $(window).height() - 300 ) ){
				$("#stwrapper").css( "top",$(window).scrollTop() + $(window).height() - 300 );
			}
		},300);
	});

	$("#d-noscript-comments").hide();

};


BLOGPOST.checkWindowResize = function(){
	var w = $(window).width();
	var s = $(window).scrollTop();

	s = 272 - s;

	if(s < 30){
		s = 30;
	}

	var leftPos = $("#container_inner").offset().left;
	$("#pagelinks")
		.css("left",leftPos - 75)
		.css("top",s);



	if(w > 1190 && window.LINKBOXSTYLE == 'small'){
		// switch to wide method
		window.LINKBOXSTYLE = 'wide';

		$(".google-box"  ).prependTo("#pagelinks");
		$(".facebook-box").prependTo("#pagelinks");
		$(".twitter-box" ).prependTo("#pagelinks");
		$(".title .title_left").css("width",'auto');
		$(".title .title_right").fadeOut();
		$("#pagelinks").fadeIn();

	} else if(w < 1191 && window.LINXBOXSTYLE != 'small'){
		// swith to small method
		window.LINKBOXSTYLE = 'small';

		$(".google-box"  ).prependTo(".title .linkswrapper");
		$(".facebook-box").prependTo(".title .linkswrapper");
		$(".twitter-box" ).prependTo(".title .linkswrapper");
		$(".title .title_left").css("width",'');
		$(".title .title_right").fadeIn();
		$("#pagelinks").fadeOut();
	}
};



function okno_detail(url, features) {
detail=window.open(url, '', features);
if (!detail.opener) {
detail.opener = self;
}
if (window.focus) {
detail.focus();
}
return false;
}


	
function vytvoritZadost (url, vystup) {
        var http_zadost = false;

        if (window.XMLHttpRequest) { 
            http_zadost = new XMLHttpRequest();
            if (http_zadost.overrideMimeType) {
                http_zadost.overrideMimeType('text/xml');
                // Podívejte na poznámku o tomto řádku níže
            }
        } else if (window.ActiveXObject) { // Internet Explorer
            try {
                http_zadost = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_zadost = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_zadost) {
            alert('Giving up :( Nemohu vytvořit XMLHTTP instanci');
            return false;
        }
        http_zadost.onreadystatechange = function() { stavObsahu(http_zadost, vystup); };
        http_zadost.open('GET', url, true);
        http_zadost.send(null);

    }

    function stavObsahu(http_zadost, vystup) {

        if (http_zadost.readyState == 4) {
            if (http_zadost.status == 200) {


			//alert(http_zadost.responseText);
           document.getElementById(vystup).innerHTML = http_zadost.responseText;

		   } else {
                alert('Byl problém se žádostí.');
            }
        }

    }
	


function createSpace(str){
str=String(str);
if(str.length<=3){
return str;
}
temp=createSpace(str.substring(0,(str.length-3)));
result=temp+" "+(str.substring(str.length-3,str.length));
return result;
}





