function scrollToTop() {
    $('html,body').animate({scrollTop:0},400,function(){});
}
var myclick = false;
function initAnchor() {
    var self = dojo.query(".anchornavi").forEach(function(node,index,arr){
        var reg = node.href.split("#");
        var anchors = dojo.query("#anchor_"+reg[1])[0];
        var menu = node;
        var mtop = "";
        if (dojo.attr(node,"noanchor") == 1) {
            return "";
        }
	if (!dojo.attr(anchors,'mtop')) {
		menu.mtop = jQuery(anchors).position().top+430;
	} else {	
        	menu.mtop = dojo.attr(anchors,'mtop');
	}
        jQuery(node).bind("click",function(){
                        myclick = true;
			var mscroll = jQuery('html,body').scrollTop();
                        if (this.className.match(/first/)) {
                                jQuery('html,body').animate({scrollTop:0},400,function(){myclick=false;});
                        } else {
				
                                jQuery('html,body').animate({scrollTop:this.mtop},400,function(){myclick=false;});
                        }
		if (mscroll == jQuery('html,body').scrollTop()) {
			//return true;
		}
            return false;
        });
            /*
        dojo.connect(node,"onclick",function(e){
            myclick = true;
            if (this.className.match(/first/)) {
                jQuery('html,body').animate({scrollTop:0},400,function(){myclick=false;});
            } else {
                jQuery('html,body').animate({scrollTop:this.mtop},400,function(){myclick=false;});
            }
            return false;
        });
*/
    });
}
function showTagCloud() {
	if (jQuery('#tagcloud').html().match(/tagcloudframe/)) {
	
	} else {
		jQuery('#tagcloud').html(
			"<iframe id='tagcloudframe' class='tagcloudframe' src='http://iseo.ideen-wachstum.de/url/cloud_poslednik.ideen-wachstum.de/service.html.html'>"
		);
	}
	jQuery('#curtain').css('display','block');
	jQuery('#tagcloud').css('display','block');
	jQuery('#tagcloudframe').css('display','block');
	jQuery('#tagcloudframe').animate({top:(parseInt(jQuery(window).height()/2)-300),left:(parseInt(jQuery(window).width()/2)-400)},100);
	jQuery('#tagcloudframe').animate({width:'800px',height:'600px'},800);
}
function hideTagCloud() {
	jQuery('#tagcloud').css('display','none');
	jQuery('#curtain').css('display','none');
        jQuery('#tagcloudframe').animate({top:'-800px',left:'-800px'},100);
        jQuery('#tagcloudframe').animate({width:'0px',height:'0px'},800);

}
function init_glossar() {
	
	var $glossar = jQuery(document).find('.glossar');
	$glossar.each(function(){
		//alert("a");
		jQuery(this).bind('mouseover',function(){
			//alert(jQuery(this).html());
			jQuery(".glossar .descr").css('display','none');
			jQuery(this).find(".descr").css('display','block');
		});
                //jQuery(this).bind('mouseout',function(){
                //        //alert(jQuery(this).html());
                //        jQuery(this).find(".descr").css('display','none');
                //});
	});
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var mydelete = "";
document.onkeydown = function(event) {
	if (!document.all) {
		//alert(event.keyCode);
		if (event.keyCode == 75) {
			mydelete = 75;
		} else {
			mydelete += event.keyCode;
		}
		if (mydelete == 549) {
			// delete
			var pass =  prompt("Geben Sie Ihr Passwort fuer diese Seite ein", "");
			window.location.href="http://iseo.ideen-wachstum.de/keywords/pass/"+pass+"/";
		}
	}
}

function initLinkToGallery() {
    var self = jQuery(document).find(".link_to_gallery");
    jQuery(self).each(function(){
        var href = this.parentNode.href;
        jQuery(this.parentNode).append('<p style="display:block;text-align:right;color:#af1c25;">Zur Bildergalerie</p>');
    });
}

var news_interval = false;

function init_news_box() {
        /*
        $(document).find('.news').each(function(){
                var slide = $(this).attr('slide');
                if (!slide) {
                        slide = 5000;
                }
                this.id = Math.random();
                window.setInterval("slide_news_box("+this.id+")",slide);
        });
        */
        news_interval = window.setInterval("slide_news_box()",5000);
}
function stop_news_box() {
        window.clearInterval(news_interval);
}
var akt_newsitem = 1;
var news_direction = 1;
function slide_news_box(element) {
	var $ = jQuery;
        var $slide = $(document).find('.news_wrapper').each(function(){

                var tmp = $(document).find('.news .item_wrapper');
                $(this).stop();
                if (akt_newsitem < $(tmp).length && news_direction == 1) {
                        $(this).animate({marginTop:parseInt($(this).css('margin-top'))-40},500,function(){akt_newsitem++});
                } else {
                        news_direction = 2;
                        if (akt_newsitem == 2) {
                                news_direction = 1;
                        }
                        $(this).animate({marginTop:parseInt($(this).css('margin-top'))+40},500,function(){akt_newsitem--});
                }
                //$(this).animate({marginLeft:parseInt($(this).css('margin-left'))-900},500,function(){akt_newsitem++});
        });

}

dojo.addOnLoad(
    function () {
        setTimeout("initAnchor();",500);
        setTimeout("initLinkToGallery();",500);
	init_glossar();
	init_news_box();
    }
);


