function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function mhcte6qb(u, h) {
	document.write('<a href="mailto:' + u + '@' + h + '">' + u + '@' + h + '</a>');
}

function toggle(id) {
	if ($('#' + id).is(':hidden')) {
		$('#' + id).show();
	} else {
		$('#' + id).hide();
	}
}

function rotate_quotes() {
	$("#quote_box").fadeOut("slow", function() {
		$('#text_to_change1').text(app_quotes[app_quote_pos][0]);
		$('#text_to_change2').text(app_quotes[app_quote_pos][1]);
		$("#quote_box").fadeIn("slow");
	});

	app_quote_pos++;
	if (app_quote_pos >= app_quotes.length) {
		app_quote_pos = 0;
	}
	setTimeout('rotate_quotes()', 6000);
}
function rotate_quotes_init() {
	app_quotes = [
	["CGE has been an absolute godsend for resources whilst I was a student teacher! The student talks were inspirational as a result and helped direct the topic.", "Student Teacher from Monk Fryston Primary School"],
	["Children really gained a lot from the artefacts AND I learnt a lot too!", "Thank you! York Primary Teacher"],
	["This is always useful and helps to focus me towards the next steps.", "Year 4 Teacher provided with global project support"],
	["Thanks Mick and Chrissie for a great input today, I look for ward to seeing how we can develop P4C.", "Education Tutor"],
	["Thank you very much for your kindness at CGE. Now I'm back to school in Japan. I learned a lot about Global Learning in UK, which impressed me a lot. I try my best to make good use of information that I gained this time.", "Visiting Japanese Teacher"],
	["Very useful resources-the children loved the items!", "Key Stage One Teacher"],
	["A superb morning - I have been able to add some activities to my Performing Arts sessions as a direct result of attending!", "Education Lecturer"],
	["Just to let you know that I had lots of positive feedback from our staff meeting and my deputy head thought how good you were.", "Comment from an East Riding Teacher following training given at a recent staff meeting"],
	["I just wanted to thank you so much once again for such a wonderful meeting last week. We had such a positive response.", "Early Years York LA Consultant"],
	["The training was great as a result of all discussions/ activities/ and meeting other teachers who are as passionate as myself about global issues.", "Teacher from Humberstone CE Primary, Grimbsy"],
	["I had a lovely day! I am so pleased to be working with such a great team!", "Teacher from All Saint's School, York"]
];
	app_quote_pos = Math.floor(Math.random()*app_quotes.length);
	rotate_quotes();
}

function rotate_quotes2() {
	$("#newsbox").fadeOut("slow", function() {
		$('#text_to_change1').text(app_quotes2[app_quote_pos2][0]);
		$('#text_to_change2').text(app_quotes2[app_quote_pos2][1]);
		$('#text_to_change3').text(app_quotes2[app_quote_pos2][2]);
		$("#newsbox").fadeIn("slow");
	});

	app_quote_pos2++;
	if (app_quote_pos2 >= app_quotes2.length) {
		app_quote_pos2 = 0;
	}
	setTimeout('rotate_quotes2()', 6000);
}
function rotate_quotes2_init() {
	app_quotes2 = [
	["2 in 5", "young people think what they do in their daily life impacts on people in other countries.", "DEA/Ipsos Mori research on young people's experience 2008"],
	["1 in 3", "secondary teachers feel schools fail to prepare children for a fast-changing globalised world.", "DEA/Ipsos Mori research on Teacher's attitudes 2009"],
	["68%", "of North Yorkshire secondary pupils had not heard of the United Kingdom Youth Party.", "NYCC HRBQ 2008"],
	["93%", "of young people think it is important to learn about issues affecting people's lives in different parts of the world.", "Ipsos Mori/Geographical Association Survey 2009"],
	["85%", "of North Yorkshire secondary pupils have not had a chance to take part in a mock election.", "NYCC HRBQ 2008"],
	["4 in 5", "teachers feel they should teach how emerging economies increasingly impact on UK life. 3 in 5 aren't confident to do so.", "DEA/Ipsos Mori research on Teacher's attitudes 2009"],
	["18%", "North Yorkshire secondary pupils worry about the environment.", "NYCC HRBQ 2008"],
	["92%", "of young people think it is important to learn where the things they use, like food, energy and water come from.", "Ipsos Mori/Geographical Association Survey 2009"],
	["50%", "of young people think those from different backgrounds should live in the same country.", "DEA/Ipsos Mori research on young people's experience 2008"],
	["5 in 8", "children are not learning about major world events and problems at school.", "Ipsos Mori/Geographical Association Survey 2009"]
];
	app_quote_pos2 = Math.floor(Math.random()*app_quotes2.length);
	rotate_quotes2();
}

