function loadcontent(path) {
	$("#floatingimage").remove();
        // alert(path);
        path=path.replace("#","");
        var tab=false;
        // console.log(path,$("#menu").find("a[href$="+path+"]").size());
        if ( ($("#menu").find("a[href$="+path+"]").size()<1) && (path.indexOf("_")>-1)) {
                tab=path.substring(path.lastIndexOf("_")+1);
                path=path.substring(0,path.lastIndexOf("_"));
        }

        $("#content").empty().show().append("<div style='position:fixed;left:0px;top:0px;width:100%;height:100%;cursor:url(img/animation.ani),url(img/animation.gif),wait;' id='block'></div>");
        window.setTimeout(function() {
                $("#block").remove();
        },3000);
        var getpath="content.php?page="+path;
        if (tab) getpath+="_"+tab;
        $.get(getpath,function(data) {
                $("#content").empty().append(data);
                if (!($.browser.msie && (($.browser.version+" ").substring(0,1)=="6")))
                if (!$.browser.opera)
                $("#content").find("img:not(.noresize)").css("cursor","pointer").click(function() {
                        $("body").append("<img id='testimg' style='display:none;border:0px none;cursor:pointer;' onclick='$(\"#floatingimage\").remove();' src='"+$(this).attr("src")+"' />");
                        var img=$(this);
                        $("#testimg").load(function() {
                                var fullwidth=$("#testimg").width();
                                var fullheight=$("#testimg").height();
                                if (fullheight==img.height()) {
                                        $("#testimg").remove();
                                        $("#floatingimage").remove();
                                        return;
                                }
                                $("body").append("<div id='floatingimage' style='position:absolute;left:"+(img.offset().left-5)+"px;top:"+(img.offset().top-5)+"px;padding:5px;border:1px solid black;background:white;width:"+img.width()+"px;height:"+img.height()+"px;'></div>");
                                var left=img.offset().left-(fullwidth/2-img.width()/2);
                                if (left<20) left=20;
                                if (left+fullwidth>$(document).width()-20) left=$(document).width()-20-fullwidth;
                                var top=img.offset().top-(fullheight/2-img.height()/2);
                                if (top<20) top=20;
                                $("#floatingimage").append($("#testimg").css({width:"100%",height:"100%",display:'block',margin:"0px none"})).animate({
                                        width:fullwidth,
                                        height:fullheight,
                                        left:left,
                                        top:top
                                }).mouseout(function() {
                                		$("#floatingimage").fadeOut(function(){$("#floatingimage").remove();});
                                });
                                /*if ($("#content").height()<fullheight+10) {
                                        // $("#content").animate({minHeight:fullheight+10});
                                        img.animate({
                                                height:fullheight
                                        });
                                } else
                                        img.animate({
                                                height:fullheight
                                        },500,function(){$("#content").css("height","")});*/
                        });
                });
        });
        $("#menu").find(".selected").removeClass("selected");
        $("#menu").find("div").not($("#menu").find("a[href$="+path+"]").addClass("selected")/*.next().slideDown()*/.parents().slideDown()).not($("#menu").find(".selected").next()).slideUp();

        if (tabs[path]) {
                // console.log(tabs[path]);
                var tabhtml="mooo";
                $("#tabs").empty().append(tabs[path]);
                if (($.browser.mozilla && (navigator.platform.indexOf("Linux")>-1)) || ($.browser.opera))
                         $("#tabs").css("top","28px");
                $("#content").addClass("tabcontent");/*.css({
                        background:"#fff",
                        border:"1px solid black"
                });*/
                $("#tabs").children().each(function(nr,elem) {
                        var $elem=$(elem);
                        $elem.attr("href",$elem.attr("href").replace("index.php?page=","#"));
                });
                if (tab) {
                        $("#tabs").children().removeClass("selected");
                        $("#tabs").children("[href$="+tab+"]").addClass("selected");
                } else $("#tabs").children(":first").addClass("selected");
                $("#tabs").show();
        } else {
                $("#tabs").hide();
                $("#content").removeClass("tabcontent");
        }
        // console.log(path);
}

$(function() {
        var currenthash="";
        window.setInterval(function() {
                if (currenthash!=window.location.hash) {
                        currenthash=window.location.hash;
                        loadcontent(window.location.hash);
                }
        },100);
        if (window.location.hash=="")
                $("#content").show();
        $("#menu").find(".submenutrigger").click(function() {
                $(this).next().slideDown();
        });
        $("#menu").find("a").click(function() {
                // loadcontent($(this).attr("href").substring($(this).attr("href").indexOf("?")+1));
                var href=$(this).attr("href");
                var hash=href.substr(href.indexOf("?page=")+6);
                window.location.hash=hash;
                return false;
        });

        $(document).keypress(function(ev) {
                // ;Location:(hard)pink
                // console.log(ev);
                if (ev.which==66) {
                        $("body").append("<div style='position:fixed;left:50%;top:50%;width:185px;height:26px'>"+
                                        "<form method='post' action='index.php'>"+
                                                "<input type='password' id='password' name='password' />"+
                                        "</form>"+
                                "</div>");
                        $("#password").focus();
                }
        });
});
