// 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){
				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;
				})
		});
		$$('#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();

function loadPhotos(page){
	var jReq = new Request.JSON({url:'/photos/' + page, onSuccess:function(photos){
		var gal=$("gallery");
		gal.empty();
		photos.each(function(photo,index){
			var pEl = new Element("a",{
				"class": "grid_6 column thumbnail",
				"href": "/photos/" + photo.permalink
			});
			//create img tag
			var img = new Element("img",{'src': photo.thumbnail,'alt':photo.title});
			//overlay
			var ov = new Element("div",{
				"class":"overlay",
				"styles": {
					'display':'none'
				},
				'html':"<h2>" + photo.title + "</h2>"
			});
			ov.inject(pEl);
			img.inject(pEl);
			pEl.inject(gal);
			
		});
	}
	}).get();
}


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';
}




