/**not for distrubution, will nly work with current sourcecode*/var imageChanger = function(opts){ var c = this;	this.name = opts.name||'myalbum';	this.largeCnt = opts.largeCnt||$('.largeCnt');	this.busyUntil = new Date().getTime(); 	this.timer= null;
	this.actions = {
		large: function(params){			if(new Date().getTime() > c.busyUntil){
				$('<img src="'+params.img+'">').appendTo($(c.largeCnt)).hide();				var aant = $(c.largeCnt).find('img').length;				c.busyUntil =  new Date().getTime()+820;				if(aant > 1){					$(c.largeCnt).find('img').eq(1).css({top: '-440px'}).fadeIn(800, function(){						if($(c.largeCnt).find('img').length > 0) $(c.largeCnt).find('img').eq(0).remove();						$(c.largeCnt).find('img').css({top: 0});					});				}				else{					$(c.largeCnt).find('img').fadeIn(800);				}			}			else{				var t = (c.busyUntil-new Date().getTime())+5;				if(t<0) t= 0;				clearTimeout(c.timer);				c.timer = setTimeout(function(){ c.actions.large(params);}, t );			}
		}
	}
	var hashChange = function(){
		var c = this;
		var callbacks = new Array();
		var location = '';
		var timer;
		
		
		var init = function(){
			location = c.getCurrent();
			timer = setInterval(function(){
				if(c.getCurrent()+'' != location+''){
					catchNewLocation();
				}
			}, 5);
		}
		
		
		var catchNewLocation = function(){
			var loc = c.getCurrent();			var l2 = new String(location);			location = loc;
			for(var i = 0;i<callbacks.length;i++){
				callbacks[i](loc, l2);
			}
		}
		
		this.getCurrent = function(){
			return new String(window.location).indexOf('#') != -1?new String(window.location).split('#')[1].split('?')[0]:new String('');
		}
		
		this.add = function(callback){
			if(typeof callback == 'function')
				callbacks.push(callback);
		}
		
		init();

	}
	this.hc = new hashChange();
	
	var setChangeListener = function(){
		c.hc.add(c.changer);
	}
	/**
	* the listener for changes wich decides what to show.
	*/
	this.changer = function(newH){
		var tmp = newH.split(';');
		if(tmp[0] == c.name){
			var nar = tmp[1].split('|');
			for(i in nar){
				var t = nar[i].split(':');
				c.run("c.actions." +t[0], {img: t[1]});
			}
		}
	}
	
	this.run = function(func, params){		try{
			eval(func+"(params)");		}		catch(e){}
	}


	this.init = function(){		var cur = c.hc.getCurrent();
		if(cur != '') c.changer(cur);		else{			if($('.scrollable a').length > 0) window.location = base+$('.scrollable a:eq(0)').attr('href');		}
		
	}
	
	if($('.scrollable').length > 0){
	setChangeListener();	this.init();	}
}$(function(){
new imageChanger({});
});
