	$(function() { 
	
		$('#slide-deck').cycle({ 
			fx: 'slideX', 
			speed: 'slow', 
			timeout: 0, 
			pager: '.slide-controls' 
		});
		
		$('#logos').cycle('scrollRight');
		
		$('#videos-list li:even').addClass('col1');
		
		
		// This Javascript is for the homepage slider and pulls up the correct video when clicking on its corresponding slide 
		$('.video-init').click(function() {
			var parentid = $(this).parent().attr('id');
			var slidecontent = "#"+parentid+"-content";
			$(slidecontent).fadeIn();
		});
		
		$('.slide-controls a').click(function() {
			$('.slider-content').fadeOut();
		});
		
		// pete added
		$('.slide-close-all a').click(function() {
			$('.slider-content').fadeOut();
		});
		// end pete added
		
		
		
		
		//This javascript is for the modals on the TV Shows page
		var counter = 0;
		var colorcounter = $('a.colorbox').size();
		
		$('a.colorbox').each(function() {
			if(counter <= colorcounter) {
				counter = counter+1
			}
			$(this).colorbox({inline: true, href: "#tvshow"+counter+"-content" })
		});
		
	
		var imgwidth = $('.homepage-background img').width();
		var currentBG = '#background0';
		$('.grounders:first').addClass('activebg');
		
		$('.slide-controls a').click(function() {
			if($(this).hasClass('slideControl1') && currentBG != '#background0') {
				currentBG = '#background0';
				$('#background0').animate({ left: 0 }, 2000, function(){  
					$(this).addClass('activebg').siblings().removeClass('activebg').css('left',-imgwidth);
				});
			};
			
			if($(this).hasClass('slideControl2') && currentBG != '#background1') {
				currentBG = '#background1';
				$('#background1').animate({ left: 0 }, 2000, function(){  
					$(this).addClass('activebg').siblings().removeClass('activebg').css('left',-imgwidth);
				});
			};
			
			if($(this).hasClass('slideControl3') && currentBG != '#background2') {
				currentBG = '#background2';
				$('#background2').animate({ left: 0 }, 2000, function(){  
					$(this).addClass('activebg').siblings().removeClass('activebg').css('left',-imgwidth);
				});
			};
			
			if($(this).hasClass('slideControl4') && currentBG != '#background3') {
				currentBG = '#background3';
				$('#background3').animate({ left: 0 }, 2000, function(){  
					$(this).addClass('activebg').siblings().removeClass('activebg').css('left',-imgwidth);
				});
			};
			
			if($(this).hasClass('slideControl5') && currentBG != '#background4') {
				currentBG = '#background4';
				$('#background4').animate({ left: 0 }, 2000, function(){  
					$(this).addClass('activebg').siblings().removeClass('activebg').css('left',-imgwidth);
				});
			};
		});
		
		
		/* This sets the homepage background randomly on load
		
		var numberofbgs = $('.grounders').size();
		var randy = Math.floor(Math.random()*numberofbgs);
		var currentBG = '#background'+randy;
		var imgwidth = $('.homepage-background img').width();
		var isactive = "nada";
		var previousBG = "nada";
		
		$(currentBG).addClass('activebg');
		
		$('.slide-controls a').click(function bgslide() {
			randy = Math.floor(Math.random()*numberofbgs);
			isactive = '#background'+randy;
			if(currentBG == isactive) { // if the current background is the same as the one we just randomly selected...
				bgslide(); // start the function over again
			} else {
				previousBG = currentBG; // marks the current background as the previous background
				$(isactive).animate({ left: 0 }, 2000, function(){  
					$(this).addClass('activebg').siblings().removeClass('activebg').css('left',-imgwidth);
				});
				currentBG = isactive;
			};	
			return false;
		});
		
		*/
	});
	
	//Validate Form
	function validateForm(aform) {
		var el = aform.elements;
		var errorMsg = '';
		
		for(var i = 0 ; i < el.length ; ++i) {
			var googleToolbar = el[i].title;
			
			if(googleToolbar.substr(0,11) == "Your Google") {continue;}
			
			/*
			if(el[i].name == 'Email') {
				if(isEmail(el[i].value) == false) {
					errorMsg += 'Invalid Email' + '\n';
				}
			}
			*/
			if (el[i].type == 'select-one') {
				if(el[i].selectedIndex < 1 && el[i].title.length > 0) {
					errorMsg += el[i].title + '\n';
				}
			} else if(el[i].name == 'First_Name' || el[i].name == 'Last_Name' || el[i].name == 'Address' || el[i].name == 'Email' || el[i].name == 'Phone') {
				if(el[i].value == '') {
					errorMsg += el[i].title + '\n';
				}
			}
		}
		
		if(errorMsg.length > 0) {
			errorMsg = 'Please complete all required fields below:\n'+errorMsg;
			alert(errorMsg);
			return false;
		} else {
			return true;
		}
		
		return false;
	}
