var cGUI = function() {
	this.corners = function(target,color) {
	  $(target).append('<div class="ltc ' +color+ '">&nbsp</div>');
	  $(target).append('<div class="rtc ' +color+ '">&nbsp</div>');
	  $(target).append('<div class="lbc ' +color+ '">&nbsp</div>');
	  $(target).append('<div class="rbc ' +color+ '">&nbsp</div>');
	}
	this.picActive = 0;
	this.divActive = 0;
	this.time = 5000;
	this.divtime = 5000;
	this.slideshow = function() {
		var pole = $("#content #fotografie-kampan .obal").children("img");
	  	$(pole[GUI.picActive]).fadeOut(function(){
			if (GUI.picActive == pole.length-1) {
				$(pole[0]).fadeIn();
				GUI.picActive = 0;
			} else {
				$(pole[GUI.picActive+1]).fadeIn();
				GUI.picActive = GUI.picActive + 1;
			};
			//console.log(GUI.picActive);
		});
		setTimeout("GUI.slideshow();",GUI.time);

	}
	this.banner = function() {
		var polediv = $("#content #obal-banner").children("div.banner");
	  	$(polediv[GUI.divActive]).fadeOut(function(){
			if (GUI.divActive == polediv.length-1) {
				$(polediv[0]).fadeIn();
				GUI.divActive = 0;
			} else {
				$(polediv[GUI.divActive+1]).fadeIn();
				GUI.divActive = GUI.divActive + 1;
			};
			//console.log(GUI.picActive);
		});
		setTimeout("GUI.banner();",GUI.divtime);

	}
};
var GUI = new cGUI();
$(
  function() {
		GUI.corners(".corner_box_white", "white");
		GUI.corners(".corner_box_black", "black");
		GUI.corners(".corner_box_none", "none");
			$("a.show").click(function () {	
			  if ($("form.diskuze").is(":hidden")) {
				$("form.diskuze").fadeIn("slow");
			  } else {
				$("form.diskuze").fadeOut("slow");
			  }
			});
		setTimeout("GUI.slideshow();",GUI.time);
		setTimeout("GUI.banner();",GUI.divtime);
/*		setTimeout(function() {
				$("#promo").jCarouselLite({
					btnNext: ".next",
					btnPrev: ".prev",
					visible: 8
				});
		},100); */
		$("#promo a").unbind("mouseover");
		$("#promo a").bind("mouseover", function(){	
					var offset = $(this).offset();
					var textHtml = "<h2>" + $(this).attr("name") + "</h2><p>" + $(this).attr("title") + "</p>";
					$("#promo_buble_content").html(textHtml);
					var bubleHeight = $("#promo_buble").height();
					var bubleWidth = $("#promo_buble").width();
					var extra;
					jQuery.each(jQuery.browser, function(i) {
					  if($.browser.msie){
						 extra = 0;
						 if (jQuery.browser.version.substr(0,1)=="8"){ extra=60; }
					  } else {
						 extra = 50;
						 if ($.browser.opera) { extra=0; }
						};

					});
					$("#promo_buble").css({"top":offset.top - extra - bubleHeight,"left":offset.left + 25 - bubleWidth/2,"opacity":"0.95", "display":"block"});
		});
		$("#promo a").unbind("mouseout");
		$("#promo a").bind("mouseout", function(){	
					$("#promo_buble").css({"display":"none"});
		});
/*		$('a[rel=facebox-video]').unbind('click');
		$('a[rel=facebox-video]').bind('click', function(){
					url = $(this).attr('href');
					$.post(url, function(data,textStatus) {
						_body = $(data).parent().find('#videoplayer').html();
						$.facebox(_body);
					}, 'xml');
					return false;
		});



    				
*/
	}
);