//Javascript navigation shit
 	var totIncrement		= 0;
 	var increment			= 293;
	var sousgardenFlash     = Cookie.read('sousgardenFlash');
    // image slider
	
 	imgSlider = {
		init: function (divobj){
			        this.itemGroup = $$(divobj + ' ul');
			        this.items = $$(divobj + ' ul li');
				    this.itemCount = this.items.length;
				    this.itemGroup.setStyle('width',this.items.length*293);
					maxRightIncrement = increment*((this.itemCount-3)*(-1));
					$('previous').setStyle('opacity', 0.3);
					maxLength = this.itemCount*(-293)+879;
					imgSlider = new Fx.Tween('portfolio-list', { property: 'margin-left',
                                                                 duration: 1000,
                                                                 transition: Fx.Transitions.Back.easeInOut,
																 onComplete: function(){ 
																           left = parseInt($('portfolio-list').getStyle('margin-left'));
																		   if ( left < 0 ) {
			                                                                  $('previous').tween('opacity', 1);
		            													   } else {
			                                                                  $('previous').tween('opacity', 0.3);
		            													   }
																		   
                    													   if ( left == maxLength ) {
			                                                                  $('next').tween('opacity', 0.3);
		            													   } else {
			                                                                  $('next').tween('opacity', 1);
		            													   }
																  }
																 });
			
					//-------------------------------------
					// EVENTS for the button "previous"
					$('previous').addEvents({ 
					      'click' : function(event){ 
		                                if ( totIncrement < 0 ) {
			  		                         totIncrement = totIncrement+increment;
					                         imgSlider.start(totIncrement); 
			                            } 
			               }			  	  
                     }); 
	 
					//-------------------------------------
					// EVENTS for the button "next"
					$('next').addEvents({ 
					      'click' : function(event){ 
		                                if(totIncrement>maxRightIncrement){
			  		                         totIncrement = totIncrement-increment;
					                         imgSlider.start(totIncrement);	 
			                            }
			               }		  		  
                     });
		
		} // init
					
	} //imgSlider
	
	
	
	var Flasher = {
        links: $$('.flasher'),
        init: function(){
              this.links.each(function(link){
                    var sw_url  = link.getChildren('a').getProperty('href');
					var sw_temp = new Swiff(themePath+'seth.swf', {
								  id: 'sw_'+link.getProperty('id'),
                                  width: 200,
                                  height: parseInt(link.getStyle('font-size'))+10,
                                  container: link.getProperty('id') ,
								  params: {
                                     wmode: 'transparent',
                                     bgcolor: '#ffffff',
									 allowScriptAccess: 'sameDomain',
									 allowFullScreen: 'false',
									 loop: 'false',
									 menu: 'false',
									 quality: 'best',
									 scale: 'noscale',
									 salign: 'lt'
								 },
								 vars: {
									myText: link.get('text').toUpperCase(),
									mySize: parseInt(link.getStyle('font-size'))+5,
									myURL: sw_url[0],
									myColor: '0x'+link.getStyle('color').substring(1, 7)
								 }
                            });			  
			  });		  
		      },
        blogdate: function(){
					var sw_temp = new Swiff(themePath+'mydate.swf', {
								  id: 'sw_blog_date',
                                  width: 150,
                                  height: 130,
                                  container: 'blog_date' ,
								  params: {
                                     wmode: 'transparent',
                                     bgcolor: '#ffffff',
									 allowScriptAccess: 'sameDomain',
									 allowFullScreen: 'false',
									 loop: 'false',
									 menu: 'false',
									 quality: 'best',
									 scale: 'noscale',
									 salign: 'lt'
								 },
								 vars: {
									myDay: $('blog_day').get('text').toUpperCase(),
									myMonth: $('blog_month').get('text').toUpperCase()
								 }
                            });			  
		}
	}
							
			
	var flashCheck = {
		init: function(){
			  if (sousgardenFlash == null) {
				  // cookie not set - check flash version
				  if (!DetectFlashVer(9, 0, 124)) {
					  // Ask for update
					  Sexy.confirm('<h2>Achtung</h2>Ihre <strong>Adobe Flash Player</strong> Version ('+GetSwfVer()+') ist <strong>veraltet</strong>.<br />Wollen Sie Ihre Version aktualisieren oder ohne Flash fortfahren?<br /><strong>Unsere seiten sind Flash optimiert.</strong>',{ 
				                  textBoxBtnOk: 'Flash aktualisieren', 
								  textBoxBtnCancel: 'Ohne Flash fortfahren',
								  onComplete: function(returnvalue) { 
								                   if (returnvalue) {
													   window.location ="http://get.adobe.com/flashplayer/";
												   } else {
													   sousgardenFlash = 'no';
					                                   Cookie.write('sousgardenFlash',sousgardenFlash); 
												   }
								              } // onComplete function
								  });
				  } else {
					 sousgardenFlash = 'yes';
					 Cookie.write('sousgardenFlash',sousgardenFlash);  
				  }
				  
			  } // If cookie not set
		}  // init function
	}
	
	
	
	
window.addEvents({
				 
	'domready': function(){

        flashCheck.init();
        
		if (sousgardenFlash == 'yes') {
		    if ($('blog_date')) {
			    Flasher.blogdate();
		    }
		
		    Flasher.init();
		}
		
		
		
	    if ($('portfolio-stage')) {
		   imgSlider.init('#portfolio-stage');
		}
		
		var myAccordion = new Accordion($$('h3.togglers'), $$('div.elements'), {
                                        display: 0,
                                        alwaysHide: true,
										onActive: function(toggler, element){
														   toggler.setStyle('background-image', 'url('+themePath+'images/arrow-up.png)');
										                   toggler.setStyle('background-color', '#6ea909');
										},
										onBackground: function(toggler, element){
										                       toggler.setStyle('background-color', '#c5e0ff');
														       toggler.setStyle('background-image', 'url('+themePath+'images/arrow-down.png)');
										}
                              });

		
		//Footer drag
		$('fooz').makeResizable({
			modifiers: {x: false, y: 'height'},
			limit: {y: [110, 350]},
			invert: true,
			handle: 'fooz'
		});
		
		//Open footer on links focus		
		$$('#booz a').each(function(link){
			link.addEvent('focus', function(){
				$('fooz').setStyle('height', 350);
			});
		});
		
		
		
	}
});