/*
Bones Scripts File
Author: Eddie Machado

This file should contain any js scripts you want to add to the site.
Instead of calling it in the header or throwing it inside wp-head()
this file will be called automatically in the footer so as not to 
slow the page load.

*/

// Modernizr.load loading the right scripts only if you need them
Modernizr.load([
	{
    // Let's see if we need to load selectivizr
    test : Modernizr.borderradius,
    // Modernizr.load loads selectivizr and Respond.js for IE6-8
    nope : ['libs/selectivizr-min.js']
	}
]);

/* imgsizer (flexible images for fluid sites) */
var imgSizer={Config:{imgCache:[],spacer:"/path/to/your/spacer.gif"},collate:function(aScope){var isOldIE=(document.all&&!window.opera&&!window.XDomainRequest)?1:0;if(isOldIE&&document.getElementsByTagName){var c=imgSizer;var imgCache=c.Config.imgCache;var images=(aScope&&aScope.length)?aScope:document.getElementsByTagName("img");for(var i=0;i<images.length;i++){images[i].origWidth=images[i].offsetWidth;images[i].origHeight=images[i].offsetHeight;imgCache.push(images[i]);c.ieAlpha(images[i]);images[i].style.width="100%";}
if(imgCache.length){c.resize(function(){for(var i=0;i<imgCache.length;i++){var ratio=(imgCache[i].offsetWidth/imgCache[i].origWidth);imgCache[i].style.height=(imgCache[i].origHeight*ratio)+"px";}});}}},ieAlpha:function(img){var c=imgSizer;if(img.oldSrc){img.src=img.oldSrc;}
var src=img.src;img.style.width=img.offsetWidth+"px";img.style.height=img.offsetHeight+"px";img.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"', sizingMethod='scale')"
img.oldSrc=src;img.src=c.Config.spacer;},resize:function(func){var oldonresize=window.onresize;if(typeof window.onresize!='function'){window.onresize=func;}else{window.onresize=function(){if(oldonresize){oldonresize();}
func();}}}}

// as the page loads, call these scripts
$(document).ready(function() {

	// add all your scripts here
	
		// FAQ: show-hide answers
	
	$("dt").click( function(event)
	{
	   var clicked = $(this); // jQuery wrapper for clicked element
	   $(this).next('dd').toggle('100ms');
	});
	
		// Speakers: show "read more" content
	
	$(".readmore-link").click( function(event)
	{
	   var clicked = $(this); // jQuery wrapper for clicked element
	   $(this).next('.readmore').toggle('100ms');
	});
	
		// Speakers: toggle arrow direction and "read more/less" text
	
	$('.readmore-link').toggle(function() {
	    $(this).text('Read Less');
	    $(this).addClass('readless');
	}, function() {
	    $(this).text('Read More');
	    $(this).removeClass('readless');
	});
	
		// Agenda: show schedule days (small-screen view)
		
	$("#show-weds").click( function(event)
	{
	   var clicked = $(this); // jQuery wrapper for clicked element
	   $('#wednesday').toggle('100ms').css("display", "block");
	});
	
	$("#show-thurs").click( function(event)
	{
	   var clicked = $(this); // jQuery wrapper for clicked element
	   $('#thursday').toggle('100ms').css("display", "block");
	});
	
	$("#show-fri").click( function(event)
	{
	   var clicked = $(this); // jQuery wrapper for clicked element
	   $('#friday').toggle('100ms').css("display", "block");
	});
	
	$('#show-weds').toggle(function() {
	    $(this).text('Hide Wednesday, April 11');
	}, function() {
	    $(this).text('Show Wednesday, April 11');
	});
	
	$('#show-thurs').toggle(function() {
	    $(this).text('Hide Thursday, April 12');
	}, function() {
	    $(this).text('Show Thursday, April 12');
	});
	
	$('#show-fri').toggle(function() {
	    $(this).text('Hide Friday, April 13');
	}, function() {
	    $(this).text('Show Friday, April 13');
	});
	
		// Agenda: show schedule days (from selector link)	
		
	$("#view-selector").click( function(event)
	{
	   var clicked = $(this); // jQuery wrapper for clicked element
	   $('#event-schedule').toggle('100ms');
	   $('#event-schedule-small').toggle('100ms');
	});	
	
	$('#view-selector').toggle(function() {
	    $(this).text('Switch to Calendar View »');
	}, function() {
	    $(this).text('Switch to Per-Day View »');
	});
 
}); /* end of as page load scripts */
