/*jQuery Plugins*/

/*Sliding Labels 3.2 | http://www.csskarma.com/blog/sliding-labels-plugin */
(function($){$.fn.slidinglabels=function(options){var defaults={className:"slider",topPosition:"5px",leftPosition:"5px",axis:"x",speed:"fast"};var options=$.extend(defaults,options);var itemwrapper=this.find("."+defaults.className+"");var labels=itemwrapper.find("label");return labels.each(function(){obj=$(this);var parent=obj.parents("."+defaults.className+"");parent.css({position:"relative"});obj.css({position:"absolute",top:defaults.topPosition,left:defaults.leftPosition,display:"inline",margin:"0px","z-index":99});var inputval=$(this).next().val();var labelwidth=$(this).width();var labelmove=labelwidth+5+"px";var labelheight=$(this).height();if(inputval!==""){if(defaults.axis=="x"){obj.stop().animate({left:"-"+labelmove},1)}else{if(defaults.axis=="y"){obj.stop().animate({top:"-"+labelheight},1)}}}$("input, textarea").focus(function(){var label=$(this).prev("label");var width=label.width();var height=label.height();var adjust=width+5+"px";var adjustUp=height+"px";var value=$(this).val();if(value==""){if(defaults.axis=="x"){label.stop().animate({left:"-"+adjust},defaults.speed)}else{if(defaults.axis=="y"){label.stop().animate({top:"-"+adjustUp},defaults.speed)}}}else{if(defaults.axis=="x"){label.css({left:"-"+adjust})}else{if(defaults.axis=="y"){label.css({top:"-"+adjustUp})}}}}).blur(function(){var label=$(this).prev("label");var value=$(this).val();if(value==""){if(defaults.axis=="x"){label.stop().animate({left:defaults.leftPosition},defaults.speed)}else{if(defaults.axis=="y"){label.stop().animate({top:defaults.topPosition},defaults.speed)}}}})})}})(jQuery);

/*Auto Sprites | Copyright (C) 2009 Joel Sutherland | Licenced under the MIT license | http://www.newmediacampaigns.com/page/autosprites-jquery-menu-plugin*/
(function($){$.fn.autosprites=function(settings){settings=$.extend({offset:'100%',orientation:'horizontal',over:{opacity:'show'},overSpeed:500,out:{opacity:'hide'},outSpeed:500,activeState:false,activeClass:'active',activeSprites:false},settings);function rempx(string){return Number(string.substr(0,string.length-2));}function addpx(number){return number+'px';}$(this).each(function(){var backgroundImage=$(this).css('background-image');$(this).css('zIndex',100).find('a').css('zIndex',99);var totalPositionOffset=0;$(this).children().each(function(){var positionOffset='-'+addpx(totalPositionOffset);var baseOffset='0px';if(settings.activeState&&$(this).hasClass(settings.activeClass)){baseOffset='-'+addpx(rempx(settings.offset));if(settings.activeSprites)baseOffset='-'+addpx(rempx(settings.offset)*2);}var position=settings.orientation=='horizontal'?positionOffset+' '+baseOffset:baseOffset+' '+positionOffset;var offsetPosition=settings.orientation=='horizontal'?positionOffset+' -'+settings.offset:'-'+settings.offset+' '+positionOffset;$(this).css({backgroundImage:backgroundImage,backgroundPosition:position});var width=$(this).css('width');var height=$(this).css('height');var hover=$('<div>&nbsp;</div>').css({cursor:'hand',zIndex:1,position:'absolute',top:0,left:0,width:width,height:height,backgroundImage:backgroundImage,backgroundPosition:offsetPosition}).hide();$(this).prepend(hover);$(this).hover(function(){$(this).find('div').stop(false,true).animate(settings.over,settings.overSpeed);},function(){$(this).find('div').stop(false,true).animate(settings.out,settings.outSpeed);});totalPositionOffset+=settings.orientation=='horizontal'?rempx(width):rempx(height);});});}})(jQuery);

