$(document).ready(function(){
    
	$('ul.sf-menu').superfish({ 
		delay:       500,
		speed:       150,
		animation:   {opacity:'show',height:'show'},
		autoArrows:  false,
		dropShadows: false
	});
	
    $("input.quick-search-submit").mouseover(function(){
		$(this).attr('src','/assets/images/icons/btn_search_over.png');
    }).mouseout(function(){
		$(this).attr('src','/assets/images/icons/btn_search.png');
    });
	
	$('input.quick-search-input').bind("click", function(e){
		if($(this).hasClass("init")){
			$(this).removeClass("init").attr("value", "");
		}
	});
	
	$(".quick-search form").submit(function(){
		if($('input.quick-search-input').val().length < 4) {
			alert('Please enter a search term that\'s at least 3 characters long');
			return false;
		}
	});
	
	$("a.more-toggle").click(function () { 
		if($(this).hasClass('expanded')){
			$('.more-body', $(this).siblings('p')).removeClass('more-body-show');
			$('.ellipsis', $(this).siblings('p')).removeClass('ellipsis-hide');
			$(this).removeClass('expanded');
			$(this).text('Show More');
		} else {
			$('.more-body', $(this).siblings('p')).addClass('more-body-show');
			$('.ellipsis', $(this).siblings('p')).addClass('ellipsis-hide');
			$(this).addClass('expanded');
			$(this).text('Show Less');
		}
		
		return false;
	});
	
	$("a.faq-toggle").click(function () { 
		$(this).siblings('.faq-body').slideToggle('fast');
		
		if($(this).hasClass('expanded')){
			$(this).removeClass('expanded');
		} else {
			$(this).addClass('expanded');
		}
		
		return false;
	});
	
	$("#credits-link").colorbox({opacity:0.75, width:"500px", inline:true, href:"#credits", transition: "none"});
});


function in_array( what, where ){
	var a=false;
	for(var i=0;i<where.length;i++){
	  if(what == where[i]){
	    a=true;
        break;
	  }
	}
	return a;
}

function getQueryVariable(variable) {
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i=0;i<vars.length;i++) {
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
			return pair[1];
		}
	}
} 
