require("blendtrans.js");
require("shortcut.js");

var isEventSupported = (function(){
    var TAGNAMES = {
      'select':'input','change':'input',
      'submit':'form','reset':'form',
      'error':'img','load':'img','abort':'img'
    }
    function isEventSupported(eventName) {
      var el = document.createElement(TAGNAMES[eventName] || 'div');
      eventName = 'on' + eventName;
      var isSupported = (eventName in el);
      if (!isSupported) {
        el.setAttribute(eventName, 'return;');
        isSupported = typeof el[eventName] == 'function';
      }
      el = null;
      return isSupported;
    }
    return isEventSupported;
})();

hoover_enabled = !isEventSupported('touchstart');

if(top.location.href.indexOf('nfm')>=0){
        if(!document.all) window.stop(); else window.document.execCommand('Stop');
        document.observe("dom:loaded", function() {
                        top.location.href=top.location.href.replace(/\?.*/,'');
        });
}

if(window.location.protocol+"//"+window.location.host+"/"!=top.location.href.replace(window.location.hash,"")){
        if(top.location.href.indexOf('nfm')==-1){
                if(!document.all) window.stop(); else window.document.execCommand('Stop');
                document.observe("dom:loaded", function() {
                                var imgpart = top.location.href.match(/\?img=(.*)/);
                                if(imgpart && imgpart.length>0){
                                        top.location.href=top.location.href.replace(/\?img=.*/,"")+"#"+imgpart[1];
                                } else {
                                        var hashpart = top.location.hash.substr(1);
                                        if(hashpart.length>0) hashpart = "~"+hashpart;
                                        top.location.href=top.location.href.replace(/#.*/,"").replace(window.location.host,window.location.host+"/#")+hashpart;
                                }
                });
        }
}

function aclick(a){
        var internal_part = a.href.replace(window.location.protocol+"//"+window.location.host,"");
        if(internal_part==a.href || internal_part.indexOf(".php")<0) return true;
        if(internal_part.match(/#[^\.\/]+$/)) return true;
        top.location.href="#"+internal_part;
        return false;
}

function run_links(){
        var as = document.getElementsByTagName("a");
        for(var i=0; i<as.length; i++){
                if(!as[i].getAttribute("onclick")) as[i].setAttribute("onclick","return aclick(this)");
        }
}

function body_onload(hash){
        if(typeof(hash)=="undefined") hash = true;
        adjust_column_height();
        run_middle_hovers();
        run_links();
        run_external_links();
	run_rubric_menu();
	if(hash && top.location.hash) load_page(top.location.hash.substr(2,top.location.hash.length-2));
        if(typeof(global_hash_refresh_timer)=="undefined") global_hash_refresh_timer = setTimeout("global_hash_refresh();",500);
}

function global_hash_refresh(){
        if(typeof(global_hash_vash)=="undefined") global_hash_vash = top.location.hash;
        if(global_hash_vash != top.location.hash){
                var tmp1 = global_hash_vash.split('/');
                var tmp2 = top.location.hash.split('/');
                var updcol2 = !(tmp1[0]==tmp2[0] && tmp1[1]==tmp2[1] && tmp1[2]==tmp2[2]);
                if(top.location.hash.length==0) load_page('home/news/index.php',true);
                else load_page(top.location.hash.substr(2,top.location.hash.length-2),true);
                global_hash_vash = top.location.hash;
        }
        global_hash_refresh_timer = setTimeout("global_hash_refresh();",500);
}

function flash_goto(section,subsection){
        if(typeof(last_section)!="undefined" && typeof(last_subsection)!="undefined") if(last_section==section && last_subsection==subsection) return true;
        var flashvars = {
                activeSection: "Box"+section,
                activeSubSection: "Box"+section+subsection
        };

        var params = {
                menu: "false",
                wmode: "transparent",
                bgcolor: '#FFFFFF',
                allowscriptaccess: "always"
        };
        
        var attributes = {
                id: "mainmenu"
        };
        
        var success;
        swfobject.embedSWF("flash/menue.swf", "mainmenu", "960", "160", "9.0.0", "flash/expressInstall.swf",flashvars,params,attributes,function callbackFn(e) { success = e.success; });
        
        last_section = section;
        last_subsection = subsection;
        
        return success;
}

function sections_from_uri(uri){
        uri = uri.split('/');
        section = subsection = 0;
        switch (uri[0]) {
         case 'home':
                 section = 1;
                 switch (uri[1]) {
                         case 'news': subsection = 1; break;
                         case 'archiv': subsection = 2; break;
                         case 'impressum': subsection = 3; break;
                         case 'agb': subsection = 4; break;	
                         case 'rechtshinweise': subsection = 5; break;
                         case 'unterstuetzung': subsection = 6; break;						 							 						 					 						 
                         default: alert("Fehler!\nUnbekannte Unterkategorie gewählt.");
                 }
                 break;
         case 'vita':
                 section = 2;
                 switch (uri[1]) {
                         case 'steckbrief': subsection = 1; break;
                         case 'meer_der_ideen': subsection = 2; break;
                         case 'netzwerk': subsection = 3; break;
                         default: alert("Fehler!\nUnbekannte Unterkategorie gewählt.");
                 }
                 break;
         case 'fotografie':
                 section = 3;
                 switch (uri[1]) {
                         case 'fotografien': subsection = 1; break;
                         case 'videotutorials': subsection = 2; break;
                         case 'presse': subsection = 3; break;
                         default: alert("Fehler!\nUnbekannte Unterkategorie gewählt.");
                 }
                 break;
         case 'illustration':
                 section = 4;
                 switch (uri[1]) {
                         case 'illustrationen': subsection = 1; break;
                         default: alert("Fehler!\nUnbekannte Unterkategorie gewählt.");
                 }
                 break;
         case 'printundweb':
                 section = 5;
                 switch (uri[1]) {
                         case 'printundwebreferenzen': subsection = 1; break;
                         default: alert("Fehler!\nUnbekannte Unterkategorie gewählt.");
                 }
                 break;
	 case 'projekte':
                 section = 6;
                 switch (uri[1]) {
						 case 'artikel': subsection = 1; break;
                         case 'mdi-projekte': subsection = 2; break;
                         default: alert("Fehler!\nUnbekannte Unterkategorie gewählt.");
                 }
                 break;
         default: alert("Fehler!\nUnbekannte Kategorie gewählt.");
        }
        
        return [section,subsection];
}

function run_external_links(){
        var as = document.getElementsByTagName("a");
        for(var i=0; i<as.length;i++){
                
                var internal_part = as[i].href.replace(window.location.protocol+"//"+window.location.host,"");
                if(internal_part!=as[i].href) continue;
                
                if((as[i].href.indexOf("#")<0 && as[i].href.substr(0,7)=="http://" || as[i].href.substr(0,8)=="https://") && as[i].firstChild && typeof(as[i].firstChild.tagName)=="undefined"){
                        if(as[i].target=="_blank") continue;
                        var span = document.createElement("span");
                        span.innerHTML = '<a href="'+as[i].href+'" target="_blank">'+as[i].innerHTML+'</a> <a href="'+as[i].href+'" target="_blank"><img src="images/link'+((underneath(as[i],$('column2')))? '_white' : '')+'.gif" width="11" height="11" alt=""/></a>';
                        as[i].parentNode.replaceChild(span,as[i]);
                }
        }
}

function run_middle_hovers(){
        if(!hoover_enabled) return;
        var imgs = document.getElementsByTagName("img");
        for(var i=0; i<imgs.length;i++){
                if(imgs[i].getAttribute("width")!="160" || imgs[i].getAttribute("height")!="133" || imgs[i].parentNode.tagName!="A") continue;
                var div = document.createElement("div");
                div.style.width   = "160px";
                div.style.height  = "133px";
                div.className = imgs[i].className;
                div.id = imgs[i].id+"div";
                div.style.backgroundImage = "url("+imgs[i].src+")";
                div.innerHTML = '<a href="'+imgs[i].parentNode.href+'"'+(imgs[i].parentNode.target ? ' target="'+imgs[i].parentNode.target+'"' : '')+'><img src="images/middle_hover.png" width="160" height="133" alt="" id="'+imgs[i].id+'hover"/></a>';
                div.firstChild.style.display = "none";
                jQuery(div).mouseover(function(){ jQuery(this).children().first().css('display','inline') });
                jQuery(div).mouseout(function(){ jQuery(this).children().first().css('display','none') });
                imgs[i].parentNode.parentNode.replaceChild(div,imgs[i].parentNode);
        }
}

function run_rubric_menu(){
        jQuery('#rubricmenu a').each(function(){
                if(jQuery(this).css('color')=="rgb(0, 0, 0)") jQuery(this).parents('ul').css('display','block').parents('li:first').find('a:first').css('color','black');
        });
	for(var i=0; i<$('rubricmenu').childNodes.length;i++) if($('rubricmenu').childNodes[i].tagName=="UL") var list = $('rubricmenu').childNodes[i];
	if(typeof(list)=="undefined") return;
	rubric_dirs = find(list,"UL");
	rubric_states = new Array();
	for(var i=0; i<rubric_dirs.length;i++){
		if(rubric_dirs[i].style.display=="none") rubric_states[i] = "collapsed";
		else rubric_states[i] = "expanded";
	}
}

function find(element,tagName){
	var result = new Array();
	for(var i=0; i<element.childNodes.length;i++) {
		if(element.childNodes[i].tagName==tagName) result.push(element.childNodes[i]);
		result = result.concat(find(element.childNodes[i],tagName));
	}
	return result;
}

function toggleRubricMenu(item){
	for(var i=0; i<rubric_dirs.length;i++) {
                if(item.nextSibling.nextSibling==rubric_dirs[i]) var index = i;
                if(item.nextSibling.nextSibling.nextSibling && item.nextSibling.nextSibling.nextSibling.nextSibling && item.nextSibling.nextSibling.nextSibling.nextSibling==rubric_dirs[i]) var index = i;
        }
	if(typeof(index)=="undefined") return;
	if(rubric_states[index] == "collapsed" || rubric_states[index] == "collapsing") rubric_expand(index);
	else rubric_collapse(index);
}

function rubric_expand(index){
        for(var i=0;i<rubric_dirs.length;i++) rubric_collapse(i);
        var teasertext_coordinates = jQuery('#teasertext').offset();
        jQuery('#teasertext').css({position:'absolute',left:teasertext_coordinates.left,top:teasertext_coordinates.top,'margin-top':0,width:189});
        jQuery(rubric_dirs[index]).show(500,'linear',function(){
                rubric_states[index] = "expanded";
                jQuery(rubric_dirs[index]).find('img').show();
                //adjust_column_height();
        });
}

function rubric_collapse(index){
        var teasertext_coordinates = jQuery('#teasertext').offset();
        jQuery('#teasertext').css({position:'absolute',left:teasertext_coordinates.left,top:teasertext_coordinates.top,'margin-top':0,width:189});
        jQuery(rubric_dirs[index]).find('img').hide();
        jQuery(rubric_dirs[index]).hide(500,'linear',function(){
                rubric_states[index] = "collapsed";
                //adjust_column_height();
        });
}

function adjust_column_height(){
        if(!$('teaserimg')) return;
        var padding_correction = Prototype.Browser.IE ? 20 : 10;
        $('teasertext').style.marginTop = 0;
        $('teasertext').style.position = "static";
        $('teaserimg').style.marginTop  = 0;
        $('column1').style.height = "auto";
        $('column2').style.height = "auto";
        $('column3').style.height = "auto";
        var max = 125+Math.max(Math.max($('column1').getHeight(),$('column2').getHeight()),$('column3').getHeight());
        $('column1').style.height = max+"px";
        $('column2').style.height = max+padding_correction+"px";
        $('column3').style.height = max+padding_correction+"px";
        $('teasertext').style.marginTop = $('column2').getHeight() - $('teasertext').getHeight() - $('rubricmenu').getHeight() - 175 + ($('tweetbox')?10:0) + "px";
        
        //var marginNewsletter = $('newsletter').style.marginTop.replace('px','') ? $('newsletter').style.marginTop.replace('px','') : 3;
        //if(marginNewsletter==3 && $('browser').innerHTML=='iexplore7') marginNewsletter = -15;
        //$('teaserimg').style.marginTop  = $('column3').getHeight() - $('teaserimg').getHeight() - $('linklist').getHeight() - $('newsletter').getHeight() -marginNewsletter - 133 + "px";
        
        $('teaserimg').style.marginTop  = $('column3').getHeight() - $('teaserimg').getHeight() - $('linklist').getHeight() - 133 + "px";
}

function newsletter_popup(email,mode){
       pname = window.open("/newsletter.php?email="+email+"&mode="+mode,"newsletter","width=522,height=129,left=320,top=200,dependent=yes,resizable=no,scrollbars=no,toolbar=no,menubar=no");
       pname.focus();
       return true;
}

function require(filename){
        document.writeln('<script type="text/javascript" src="jscripts/'+filename+'"></script>');
}

function flash_load_page(filename){
        load_page(filename,true,true);
}

function load_page(filename,update_column2,no_flash_update){
        if(!filename) return;
        if(filename.indexOf("~")!=-1){
                var open_gallery_item = filename.replace(/.*~/,'');
                filename = filename.replace(/~.*/,'');
        }
	if(typeof(update_column2)=="undefined") update_column2 = true;
        if(typeof(no_flash_update)=="undefined") no_flash_update = false;
        prev = $('column1').innerHTML;
        $('column1').innerHTML = '<table width="100%" height="100%"><tr><td align="center"><img src="images/loading.gif" alt="Laden..."/></td></tr></table>';
        new Ajax.Request(filename,
        {
          method:'get',
          parameters: {ajaxload:true},
          onSuccess: function(transport){
            var response = transport.responseText.split('#####');
            $('column1').style.visibility="visible";
            $('column2').style.visibility="visible";
            $('column3').style.visibility="visible";
            $('column1').innerHTML = response[0];
            var scripts = document.getElementsByTagName("script");
            for (var i=0; i<scripts.length;i++) {
                    if(underneath(scripts[i],$('column1'))) eval(scripts[i].innerHTML);
            }
            if(typeof(response[1])!="undefined" && response[1]!=""){
                    $('linklist').innerHTML = response[1];
                    //$('newsletter').style.marginTop = "25px";
                    $('linklist').style.display = "block";
                    var scripts = document.getElementsByTagName("script");
                    for (var i=0; i<scripts.length;i++) {
                            if(underneath(scripts[i],$('linklist'))) eval(scripts[i].innerHTML);
                    }
            } else {
                    $('linklist').innerHTML = "";
                    $('linklist').style.display = "none";
                    //$('newsletter').style.marginTop = "3px";
            }
	    if(update_column2){
		    if(typeof(response[2])!="undefined"){
                            $('rubricmenu').innerHTML = response[2];
                            var scripts = document.getElementsByTagName("script");
                            for (var i=0; i<scripts.length;i++) if(underneath(scripts[i],$('rubricmenu'))) eval(scripts[i].innerHTML);
                    }else $('rubricmenu').innerHTML = "";
	    }
	    if(typeof(response[3])!="undefined") $('teasertext').innerHTML = '<img src="images/render_text.png.php?input=Bild rechts:&amp;height=9&amp;width=76" height="12" alt="Bild rechts:" /><br/>'+response[3];
	    if(typeof(response[4])!="undefined") $('teaserimg').innerHTML = response[4];
            if(typeof(response[5])!="undefined") document.title = response[5];
	    body_onload(false);
	    top.location.hash="/"+filename;
            if(typeof(global_hash_vash)!="undefined") global_hash_vash = top.location.hash;
            secinfo = sections_from_uri(filename);
            if(!no_flash_update){
                    var success = flash_goto(secinfo[0],secinfo[1]);
                    if(!success){
                            $('mainmenu').style.marginBottom = "7px";
                            nonflashmenu_run();
                            nonflashmenu_changeto(filename);
                    }
            }
            last_section = secinfo[0];
            last_subsection = secinfo[1];
            window.scrollTo(0,0);
            if(typeof(open_gallery_item)!="undefined" && $('gallery_preview')){
                    for(var i=0; i<gallery_preview_images.length; i++){
                            if(gallery_preview_images[i].indexOf(open_gallery_item+"_small.png")!=-1) {
                                    open_gallery(gallery_preview_images[i]);
                                    break;
                            }
                    }
            }
          },
          onFailure: function(){ alert("Fehler beim Laden der Seite!\r\nVermutlich gibt es \""+filename+"\" nicht."); $('column1').innerHTML=prev; }
        });
}

function underneath(needle,haystack){
        if(!needle) return false;
        if(needle==haystack) return true;
        return underneath(needle.parentNode,haystack);
}

function gallery_preview_run(){
        if(!$('gallery_preview')) return;
        for(var i=1; i<=5; i++) if($('gallery_preview_thumb_'+i)) {
                if($('gallery_preview_thumb_'+i+'_img').getAttribute('src').indexOf(".png")<=0) {$('gallery_preview_thumb_'+i).style.visibility = "hidden"; continue;}
                $('gallery_preview_thumb_'+i).style.backgroundImage = 'url('+$('gallery_preview_thumb_'+i+'_img').getAttribute('src')+')';
                $('gallery_preview_thumb_'+i+'_img').style.display = 'none';
                magnifier = document.createElement('img');
                magnifier.src= "images/gallery_preview_magnifier.png";
                $('gallery_preview_thumb_'+i).appendChild(magnifier);
                if(hoover_enabled){
                        if(typeof(window.addEventListener) != 'undefined')
                                $('gallery_preview_thumb_'+i).addEventListener('mouseover',gallery_preview_onmouseover,false);
                        else    $('gallery_preview_thumb_'+i).attachEvent('onmouseover',gallery_preview_onmouseover);
                } else jQuery("#gallery_preview_thumb_"+i).click(function(){open_gallery(jQuery("#"+jQuery(this).attr('id')+"_img").attr('src'));});
        }
        $('gallery_preview_arrow_back').innerHTML = '<a href="javascript:gallery_preview_back();"><img src="images/gallery_preview_back.png" alt="Zurück"/></a>';
        $('gallery_preview_arrow_back').style.visibility = "hidden";
        $('gallery_preview_arrow_forward').innerHTML = '<a href="javascript:gallery_preview_forward();"><img src="images/gallery_preview_forward.png" alt="Vor"/></a>';
        gallery_preview_page = 1;
        if(gallery_preview_images.length<=5) $('gallery_preview_arrow_forward').style.visibility = "hidden";
        
        if(!$('preload_area')) {
                preload_area = document.createElement("div");
                preload_area.id = "preload_area";
                preload_area.style.display = "none";
                $('column1').appendChild(preload_area);
        }
        for(var i=0;i<gallery_preview_images.length;i++) $('preload_area').innerHTML += '<img src="'+gallery_preview_images[i]+'" alt=""/>';
        $('preload_area').innerHTML += '<img src="images/gallery_preview_hover.png" alt=""/>';
        if(typeof(hover_frame)!="undefined") delete(hover_frame);
}

function gallery_set_arrows(){
        if(!$('gallery_selection_arrow_back') || !$('gallery_selection_arrow_forward')) return;
        if(gallery_first_image == 0) $('gallery_selection_arrow_back').style.display = "none"; else $('gallery_selection_arrow_back').style.display = "block";
        if(gallery_number_of_images == gallery_number_of_images_shown+gallery_first_image) $('gallery_selection_arrow_forward').style.display = "none"; else $('gallery_selection_arrow_forward').style.display = "block";
        
        if($('gallery_selection_arrow_back').style.display == "none" && $('gallery_selection_arrow_forward').style.display == "none") $('gallery_selection_wraper').style.paddingLeft = "56px";
        if($('gallery_selection_arrow_back').style.display == "block" && $('gallery_selection_arrow_forward').style.display == "block") $('gallery_selection_wraper').style.paddingLeft = "4px";
        if($('gallery_selection_arrow_back').style.display == "none" && $('gallery_selection_arrow_forward').style.display == "block") $('gallery_selection_wraper').style.paddingLeft = "55px";
}

function gallery_selection_forward(){
        gallery_first_image = Math.min(gallery_first_image+gallery_number_of_images_shown,gallery_number_of_images-gallery_number_of_images_shown);
        gallery_select_images();
}

function gallery_select_images(){
        var i=0;
        while($('gallery_selection_thumb_'+i)){
                if(i<gallery_first_image) $('gallery_selection_thumb_'+i).style.display = "none";
                else if(i>=gallery_first_image+gallery_number_of_images_shown) $('gallery_selection_thumb_'+i).style.display = "none";
                else $('gallery_selection_thumb_'+i).style.display = "block";
                i++;
        }
        gallery_set_arrows();
}

function gallery_selection_back(){
        gallery_first_image = Math.max(gallery_first_image-gallery_number_of_images_shown,0);
        gallery_select_images();
}

function gallery_run(){
        i=0;
        while($('gallery_selection_thumb_'+i)){
                $('gallery_selection_thumb_'+i).style.backgroundImage = 'url('+$('gallery_selection_thumb_'+i+'_img').getAttribute('src')+')';
                $('gallery_selection_thumb_'+i+'_img').style.display = 'none';
                if(hoover_enabled){
                        if(typeof(window.addEventListener) != 'undefined')
                                $('gallery_selection_thumb_'+i).addEventListener('mouseover',gallery_preview_onmouseover,false);
                        else    $('gallery_selection_thumb_'+i).attachEvent('onmouseover',gallery_preview_onmouseover);
                } else jQuery("#gallery_selection_thumb_"+i).click(function(){open_gallery(jQuery("#"+jQuery(this).attr('id')+"_img").attr('src'));});
                i++;
        }
        $('gallery_selection_arrow_back').innerHTML = '<a href="javascript:gallery_selection_back();"><img src="images/gallery_preview_back.png" alt="Zurück"/></a>';
        $('gallery_selection_arrow_forward').innerHTML = '<a href="javascript:gallery_selection_forward();"><img src="images/gallery_preview_forward.png" alt="Vor"/></a>';
        gallery_first_image = 0;
        gallery_number_of_images = gallery_number_of_images_shown = i;
        adjust_gallery_selection();
        if(typeof(window.addEventListener) != 'undefined')
		window.addEventListener('resize',adjust_gallery_selection,false);
	else 	window.attachEvent('onresize',adjust_gallery_selection);
        setActiveFrame($('gallery_picture_img').src.replace('normal.jpg','small.png'));
        Event.observe('gallery_picture_img', 'load', function(event) {
                        gallery_navpos();
                        Event.stopObserving('gallery_picture_img', 'load');
        });
        gallery_img_loading = false;
        gallery_selection_state = "expanded";
        //debug();
}

function debug(){
        if(gallery_img_loading) document.title = "loading"; else document.title = "not_loading";
        setTimeout("debug();",100);
}

function adjust_gallery_selection(){
        if(typeof(window.innerWidth)=='number') {myWidth = window.innerWidth;myHeight = window.innerHeight;}
	else {myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight;}
        i=0;c=99;
        while($('gallery_selection_thumb_'+i)){
                $('gallery_selection_thumb_'+i).style.display = "block";
                if((i+2)*99>myWidth) {
                        c = Math.min(c,i);
                        $('gallery_selection_thumb_'+i).style.display = "none";
                }
                i++;
        }
        if(c==99) c=i;
        gallery_number_of_images_shown = c;
        if($('gallery_selection_wraper')) $('gallery_selection_wraper').style.width = ((c+1)*99-45)+"px";
        gallery_set_arrows();
}

function gallery_preview_onmouseover(evt){
        var id = (typeof(window.event)!="undefined")? event.srcElement.id : evt.target.id;
        if(!id) id = (typeof(window.event)!="undefined")? event.srcElement.parentNode.id : evt.target.parentNode.id;
        if(typeof(hover_frame)!="undefined") {
                if(id && id != hover_frame.parentNode.id){
                        hover_frame.parentNode.removeChild(hover_frame);
                        delete(hover_frame);
                } else return;
        }
        hover_frame = document.createElement("a");
        hover_frame.setAttribute("href","javascript:open_gallery('"+$(id+'_img').getAttribute('src')+"');");
        if(id.substr(0,17)!="gallery_selection"){
                hover_frame.style.position = "relative";
                hover_frame.style.top = "-82px";
        }
        hover_frame.innerHTML = '<img src="images/gallery_preview_hover.png" alt=""/>';
        if(typeof(window.addEventListener) != 'undefined')
                hover_frame.addEventListener('mouseout',gallery_preview_onmouseout,false);
        else    hover_frame.attachEvent('onmouseout',gallery_preview_onmouseout);
        document.getElementById(id).appendChild(hover_frame);
}

function gallery_preview_onmouseout(evt){
	if(typeof(hover_frame)=="undefined") return;
	hover_frame.parentNode.removeChild(hover_frame);
	delete(hover_frame);
}

function gallery_preview_forward(){
        for(var i=1;i<=5;i++){
                if(typeof(gallery_preview_images[gallery_preview_page*5+i-1])!="undefined"){
                        $('gallery_preview_thumb_'+i+'_img').setAttribute('src',gallery_preview_images[gallery_preview_page*5+i-1]);
                        $('gallery_preview_thumb_'+i).style.backgroundImage = 'url('+gallery_preview_images[gallery_preview_page*5+i-1]+')';
                        $('gallery_preview_thumb_'+i).style.visibility = "visible";
                } else {
                        $('gallery_preview_thumb_'+i).style.visibility = "hidden";
                }
        }
        gallery_preview_page++;
        if(gallery_preview_page>=gallery_preview_images.length/5) $('gallery_preview_arrow_forward').style.visibility = "hidden";
        $('gallery_preview_arrow_back').style.visibility = "visible";
}

function gallery_preview_back(){
        gallery_preview_page--;
        for(var i=1;i<=5;i++){
                if(typeof(gallery_preview_images[gallery_preview_page*5-5+i-1])!="undefined"){
                        $('gallery_preview_thumb_'+i+'_img').setAttribute('src',gallery_preview_images[gallery_preview_page*5-5+i-1]);
                        $('gallery_preview_thumb_'+i).style.backgroundImage = 'url('+gallery_preview_images[gallery_preview_page*5-5+i-1]+')';
                        $('gallery_preview_thumb_'+i).style.visibility = "visible";
                } else {
                        $('gallery_preview_thumb_'+i).style.visibility = "hidden";
                }
        }
        if(gallery_preview_page<=1) $('gallery_preview_arrow_back').style.visibility = "hidden";
        $('gallery_preview_arrow_forward').style.visibility = "visible";
}

function gallery_navpos(){
        var picpos = findPos($('gallery_picture_img'));
        var correction = ($('browser').innerHTML=='iexplore7') ? 2 : 0;
        
        if($('gallery_selection_thumb_0_img').src.replace('_small.png','') == $('gallery_picture_img').src.replace('_normal.jpg','')){
                $('gallery_back').style.visibility = "hidden";
                $('imagemap_left').setAttribute("coords","0,0,0,0");
        } else {
                $('gallery_back').style.visibility = "visible";
                $('gallery_back').style.position = 'absolute';
                $('gallery_back').style.left = picpos[0]+'px';
                $('gallery_back').style.top =  (picpos[1]+($('gallery_picture_img').getHeight()-$('gallery_back').getHeight())/2)+'px';
        }
        
        var i=0; while($('gallery_selection_thumb_'+i+'_img')) i++; i--;
        if($('gallery_selection_thumb_'+i+'_img').src.replace('_small.png','') == $('gallery_picture_img').src.replace('_normal.jpg','')){
                $('gallery_forward').style.visibility = "hidden";
                $('imagemap_right').setAttribute("coords","0,0,0,0");
        } else {
                $('gallery_forward').style.visibility = "visible";
                $('gallery_forward').style.position = 'absolute';
                $('gallery_forward').style.left = correction+(picpos[0]+($('gallery_picture_img').getWidth()-$('gallery_forward').getWidth()))+'px';
                $('gallery_forward').style.top = (picpos[1]+($('gallery_picture_img').getHeight()-$('gallery_forward').getHeight())/2)+'px';
        }
}

function gallery_back(){
        if(typeof(gallery_img_loading)!="undefined" && gallery_img_loading) return;
        var i=0;
        var last_img = $('gallery_selection_thumb_0_img').src;
        while($('gallery_selection_thumb_'+i+'_img')){
                if($('gallery_selection_thumb_'+i+'_img').src.replace('_small.png','') == $('gallery_picture_img').src.replace('_normal.jpg','')){
                        open_gallery(last_img);
                        break;
                }
                last_img = $('gallery_selection_thumb_'+i+'_img').src;
                i++;
        }
}

function gallery_forward(){
        if(typeof(gallery_img_loading)!="undefined" && gallery_img_loading) return;
        var i=0;
        while($('gallery_selection_thumb_'+i+'_img')){
                if($('gallery_selection_thumb_'+i+'_img').src.replace('_small.png','') == $('gallery_picture_img').src.replace('_normal.jpg','')){
                        if($('gallery_selection_thumb_'+(i+1)+'_img')) open_gallery($('gallery_selection_thumb_'+(i+1)+'_img').src);
                        break;
                }
                i++;
        }
}

function gallery_toggle_selection(){
        if(typeof(gallery_selection_state)=="undefined") gallery_selection_state = "expanded";
        if(gallery_selection_state == "expanded"){
                smooth_px_transition('gallery_selection',82,1,200);
                $('gallery_toggle_selection').innerHTML = '<a href="javascript:gallery_toggle_selection();"><img src="images/button_maximieren.png" alt="Vorschau maximieren" onmouseover="this.src=\'images/button_maximieren_hover.png\'" onmouseout="this.src=\'images/button_maximieren.png\'"/></a>';
                gallery_selection_state = "collapsing";
        } else if(gallery_selection_state == "collapsed"){
                smooth_px_transition('gallery_selection',1,82,200);
                $('gallery_toggle_selection').innerHTML = '<a href="javascript:gallery_toggle_selection();"><img src="images/button_minimieren.png" alt="Vorschau minimieren" onmouseover="this.src=\'images/button_minimieren_hover.png\'" onmouseout="this.src=\'images/button_minimieren.png\'"/></a>';
                gallery_selection_state = "expanding";
        }
}

function smooth_px_transition(element_id,begin,end,duration,position){
        if(typeof(position)=="undefined") position = 0;
        if(!$(element_id)) return;
        if(position>=duration) {
                $(element_id).style.height= end+"px";
                gallery_navpos();
                if(end==82) gallery_selection_state = "expanded";
                if(end==1) gallery_selection_state = "collapsed";
                return;
        }
        
        var x = position/duration;
        var value = begin+(end-begin)*(Math.atan(x/(.15)-3)+1.25)/(2.55);
        
        $(element_id).style.height= value+"px";
        setTimeout('smooth_px_transition("'+element_id+'",'+begin+','+end+','+duration+','+(position+10)+');',40);
}

function load_img(filename){
        if(!$('gallery_picture_img')) { gallery_img_loading = false; return;}
        $('gallery_picture_img').src = filename.replace('small.png','normal.jpg');
        $('gallery_picture_title').src = "images/render_text.png.php?input=Laden...&height=12&color=8B806A";
        $('gallery_picture_img').style.display = "none";
        $('gallery').appendChild($('gallery_picture_img'));
        imgLoadingTO = setTimeout('$(\'gallery_picture_img_wrapper\').innerHTML = \'<table width="100%" height="100%"><tr><td align="center"><img src="images/loading.gif" alt="Laden..."/></td></tr></table>\';',250);
        Event.observe('gallery_picture_img', 'load', function(event) {
                        clearTimeout(imgLoadingTO);
                        if(!$('gallery_picture_img_wrapper')) { gallery_img_loading = false; return;}
                        if(!$('gallery_picture_img')) { gallery_img_loading = false; return;}
                        $('gallery_picture_img_wrapper').innerHTML = '';
                        $('gallery_picture_img_wrapper').appendChild($('gallery_picture_img'));
                        $('gallery_picture_img').style.display = "inline";
                        $('gallery_picture_img_wrapper').style.width = $('gallery_picture_img').getWidth()+"px";
                        $('gallery_picture_img_wrapper').style.height = $('gallery_picture_img').getHeight()+"px";
                        $('imagemap_left').setAttribute('coords',"0,0,"+($('gallery_picture_img').getWidth()/2)+","+$('gallery_picture_img').getHeight());
                        $('imagemap_right').setAttribute('coords',($('gallery_picture_img').getWidth()/2)+",0,"+$('gallery_picture_img').getWidth()+","+$('gallery_picture_img').getHeight());
                        if(Prototype.Browser.IE) opacity('gallery_picture_img',0,100,64); else opacity('gallery_picture_img',0,100,167);
                        i=0;
                        while($('gallery_selection_thumb_'+i+'_img')){
                                if($('gallery_selection_thumb_'+i+'_img').src.indexOf(filename)>=0) {
                                        var info = $('gallery_selection_thumb_'+i+'_img').alt.split("#####");
                                        $('gallery_picture_title').src = "images/render_text.png.php?input="+info[0]+"&height=12&color=8B806A";
                                        if(typeof(info[1]!="undefined")) $('gallery_picture_text').innerHTML = info[1]; else $('gallery_picture_text').innerHTML = "";
                                }
                                i++;
                        }
                        gallery_navpos();
                        Event.stopObserving('gallery_picture_img', 'load');
                        if($('p_showlink')){
                                link_copy();
                                link_copy();
                        }
        });
}

function stop_loading(){
        if(self.stop) stop();
        else if(document.execCommand) document.execCommand('Stop');
}

function setActiveFrame(filename){
        var i=0; var position = -1;
        while($('gallery_selection_thumb_'+i)){
                if(position == -1 && $('gallery_selection_thumb_'+i).style.display=="block") position = 0;
                if(position == 0 && $('gallery_selection_thumb_'+i).style.display=="none") position = 1;
                if($('gallery_selection_thumb_'+i+'_img').src.indexOf(filename)>=0){
                        if(position<0){gallery_selection_back();setActiveFrame(filename); return;}
                        if(position>0){gallery_selection_forward();setActiveFrame(filename); return;}
                        if(typeof(window.removeEventListener) != 'undefined')
                                $('gallery_selection_thumb_'+i).removeEventListener('mouseover',gallery_preview_onmouseover,false);
                        else    $('gallery_selection_thumb_'+i).detachEvent('onmouseover',gallery_preview_onmouseover);
                        if(typeof(hover_frame)!="undefined") {
                                hover_frame.parentNode.removeChild(hover_frame);
                                delete(hover_frame);
                        }
                        if(typeof(active_frame)!="undefined") {
                                if(typeof(window.addEventListener) != 'undefined')
                                        active_frame.parentNode.addEventListener('mouseover',gallery_preview_onmouseover,false);
                                else    active_frame.parentNode.attachEvent('onmouseover',gallery_preview_onmouseover);
                                active_frame.parentNode.removeChild(active_frame);
                                delete(active_frame);
                        }
                        active_frame = document.createElement('img');
                        active_frame.src = 'images/gallery_preview_active.png';
                        $('gallery_selection_thumb_'+i).appendChild(active_frame);
                }
                i++;
        }
}

function open_gallery(filename){
        if(typeof(gallery_img_loading)!="undefined" && gallery_img_loading) return;
        if($('gallery')){
                if($('gallery_picture_img').src.indexOf(filename.replace('small.png','normal.jpg'))>=0) return;
                gallery_img_loading = true;
                setActiveFrame(filename);
                
                if(Prototype.Browser.IE) {
                        opacity('gallery_picture_img',99,0,64);
                        setTimeout("load_img('"+filename+"')",150);
                } else {
                        opacity('gallery_picture_img',99,0,167);
                        setTimeout("load_img('"+filename+"')",400);
                }
                return;
        }
        gallery_state_loading = true;
        gallery_background = document.createElement('div');
        gallery_background.id = 'gallery_background';
        gallery_background.style.position = "fixed";
	gallery_background.style.top  = "0";
	gallery_background.style.left = "0";
	gallery_background.style.backgroundColor = "#000000";
	if(Prototype.Browser.IE) gallery_background.style.filter = "alpha(opacity = 0)";
        else gallery_background.style.opacity = "0";
        jQuery(gallery_background).click(gallery_close);
        
        $('page').parentNode.appendChild(gallery_background);
        if(Prototype.Browser.IE) opacity('gallery_background',0,80,382);
        else opacity('gallery_background',0,80,1000);
        
        gallery = document.createElement('div');
        gallery.id = 'gallery';
        gallery.style.position = "absolute";
	gallery.style.top  = "0";
	gallery.style.left = "0";
        jQuery(gallery).click(function(evt){
                        var node_ids = ["gallery","gallery_picture", "gallery_close", "gallery_toggle_selection", "gallery_picture_fbshare", "p_showlink"];
                        if(node_ids.indexOf(evt.target.id)>=0) gallery_close();
        });
        $('page').parentNode.appendChild(gallery);
        
        gallery_loading = document.createElement('img');
        gallery_loading.id = 'gallery_loading';
        gallery_loading.style.position = "fixed";
	gallery_loading.style.top  = "0";
	gallery_loading.style.left = "0";
        gallery_loading.src = "images/loading.gif";
        $('page').parentNode.appendChild(gallery_loading);
        
        size_gallery();
        if(typeof(window.addEventListener) != 'undefined')
		window.addEventListener('resize',size_gallery,false);
	else 	window.attachEvent('onresize',size_gallery);
        
        new Ajax.Request('gallery.php',
        {
          method:'get',
          parameters: {show: filename, ajaxload:true},
          onSuccess: function(transport){
            var response = transport.responseText || "no response text";
            $('gallery').innerHTML = response;
            $('page').parentNode.removeChild(gallery_loading);
            delete(gallery_loading);
            window.scrollTo(0,0);
            var scripts = document.getElementsByTagName("script");
            for (var i=0; i<scripts.length;i++) {
                if(underneath(scripts[i],$('gallery'))) eval(scripts[i].innerHTML);
            }
            shortcut.add("esc",gallery_close);
            shortcut.add("up",function() {if(typeof(gallery_selection_state)=="undefined" || gallery_selection_state == "expanded") gallery_toggle_selection();});
            shortcut.add("down",function() {if(typeof(gallery_selection_state)!="undefined" && gallery_selection_state == "collapsed") gallery_toggle_selection();});
            shortcut.add("left",gallery_back);
            shortcut.add("right",gallery_forward);
            
          },
          onFailure: function(){ alert('Something went wrong...') }
        });
}

 function size_gallery(){
	 if(typeof(window.innerWidth)=='number') {myWidth = window.innerWidth;myHeight = window.innerHeight;}
	 else {myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight;}
	 gallery_background.style.width  = myWidth+"px";
	 gallery_background.style.height = (myHeight+20)+"px";
         gallery.style.width  = myWidth+"px";
	 gallery.style.height = myHeight+"px";
         if(typeof(gallery_loading)!='undefined'){
                 gallery_loading.style.top  =  Math.ceil((myHeight-gallery_loading.style.height.substr(0,gallery_loading.style.height.length-2))/2)+"px";
                 gallery_loading.style.left =  Math.ceil((myWidth-gallery_loading.style.width.substr(0,gallery_loading.style.width.length-2))/2)+"px";
         }
 }
 
 function gallery_close(){
         if(typeof(gallery_state_loading)=="undefined" || gallery_state_loading) return;
         if(typeof(gallery_selection_state)!="undefined") delete(gallery_selection_state);
         $("page").parentNode.removeChild(gallery);
         gallery_img_loading = false;
         shortcut.remove("esc");
         shortcut.remove("up");
         shortcut.remove("down");
         shortcut.remove("left");
         shortcut.remove("right");
         if(Prototype.Browser.IE) {
                 opacity("gallery_background",80,0,382);
                 setTimeout('$("page").parentNode.removeChild(gallery_background);',382);
         } else {
                 opacity("gallery_background",80,0,1000);
                 setTimeout('$("page").parentNode.removeChild(gallery_background);',1000);
         }
 }
 
 function findPos(obj) {
	 var curleft = curtop = 0;
         if (obj.offsetParent) {
                 do {
			 curleft += obj.offsetLeft;
			 curtop += obj.offsetTop;
                 } while (obj = obj.offsetParent);
         }
         return [curleft,curtop];
 }
 
 function rubric_click(element){
         jQuery(element).parents('ul').find('a').css('color','white');
         if(jQuery(element).parents('li').length==2) jQuery(jQuery(element).parents('li')[1]).find('a:first').css('color','black');
         jQuery(element).css('color','black');
 }
 
 var nrml = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-_@#';
 var sbst = 'XgqvxsQArhIlPREimdOteGjfBSDpNkyYTozHnWCVawUuZKbJFMcL-_.#@';
 var a_nrml = []; var aa_sbst = [];
 for (var i=0; i<nrml.length ;i++) {
    a_nrml[i] = nrml.charAt(i);
    aa_sbst[sbst.charAt(i)] = i;
 }
 
 function unveil(input){
    var result = '';
    for (var i=0; i<input.length ;i++) {
        index = aa_sbst[input.charAt(i)];
        if(typeof index=='undefined') result += input.charAt(i);
        else result += a_nrml[index];
    }
    return result;
 }
 
 function fb_share() {
    var url = document.location.href;
    if (url.indexOf('/#') !== -1) {
    	url = url.split('/#').join('');
    }
    var title = document.title.replace(/#.*$/,'');
    if($('gallery_picture_img')) {
            url = url+"%3fimg="+$('gallery_picture_img').src.replace(/^.*\//,'').replace(/_normal\..*/,'');
            title = $('gallery_picture_title').src.replace(/^.*input=/,'').replace(/&.*/,'')+" | "+title;
    }
		window.open('http://www.facebook.com/sharer.php?u='+url+'&t='+title);
 }
 
 
// DF1.1 :: domFunction 
// *****************************************************
// DOM scripting by brothercake -- http://www.brothercake.com/
// GNU Lesser General Public License -- http://www.gnu.org/licenses/lgpl.html
//******************************************************
//DOM-ready watcher
function domFunction(f, a)
{
	var n = 0;
	var t = setInterval(function()
	{
		var c = true;
		n++;
		if(typeof document.getElementsByTagName != 'undefined' && (document.getElementsByTagName('body')[0] != null || document.body != null))
		{
			c = false;
			if(typeof a == 'object')
			{
				for(var i in a)
				{
					if
					(
						(a[i] == 'id' && document.getElementById(i) == null)
						||
						(a[i] == 'tag' && document.getElementsByTagName(i).length < 1)
					) 
					{ 
						c = true; 
						break; 
					}
				}
			}
			if(!c) { f(); clearInterval(t); }
		}
		if(n >= 60)
		{
			clearInterval(t);
		}
	}, 250);
};
var onDomLoad = new domFunction(function()
{
	body_onload();		
}, {'footer':'id'});

function raiseEvent (eventType, element){
        var o = (typeof(element)=="object") ? element : document.getElementById(element);
        if(!o)return;
        if (document.createEvent){
                var evt = document.createEvent("Events");
                evt.initEvent(eventType, true, true);
                o.dispatchEvent(evt);
        }
        else if (document.createEventObject){
                var evt = document.createEventObject();
                o.fireEvent('on' + eventType, evt);
        }
        o = null;
}

prevent_first_click = false;
function nonflashmenu_run(){
           var nodes = $('nonflashmenu').select('.categories a');
           for(var i=0; i<nodes.length; i++){
                   nodes[i].href=""; // Todo: Skip this line if a correct value for href is calculated later
                   Event.stopObserving(nodes[i],'click');
                   Event.observe(nodes[i], 'click', function(evt) {
                                   var elem = (evt.target) ? evt.target : evt.srcElement;
                                   elem.category_name = elem.className.match(/Box (.*) Inactive/)[1];
                                   var active = $('nonflashmenu').select('.categories div');
                                   for(var j=0; j<active.length; j++){
                                           var category_name = active[j].className.match(/Box (.*)Active/)[1];
                                           //Todo: Calculate correct value for href in the next line
                                           active[j].replace('<a href="" title="'+category_name+'" class="Box '+category_name+' Inactive"></a>');
                                   }
                                   elem.replace('<div class="Box '+(elem.category_name)+'Active"></div>');
                                   var category_img = $('nonflashmenu').select('.category');
                                   if(category_img.length>0) category_img[0].replace('<img class="category" alt="'+(elem.category_name=="PrintWeb"?"Print &amp; Web":elem.category_name)+'" src="images/render_text.png.php?input='+(elem.category_name=="PrintWeb"?"Print %26 Web":elem.category_name)+'&amp;height=14"/>');
                                   var rubric_items = $('nonflashmenu_rubrics').descendants();
                                   for(var j=0; j<rubric_items.length; j++) rubric_items[j].remove();
                                   for(var j=0; j<nonflashmenu.length; j++) if(nonflashmenu[j][1]==(elem.category_name=="PrintWeb"?"Print %26 Web":elem.category_name)) {
                                           for(var k=0; k<nonflashmenu[j][2].length; k++){
                                                   var li = document.createElement('li');
                                                   //Todo: Calculate correct value for hrefs
                                                   if(nonflashmenu[j][0]==nonflashmenu_active_category && nonflashmenu[j][2][k][0]==nonflashmenu_active_rubric) li.innerHTML = '<img class="rubric inactive" alt="'+nonflashmenu[j][2][k][1]+'" src="images/render_text.png.php?input='+nonflashmenu[j][2][k][1]+'&amp;height=9&amp;color=000000"/>';
                                                   else li.innerHTML = '<a href="" title="'+nonflashmenu[j][2][k][1].replace(/%26/,'&amp;')+'"><img class="rubric inactive" alt="'+nonflashmenu[j][2][k][1]+'" src="images/render_text.png.php?input='+nonflashmenu[j][2][k][1]+'&amp;height=9&amp;color=8A7F6A"/><img style="display:none;" class="rubric hover" alt="" src="images/render_text.png.php?input='+nonflashmenu[j][2][k][1]+'&amp;height=9&amp;color=CDCDCD"/></a>';
                                                   $('nonflashmenu_rubrics').appendChild(li);
                                           }
                                           break;
                                   }
                                   nonflashmenu_run();
                                   
                                   if(!prevent_first_click){
                                           raiseEvent('click',jQuery('#nonflashmenu_rubrics li:first a')[0]);
                                   }
                                   evt.stop();
                   });
           }
           var nodes = $('nonflashmenu_rubrics').select('a');
           for(var i=0; i<nodes.length; i++) {
                   Event.stopObserving(nodes[i],'click');
                   Event.observe(nodes[i], 'click', function(evt) {
                                   var elem = (evt.target) ? evt.target : evt.srcElement;
                                   if(elem.tagName=="A") elem = elem.firstChild;
                                   var active = $('nonflashmenu').select('.categories div');
                                   if(active.length>0) var category_name = active[0].className.match(/Box (.*)Active/)[1]; else var category_name = "";
                                   category_name = (category_name=="PrintWeb"?"Print %26 Web":category_name);
                                   var rubric_name = elem.src.match(/input=([^&]*)/)[1].replace(/%20/g," ");
                                   var category_id = ""; var rubric_id = "";
                                   for(var j=0; j<nonflashmenu.length; j++) if(nonflashmenu[j][1]==category_name) {
                                           category_id = nonflashmenu[j][0];
                                           for(var k=0; k<nonflashmenu[j][2].length; k++) if(nonflashmenu[j][2][k][1]==rubric_name) rubric_id = nonflashmenu[j][2][k][0];
                                           break;
                                   }
                                   if(category_id!="" && rubric_id!="") load_page(category_id+"/"+rubric_id+"/index.php");
                                   nonflashmenu_active_category = category_id;
                                   nonflashmenu_active_rubric = rubric_id;
                                   var rubrics = $('nonflashmenu_rubrics').select('li');
                                   for(var j=0; j<rubrics.length; j++) if (rubrics[j].firstChild.tagName=="IMG"){
                                           var name = rubrics[j].firstChild.src.match(/input=([^&]*)/)[1];
                                           rubrics[j].firstChild.replace('<a href="" title="'+name.replace(/%20/g,' ').replace(/%26/g,"&amp;")+'"><img class="rubric inactive" alt="'+name+'" src="images/render_text.png.php?input='+name+'&amp;height=9&amp;color=8A7F6A"/><img style="display:none;" class="rubric hover" alt="" src="images/render_text.png.php?input='+name+'&amp;height=9&amp;color=CDCDCD"/></a>');
                                           break;
                                   }
                                   elem.parentNode.parentNode.innerHTML = '<img class="rubric inactive" alt="'+rubric_name+'" src="images/render_text.png.php?input='+rubric_name+'&amp;height=9&amp;color=000000"/>';
                                   nonflashmenu_run();
                                   evt.stop();
                   });
           }
           
           //Hover Effects:
           if(hoover_enabled){
                   var nodes = $('nonflashmenu_rubrics').select('[class="rubric inactive"]');
                   for(var i=0; i<nodes.length; i++){
                           Event.stopObserving(nodes[i],'mouseover');
                           Event.observe(nodes[i], 'mouseover', function(evt) {
                                           var elem = (evt.target) ? evt.target : evt.srcElement;
                                           if(elem.nextSibling){
                                                   elem.nextSibling.style.display="inline";
                                                   elem.style.display="none";
                                           }
                           });
                   }
                   var nodes = $('nonflashmenu_rubrics').select('[class="rubric hover"]');
                   for(var i=0; i<nodes.length; i++){
                           Event.stopObserving(nodes[i],'mouseout');
                           Event.observe(nodes[i], 'mouseout', function(evt) {
                                           var elem = (evt.target) ? evt.target : evt.srcElement;
                                           if(elem.parentNode.firstChild){
                                                   elem.parentNode.firstChild.style.display="inline";
                                                   elem.style.display="none";
                                           }
                           });
                   }
           }
}

function nonflashmenu_changeto(path){
           path = path.split("/");
           var nodes = $('nonflashmenu').select('.categories a');
           for(var i=0; i<nodes.length; i++)  for(var j=0; j<nonflashmenu.length; j++){
                   var temp = (nodes[i].title=="Print & Web"?"Print %26 Web":nodes[i].title);
                   if(nonflashmenu[j][1]==temp) if(nonflashmenu[j][0]==path[0]) {
                           prevent_first_click = true;
                           raiseEvent('click',nodes[i]);
                           prevent_first_click = false;
                           break;
                   }
           }
           if(path.length<=1) return;
           var active = $('nonflashmenu').select('.categories div');
           if(active.length==0) return;
           var category_name = active[0].className.match(/Box (.*)Active/)[1];
           category_name = category_name=="PrintWeb"?"Print %26 Web":category_name;
           for(var j=0; j<nonflashmenu.length; j++) if(nonflashmenu[j][1]==category_name) var category_number = j;
           var nodes = $('nonflashmenu_rubrics').select('a');
           for(var i=0; i<nodes.length; i++) for(var j=0; j<nonflashmenu[category_number][2].length; j++) if(nonflashmenu[category_number][2][j][1]==nodes[i].title.replace(/&/g,"%26")) if(nonflashmenu[category_number][2][j][0]==path[1]) {
                   var rubrics = $('nonflashmenu_rubrics').select('li');
                   for(var j=0; j<rubrics.length; j++) if (rubrics[j].firstChild.tagName=="IMG"){
                           var name = rubrics[j].firstChild.src.match(/input=([^&]*)/)[1];
                           rubrics[j].firstChild.replace('<a href="" title="'+name.replace(/%20/g,' ').replace(/%26/g,"&amp;")+'"><img class="rubric inactive" alt="'+name+'" src="images/render_text.png.php?input='+name+'&amp;height=9&amp;color=8A7F6A"/><img style="display:none;" class="rubric hover" alt="" src="images/render_text.png.php?input='+name+'&amp;height=9&amp;color=CDCDCD"/></a>');
                           break;
                   }
                   var rubric_name = nodes[i].firstChild.src.match(/input=([^&]*)/)[1].replace(/%20/g," ");
                   nodes[i].parentNode.innerHTML = '<img class="rubric inactive" alt="'+rubric_name+'" src="images/render_text.png.php?input='+rubric_name+'&amp;height=9&amp;color=000000"/>';
                   nonflashmenu_active_category = path[0];
                   nonflashmenu_active_rubric = path[1];
                   nonflashmenu_run();
                   break;
           }
}

