// ******************************************************************************
// Global Constants and Variables
// ******************************************************************************


// ******************************************************************************
// typo3 std functionen
// ******************************************************************************

function decryptCharcode(n,start,end,offset){
	n=n+offset;if(offset>0&&n>end){n=start+(n-end-1);}else if(offset<0&&n<start){n=end-(start-n-1);}
	return String.fromCharCode(n);
}

function decryptString(enc,offset){
	var dec="";
	var len=enc.length;
	for(var i=0;i<len;i++){
		var n=enc.charCodeAt(i);
		if(n>=0x2B&&n<=0x3A){
			dec+=decryptCharcode(n,0x2B,0x3A,offset);
		}else if(n>=0x40&&n<=0x5A){dec+=decryptCharcode(n,0x40,0x5A,offset);
		}else if(n>=0x61&&n<=0x7A){dec+=decryptCharcode(n,0x61,0x7A,offset);
		}else{dec+=enc.charAt(i);
		}}
	return dec;
}

function linkTo_UnCryptMailto(s){
	location.href=decryptString(s,-3);
}






// ******************************************************************************
var Base = Class.create();
Base.prototype = {

	// ******************************************************************************
	// Constants
	// ******************************************************************************
	Version: '1.0',

	classNames: {
	  xxx : 'footNav-top'
	},

	elmIds: {
	  searchInput : 'searchInput',
	  directAccessSelect : 'directAccessSelect',
	  directAccessSubmit : 'directAccessSubmit',
	  closeLink : 'closeLink',
	  printLink : 'printLink',
	  topLink : 'topLink'
	},
	
	options : {
		googleAnalyticsTrackingCode : 'UA-xxxxxxx-1'
	},

	// ******************************************************************************
	// vars
	// ******************************************************************************
	//ajaxLoadingIconObj: new Object,


	// ******************************************************************************
	// Constructor
	// ******************************************************************************
	initialize: function()
	{
	  if((typeof Prototype=='undefined') || (typeof Element == 'undefined') || (typeof Element.Methods=='undefined') || parseFloat(Prototype.Version.split(".")[0] + "." + Prototype.Version.split(".")[1]) < 1.6)
  	    throw("dieses Script ben�tigt das Prototype JavaScript framework >= 1.6.0");


	  document.observe('dom:loaded',this.onDomReadyHandler.bind(this), false);
	  Event.observe(window, 'load', this.onLoadHandler.bind(this), false);


	},


	onDomReadyHandler: function() {
        // anchorLink scroller
        $$('a.anchorLink').each(function(elm){Event.observe(elm, 'click', this.anchorLinkClick.bindAsEventListener(this), false);}.bind(this));


        // carousel setup
        $$('.carousel').each(function(elm){new Carousel({carousel : elm});});
        // accordion setup
        $$('#margin .accordion').each(function(elm){new Accordion({accordion : elm, firstOpen : true});});
        $$('#content .accordion').each(function(elm){new Accordion({accordion : elm, stayOpen : true});});
        $$('.printLink,.print').invoke('observe', 'click', function(ev){
            ev.stop();
            window.print();
            ;});
        // menu setup
        new Menu();
        new Search();
        new Lang();
        new Quicknav();
	  
        myFormStyler = new FormStyler();
        myFormStyler.start();
	  
	  
        // google analytics api call
/*
	  try {
		var pageTracker = _gat._getTracker(this.googleAnalyticsTrackingCode);
		pageTracker._trackPageview();
	  } catch(err) {}
*/
   	},


	onLoadHandler: function() {

   	},

	closeLinkClick : function(ev){
	  ev.stop();
	  window.close();
	},


	anchorLinkClick : function(ev){
	  ev.stop();
	  elm = ev.findElement('a');
	  hash = elm.href.split('#')[1];
	  scrollElm = $$('a[name='+ hash  +']').first();

	  new Effect.ScrollTo(scrollElm);

	},
	

	
	
	// ***********************************************************************************************
	// Dummy end func
	// ***********************************************************************************************
	dummy: function(){
	}
};




myBase = new Base();





