/*
CSS Browser Selector v0.3.4 (Sep 29, 2009)
Rafael Lima (http://rafael.adm.br)
http://rafael.adm.br/css_browser_selector
License: http://creativecommons.org/licenses/by/2.5/
Contributors: http://rafael.adm.br/css_browser_selector#contributors
*/
function css_browser_selector(u){var ua = u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',o='opera',h=document.getElementsByTagName('html')[0],b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?'mobile':is('iphone')?'iphone':is('ipod')?'ipod':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win':is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; 

css_browser_selector(navigator.userAgent);

function moveFooter(){
	var windowHeightHolder = $(window).height() - 159;
	var windowHeightHolder2 = $('.content_area div').height();

	if (windowHeightHolder < windowHeightHolder2)
	{
		windowHeightHolder = windowHeightHolder2+30;
	}

	//alert(windowHeightHolder2)

	$('.content_area').css('height', windowHeightHolder  +'px');
	//$('.content_area').css('min-height', windowHeightHolder  +'px');
}

function resizeBackgroundPanel() {
	var resizeTimer = null;	
	$(window).resize(function(){
  		moveFooter()
	});

}
resizeBackgroundPanel();

function initialiseSidePanel(){
	loadFooter();
	moveFooter();
	/*$(".goto_student_login").click(
		function(){
			$("#login_student").fadeIn("slow");
			$("#login_buttons").css("display" , "none");
            return false;	
        }
	);*/
	$("#go_back_student").click(
		function(){
        	$("#login_buttons").fadeIn("slow");	                
			$("#login_student").css("display" , "none");
			return false;	
        }
	);
	/*$(".goto_teacher_login").click(
		function(){
			$("#login_teacher").fadeIn("slow");	                
			$("#login_buttons").css("display" , "none");
        	return false;	
        }
	);*/
	$("#go_back_teacher").click(
		function(){
            $("#login_buttons").fadeIn("slow");	                
			$("#login_teacher").css("display" , "none");
			return false;	
        }
	);		
	//$("#log_student_in").attr("href","student.aspx");
	//$("#log_teacher_in").attr("href","teacher.aspx");
	$("#register_student").attr("href","studentregistration.aspx");
	$("#register_teacher").attr("href","teacherregistration.aspx");
}

function loadFooter(){
	$("#footer").html('Philip Allan Updates 2011&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href="/Documents/Literature-Guides-Online-Terms-and-Conditions.aspx" target="_blank" class="grey_links">Terms and conditions</a><div id="footer_mmt"><a href="http://www.mmtdigital.co.uk" target="_blank">Site produced by MMT Digital</a></div>');
}

function loadSWF(targetElement, swfPath, _width, _height, _wmode, _fpVersion,  scaleMode, _flashVarsObj)
{
	
	if(_fpVersion == null){
		_fpVersion = "8.0.0";
	}
	if(_wmode == null){
		_wmode = "window";
	} else {
		if(_wmode != "transparent") {
			_wmode = "opaque";
		} else {
			_wmode = "transparent";
		}
	}
	if (scaleMode == null)
	{
		scaleMode = "showAll";
	}
	if(typeof(swfobject) != "undefined") {
		if (swfobject.hasFlashPlayerVersion(_fpVersion)) {			
			var holder = document.createElement("div");
				holder.id = "flash_element";
				$(targetElement).html(holder);
			if (_flashVarsObj){
				flashVarsObj = _flashVarsObj;
				}
			else{
				flashVarsObj = {};
				}	
			flashVarsObj.urlPageName=window.location.href.toString();			
			swfobject.embedSWF(swfPath, "flash_element", _width, _height, _fpVersion, "", flashVarsObj, {menu:"false", quality:"high", wmode:_wmode, scale:scaleMode, salign:"lt", loop:"false", allowScriptAccess:"always"}, {});
			
		} else {					
			$(targetElement).html("This content requires the Adobe Flash Player. <a class='white_links' href=\"https://www.adobe.com/go/getflash/\">Get Flash</a>");
			$(targetElement).addClass("whiteText");
		}
	}
}

$(function() {
	$('.truncate_area').truncate({max_length: 80});
});

jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}
