/*
 * Main View Controller Class for all RAV views
 * Uses the very nice - Mootools Framework
 * @Author Andy Johnston (andy [at] parca [dot] com [dot] au)
 * @Updated July 2007
 */

var View = {
	controller: null,
	init: function(){
		this.controller = new ViewController({
			tooltipProps : {
				maxTitleChars : 50
			}
		});	
		
		// setup mootools components
		this.controller.setupTips();			
		new SmoothScroll({ duration: 900 });
		
		// clear search field on focus
		var searchField = $('fld_search');		
		searchField.addEvent('focus', function(e){
			e = new Event(e);	
			this.value = '';
		});	

		// show the Accordion when loaded..
		if($('Accordion')){		
			var catNav = $("Accordion");
			catNav.setStyle("display","block");
			
			var accordion = new Accordion('h3.atStart', 'div.atStart', {
		opacity: false, //true causes some sub menus to be blank but having height
		display : -1, // (integer: defaults to 0) The index of the element to show at start (with a transition). To force all elements to be closed by default, pass in -1.
    alwaysHide: true,  /*allows toggle close ------ alwaysHide - (boolean: defaults to false) If set to true, it will be possible to close all displayable elements. Otherwise, one will remain open at all time.  --- side effect: can generate flicker bug -- solved in css by overflow:auto  !important;  on .toggler */
			onActive: function(toggler, element){
				toggler.setStyle('color', '#ff0000');
			},
		 
			onBackground: function(toggler, element){
				toggler.setStyle('color', '#16549b');
			}
			}, $('Accordion'));
		}
		
		// nifty settings 
		Nifty("div.button a","small");
		Nifty("div.red a","small");
		Nifty("div.ctrl_holder","small");
		Nifty("div.home_product_pic","small");
		Nifty("div.promo_item","small"); 
		Nifty("div#promo_list","small"); 
		Nifty("div#promo_item1","small"); 
		Nifty("div.step","small"); 
		Nifty("div.form_button","small");
		Nifty("div.news_detail_image","small"); 
		Nifty("div.products_cat","small"); 
		Nifty("div.item","small"); 
		Nifty("div.item_last","small"); 


		//Nifty("div#promo_item13","small"); 
		//Nifty("div#promo_item4","small");





	}
}
window.onDomReady(View.init.bind(View));