function rotate_quotes3() {
	$("#quote_box").fadeOut("slow", function() {
		$('#text_to_change1').html('&ldquo;' + app_quotes3[app_quote_pos3][0] + '&rdquo;');
		$('#text_to_change2').text(app_quotes3[app_quote_pos3][1]);
		$("#quote_box").fadeIn("slow");
	});

	app_quote_pos3++;
	if (app_quote_pos3 >= app_quotes3.length) {
		app_quote_pos3 = 0;
	}
	setTimeout('rotate_quotes3()', 6000);
}
function rotate_quotes3_init() {
	app_quotes3 = [
	["No one is born a good citizen; no nation is born a democracy. Young people must be included from birth. A society that cuts off from its youth severs its lifeline.", "Kofi Annan"],
	["Good government is no substitute for self-government.", "Gandhi"],
	["The efforts of the government alone will never be enough. In the end the people must choose and the people must help themselves.", "John F. Kennedy"],
	["By community cohesion, we mean working towards a society in which there is a common vision and sense of belonging; where diversity is appreciated and valued; similar life opportunities are available to all; strong and positive relationships exist and continue to be developed in the all communities.", "Community Cohesion-guidance on inspection 2009"],
	["Education influences and reflects the values of society, and the kind of society we want to be.", "Values, Aims & Purposes, National Curriculum"],
	["Global education is good education. It is about success, both academic and social, and about engaging with our world as global citizens, willing to take action in support of our local and global communities.", "Rt. Hon. Hilary Benn MP"],
	["Take every penny you have set aside for aid in Tanzania and spend it in the UK explaining to people the facts and causes of poverty.", "Julius Nyerere, former President of Tanzania"],
	["Before you finish breakfast you will have depended on half the world.", "Martin Luther King"],
	["A curriculum for the 21st century should encourage learners to be aware of global issues.", "The National Curriculum"],
	["Education is the most powerful weapon which you can use to change the world.", "Nelson Mandela"]
];
	app_quote_pos3 = Math.floor(Math.random()*app_quotes3.length);
	rotate_quotes3();
}


/* accessibility start */
function writeJS() {
var str='';
str+='<div id="switcher">';
str+='    <div id="access-widget">';
str+='      <div id="access-widget-panel">';
str+='        <p>Change font size and<br \/>';
str+='          colours on this site</p>';
str+='        <ul id="font-sizes">';
str+='          <li><a href="#" id="font-normal">A<span class="hide-op"> - switch to normal font size<\/span><\/a><\/li>';
str+='          <li><a href="#" id="font-bigger">A<span class="hide-op"> - switch to bigger font size<\/span><\/a><\/li>';
str+='          <li><a href="#" id="font-biggest">A<span class="hide-op"> - switch to biggest font size<\/span><\/a><\/li>';
str+='        <\/ul>';
str+='        <ul id="themes">';
str+='          <li><a href="#" id="theme-default">C<span class="hide-op"> - switch to Default theme<\/span><\/a><\/li>';
str+='          <li><a href="#" id="theme-blue">C<span class="hide-op"> - switch to Blue theme<\/span><\/a><\/li>';
str+='          <li><a href="#" id="theme-hiviz">C<span class="hide-op"> - switch to Hi Viz theme<\/span><\/a><\/li>';
str+='          <li><a href="#" id="theme-soft">C<span class="hide-op"> - switch to Soft theme<\/span><\/a><\/li>';
str+='        <\/ul>';
str+='      <\/div>';
str+='    <\/div>';
str+='    <div style="clear:both"><\/div>';
str+='  <\/div>';
document.write(str);
}

