


var Controller = new Class({

	initialize: function()
	{
		
		//$$('body .ttfLink').each(function(e){new ttfLink(e);});
		//$$('body .ttfText').each(function(e){new ttfText(e);});	
		$$('body .imageLink').each(function(e){new imageLink(e);});	
		
		this.setPager();
		this.setFooter();
	},
	
	doAction: function(action, instance)
	{
		VO.action =  action;
		this.instance = instance;
		this.url = PATH.root + PATH.site + 'php/do.php';

		switch(action)
		{
			case 'doSomething':
			break;
			default:
				alert(action);
		}
	},
	
	setFooter: function()
	{
		var e = $('footerSpacer')
		if(e)
		{
			var h = window.getSize().y;
			var y = e.getCoordinates().top;
	
			if(y < h)
			{
				var d = (h-y) + 50;
				e.setStyles({'margin-top': d, 'display':'block'})
			}
		}
	},
	
	setPager: function()
	{
		var e = $('pagerBottom');
		if(e)
		{
			var h = window.getSize().y + 30;
			var y = e.getCoordinates().top;
	
			if(y < h)
			{
				var d = (h-y);
				e.setStyles({'margin-top': d, 'display':'block'})
			}
		}
	},
	afterRequest:function(rT, rE, rH, rJ)
	{
		VO.checkSession = false;

		switch(VO.action)
		{
			case 'doSomething':
			break;
			default:
			alert(rH);
		}
	},
	
	doRequest:function(type)
	{
		switch(type)
		{
			case 'html':
				new Request.HTML({url:this.url, update:this.update, data:VO, onComplete:function(rT, rE, rH, rJ){this.afterRequest(rT, rE, rH, rJ);}.bind(this) }).send();
				break;
			default:
				new Request({url:this.url, data:VO, onComplete:function(rT, rE){this.afterRequest(rT, rE);}.bind(this) }).send();
		}
	}
	
})
