jQuery(document).ready(function() {
  jQuery(".entry").find("img").fadeIn('normal');
  jQuery("div.postlink a").click(function() {
     jQuery(".entry").find("img").fadeOut('normal');
  });
  jQuery("span.zusatz a").click(function(){
    jQuery("#popup").bPopup({fadeSpeed:'slow', follow:false, loadUrl:'size-price-and-shipping-information div#staticpage'});
    return false;
  });
  jQuery("#popup div#staticpage").live('click', function() {
    jQuery("#popup").bPopup().close();
  });
/*
	jQuery("ul.cat").hide();
	jQuery("a#galerielist").click(function() {
  window.location.href = "http://xuru.eu/artikel/";
		jQuery("ul.galerielist").find(".cat").slideToggle('middle');
		return false;
	});

	jQuery("div.tags").hide();
	jQuery("a#taglist").click(function() {
		jQuery("div.tags").slideToggle('middle');
		return false;
	});
	var myurl = document.URL;
	var mysearch = myurl.search(/#comment/);
	if(mysearch == -1) {
		jQuery("ol.commentlist").hide();
	};
	jQuery("a#ToogleCommentlist").click(function() {
		jQuery("ol.commentlist").slideToggle('middle');
		return false;
	});
	jQuery("form.commentform").hide();
	jQuery("a#ToogleCommentform").click(function() {
		jQuery("form.commentform").slideToggle('middle');
		return false;
	});
*/
});
/************************************************************************
 * @name: bPopup
 * @author: Bjoern Klinggaard (http://dinbror.dk/bpopup)
 * @version: 0.4.0.min
 ************************************************************************/ 
(function(a){a.fn.bPopup=function(f,j){function s(){var c=a("input[type=text]",b).length!=0,k=o.vStart!=null?o.vStart:d.scrollTop()+g;if(o.xLink){a("a#bContinue").attr({href:a("a.xlink").attr("href")});a("a#bContinue .btnLink").text(a("a.xlink").attr("title"))}b.css({left:d.scrollLeft()+h,position:"absolute",top:k,"z-index":o.zIndex}).appendTo(o.appendTo).hide(function(){c&&b.each(function(){b.find("input[type=text]").val("")});o.loadUrl!=null&&b.load(o.loadUrl)}).fadeIn(o.fadeSpeed,function(){c&&
b.find("input[type=text]:first").focus();a.isFunction(j)&&j()});t()}function i(){o.modal&&a("#bModal").fadeOut(o.fadeSpeed,function(){a("#bModal").remove()});b.fadeOut(o.fadeSpeed,function(){o.loadUrl!=null&&b.empty()});o.scrollBar||a("html").css("overflow","auto");a("."+o.closeClass).die("click");a("#bModal").die("click");d.unbind("keydown.bPopup");e.unbind(".bPopup");b.data("bPopup",null);return false}function u(){if(m){var c=[d.height(),d.width()];return{"background-color":o.modalColor,height:c[0],
left:l(),opacity:0,position:"absolute",top:0,width:c[1],"z-index":o.zIndex-1}}else return{"background-color":o.modalColor,height:"100%",left:0,opacity:0,position:"fixed",top:0,width:"100%","z-index":o.zIndex-1}}function t(){a("."+o.closeClass).live("click",i);o.modalClose&&a("#bModal").live("click",i);o.follow&&e.bind("scroll.bPopup",function(){b.stop().animate({left:d.scrollLeft()+h,top:d.scrollTop()+g},o.followSpeed)}).bind("resize.bPopup",function(){if(o.modal&&m){var c=[d.height(),d.width()];
n.css({height:c[0],width:c[1],left:l()})}c=p(b,o.amsl);g=c[0];h=c[1];b.stop().animate({left:d.scrollLeft()+h,top:d.scrollTop()+g},o.followSpeed)});o.escClose&&d.bind("keydown.bPopup",function(c){c.which==27&&i()})}function l(){return e.width()<a("body").width()?0:(a("body").width()-e.width())/2}function p(c,k){var q=(e.height()-c.height())/2-k,v=(e.width()-c.width())/2+l();return[q<20?20:q,v]}if(a.isFunction(f)){j=f;f=null}o=a.extend({},a.fn.bPopup.defaults,f);o.scrollBar||a("html").css("overflow",
"hidden");var b=a(this),n=a('<div id="bModal"></div>'),d=a(document),e=a(window),r=p(b,o.amsl),g=r[0],h=r[1],m=a.browser.msie&&parseInt(a.browser.version)==6&&typeof window.XMLHttpRequest!="object";this.close=function(){o=b.data("bPopup");i()};return this.each(function(){if(!b.data("bPopup")){o.modal&&n.css(u()).appendTo(o.appendTo).animate({opacity:o.opacity},o.fadeSpeed);b.data("bPopup",o);s()}})};a.fn.bPopup.defaults={amsl:150,appendTo:"body",closeClass:"bClose",escClose:true,fadeSpeed:250,follow:true,
followSpeed:500,loadUrl:null,modal:true,modalClose:true,modalColor:"#000",opacity:0.7,scrollBar:true,vStart:null,zIndex:9999}})(jQuery);

/* Stylesheet switcher, based on http://alistapart.com/stories/alternate/ */
function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

function switchActiveStyleSheet() {
	var title = getActiveStyleSheet();
	if ( title == "dark")
		setActiveStyleSheet("light");
	else
		setActiveStyleSheet("dark");
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);
