function getCookieVal (offset) {
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1)
        endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
        return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
    }
   return null;
}

function SetCookie (name, value) {
    var argv = SetCookie.arguments;
    var argc = SetCookie.arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    var path = (argc > 3) ? argv[3] : null;
    var domain = (argc > 4) ? argv[4] : null;
    var secure = (argc > 5) ? argv[5] : false;
    document.cookie = name + "=" + escape (value) +
        ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
        ((path == null) ? "" : ("; path=" + path)) +
        ((domain == null) ? "" : ("; domain=" + domain)) +
        ((secure == true) ? "; secure" : "");
    }

function DeleteCookie() {
   var exp = new Date();
   exp.setTime (exp.getTime() - 1000000000);  // This cookie is history (changed -1 to make it previous time)
   var cval = GetCookie ('DemoName');
   document.cookie ='DemoName' + "=" + cval + "; expires=" + exp.toGMTString();
   alert("The cookie has been deleted.");
}




var supersleight=function(){
    var root=false;
    var applyPositioning=true;
    // var shim='/gemeinde-irschen/20080627_RedDot_Version/structure/x.gif';
    var shim_pattern=/x\.gif$/i;
    var fnLoadPngs=function() { 
        if(root){
            root=document.getElementById(root);
        } else {
            root=document;
        }
        for(var i=root.all.length-1,obj=null;(obj=root.all[i]);i--){
            if(obj.currentStyle.backgroundImage.match(/\.png/i)!==null){bg_fnFixPng(obj);}
            if(obj.tagName=='IMG'&&obj.src.match(/\.png$/i)!==null){el_fnFixPng(obj);}
            if(applyPositioning&&(obj.tagName=='A'||obj.tagName=='INPUT')&&obj.style.position===''){obj.style.position='relative';}
        }
    };
    var bg_fnFixPng=function(obj){
        var mode='scale';
        var bg=obj.currentStyle.backgroundImage;
        var src=bg.substring(5,bg.length-2);
        if(obj.currentStyle.backgroundRepeat=='no-repeat'){mode='crop';}
        obj.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"', sizingMethod='"+mode+"')";
        obj.style.backgroundImage='url('+shim+')';
    };
    var el_fnFixPng=function(img){
        var src=img.src;img.style.width=img.width+"px";
        img.style.height=img.height+"px";
        img.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"', sizingMethod='scale')";
        img.src=shim;
    };
    var addLoadEvent=function(func){
        var oldonload=window.onload;
        if(typeof window.onload!='function'){
            window.onload=func;
        }else{
            window.onload=function(){
                if(oldonload){oldonload();}
                func();
            };
        }
    };
    return{
        init:function(){
            addLoadEvent(fnLoadPngs);
        },
        limitTo:function(el){
            root=el;
        },
        run:function(){
            fnLoadPngs();
        }
    };
}();


function indexBottomSlider() {
    window.addEvent('domready', function() {
        var myTransition;
        var myDuration; 
        var pleahs = $$("#pleah .acContent");
        var pleahFx = new Fx.Elements(pleahs, {wait: false, duration: 1000});
        var moveAmount = 0, interval = 0;
        
        $$('#pleah .acContent h2').each(function(pleahH2, i) {
            interval = pleahH2.getStyle('width').toInt();
        });
        moveAmount = $('pleah').getStyle('width').toInt() - interval * $$('#pleah .acContent h2').length;
        pleahs.each(function(pleah, i) {
            pleah.setStyle("left", i * interval);
            pleah.addEvent("mousedown", function(event) {
                $$('#pleah .acContent h2').each(function(pleahH2, i) {
                    interval = pleahH2.getStyle('width').toInt();
                });
                moveAmount = $('pleah').getStyle('width').toInt() - interval * $$('#pleah .acContent h2').length;
                var o = {};
                var l = pleah.getStyle("left").toInt()
                o[i] = {left: [l, i * interval]}
                pleahs.each(function(other, j) {
                    var l2 = other.getStyle("left").toInt();
                    if(i > j) {
                        o[j] = {left: [l2, j * interval]};
                    }
                    if(i < j) {
                        o[j] = {left: [l2, (j * interval) + moveAmount]};
                    }
                });
                pleahFx.start(o);
            });
        });
    });
}


window.addEvent('domready', function() {
    var font = 0.8;
    if(Cookie.read("fontsize") != ""){
        font = Cookie.read("fontsize");
    }
    var morph = new Fx.Morph($(document.body),{unit:'em'});
    morph.set({
            'font-size': font
    });

	$('normal').addEvent('click', function(e) {
		e.stop();
		var morph = new Fx.Morph($(document.body),{unit:'em'});
		morph.set({
			'font-size': 0.8
		});
	});
	$('big').addEvent('click', function(e) {
		e.stop();
		var morph = new Fx.Morph($(document.body),{unit:'em'});
		morph.set({
			'font-size': 0.9
		});
	});
	$('bigger').addEvent('click', function(e) {
		e.stop();
		var morph = new Fx.Morph($(document.body),{unit:'em'});
		morph.set({
			'font-size': 1.0
		});
	});
});


window.addEvent('domready', function() {
    $('l_layer2').setStyle('display', 'none');
    var font = 0.8;
    cookieFont = GetCookie('fontsize');
    if(cookieFont > 0){
        var morph = new Fx.Morph($(document.body),{unit:'em'});
        morph.set({'font-size': cookieFont});
    }

	$('normal').addEvent('click', function(e) {
		e.stop();
		var morph = new Fx.Morph($(document.body),{unit:'em'});
		morph.set({'font-size': 0.8});
        SetCookie('fontsize',0.8);
	});
	$('big').addEvent('click', function(e) {
		e.stop();
		var morph = new Fx.Morph($(document.body),{unit:'em'});
		morph.set({'font-size': 0.9});
        SetCookie('fontsize',0.9);
	});
	$('bigger').addEvent('click', function(e) {
		e.stop();
		var morph = new Fx.Morph($(document.body),{unit:'em'});
		morph.set({'font-size': 1.0});
        SetCookie('fontsize',1);
	});
});

