// Galerie
jQuery(document).ready(function() {
	$("a[rel=group]").fancybox({
		'titleShow' : true,
		'titlePosition' : 'over',
		'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
		    return '<span id="fancybox-title-over">Bild ' +  (currentIndex + 1) + ' von ' + currentArray.length + ' <br /> ' + title + '</span>';
		}
	});
});

// Login-Box
$(document).ready(function(){
  $(".showbox").click(function(){
    $("#loginDropdown").slideToggle("fast");
    return false;
  });
});

// Login-Box (mouseover)
function showbox(id) {
  with (document) {
    if (getElementById)
      getElementById(id).style.display = 'block';
    else if (all)
      all[id].style.display = 'block';
    else
      layers[id].display = 'block';
  }
}
function hidebox(id) {
  with (document) {
    if (getElementById)
      getElementById(id).style.display = 'none';
    else if (all)
      all[id].style.display = 'none';
    else
      layers[id].display = 'none';
  }
}

// Ajax-Login
$(document).ready(function() {
  $("#login_form").submit(function() {
    $("#info").removeClass().addClass('info').text('').fadeIn('fast');
    $.post("/api/",{username:$('#username').val(),password:$('#password').val(),rand:Math.random()},function(check) {
      if (check == 'true') {
        $("#info").fadeTo('fast', 0.1, function() {
    	  $(this).html('einloggen...').addClass('info_login').fadeTo('fast', 1, function() {
          document.location='/';
    	  });
    	});
      } else {
      	$("#info").fadeTo('fast', 0.1, function() {
    	$(this).html('Ungültige Angaben!').addClass('info_error').fadeTo('fast', 1);
    	});
      }
    });
    return false;
  });
});

// CMS loeschen, aktivieren usw.
function cmsinfo(link,btext) {
  Check = confirm(btext);
    if(Check == false) {
    return ;
  } else {
    window.open(link,'_top') ;
  }
}

