// jQuery preload images
jQuery.preloadImages = function() {
	for(var i=0; i<arguments.length; i++) {
		$("<img>").attr("src", arguments[i]);
	}
}

// jQuery actions
$(document).ready(function(){
	
	//first find any items that have ul children
	
  $('#menu ul ul').hide().each(function(){
    var menu = $(this);
    var menu_item = menu.parent('li');
    menu_item.addClass('expandable');
    var arrow = $('<span></span>').addClass('dd_arrow').appendTo(menu_item);
    
    
    menu_item.hover(
      function(){
        menu.fadeIn('fast');
      },
      function(){
        menu.fadeOut('fast');
      }
    );
  })
	
	// video category toggle
	$(".video_category").click(function(){
		$(".video_category_list").slideUp("slow");
		$(this).siblings(".video_category_list").slideToggle();
	});

	// support answer toggle
	$(".question").click(function(){
		// jQuery(this).siblings(".answer").toggle();
		$(".answer").hide();
		$(this).siblings(".answer").show();
	});
  
	// dropdown redirect
	$("select#subnav_dropdown").change( function() {
		if (url = $(this).val()) {
			window.location = url;
		}
	});


});

// nav dropdown function
$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover( 
			function() { $(this).addClass(c);  },
			function() { $(this).removeClass(c); }
		);
	});
};

/* REGION SELECTOR */
Shadowbox.loadSkin('classic', '/shadowbox/skin');
$(document).ready(function(){
	Shadowbox.init({
        overlayColor: '#000',
        overlayOpacity: 0.9
  });
  $('#changeregion').click(function(e){
    e.preventDefault();
    s = Shadowbox.open({
      content: '/settings',
      width: '225px',
      height: '300px',
      player: 'xhr',
      title: 'Select a region:'
    });
  });
  if(region == '') $('#changeregion').triggerHandler('click');
});

