﻿/*-- Moin! Moin! Welcome to various StSB snippets; depend on: jQuery core file (by K Mintropp) --*/

/*-- Main menu at the top etc. (by Mi)---- with hoverIntent r6;  2011.02.26: <http://cherne.net/brian/resources/jquery.hoverIntent.html> --*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev])}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev])};var handleHover=function(e){var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t)}if(e.type=="mouseenter"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob)},cfg.timeout)}}};return this.bind('mouseenter',handleHover).bind('mouseleave',handleHover)}})(jQuery);
$(document).ready(function(){	function show() {var menu = $(this);menu.children(".sub").slideDown(400);}	function hide() {var menu = $(this);menu.children(".sub").slideUp(400);}$("#top li").hoverIntent({sensitivity:7,interval:300,over:show,timeout:400,out:hide});});		

/*-- Stylesheet switcher built on jQuery; by Kelvin Luck (http://www.kelvinluck.com); slightly modified by K.M. --**/
(function($){$(document).ready(function(){$('a.styleswitch').click(function(){switchStylestyle(this.getAttribute("rel"));return false});var c=readCookie('style');if(c)switchStylestyle(c)});function switchStylestyle(styleName){$('link[rel*=style][title]').each(function(i){this.disabled=true;if(this.getAttribute('title')==styleName)this.disabled=false});createCookie('style',styleName,365)}})(jQuery);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 var 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 eraseCookie(name){createCookie(name,"",-1)};

/*-- Search form: onfocus --*/
$(document).ready(function(){$('input[type="text"]').addClass("idle");$('input[type="text"]').focus(function(){$(this).removeClass("idle").addClass("focus");if(this.value==this.defaultValue){this.value=""}if(this.value!=this.defaultValue){this.select()}});$('input[type="text"]').blur(function(){$(this).removeClass("focus").addClass("idle");if($.trim(this.value)==""){this.value=this.defaultValue?this.defaultValue:""}})})

/*-- Toggle content/container (e.g. Chronik) -- */
$(document).ready(function(){$(".container").hide();	$(".trigger").click(function(){$(this).toggleClass("active").next().slideToggle(400);});});

$(document).ready(function(){$(".toggle").click(function(){$(".content").slideToggle();});});
