/*
Site: All, symlinked
Name: scienceoxford.js

WARNING: THIS FILE IS SYMBOLICALLY LINKED FROM:-
  <http://scienceoxford.com>

... across the filesystem to these sites:-
  <http://scienceoxfordnetworks.com>
  <http://scienceoxfordnext.com>
  <http://scienceoxfordlive.com>

*/

jQuery.fn.niceOrderedLists = function () {
	return this.each(function()
	{
		jQuery(this).find ("li").each (function (index)
		{
			jQuery(this).css("list-style-type","none");
			var clss = (index%2) ?  'bfi2' : 'bfi1' ;
			jQuery(this).html('<div class="drop_number">' + (index+1) +'</div><div class="li_content ' + clss + '">' + jQuery(this).html() + '</div>');
		});
		jQuery(this).append('<br style="clear: both">');
	});
};


/*
	return window.location = $(this).children('H3').children('A.article-list-item-link').attr('href');
*/

$(document).ready(function($)	{
// Let's deal with the "lesser" browsers...
	jQuery("IMG").pngfix();
	jQuery("#logo").pngfix();

// Formats the 2nd level navigation
	jQuery('#tier2').makeacolumnlists({cols: 2, colWidth: 205, equalHeight: 'ul', startN: 1});
	jQuery('.toggle').toggle(function() {
		jQuery('.list1').makeacolumnlists({cols: 2, colWidth: 0, equalHeight: 'ol', startN: 1});
	}, function() {
		jQuery('.li_container').uncolumnlists();
	});
	jQuery("OL.bigfancy").niceOrderedLists();

/* Rotating Banner Images */
	$("#rotating-banner-list").innerfade ({
		speed: 1000,
		timeout: 7000,
		containerheight: 274
	});


// Allows a DIV area to be a pseudo "<A HREF..."
	$('.article-list-item-summary').click(function()	{
		if ($(this).find("A.article-list-item-link").attr('href'))	{
			window.location = $(this).find("A.article-list-item-link").attr('href');
		}
		return true;
	});

	$('.article-list-item-summary').mouseover(function()	{
		if ($(this).find("A.article-list-item-link").attr('href'))	{
			$(this).css("cursor","pointer");
		}
		return true;
	});


/* Footer */
	$('#footer-nav-intersite .site').mouseout(function()	{
		$(this).find('OL').each(function(){
			$(this).find('A').each(function(){
				$(this).css("color","#999999");
			});
		});
	});
	$('#footer-nav-intersite #so').mouseover(function()	{
		$(this).find('OL').each(function(){
			$(this).find('A').each(function(){
				$(this).css("color","#CFCFCF");
			});
		});
	});
	$('#footer-nav-intersite #so-network').mouseover(function()	{
		$(this).find('OL').each(function(){
			$(this).find('A').each(function(){
				$(this).css("color","#26A7DD");
			});
		});
	});
	$('#footer-nav-intersite #so-next').mouseover(function()	{
		$(this).find('OL').each(function(){
			$(this).find('A').each(function(){
				$(this).css("color","#85B700");
			});
		});
	});
	$('#footer-nav-intersite #so-live').mouseover(function()	{
		$(this).find('OL').each(function(){
			$(this).find('A').each(function(){
				$(this).css("color","#DC6AA5");
			});
		});
	});
	$('#footer-nav-intersite #so-online').mouseover(function()	{
		$(this).find('OL').each(function(){
			$(this).find('A').each(function(){
				$(this).css("color","#DD6300");
			});
		});
	});


	$('#editor-notes').click(function()	{
		$(this).toggleClass("editor-notes-show");
	});

});

/* Begin: Live */
function forces_DoFSCommand(command, args) {
	if (command == 'loadVideo')	{
		switch (args)	{
			case 'force':
				loadNewVideo('-0SSI-NqJT4', 0, '#ytmovie1');
				loadNewVideo('zg0wD-ETg-E', 0, '#ytmovie2');
				break;
			case 'light':
				loadNewVideo('ioHzsJOsLSs', 0, '#ytmovie1');
				loadNewVideo('zZz7FTKQCoU', 0, '#ytmovie2');
				break;
			case 'sound':
				loadNewVideo('UWJzJZK8ZS4', 0, '#ytmovie1');
				loadNewVideo('HxI8HRIX4Es', 0, '#ytmovie2');
				break;
			case 'magnet':
				loadNewVideo('Fqx-ssQOchQ', 0, '#ytmovie1');
				loadNewVideo('E94zpTllte8', 0, '#ytmovie2');
				break;
			case 'problem':
				loadNewVideo('LQjocW1HHXo', 0, '#ytmovie1');
				loadNewVideo('N0gibxbZcX4', 0, '#ytmovie2');
				break;
			default:
				alert("Um, wasn't expecting to see this argument:" + args);
				break;
		}
	} else {
		alert("Um, wasn't expecting to see the command:" + command);
	}
}

// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub forces_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call forces_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}

function onYouTubePlayerReady(playerId) {
	ytplayer = document.getElementById("myytplayer");
}

function loadNewVideo(id, startSeconds, playerID) {
	myvar = $(playerID)[0];
	myvar.cueVideoById(id, parseInt(startSeconds));
}


/*  End: Live */
