function db_textsize(factor){
	var b=$$('body');
	b[0].setStyle({fontSize:factor+'%'});
	set_cookie('page_size', factor, 30);
}

function set_cookie(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 get_cookie(name) {
    var name_eq = 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(name_eq) == 0) return c.substring(name_eq.length,c.length);
    }
    return null;
}

var factor;
if((factor=get_cookie("page_size"))!=null) {
	Event.observe(document, 'dom:loaded', function(){
		var b=$$('body');
		b[0].setStyle({fontSize:factor+'%'});
	});
}

if($('contentmenu'))
	new accordion('contentmenu', {toggle:'.menu>li>a',defaultOpen:'.active>a'});
(function(){
	var bott=$('parents-bott'), h=bott.getHeight(), parents=$('parents'), ending=new Element('div',{id:'parents-ending'}).setStyle({opacity:0,height:'0px'}), timeout=null, opened=false, opening=false;
	parents.appendChild(ending);
	parents.observe('mouseenter',function() {
		if(!timeout) {
			timeout = (function(){
				opening = new Effect.Parallel([
					new Effect.Scale(bott, 100, {scaleFrom: h/(h+130)*100, scaleX: false, scaleY: true, scaleContent: false, scaleMode:{originalHeight:h+130}, sync:true}),
					new Effect.Scale(ending, 100, {scaleFrom: 0, scaleX: false, scaleY: true, scaleContent: false, scaleMode:{originalHeight:130}, sync:true}),
					new Effect.Opacity(ending, {from:0.0, to:1.0, sync:true})
				], {transition:Effect.Transitions.sinoidal, duration:.5, queue:{position:'end',scope:'parents'}, afterFinish:function() {
					opened=true;
				}});
				timeout=null;
			}).delay(.5);
		}
	});
	parents.observe('mouseleave',function() {
		if(timeout) {
			clearTimeout(timeout);
			timeout=null;
		}
		else{
			if(opening) {
				opening.cancel();
				opening=false;
				opened=true
			}
			if(opened) {
				new Effect.Parallel([
					new Effect.Scale(bott, 100, {scaleFrom:(1+130/h)*100, scaleX: false, scaleY: true, scaleContent: false, scaleMode:{originalHeight:h}, sync:true}),
					new Effect.Scale(ending, 0, {scaleX: false, scaleY: true, scaleContent: false, scaleMode:'box', sync:true}),
					new Effect.Opacity(ending, {from:1.0, to:0.0, sync:true})
				], {transition:Effect.Transitions.sinoidal, duration:.5, queue:{position:'end',scope:'parents'}});
			}
		}
	});
})();