// jQuery preload images
jQuery.preloadImages = function() {
	for(var i=0; i<arguments.length; i++) {
		$("<img>").attr("src", arguments[i]);
	}
}

// jQuery actions
$(document).ready(function(){
	
	// 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();
	});

	// nav hover
	$('#nav li').hover(
		function () {
			//show its submenu
			$('ul', this).slideDown(100);

		}, 
		function () {
			//hide its submenu
			$('ul', this).slideUp(100);			
		}
	);
	
	// 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: '180px',
      height: '250px',
      player: 'xhr',
      title: 'Select a region:'
    });
  });
  if(region == '') $('#changeregion').triggerHandler('click');
});
