$(document).ready(function(){

	/* Schriftgroesse fuer Fliesstext
	 */
	var fs = $.cookie('fontSize');
	if (fs && (fs = parseInt(fs)) && fs > 12) {
		$.ISOSHADE('setFont', fs);
	}
	$("#fontresize > .normal").click(function() {
		$.ISOSHADE('setFont', 12);
		$.cookie('fontSize', null);
     	});
	$("#fontresize > .large").click(function() {
		$.ISOSHADE('setFont', 15);
		$.cookie('fontSize', '15', {expires:30});
     	});

	/* Listen mit erweiterter Info auf mouseover
	 */
	$(".ballonliste>li").each(function(i) {
		$(this).mousemove(function(e){
			 var elmw = parseInt($(this).children().width());
		         var winw = ((document.body.offsetWidth!=null)?document.body.offsetWidth:window.innerWidth) - 45;

			 // Mauspos relativ zu links oben
		         var posx = parseInt(e.pageX);
		         var posy = parseInt(e.pageY) + 3;

       			 if ((posx + elmw) > winw ) {
				posx = winw - elmw;
			 }

		         $(this).css("backgroundColor", "#ccc");

		         $(this).children().css({left: posx+"px", top: posy+"px"});
		         $(this).children().show();

		     }).mouseout(function(e){
		         $(this).css("backgroundColor", "white");
			 $(this).children().fadeOut("fast");
		     });
	});

});


jQuery.ISOSHADE = function(command, value) {
	if (command == 'setFont') {
		fs = parseInt(value);
		if (fs > 12) {
			$("body").css("fontSize", fs+"px" );
			// $("h1").css("backgroundPosition", "left 7px" );
		} else {
			$("body").css("fontSize", "12px" );
			//$("h1").css("backgroundPosition", "left 2px" );
		}
	}
}


/* $Id: jquery.cookie.js,v 1.1 2007/10/14 05:14:31 redbox2000drupalorg Exp $ */
/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * @example $.cookie('the_cookie', 'the_value', {expires: 7, path: '/', domain: 'jquery.com', secure: true});
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie. (nur fuer diese Browser-Sitzung)
 */

jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        var path = options.path ? '; path=' + options.path : '';
        var domain = options.domain ? '; domain=' + options.domain : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};