/*Superfish v1.4.8 - jQuery menu widget | Copyright (c) 2008 Joel Birch | Dual licensed under the MIT and GPL licenses: http://www.opensource.org/licenses/mit-license.php | http://www.gnu.org/licenses/gpl.html*/
;(function($){$.fn.superfish = function(op){var sf = $.fn.superfish,c = sf.c,$arrow = $(['<span class="',c.arrowClass,'"> &#187;</span>'].join('')),over = function(){var $$ = $(this), menu = getMenu($$);clearTimeout(menu.sfTimer);$$.showSuperfishUl().siblings().hideSuperfishUl();},out = function(){var $$ = $(this), menu = getMenu($$), o = sf.op;clearTimeout(menu.sfTimer);menu.sfTimer=setTimeout(function(){o.retainPath=($.inArray($$[0],o.$path)>-1);$$.hideSuperfishUl();if (o.$path.length && $$.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path);}},o.delay);	},getMenu = function($menu){var menu = $menu.parents(['ul.',c.menuClass,':first'].join(''))[0];sf.op = sf.o[menu.serial];return menu;},addArrow = function($a){ $a.addClass(c.anchorClass).append($arrow.clone()); };return this.each(function() {var s = this.serial = sf.o.length;var o = $.extend({},sf.defaults,op);o.$path = $('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){$(this).addClass([o.hoverClass,c.bcClass].join(' ')).filter('li:has(ul)').removeClass(o.pathClass);});sf.o[s] = sf.op = o;$('li:has(ul)',this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out).each(function() {if (o.autoArrows) addArrow( $('>a:first-child',this) );}).not('.'+c.bcClass).hideSuperfishUl();var $a = $('a',this);$a.each(function(i){var $li = $a.eq(i).parents('li');$a.eq(i).focus(function(){over.call($li);}).blur(function(){out.call($li);});});o.onInit.call(this);}).each(function() {var menuClasses = [c.menuClass];if (sf.op.dropShadows  && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass);$(this).addClass(menuClasses.join(' '));});};var sf = $.fn.superfish;sf.o = [];sf.op = {};sf.IE7fix = function(){var o = sf.op;if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity!=undefined)this.toggleClass(sf.c.shadowClass+'-off');};sf.c = {bcClass     : 'sf-breadcrumb',menuClass   : 'sf-js-enabled',anchorClass : 'sf-with-ul',arrowClass  : 'sf-sub-indicator',shadowClass : 'sf-shadow'};sf.defaults = {hoverClass	: 'sfHover',pathClass	: 'overideThisToUse',pathLevels	: 1,delay		: 800,animation	: {height: "show"},speed		: 'normal',autoArrows	: true,dropShadows : true,disableHI	: false,onInit		: function(){},onBeforeShow: function(){},onShow		: function(){},onHide		: function(){}};$.fn.extend({hideSuperfishUl : function(){var o = sf.op,not = (o.retainPath===true) ? o.$path : '';o.retainPath = false;var $ul = $(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass).find('>ul').hide().css('visibility','hidden');o.onHide.call($ul);return this;},showSuperfishUl : function(){var o = sf.op,sh = sf.c.shadowClass+'-off',$ul = this.addClass(o.hoverClass).find('>ul:hidden').css('visibility','visible');sf.IE7fix.call($ul);o.onBeforeShow.call($ul);$ul.animate(o.animation,o.speed,function(){ sf.IE7fix.call($ul); o.onShow.call($ul); });return this;}});})(jQuery);

/*Easy Slider 1.7 - jQuery plugin | written by Alen Grakalic | http://cssglobe.com/post/4004/easy-slider-15-the-easiest-jquery-plugin-for-sliding | Copyright (c) 2009 Alen Grakalic (http://cssglobe.com) | Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses.*/
(function($) {$.fn.easySlider = function(options){var defaults = {prevId:'prevBtn',prevText:'Previous',nextId:'nextBtn',nextText:'Next',controlsShow:true,controlsBefore:'',controlsAfter:	'',controlsFade:true,firstId:'firstBtn',firstText:'First',firstShow:false,lastId:'lastBtn',	lastText:'Last',lastShow:false,vertical:false,speed:800,auto:false,pause:2000,continuous:false, numeric:false,numericId:'controls'};var options = $.extend(defaults, options);this.each(function() {var obj = $(this);var s = $("li", obj).length;var w = $("li", obj).width();var h = $("li", obj).height();var clickable = true;obj.width(w);obj.height(h);obj.css("overflow","hidden");var ts = s-1;var t = 0;$("ul", obj).css('width',s*w);if(options.continuous){$("ul", obj).prepend($("ul li:last-child", obj).clone().css("margin-left","-"+ w +"px"));$("ul", obj).append($("ul li:nth-child(2)", obj).clone());$("ul", obj).css('width',(s+1)*w);};if(!options.vertical) $("li", obj).css('float','left');if(options.controlsShow){var html = options.controlsBefore;if(options.numeric){html += '<ol id="'+ options.numericId +'"></ol>';} else {if(options.firstShow) html += '<span id="'+ options.firstId +'"><a href=\"javascript:void(0);\">'+ options.firstText +'</a></span>';html += ' <span id="'+ options.prevId +'"><a href=\"javascript:void(0);\">'+ options.prevText +'</a></span>';html += ' <span id="'+ options.nextId +'"><a href=\"javascript:void(0);\">'+ options.nextText +'</a></span>';if(options.lastShow) html += ' <span id="'+ options.lastId +'"><a href=\"javascript:void(0);\">'+ options.lastText +'</a></span>';};html += options.controlsAfter;$(obj).after(html);};if(options.numeric){for(var i=0;i<s;i++){$(document.createElement("li")).attr('id',options.numericId + (i+1)).html('<a rel='+ i +' href=\"javascript:void(0);\">'+ (i+1) +'</a>').appendTo($("#"+ options.numericId)).click(function(){animate($("a",$(this)).attr('rel'),true);});};} else {$("a","#"+options.nextId).click(function(){animate("next",true);});$("a","#"+options.prevId).click(function(){animate("prev",true);});$("a","#"+options.firstId).click(function(){animate("first",true);});$("a","#"+options.lastId).click(function(){animate("last",true);});};function setCurrent(i){i = parseInt(i)+1;$("li", "#" + options.numericId).removeClass("current");$("li#" + options.numericId + i).addClass("current");};function adjust(){if(t>ts) t=0;if(t<0) t=ts;if(!options.vertical) {$("ul",obj).css("margin-left",(t*w*-1));} else {$("ul",obj).css("margin-left",(t*h*-1));}clickable = true;if(options.numeric) setCurrent(t);};function animate(dir,clicked){if (clickable){clickable = false;var ot = t;switch(dir){case "next":t = (ot>=ts) ? (options.continuous ? t+1 : ts) : t+1;break;case "prev":t = (t<=0) ? (options.continuous ? t-1 : 0) : t-1;break;case "first":t = 0;break;case "last":t = ts;break; default:t = dir;break;};var diff = Math.abs(ot-t);var speed = diff*options.speed;if(!options.vertical) {p = (t*w*-1);$("ul",obj).animate({ marginLeft: p }, { queue:false, duration:speed, complete:adjust });} else {p = (t*h*-1);$("ul",obj).animate({ marginTop: p },{ queue:false, duration:speed, complete:adjust });};if(!options.continuous && options.controlsFade){if(t==ts){$("a","#"+options.nextId).hide();$("a","#"+options.lastId).hide();} else {$("a","#"+options.nextId).show();$("a","#"+options.lastId).show();};if(t==0){$("a","#"+options.prevId).hide();$("a","#"+options.firstId).hide();} else {$("a","#"+options.prevId).show();$("a","#"+options.firstId).show();};};if(clicked) clearTimeout(timeout);if(options.auto && dir=="next" && !clicked){;timeout = setTimeout(function(){animate("next",false);},diff*options.speed+options.pause);};};};var timeout;if(options.auto){;timeout = setTimeout(function(){animate("next",false);},options.pause);};if(options.numeric) setCurrent(0);if(!options.continuous && options.controlsFade){$("a","#"+options.prevId).hide();$("a","#"+options.firstId).hide();};});};})(jQuery);

/*Setup*/
jQuery(function(){
	var teamsImages = ['lady-raider-bball.png', 'volleyball.png', 'men-bball.png'];
	$('<img src="/images/athletics/' + teamsImages[Math.floor(Math.random() * teamsImages.length)] + '">').prependTo('#teams');
	var showcaseImages = ['Twain-ZZ-Strait.png', 'Aerosmith-BlueMen-Dunham.png'];
	$('#showcase h2').css("background-image", "url(/images/showcase/" + showcaseImages[Math.floor(Math.random() * showcaseImages.length)] + ")");  
	$('#pagecontent .date').each(function() { 
		var dateArray = $(this).text().split('-');
		var newDay = dateArray[0];
		var newMonth = dateArray[1];
		var Month = newMonth.replace("Jan","01").replace("Feb","02").replace("Mar","03").replace("Apr","04").replace("May","05").replace("Jun","06").replace("Jul","07").replace("Aug","08").replace("Sep","09").replace("Oct","10").replace("Nov","11").replace("Dec","12");
		var newYear = dateArray [2];
		var monthVal = Month - 1;
		var d = new Date(newYear, monthVal, newDay);
		var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
		var dayOfWeek = dayNames[d.getDay()];
		var newDateFormat = dayOfWeek + " | " + Month + "." + newDay + "." + newYear;
		$(this).html(newDateFormat);
	});
	$('#rail .date').each(function() { 
		var dateArray = $(this).text().split('-');
		var newDay = dateArray[0];
		var newMonth = dateArray[1];
		var Month = newMonth.replace("Jan","01").replace("Feb","02").replace("Mar","03").replace("Apr","04").replace("May","05").replace("Jun","06").replace("Jul","07").replace("Aug","08").replace("Sep","09").replace("Oct","10").replace("Nov","11").replace("Dec","12");
		var newYear = dateArray [2];
		var newDateFormat = Month + "." + newDay + "." + newYear;
		$(this).html(newDateFormat);
	});
	$('#nav_594306').autosprites({
		offset:	'38px',
		activeState:	true,
		activeSprites:	true,
		activeClass:	'selected'
	});
	$('#nav_teams').autosprites({
		offset:	'270px',
		orientation:	'vertical'
	});
	$('ul#nav_594306').superfish(); 
	$("#event_slider").easySlider({
		controlsBefore:	'<p id="controls">',
		controlsAfter:	'</p>',
		auto:	true, 
		continuous:	true,
		pause:	4000
	});
	$('#backstage-form').slidinglabels({
                        
		/* these are all optional */
		className    : 'form-slider', // the class you're wrapping the label & input with -> default = slider
		topPosition  : '7px',  // how far down you want each label to start
		leftPosition : '6px',  // how far left you want each label to start
		axis         : 'y',    // can take 'x' or 'y' for slide direction
		speed        : 'fast'  // can take 'fast', 'slow', or a numeric value

	});
});
