//<script language="JavaScript">

/*

	network.js
	Copyright (c) 2010 Shannon Ware. All Rights Reserved.
	
*/

// Using jQuery.js

var index = 0;

function glTest () {
	alert('glTest() for network.js at '+new Date().toString());
}

function showPageValues(pW, pH, tP, lP, hPh) {
	alert('Page width: '+pW+'; page height: '+pH+'; top position: '+tP+'; left position: '+lP+'; half page height: '+hPh+'; at '+new Date().toString());	
}

$(function() {
	//alert('July 23, 2010');
	var pageWidth = $(window).width();
	var pageHeight = $(window).height();
	var topPosition = ((pageHeight/2)-110).toString()+'px'; //'+='+
	var leftPosition = '+='+((pageWidth/2)-200).toString();
	var halfPageHeight = pageHeight/2;
	
	//showPageValues(pageWidth, pageHeight, topPosition, leftPosition, halfPageHeight);
	
	$("#glShow").css("border", "1px solid #1e90ff").animate({
		//css("width", "80px")
		left: '+=90'
	}, 200, function() {
		// something else I guess
		//alert('animation complete');
	}).animate({
		top: halfPageHeight
	}, 200, function (){
		// Hi Guy	
	}).animate({
		width : "+=80"
	}, 200, function() {
		// alert('animation complete. this: '+this);
		$('#glShow').html("Loading...");
	}).animate ({
		left: leftPosition //'+='+300 //'halfPageWidth'
	}, 200, function () {
		$('#glShow').html("<p>Ô Canada! Terre de nos aïeux,<br />Ton front est ceint de fleurons glorieux!<br />Car ton bras sait porter l'épée,<br />Il sait porter la croix!<br />Ton histoire est une épopée<br />Des plus brillants exploits.<br />Et ta valeur, de foi trempée,<br />Protégera nos foyers et nos droits.<br />Protégera nos foyers et nos droits.</p>");
	}).animate({
		top: topPosition, //"-=100",
		width: "+=400",
		height: "+=200"
	}, 200, function () {
		var index = 0;
		$('#glShow').html('<div id="scrolling"></div> <!-- scrolling --><button id="previous">Prev</button><button id="next">Next</button>');
		$('#scrolling').html('<a href="http://www.uTouch.ca" target="_blank"><img src="images/Network_01.png"></a>');
		$('#scrolling').append('<a href="http://www.peepandthebigwideworld.com/" target="_blank"><img src="images/Network_02.png"></a>');
		$('#scrolling').append('<a href="http://www.bbc.co.uk/children/" target="_blank"><img src="images/Network_03.png"></a>');
		$('#scrolling').append('<a href="http://www.bbc.co.uk/cbeebies/charlieandlola/" target="_blank"><img src="images/Network_06.png"></a>');
		$('#scrolling').append('<a href="http://www.nickjr.com/playtime/cats/games/index.jhtml?=" target="_blank"><img src="images/Network_08.png"></a>');
		$('#scrolling').append('<a href="http://www.snoopy.com/" target="_blank"><img src="images/Network_10.png"></a>');
		$('#scrolling').append('<a href="http://www.tvokids.com/" target="_blank"><img src="images/Network_11.png"></a>');
		$('#scrolling').append('<a href="http://pbskids.org/" target="_blank"><img src="images/Network_12.png"></a>');
		$('#scrolling').append('<a href="http://treehousetv.com/kids/index.asp" target="_blank"><img src="images/Network_07.png"></a>');
		$('#scrolling').append('<a href="http://www.wikipedia.org/" target="_blank"><img src="images/Network_04.png"></a>');
		$('#scrolling').append('<a href="http://www.gamelab.ca" target="_blank"><img src="images/Network_09.png"></a>');
		$('#scrolling').append('<a href="http://www.google.com" target="_blank"><img src="images/Network_05.png"></a>');
		
		$('#previous').click(function() {
			//alert('Hi');
			index--;
			if (index < 0) index = -1;
			if (index > -1) {
				$('#scrolling').animate ({
					left: "+=200"
				}, 100, function () {
					//alert('Test Passed');
				});
			}
		});
		$('#next').click(function() {
			index++;
			if (index > 10) index = 11;
			if (index < 11) {
				$('#scrolling').animate ({
					left: "-=200"
				}, 100, function () {
					//alert('Test Passed');
				});
			}
		});			
		
		$('button').click(function() {
			/*
			if (index < 0) index = 12;
			if (index > 12) index = 0;
			*/
			
			// remove in production
			//$("#main").html(index);		
		});
	});

		
});

//alert('gamelab.js inline alert');
//</script>
