
window.addEvent('domready', function() {
	
	//create our Accordion instance
	var myAccordion = new Accordion($('accordion'), 'div.toggler', 'div.project', {
		opacity: false,
		alwaysHide: true,
		onActive: function(toggler, project){
			toggler.setStyle('cursor','pointer');
			toggler.getElements('img').setProperty('src', 'images/upArrow.gif');
			
		},
		onBackground: function(toggler, project){
			toggler.setStyle('cursor','pointer');
      toggler.getElements('img').setProperty('src', 'images/downArrow.gif');	
		},
		start:'all-close'
	});
	
	/* Frontfeature stuff */
	/* preload image(s) */
	new Asset.images([
    '../images/feature-l-off-norm.png',
    '../images/feature-l-off-over.png',
    '../images/feature-l-on-norm.png',    
    '../images/feature-l-on-over.png',
    
    '../images/feature-c-off1-norm.png',    
    '../images/feature-c-off1-over.png',
    '../images/feature-c-off2-norm.png',  
    '../images/feature-c-off2-over.png',
    '../images/feature-c-on-norm.png',
    '../images/feature-c-on-over.png',
    
    '../images/feature-r-off1-norm.png',    
    '../images/feature-r-off1-over.png',
    '../images/feature-r-off2-norm.png',
    '../images/feature-r-off2-over.png',
    '../images/feature-r-on-norm.png',
    '../images/feature-r-on-over.png',
    
    // AK Buttons
    '../images/ak1-button-norm.png',
    '../images/ak1-button-over.png',
    '../images/ak2-button-norm.png',
    '../images/ak2-button-over.png',
    '../images/ak3-button-norm.png',
    '../images/ak3-button-over.png',
    
    // Abonnement Buttons
    '../images/signupButton-norm.png',
    '../images/signupButton-over.png'
  ]);
  
  // Buttons initialisieren
	$$('img.roll').each(function(el){
		 
		el.addEvent('mouseover',function(){
			this.setAttribute('src',this.src.replace('-norm', '-over'));
		});
		
		el.addEvent('mouseout',function(){
			this.setAttribute('src',this.src.replace('-over','-norm'));
		});
		
	
	});
	
	// Initialize tabs
	var tabOne = $('featureOne');
	var tabTwo = $('featureTwo');
	var tabThree = $('featureThree');
	
	// Only hide tabs when Javascript's active
	if($$('div.hidden')){
    $$('div.hidden').each(function(el){
      el.setStyle('display','none');
    });
  }
	
	if($('featureButtonLeft')){	   
	   $('featureButtonLeft').addEvent('click',function(){	
	     $('featureButtonLeft').setProperty('src', 'assets/templates/wjo/images/feature-l-on-norm.png');
	     if($('featureButtonCenter'))
	       $('featureButtonCenter').setProperty('src', 'assets/templates/wjo/images/feature-c-off2-norm.png');
	     if($('featureButtonRight'))
	       $('featureButtonRight').setProperty('src', 'assets/templates/wjo/images/feature-r-off1-norm.png');
	       
	      // Display first tab
	      $$('.tab').setStyle('display', 'none');
	      tabOne.setStyle('display', 'block');
	   });   
   }
   
   if($('featureButtonCenter')){
   
	   $('featureButtonCenter').addEvent('click',function(){
	   
	     $('featureButtonCenter').setProperty('src', 'assets/templates/wjo/images/feature-c-on-norm.png');
	     if($('featureButtonLeft'))
	       $('featureButtonLeft').setProperty('src', 'assets/templates/wjo/images/feature-l-off-norm.png');
	     if($('featureButtonRight'))
	       $('featureButtonRight').setProperty('src', 'assets/templates/wjo/images/feature-r-off2-norm.png');
	       
	       $$('.tab').setStyle('display', 'none');
	       tabTwo.setStyle('display', 'block');
	    
	   });  
   }
   
   if($('featureButtonRight')){
	   $('featureButtonRight').addEvent('click',function(){
	     $('featureButtonRight').setProperty('src', 'assets/templates/wjo/images/feature-r-on-norm.png');
	     if($('featureButtonLeft'))
	       $('featureButtonLeft').setProperty('src', 'assets/templates/wjo/images/feature-l-off-norm.png');
	     if($('featureButtonCenter'))
	       $('featureButtonCenter').setProperty('src', 'assets/templates/wjo/images/feature-c-off1-norm.png');
	       
	    // Display third tab only
	    $$('.tab').setStyle('display', 'none');
	    tabThree.setStyle('display', 'block');
	   });   
   }
	
  // Slider (whereever needed :-) )
  $$(".slideContainer").each(function(container){
		/*var mySlide = new Fx.Slide(container.getElement(".slide"), {
      duration: 800,transition: Fx.Transitions.Pow.easeOut
    }).hide();*/
    
    var currentElement = container.getElement(".slide");
    var currentHeight = currentElement.getSize().y;
    var mySlide = new Fx.Slide(currentElement, {
      duration: 800,transition: Fx.Transitions.Pow.easeOut
    }).hide();
    
    // hier geht's weiter !!
    // Browserweiche IE < 7
    if ((navigator.userAgent.indexOf("MSIE") != -1) ){
      currentElement.setStyle('height',currentHeight+'px');
      
    }
    
    container.getElement("div.slideToggler").addEvent("click", function(e){
			new Event(e).stop();
			mySlide.toggle();
			var arrowImage = this.getElement("img");
			if(mySlide.open)arrowImage.setProperty('src', 'assets/templates/wjo/images/downArrow.gif');
			else arrowImage.setProperty('src', 'assets/templates/wjo/images/upArrow.gif');
		});
				
		if($('toggleAll')) $('toggleAll').addEvent("click", function(e){
			new Event(e).stop();
			mySlide.toggle();
			var arrowImage = $('toggleAll').getElement("img");
			if(mySlide.open)arrowImage.setProperty('src', 'assets/templates/wjo/images/downArrow.gif');
			else arrowImage.setProperty('src', 'assets/templates/wjo/images/upArrow.gif');
		}); 
	});
	
	
  var customTips = $$('.tooltip');
  
  var toolTips = new Tips(customTips, {
		
	  onShow: function(toolTipElement){
	    //passes the tooltip element
		//you can fade in to full opacity
		//or leave them a little transparent
  			toolTipElement.fade(.8);
		},
		onHide: function(toolTipElement){
			toolTipElement.fade(0);
		},
	  
		//this sets the x and y offets
		offsets: {
			'x': 20,       //default is 16
			'y': 20        //default is 16
		},
		
		showDelay: 600,
		hideDelay: 0,
		
	 	className: 'toolMyTip'
		//if you call the functions outside of the options
		//then it may "flash" a bit on transitions
		//much smoother if you leave them in here
		
	});


  
  
  var myMenu = new MenuMatic();	  
});


var showFunction = function() {

	$$('.tab').setStyle('display', 'none'); 
	this.setStyle('display', 'block');
}


function getConfirmation(transmitUrl){
   var retVal = confirm("Bist Du sicher, dass Du den Teilnehmer löschen willst?");
   if( retVal == true ){
	  window.location.href = transmitUrl;
   }
}

