// add to this any files that need downloading \\
var listExtensions = /^.*\.(jpg|JPG|gif|GIF|doc|DOC|pdf|PDF|mp3|MP3|docx|xls|xlsx|ppt|ppts|pps|pptx)$/;
if (typeof console == 'undefined') {
	var console = {
		log: function(str) {
			return console.data.push(str);
		},
		data: new Array(),
		type: 'DOM'
	};
}
// This MUST be changed before going live \\
	var urlPrep = '/';
	//console.log(urlPrep + ' This MUST be changed before going live RW');
// This MUST be changed before going live \\

// Query String Management for Script SRC \\

// parsing GET function \\
function parseQuery ( query ) {
   var Params = new Object ();
   if ( ! query ) return Params; // return empty object
   var Pairs = query.split(/[;&]/);
   for ( var i = 0; i < Pairs.length; i++ ) {
      var KeyVal = Pairs[i].split('=');
      if ( ! KeyVal || KeyVal.length != 2 ) continue;
      var key = unescape( KeyVal[0] );
      var val = unescape( KeyVal[1] );
      val = val.replace(/\+/g, ' ');
      Params[key] = val;
   }
   return Params;
}

// Query String Management for Script SRC \\

$(document).ready(function() {	
	$(".hover").hover(function() {
		$(this).css({backgroundPosition: 'bottom center'});
	}, function() {
		$(this).css({backgroundPosition: 'top center'});
	});
	$(".txtLayout").each(function() {
		var html = $(this).html();
		var newHTML = new Array();
		newHTML += ['<table cellpadding="0" cellspacing="0" width="100%">'];
		newHTML += ['<tr>'];
		newHTML += ['<td class="tl"><img src="img/borders/tl.png" width="15" height="15" alt="" /></td>'];
		newHTML += ['<td class="tm"></td>'];
		newHTML += ['<td class="tr"><img src="img/borders/tr.png" width="15" height="15" alt="" /></td>'];
		newHTML += ['</tr>'];
		newHTML += ['<tr>'];
		newHTML += ['<td class="ml"></td>'];
		newHTML += ['<td class="mm" valign="top">'+ html +'</td>'];
		newHTML += ['<td class="mr"></td>'];
		newHTML += ['</tr>'];
		newHTML += ['<tr>'];
		newHTML += ['<td class="bl"><img src="img/borders/bl.png" width="15" height="15" alt="" /></td>'];
		newHTML += ['<td class="bm"></td>'];
		newHTML += ['<td class="br"><img src="img/borders/br.png" width="15" height="15" alt="" /></td>'];
		newHTML += ['</tr>'];
		newHTML += ['</table>'];
		$(this).html(newHTML.toString());
	});
	var activeBtn = false;
	$("div.mainNav div").hover(function() {
		$(this).find('div').css({backgroundPosition: 'bottom center'});
		var subNav = $(this).find('div.subNav');
		subNav.fadeIn();
		subNav.find('div.subNavItem').hover(function() {
			$(this).css({backgroundColor: '#461b1d', color:'#fff'});
		}, function() {
			$(this).css({backgroundColor: '#622f31', color:'#ddd'});
		}).click(function() {
			var target = $(this).attr('id').split(':');
			switch (target[0]) {
				case 'link':
					document.location.href = urlPrep+target[1];
					break;
			}
		});
	}, function() {
		if ($(this).data('active') !== true) {
			$(this).find('div').css({backgroundPosition: 'top center'});
			$(this).find('div.subNav').fadeOut();
		}
	});
	$("#subjectsBtn").toggle(function() {
		$(".subjectsBar").fadeIn("slow");
		$(this).data('active', true).find('div').css({backgroundPosition: 'bottom center'});
	}, function() {
		$(".subjectsBar").fadeOut("slow");
		$(this).data('active', false).find('div').css({backgroundPosition: 'top center'});
	});
	$(".buttons").hover(function() {
		var src = $(this).attr('src');
		src = src.replace('.gif','_on.gif');
		$(this).attr('src',src);
	}, function() {
		var src = $(this).attr('src');
		src = src.replace('_on.gif','.gif');
		$(this).attr('src',src);
	});
	if ($("img.printBtn").length == 1) {
		$("img.printBtn").css({background: 'url(img/printBtn.png) no-repeat top left', cursor: 'pointer'}).hover(function() {
			$(this).css({backgroundPosition: 'top right'});
		}, function() {
			$(this).css({backgroundPosition: 'top left'});
		}).click(function() {
			window.print();
		});
	}
	if ($("div.extranetSideHeading").length > 0) {
		var height = (($(document).height() > $(window).height()) ? $(document).height() : $(window).height()) - 170;
		height = (height < 690) ? 690 : height;
		$("div.extranetSideHeading").css({height: height});
	}
	$("div.extranetHomeBtn").click(function() {
		window.location = urlPrep+'extranet/';
	});
	$("div.pageNav").stickyfloat({duration: 400});
	$.smoothScroll({duration: 400});
	$(document).pngFix();
	$.floatFix();
});

