//Meyocks
// Created: 04/01/10 Last modified: 04/08/10 
//Font resize
function smallText() {
    $(document.body).tween('font-size', '13px');
	Cookie.write('fontsize','13',{path: '/'});//set the cookie
}
function bigText() {
    $(document.body).tween('font-size', '16px');
	Cookie.write('fontsize', '16',{path: '/'});//set the cookie
} 
//All functions below this line are loaded on DOM ready 
window.addEvent('domready', function() {
    //Font resize
	var smallcolor = $('small-text');
	smallcolor.setStyle.apply(smallcolor, (Cookie.read('fontsize') == '13') ? ['color','#CCC'] : ['color','#4F5F59']);
	$('small-text').addEvent('click', function(){
    	smallText();		
		bigcolor.setStyle('color','#4F5F59');
		this.setStyle('color','#CCC');
		return false;
	});
	var bigcolor = $('big-text');
	bigcolor.setStyle.apply(bigcolor, (Cookie.read('fontsize') == '16') ? ['color','#CCC'] : ['color','#4F5F59']);
    $('big-text').addEvent('click', function(){
    	bigText();		
		smallcolor.setStyle('color','#4F5F59');
		this.setStyle('color','#CCC');
		return false;
	});
	//load the font-size cookie if it exists and change body font
	var start = Cookie.read('fontsize') || '16';
	$(document.body).setStyle('font-size',start + 'px');

//LightWindow
	SqueezeBox.assign($$('a[rel=boxed]'), {
		size: {x: 600, y: 500},
		ajaxOptions: {
			method: 'get' // we use GET for requesting plain HTML (you can skip it, it is the default value)
		}
	});
	SqueezeBox.assign($$('a.boxed'), {
		parse: 'rel'
	});
//
// ToolTip
/* Tips 1 
		var Tips1 = new Tips($$('.Tips1'), {
					className:'outer3',
					offset: {
						'x': -30,       //default is 16
						'y': 20        //default is 16
					},
					onShow: function(toolTipElement){
						toolTipElement.fade(1);
					},
					onHide: function(toolTipElement){
						toolTipElement.fade(0);
					}
		}); */

//Scrolling Tidbits
    /* settings */
if($('scrolling-tidbit')) {
	var showDuration = 10000; //Adjust this to change the timing
    var container = $('scrolling-tidbit');
    var quotes = container.getElements('blockquote');
    var interval;
    /* opacity and fade */
    var currentIndex = Math.floor(Math.random() * quotes.length);
    
    quotes.each(function(blockquote, i){
        if(i != currentIndex) {
            blockquote.setStyles({
				opacity: 0,
				position: 'absolute'
			});
        }
    });
    /* worker */
    var show = function() {
        quotes[currentIndex].fade('out');
        quotes[currentIndex = currentIndex < quotes.length - 1 ? currentIndex+1 : 0].fade('in');
    };
        interval = show.periodical(showDuration);
}
//Accordion					 
	/*var toggles = $$('#archivebtn');
	var content = $$('.collapse');
	//set up your object var
	//create a "new" Accordion object
	//set the toggle array
	//set the content array
	var AccordionObject = new Accordion(toggles, content, { 
		alwaysHide: true
		//start: 'all-closed'
	});*/
//Accordion					 
	/*var toggles = $$('#archivebtn','#archivebtn2');
	var content = $$('.collapse','.collapse2');
	//set up your object var
	//create a "new" Accordion object
	//set the toggle array
	//set the content array
	var AccordionObject = new Accordion(toggles, content, { 
		alwaysHide: true
		//start: 'all-closed'
	});*/
	var accordion = new Fx.Accordion($$('.#archivebtn','#archivebtn2','#archivebtn3'),$$('.collapse','.collapse2'), {
    opacity: 0,
    onActive: function(toggler) { toggler.setStyle('color', '#474646'); },
	onBackground: function(toggler) { toggler.setStyle('color', '#ffffff'); },
	alwaysHide:true
  });

//Hide unpublished months and show current and past months
	//Grab all links in an array
	var pageLinks = $$('a');
	var currentTime = new Date()
	//var futurMonths = currentTime.increment('month', 4);
	//var month = currentTime.format('%B');
	var month = currentTime.getMonth() +1;
	
	//Exclude months
	var titles = ['January','February','March','April','May','June','July','August','September','October','November','December'];
	titles.slice(month).each(function(month) {
		$$('a[title='+month+']');
	});
//Hide no content months
	var noContent = ['March','April'];
	//This code will have to be modified for future years
	noContent.each(function(month) {
	$$('a[title='+month+']').setStyle('color', '#CCC').addEvent('click', function(e) { e.stop(); });
	});
});
