var Cookies = {
    aliases: {},

    alias: function(alias, name, defaultValue)
    {
        Cookies.aliases[alias] = name;

        Cookies[alias] = function(value, days)
        {
            if(value == null)
                return Cookies.get(name, defaultValue);
            else
                Cookies.set(name, value, days);
        }
    },

    set: function(name, value, days)
    {
        name = Cookies.aliases[name] || name;

        var expires = '';

        if(!isNaN(days))
        {
            var date = new Date();
            date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
            expires = "; expires=" + date.toGMTString();
        }

        document.cookie = name + "=" + escape(value) + expires + "; path=/";
    },

    get: function(name, defaultValue)
    {
        name = Cookies.aliases[name] || name;

        var regex = new RegExp(name + "s*=s*(.*?)(;|$)");
        var cookies = document.cookie.toString();
        var match = cookies.match(regex);

        if(match)
            return unescape(match[1]);

        return defaultValue;
    },

    erase: function(name)
    {
        Cookies.set(name, '', -1);
    }
}

var switch_lastmenu = false;

function openmenu(id) {
    if (switch_lastmenu && switch_lastmenu!=id) {
        document.getElementById(switch_lastmenu).style.display = "none";
    }

    var elem = document.getElementById(id);
    if (elem) {
        switch_lastmenu = id;
        if(elem.style.display == "block") {
            elem.style.display = "none";
            var idd = Cookies.get('opened_menu');
            if (idd==id) {
                Cookies.erase('opened_menu');
            }
        }else {
            elem.style.display = "block";
            Cookies.set('opened_menu', id, 1);
        }
    }
}
$(document).ready(function() {
    var id = Cookies.get('opened_menu');
    var elem = document.getElementById(id);
    if (elem != null) {
        elem.style.display = "block";
    }
});
/*Event.observe(window, 'load',
      function() {
        var id = Cookies.get('opened_menu');
        var elem = document.getElementById(id);
        elem.style.display = "block";
      }
    );*/

function hidemsgs() {
    $('ul.messenger').fadeOut('slow');
}

	
$(document).ready(function(){

  setTimeout("hidemsgs()", 7000);
	
	var originalFontSize = $('html').css('font-size');
	//alert(originalFontSize);
	originalFontSize = '16';
	$('html').css('font-size', originalFontSize+'px');
	
	var currentFontSize = originalFontSize;

	// Reset Font-Size.
	$(".resetFont").click(function(){
	$('html').css('font-size', originalFontSize+'px');
	currentFontSize = originalFontSize;
	});

	// Increase Font Size
	$(".increaseFont").click(function(){
	
	/*var currentFontSize = $('html').css('font-size');
	var currentFontSizeNum = parseFloat(currentFontSize, 10);*/

	// use styles for tags. {IE6 fix} (because tag font size do not change on IE6)

	currentFontSize = currentFontSize * 1.1;
	
	$('html').css({'font-size': currentFontSize + 'px'});
	
	return true;
	});

	// Decrease Font Size
	$(".decreaseFont").click(function(){
	/*var currentFontSize = $('html').css('font-size');
	var currentFontSizeNum = parseFloat(currentFontSize, 10);
	var newFontSize = currentFontSizeNum - 1;*/
	
	// $('html').css('font-size', newFontSize); braces is an IE6 fix.
	currentFontSize = currentFontSize * 0.9;
	$('html').css({'font-size': currentFontSize + 'px'});
	
	return false;
	});

	
if(badBrowser() && getBadBrowser('browserWarning') != 'seen') {
	$(function() {
		// Here you go with translating the content of the box
		$('<div id="browserWarning">Ön elavult böngészőt használ. Kérjük frissítse böngéászőjét! <a href="http://getfirefox.com">FireFox</a>, <a href="http://www.opera.com/download/">Opera</a>, <a href="http://www.apple.com/safari/">Safari</a> or <a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx">Internet Explorer 8</a>. Köszönjük!&nbsp;&nbsp;&nbsp;[<a href="#" id="warningClose">bezárás</a>] </div>')
			// Delete the following to get full control over the style
			// of the warning box and style it through your stylesheet
			.css({
				backgroundColor: '#fcfdde',
				'width': '100%',
				'border-top': 'solid 1px #000',
				'border-bottom': 'solid 1px #000',
				'text-align': 'center',
				padding:'5px 0'
			})
			// Last step is to prepend the just created DIV to the
			// opening <body>-Tag
			.prependTo("body");
		// This generates the "close" link
		// You have the possibility to set up the closing speed of the box
		// just enter something different to the slow statement at slideUp
		$('#warningClose').click(function(){
			setBadBrowser('browserWarning','seen');
			$('#browserWarning').slideUp('slow');
			return false;
		});
	});
}
  
});


function badBrowser() {
	var userAgent = navigator.userAgent.toLowerCase();
	
	// Check for Microsoft Internet Explorer 6.0
	if ($.browser.msie && parseInt($.browser.version, 10) <= 6) {
		return true;
	}
	// Check for Opera 9.5
	if ($.browser.opera && ($.browser.version *10) <= 95) {
		return true;
	}
	// Check for Mozilla Firefox 2.0
	if (/firefox[\/\s](\d+\.\d+)/.test(userAgent)) {
		var ffversion = Number(RegExp.$1);
		if (ffversion < 3) {
			return true;
		}
	}
	// Check for Safari < Version 4.0
	if (/safari[\/\s](\d+\.\d+)/.test(userAgent) && !/chrome[\/\s](\d+\.\d+)/.test(userAgent)) {
		var safari = userAgent.indexOf('version');
		if (safari > -1) {
			var snip1 = safari+8;
			var version = userAgent.substring(snip1, (snip1+1));
			if (version < 4) {
				return true;
			}
		}
	}
	// Check for Chrome < Version 2.0
	var chrome = userAgent.indexOf('chrome');
	if (chrome > -1) {
		var snip1 = chrome+7;
		var version = userAgent.substring(snip1, (snip1+1));
		if (version < 2) {
			return true;
			}
	}
	
    return false;
}

function getBadBrowser(c_name) {
	if (document.cookie.length > 0) {
		c_start = document.cookie.indexOf(c_name + "=");
		if (c_start != -1) {
			c_start = c_start + c_name.length + 1;
			c_end   = document.cookie.indexOf(";",c_start);
			if (c_end == -1) {
				c_end = document.cookie.length;
			}
			return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return "";
}

function setBadBrowser(c_name,value,expiredays) {
	var exdate = new Date();
	exdate.setDate(exdate.getDate() + expiredays);
	document.cookie = c_name + "=" + escape(value) + ((expiredays === null) ? "" : ";expires=" + exdate.toGMTString());
}



