
//ACCORDS
function accords(content,bar) {
   if (!content.length && !bar.length) return;
      content.hide();
   bar.click( function() {
   bar.removeClass("current");
   content.not(":hidden").slideUp('slow');
   //$(this).next().not(":visible").slideDown('slow').prev().addClass("current");
   var current = $(this);
   $(this).next().not(":visible").slideDown('slow',function() {
      current.addClass("current");
   });
});
}

// TABS
function tabs(pages) {

if (!pages.length) return;

pages.addClass("dyn-tabs");
pages.first().show();

var tabNavigation = $('<dl id="tabs" />').insertBefore(pages.first());

pages.each(function() {
   var listElement = $("<dt />");
   var label = $(this).attr("title") ? $(this).attr("title") : "Kein Label";
   listElement.text(label);
   tabNavigation.append(listElement);
});

var items = tabNavigation.find("dt");
items.first().addClass("current");

items.click(function() {
   items.removeClass("current");
   $(this).addClass("current");
   pages.hide();
   pages.eq($(this).index()).fadeIn("slow");
});

}

$(document).ready(function(){

tabs($("div.tabs"));

accords($(".content"),$(".bar"));

// FANCYBOX
$("a.fancyboxStyleDefault").fancybox({
   'titlePosition':'inside',
   'transitionIn':'none',
   'transitionOut':'none',
   'titleFormat':function(title, currentArray, currentIndex, currentOpts) {
return '<span id="fancybox-title-inside">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' : ' + title : '') + '</span>';
}
});

$("a.fancyboxStyleSpecial-1").fancybox({
   'titlePosition':'inside',
   'titleFormat':function(title, currentArray, currentIndex, currentOpts) {
return '<span id="fancybox-title-inside">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' : ' + title : '') + '</span>';
}
});

$("a.fancyboxStyleSpecial-2").fancybox({
   'titlePosition':'inside',
   'transitionIn':'elastic',
   'transitionOut':'elastic',
   'titleFormat':function(title, currentArray, currentIndex, currentOpts) {
return '<span id="fancybox-title-inside">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' : ' + title : '') + '</span>';
}
});

$("a.fancyboxStyleInline-1").fancybox({
   'width':'75%',
   'height':'75%',
   'autoScale':false,
   'transitionIn':'none',
   'transitionOut':'none',
   'type':'iframe'});

$("a.fancyboxStyleInline-2").fancybox({
   'width':'90%',
   'height':'90%',
   'autoScale':false,
   'transitionIn':'none',
   'transitionOut':'none',
   'type':'iframe'});

$("a.fancyboxStyleInline-3").fancybox({
   'width':980,
   'height':600,
   'autoScale':false,
   'transitionIn':'none',
   'transitionOut':'none',
   'overlayOpacity':0.8,
   'overlayColor': '#000',
   'type':'iframe'});

// FORM
$('input[type="text"]').addClass("idleField");
$('input[type="text"]').focus(function() {
   $(this).removeClass("idleField").addClass("focusField");
   if (this.value == this.defaultValue){ 
      this.value = '';
   }
   if(this.value != this.defaultValue){
      this.select();
   }
});
$('input[type="text"]').blur(function() {
   $(this).removeClass("focusField").addClass("idleField");
   if ($.trim(this.value) == ''){
      this.value = (this.defaultValue ? this.defaultValue : '');
   }
});

// SLIDER
$("#slider").easySlider({
   auto: true,
   continuous: true,
   allControls: true
});

});
