function loadu1tab() {
  var x = 'x';
  jQuery.post(blogUrl + "/wp-content/themes/baerensound/ajaxcalls/u1tab.php",
  			{ x: x },
  			function(data){
  				jQuery('#stdBanner').html(data);
  		});
}

$(document).ready(function () {

  // U1 TAB
  
  $(".u1tab").click( function() {
    if(jQuery('#stdBanner').is('*')) {
      loadu1tab();
		} else window.location.href = "/?go=u1tab";
  });
  
  // U1 TAB
  refresh = 'yes';
  $("#refreshu1").click( function() {
    jQuery.post(blogUrl + "/wp-content/themes/baerensound/ajaxcalls/u1tab.php",
			{ refresh: refresh },
			function(data){
				if(data) jQuery('#stdBanner').html(data);
			});
  });

   // News comments Slider 18.01.2011
  $('.stdComments').jCarouselLite({
    btnNext: ".nextnews",
    btnPrev: ".prevnews"
  });
  $('.stdCommentsRead').jCarouselLite({
    btnNext: ".nextread",
    btnPrev: ".prevread"
  });
  
  // Partner Slider
  $('.stdPartner').jCarouselLite({
    btnNext: ".next",
    btnPrev: ".prev"
  });

  // Banner Slider
  /***************** NEW - 18.03.11 */
  var theInt = null;
  var curclicked = 0;
  var stop = 0;

  $("#main-photo-slider").codaSlider();
  theInterval();
  $(".cross-link").click(function(){
    clearInterval(theInt);
    theInterval();
  });
  
  function theInterval(){
    clearInterval(theInt);
        theInt = setInterval(function(){
                $(".stripNavR a").trigger('click');
                curclicked++;
               /* $(".controls .cross-link").each(function(){
                  $(this).removeClass("active");
                });
                $(".controls .cross-link").eq(curclicked).addClass("active");*/
                if( 4 == curclicked ) curclicked = 0;
        }, 8000);
  };
  /***************** NEW (ende) - 18.03.11 */

  // margin fixes
  $('#stdCommunity .comments li:nth-child(2n), #stdEvents .events li:nth-child(2n)').css('marginRight', 0);

  // Form placeholder
  function placeholder() {
    $("input[type=text], input[type=password], textarea").each(function () {
      var phvalue = $(this).attr("placeholder");
      $(this).val(phvalue);
    });
  }
  placeholder();
  $("input[type=text], input[type=password], textarea").focusin(function () {
    var phvalue = $(this).attr("placeholder");
    if (phvalue == $(this).val()) {
      $(this).val("");
    }
  });
  $("input[type=text], input[type=password], textarea").focusout(function () {
    var phvalue = $(this).attr("placeholder");
    if ($(this).val() == "") {
      $(this).val(phvalue);
    }
  });

  // Tab switching

  // ** show first entry
  $(".stdTabContent > li").hide();
  $(".stdTabContent").each(function () {
    $(this).children("li:eq(0)").show();
  });
  $(".stdTabs").each(function () {
    $(this).children("li:eq(0)").addClass("active");
  });

  $('.stdTabs a').click(function () {
    // ** set active on click
    $(this).parent().parent().children().removeClass('active');
    $(this).parent().addClass('active');

    // ** show content with specific ID
    $obj = $(this).parent().parent().next('.stdTabContent');
    var nr = $(this).parent().attr("rel");
    $obj.children('li').hide();
    $obj.children('li:eq(' + nr + ')').show();
  });
  
  // same heights
  sameHeight('.col.left','.col.right');
});


function sameHeight(one, two) {
  if ($(one).height() > $(two).height()) $(two).height($(one).height());
  else $(one).height($(two).height());
}

function radioPopup()
{
  radioPopup1=window.open('radio.html','Radio','height=275,width=212');
}

function newsletterPopup()
{
  newsletterPopup1=window.open('/newsletter','Newsletteranmeldung','height=360,width=212');
}

// accordion (Radio Box)
$(document).ready(function() {
	$('#stdRadio li.sub').hide(); // zuerst alle schließen
  
  $('#stdBanner #stdRadio li.top:first-child').addClass("active").next().show();
  
	$('#stdRadio li.top').click( function() {
		var cur = $(this).next();
    $(this).parent().children().removeClass("active");
    $(this).addClass("active");
		var old = $(this).parent().find('.sub:visible');

		/* Zweifacher Klick auf ein Element */
		if ( cur.is(':visible') ) {
			cur.slideToggle(400);
      $(this).removeClass("active");
			return false;
		}

		/* Animationszeit */
		old.slideToggle(400);
		cur.stop().slideToggle(400);
	} );
});


// datepicker
$(function() {
		$(".date").datepicker({
			dateFormat: 'dd.mm.yy',
			firstDay: 1,
			minDate: -0
		});
});

function accordion() {
	$('#stdRadio li.sub').hide(); // zuerst alle schließen
  
  $('#stdBanner #stdRadio li.top:first-child').addClass("active").next().show();
  
	$('#stdRadio li.top').click( function() {
		var cur = $(this).next();
    $(this).parent().children().removeClass("active");
    $(this).addClass("active");
		var old = $(this).parent().find('.sub:visible');

		/* Zweifacher Klick auf ein Element */
		if ( cur.is(':visible') ) {
			cur.slideToggle(400);
      $(this).removeClass("active");
			return false;
		}

		/* Animationszeit */
		old.slideToggle(400);
		cur.stop().slideToggle(400);
	} );
}
