$(function () {
	if($.browser.msie){
		$("#content .block").addClass("msie");
		$("#content .block.msie").wrap('<div class="msieborder" />');
		$("#content .block.msie p.multicolumn").wrap('<div class="msiep" />');
		$("#content .block.msie .msiep").columnize({width:260, lastNeverTallest: true });
		
		$("#navigation").addClass("msie");
		$("#navigation>ul").wrap('<div class="msieborder" />');
	} else if(navigator.userAgent.match(/iPhone|Android|webOS/i) && !navigator.userAgent.match(/iPad/i)){
		if($.cookie("ui")!=="desktop"){
			$("head").append('<link rel="stylesheet" type="text/css" href="fileadmin/kulturkosmos_neu/template/css/480.css" media="all" />');
		$("#content").append('<div id="navigation">'+$("#navigation").html()+"</div>");
		$("#content").append('<div class="block" style="margin-top:2em; padding-bottom:0.2em"><p><a href="#" onclick="go_mobile(); return false;" >Desktop Version</a> | Mobile Website by <a style="color:#333; font-weight: normal" href="http://dfacts.de" target="_blank">dFacts.de</a></p></div>');
		}
	} else {
		$("#content .block").css("border-width","10px 25px 30px 25px").
		css("padding","0px").
		borderImage('url("fileadmin/kulturkosmos_neu/template/images/block-border.png") 10 25 30 25 stretch round', false);
		$("#navigation").css("border-width","10px 15px 12px 3px").borderImage('url("fileadmin/kulturkosmos_neu/template/images/navi-bg.png") 10 15 12 3 stretch round', false);
	}
});

jQuery.cookie = function (key, value, options) {

    // key and value given, set cookie...
    if (arguments.length > 1 && (value === null || typeof value !== "object")) {
        options = jQuery.extend({}, options);

        if (value === null) {
            options.expires = -1;
        }

        if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }

        return (document.cookie = [
            encodeURIComponent(key), '=',
            options.raw ? String(value) : encodeURIComponent(String(value)),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''
        ].join(''));
    }

    // key and possibly options given, get cookie...
    options = value || {};
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};


function go_mobile(){
	$.cookie('ui','desktop'); 
	window.location.reload()
}
