function settext(theme_name) {
	
	// Searches for existance of cookie
	var starter = document.cookie.indexOf("TEXTSIZE=");
	var ender = document.cookie.indexOf("ENDTEXTSIZE");
	var size = document.cookie.substring(starter+9,ender);
	
	var contraststarter = document.cookie.indexOf("CONTRAST=");
	var contrastender = document.cookie.indexOf("ENDCONTRAST");
	var contrast = document.cookie.substring(contraststarter+9,contrastender);
	
	/*if the cookie wasn't found (text sizing never having been done before), 
	output the bog-standard stylesheet html tag  */
	if (starter < 0) {
		//alert('no cookie');
		document.getElementById('bodycss').href='/css/front/body.css';
	}
	/*Otherwise, if the cookie IS found, load the correct size.*/
	else {
		//alert('/css/front/body' +size+ '.css');
		document.getElementById('bodycss').href='/css/front/body' +size+ '.css';
	}
	
	/*if the cookie wasn't found (contrast change never having been done before), 
	output the bog-standard stylesheet html tag  */
	if (contraststarter < 0) {
		//don't need to do anything
	}
	/*Otherwise, if the cookie IS found, load the correct contrast.*/
	else {
		if (contrast == "high") {
			document.getElementById('themecss').href='/css/front/highcontrast.css';
		}
		else {
			document.getElementById('themecss').href='/css/front/' +theme_name+ '.css';
		}
	}
}

function textchanger(type,theme_name){
	var starter = document.cookie.indexOf("TEXTSIZE=");
	var ender = document.cookie.indexOf("ENDTEXTSIZE");
	var size = document.cookie.substring(starter+9,ender);
	
	var contraststarter = document.cookie.indexOf("CONTRAST=");
	var contrastender = document.cookie.indexOf("ENDCONTRAST");
	var contrast = document.cookie.substring(contraststarter+9,contrastender);
	
	if (starter < 0) {
		size = "";
	}
	if (contraststarter < 0) {
		contrast = "";
	}
	
	// text size stuff
	if (type == "size") {
		if (size==""){
		var the_cookie ="TEXTSIZE=medENDTEXTSIZE+CONTRAST=" + contrast + "ENDCONTRAST; path=/";
		document.cookie = the_cookie;
		document.getElementById('bodycss').href='/css/front/bodymed.css';
		}
		
		if (size=="med"){
			//set medium cookie
			var the_cookie ="TEXTSIZE=lrgENDTEXTSIZE+CONTRAST=" + contrast + "ENDCONTRAST; path=/";
			document.cookie = the_cookie;
			document.getElementById('bodycss').href='/css/front/bodylrg.css';
		}
		
		if (size=="lrg"){
			//set large cookie
			var the_cookie ="TEXTSIZE=ENDTEXTSIZE+CONTRAST=" + contrast + "ENDCONTRAST; path=/";
			document.cookie = the_cookie;
			document.getElementById('bodycss').href='/css/front/body.css';
		}
	}
	
	// contrast stuff
	if (type == "contrast") {
		if (contrast==""){
		var the_cookie ="TEXTSIZE=" + size + "ENDTEXTSIZE+CONTRAST=highENDCONTRAST; path=/";
		document.cookie = the_cookie;
		document.getElementById('themecss').href='/css/front/highcontrast.css';
		}
		
		if (contrast=="high"){
			//set large cookie
			var the_cookie ="TEXTSIZE=" + size + "ENDTEXTSIZE+CONTRAST=ENDCONTRAST; path=/";
			document.cookie = the_cookie;
			document.getElementById('themecss').href='/css/front/' +theme_name+ '.css';
		}
	}
}


