// default page initializer class
var PageInit = new Class({
	initialize: function(){
	    this.removeThumbLinks();
	    this.addLinkEffects();
	    //this.addMenuFX();
		this.addMetaHover();
		this.addFooterHover();
		this.addGridListener();
	},
	addMetaHover: function(){
		var meta=$('#meta');
		if(meta==null)return;
		
		meta.addClass("noHover");
		meta.setOpacity(0.9);
		meta.addEvent('mouseover',function(){
			this.fade(1);
			return false;
		});
		meta.addEvent('mouseleave',function(){
			this.fade(0.9);
			return false;
		})
		
	},
	
	addGridListener:function(){
		var myKeyboardEvents = new Keyboard({
		    defaultEventType: 'keyup', 
		    events: { 
		        'keydown:shift+g': createGridder
		    }
		});
		
	},
	
	addFooterHover: function(){
		var footer=$('footer');
		footer.setOpacity(0.7);
		footer.addEvent('mouseover',function(){
			this.fade(1);
			return false;
		});
		footer.addEvent('mouseleave',function(){
			this.fade(0.7);
			return false;
		})
	},
	
	addLinkEffects: function(){
		$$('a').each(function(item,index){
				//add effect to all but the menu links
				if(!item.getParent("#menu")){
					
					item.addClass("noHover");
					item.set('morph', {duration:600});

					var sColor=item.hasClass("button") ? "#6fc1bc" : "#6fc1bc";
					item.setStyle('color',sColor);

					item.addEvent('mouseover',function(){
						this.morph({color:"#f06c3c"});
						return false;
					});
					item.addEvent('mouseleave',function(){
						this.morph({color:sColor});
						return false;
					});
				}
		});
		
		
		//Don't need this right now
		// $$('#menu a').each(function(item,index){
		// 		item.addClass("noHover");
		// 		if(item.hasClass(""))
		// 		item.set('tween', {duration:50,transition:'quad'});
		// 		item.addEvent('mouseover',function(){
		// 			//this.tween("padding-top",9);
		// 			return false;
		// 		});
		// 		
		// 		item.addEvent('mouseleave',function(){
		// 			//this.tween("padding-top",0);				
		// 			return false;
		// 		})
		// });
		
		// $$(".note").each(function(item,index){
		// 	item.addClass("noBgHover");
		// 	item.set('morph', {duration:600});
		// 	item.addEvent('mouseover',function(){
		// 		this.morph({background:"#fcfce0"});
		// 		return false;
		// 	});
		// 	item.addEvent('mouseleave',function(){
		// 		this.morph({background:"#fff"});
		// 		return false;
		// 	})
		// 
		// });
			
	},
	
	removeThumbLinks: function(){
		$$(".thumbnail").each(function(item,index){;
			item.addEvent('mouseover',function(){
				this.getElement('.overlay').setOpacity(0);
				this.getElement('.overlay').setStyle("display","block");
				this.getElement('.overlay').fade("in");
				return false;
			});
			item.addEvent('mouseout',function(){
				this.getElement('.overlay').fade("out");
				return false;
			});

		});		
	},
	
	addLogoHover : function(){
		var logo=$('logo');
		logo.setOpacity(0.8);
		logo.addEvent('mouseover',function(){
			this.fade(1);
			return false;
		});
		logo.addEvent('mouseleave',function(){
			this.fade(0.5);
			return false;
		})
	}
});
var Init = PageInit;
slideBox = new SlideBox();



var gOverride = {
  urlBase: 'http://gridder.andreehansson.se/releases/latest/',
  gColor: '#ffe5e5',
  gColumns:24,
  gOpacity: 0.55,
  gWidth: 5,
  pColor: '#C0C0C0',
  pHeight: 18,
  pOffset: 0,
  pOpacity: 0.55,
  center: true,
  gEnabled: true,
  pEnabled: true,
  setupEnabled: true,
  fixFlash: true,
  size: 960
};

createGridder = function() {
  document.body.appendChild(
    document.createElement('script'))
    .src='/javascripts/960.gridder.js';
}

//this wil be eliminated but it's needed right now

window.addEvent('domready', function(){
	if(document.id("mainPhoto")){
		addMainImageHover();
	}
  });


function addMainImageHover(){
	var imgEl =  document.id('mainPhoto');
	var captionEl = imgEl.getChildren(".caption");
	
	imgEl.addEvent("mouseover",function(){
		captionEl.fade(1);
	});
	imgEl.addEvent("mouseout",function(){
		captionEl.fade(0.0);
	});		
	captionEl.setOpacity(0.0);
}



