var App = {
	numStoresPerPage: 3,
		
	boot: function() {
		this.cufon();
		this.collectionIndex();
		this.storeLocator();
		this.verticalCenter();
		window.addEvent('resize', function(e){
			this.verticalCenter();
		}.bind(this));	   
	},

	cufon: function() {
	    this.setFonts();
	    Cufon.now();  
	},

	setFonts: function(){
		Cufon.set('fontFamily', 'FS_Clerkenwell');
		Cufon.replace('h1');
		Cufon.replace('div#season');
		Cufon.replace('div#leftcolumn div.menu ul li a', {hover: true});
		Cufon.replace('div#footer ul li a', {hover: true});
		Cufon.replace('div#language ul li a', {hover: true});
		Cufon.replace('a.submitbutton', {hover: true});
		
	},

	collectionIndex: function(){
		var items = $$('ul.collection-index li');
		if(items != null){
			$each(items, function(obj, index){
				obj.addEvent('mouseenter', function(){
					this.getChildren('div.overlay')[0].setStyle('visibility', 'hidden');
				}.bind(obj))
				obj.addEvent('mouseleave', function(){
					this.getChildren('div.overlay')[0].setStyle('visibility', 'visible');
				}.bind(obj))
				if( (index+1) % 7 == 0){
					obj.setStyle('margin-right', '0');
				}
			});
		}
	},
	
	storeLocator: function(){
		var cityPostcode = $('tx_locator_pi1_city');
		var cityPostcodeInit = $('tx_locator_pi1_city_init');
		if($chk(cityPostcode)){
			cityPostcode.addEvent('click', function(){
				if(cityPostcode.value == cityPostcodeInit.value){
					cityPostcode.value = '';
				}
			});
			cityPostcode.addEvent('blur', function(){
				if(cityPostcode.value == ''){
					cityPostcode.value = cityPostcodeInit.value;
				}
			});
			
		}
	},
	
	verticalCenter: function(){
		var margin = (window.getHeight() - $('container').getHeight()) / 2;
		if (margin > 0){
			$('container').setStyle('margin-top', (window.getHeight() - $('container').getHeight()) / 2);
		}
	}
}