AccessWidget = {
	defaultTheme : "theme-default",
	fontSizes :{
		normal: "14px",
		bigger: "15px",
		biggest: "17px"
	},
	
	init : function(){
		
		//try {
			if ($.cookie("mywayAccessPrefs_s")) {
				AccessWidget.currentFontSize = $.cookie("mywayAccessPrefs_s");
			}else{
				AccessWidget.currentFontSize = AccessWidget.fontSizes.normal;
			}
			if ($.cookie("mywayAccessPrefs_t")) {
				AccessWidget.currentTheme = $.cookie("mywayAccessPrefs_t");
			}else{
				AccessWidget.currentTheme = AccessWidget.defaultTheme;
			}

			AccessWidget.setTheme();

			AccessWidget.showPage();
		//} 
		/*catch (e) {
			AccessWidget.showPage();
		}*/
	},

	init_onload : function(){
			//if($('#access-widget')) {
				$('#font-normal').click(function() { AccessWidget.handleChangeFontSize('normal'); return false; });
				$('#font-bigger').click(function() { AccessWidget.handleChangeFontSize('bigger'); return false; });
				$('#font-biggest').click(function() { AccessWidget.handleChangeFontSize('biggest'); return false; });
				$('#theme-default').click(function() { AccessWidget.handleClickTheme('theme-default'); return false; });
				$('#theme-blue').click(function() { AccessWidget.handleClickTheme('theme-blue'); return false; });
				$('#theme-hiviz').click(function() { AccessWidget.handleClickTheme('theme-hiviz'); return false; });
				$('#theme-soft').click(function() { AccessWidget.handleClickTheme('theme-soft'); return false; });

				//$('switcher').style.display = 'block';
			//}
			AccessWidget.setFontSize(AccessWidget.currentFontSize);
	},

	handleChangeFontSize : function(e){
		var sizeName = e;
		AccessWidget.setFontSize(AccessWidget.fontSizes[sizeName]);
	},
	
	handleClickTheme : function(e){
		AccessWidget.currentTheme = e;
		AccessWidget.setTheme();
		//history.go(0);
	},
	

	setTheme : function(){
		var e = document.createElement("link");
		e.type = 'text/css';
		e.rel = 'stylesheet'
		e.href = "/css/" + AccessWidget.currentTheme + ".css";
		e.media = 'all';
		document.getElementsByTagName("head")[0].appendChild(e);
		/*for (i = 1; i < 11; i++)
		{
			//alert('start' + i);
			if (document.getElementById("swap" + i))
			{
			//alert('in');
				var pic = document.getElementById("swap" + i);
				//alert (pic.id);
				var picdir = pic.src;
				var z=picdir.replace("/images/","/images/" + AccessWidget.currentTheme + "/");
				pic.src = z;
				//alert (pic.id);
				//pic.id = "swap" + i;
				//alert('out');
			} 
		}*/
		
		AccessWidget.saveCookie();
	},
	
	setFontSize : function(size){
		AccessWidget.currentFontSize = size;
		//if ($('#content'))
			$('body').css({'fontSize' : size});
		AccessWidget.saveCookie();
	},
	
	saveCookie : function(){
		$.cookie("mywayAccessPrefs_s", AccessWidget.currentFontSize, { expires: 7 });
		$.cookie("mywayAccessPrefs_t", AccessWidget.currentTheme, { expires: 7 });
	},
	
	showPage : function(){
		//document.body.style.display = 'block';
	}
};

//try {
	AccessWidget.init();
	$(document).ready(function() {
		AccessWidget.init_onload();
	});
//}
//catch (e) {
//	alert('!!');window.setTimeout("AccessWidget.showPage()", 100);
//}
/* accessibility end */
