
function cl(msg){
	if(typeof console != 'undefined')
		console.log(msg);
}

document.observe('dom:loaded',function(){
	//add slide class for buttons [IE fix for onclick shift]
	$$("button span").invoke('wrap', 'span').invoke('addClassName', 'slide');
	
	// the padding is screwy in FF text inputs
	if(Prototype.Browser.Gecko){
		$$("input#search").each(function(el){
			el = $(el);
			el.setStyle({paddingTop:'5px'});
		});
	}
	
	//prototip 1.3.5.1 implementation 
	//-- big ole' if statement to see if there's a .tooltip element just before a .tooltip-content element
	var useTooltipContent = false;
	if($$('.tooltip')!=''){
		$$('.tooltip').each(function(el) {
			if($(el).next().hasClassName('tooltip-content')){
				var tooltipId = $(el).identify();
				var tooltipContent = $(el).next().innerHTML;
				// give tooltip-content an id so it doesn't get run again below
				$(el).next().identify();
			} else {
				useTooltipContent = true;
			}
			new Tip(tooltipId, tooltipContent, {offset: {x:-422,y:-30}});
		});
	} else {
		useTooltipContent = true;
	}
	// and a catch if there's not
	if(useTooltipContent){
		$$('.tooltip-content').each(function(el) {
			if(!el.readAttribute('id')){
				var idArray = $(el).ancestors();
				var tooltipId = idArray[0];
				var tooltipContent = $(el).innerHTML;
				new Tip(tooltipId, tooltipContent, {offset: {x:-422,y:-30}});
			}
		});		
	}
	
	
	//tour facility pager
	
	var ClassyPager = Class.create({
		initialize: function(el){
			this.liArr = el.childElements();
			this.counter=0;
			el.setStyle({height:'100%'});
			var nextBtn = new Element('a', { href: '#', style:'float:right', onclick: '$(\'classy_pager\').obj.next();' }).update('Next &raquo;');
			var prevBtn = new Element('a', { href: '#', style:'float:left', onclick: '$(\'classy_pager\').obj.prev();' }).update('&laquo; Previous');
			el.insert(nextBtn);
			el.insert(prevBtn);
			
			for(i=0;i<this.liArr.length;i++){
			  this.liArr[i].setStyle({listStyle:"none"});
			  if(i!=0){
			  this.liArr[i].setStyle({display:"none"});
			  }
			}
			return this;
		},
		counterUp: function(){
			this.counter++;
			if(this.counter>=this.liArr.length){this.counter=0};
		},
		counterDown: function(){
			this.counter--;
			if(this.counter<0){this.counter=this.liArr.length-1};
		},
		next: function(){
			// new Effect.Fade(this.liArr[this.counter], {from:1, to:0, duration:1, queue:'front'});
			// this.counter=(this.counter>this.liArr.length)?0:this.counter+1;
			// new Effect.Appear(this.liArr[this.counter], {from:0, to:1, duration:1, queue:'end'});
			new Effect.BlindUp(this.liArr[this.counter], {duration:1, queue:'front'});
			this.counterUp();
			new Effect.BlindDown(this.liArr[this.counter], {duration:1, queue:'end'});			
		},
		prev: function(){
			new Effect.BlindUp(this.liArr[this.counter], {duration:1, queue:'front'});
			this.counterDown();
			new Effect.BlindDown(this.liArr[this.counter], {duration:1, queue:'end'});
		}
	});
	
	if($('classy_pager')){
	var el=$('classy_pager');
	el.obj = new ClassyPager(el);
	}
	
	
});


