// Copyright © 2009 Government of Manitoba



/* 

To add to a page, include the following above the breadcrumb:

ENGLISH

---------------------------------

<div id="textResize" style="float: right; padding: 3px 5px 0px 0px;">

	<a href="javascript:fontSize('fsmall');"><img src="images/font_small.jpg" alt="Set text to smallest size" name="font_small" width="20" height="19" border="0" id="font_small" /></a> 

	<a href="javascript:fontSize('fnormal');"><img src="images/font_normal.jpg" alt="Set text to normal size" name="font_normal" width="20" height="19" border="0" id="font_normal" /></a>

	<a href="javascript:fontSize('fmedium');"><img src="images/font_medium.jpg" alt="Set text to larger size" name="font_medium" width="20" height="19" border="0" id="font_medium" /></a>

	<a href="javascript:fontSize('flarge');"><img src="images/font_large.jpg" alt="Set text to largest size" name="font_large" width="20" height="19" border="0" id="font_large" /></a></div>

--------------------------------

FRENCH

--------------------------------

<div id="textResize" style="float: right; padding: 3px 5px 0px 0px;">

    		<img src="../textresize/images/font_small.jpg" alt="R&eacute;gler la taille de texte &agrave; petit" name="font_small" width="20" height="19" border="0" id="font_small" onclick="fontSize('fsmall')" />

        	<img src="../textresize/images/font_normal.jpg" alt="R&eacute;gler la taille de texte &agrave; normal" name="font_normal" width="20" height="19" border="0" id="font_normal" onclick="fontSize('fnormal')" />

        	<img src="../textresize/images/font_medium.jpg" alt="R&eacute;gler la taille de texte &agrave; moyen" name="font_medium" width="20" height="19" border="0" id="font_medium" onclick="fontSize('fmedium')" />

        	<img src="../textresize/images/font_large.jpg" alt="R&eacute;gler la taille de texte &agrave; plus grand" name="font_large" width="20" height="19" border="0" id="font_large" onclick="fontSize('flarge')" /></div>

--------------------------------



Add the following into <body onload="">:

--------------------------------

readCookie();

--------------------------------



Add the following in the <head>:

--------------------------------

<script src="resize.js" type="text/javascript"></script>

--------------------------------



Blockquotes will break the template. Use the following CSS if useing blockquotes:

--------------------------------

blockquote{

width: 450px;

padding: 0px;

margin: 0px 0px 0px 59px;

}

--------------------------------



<em> tags might break the page in some places in IE6, use this css hack:

--------------------------------

em{

overflow: hidden;

o\verflow: visible;

width: 100%;

w\idth: auto;

zoom: 1;

}

--------------------------------

*/



// divs that you would like to be resizeable (please enter the id/class name)

var div = new Array( 

	"pageinfo",

	"organization",

	"breadcrumb",

	"sidemenu",

	"links",

	"widecenter",

	"pdf",

	"news1",

	"news2",

	"news3",

	"news4",

	"news5",

	"news6",

	"news7",

	"news8",

	"news9",

	"news10",

	"news11",

	"news12",

	"services1",

	"services2",

	"services3",

	"services4",

	"services5",

	"services6",

	"services7",

	"services8",

	"services9",

	"services10",

	"services11",

	"services12",

	"services13",

	"services14",

	"info1",

	"info2",

	"info3",

	"info4",

	"info5",

	"info6",

	"info7",

	"info8",

	"info9",

	"other"

);



// creates a cookie to store users font size

function createCookie(size){

	var expires = new Date();

	expires.setDate(expires.getDate() + 30); // expire date for cookie

	document.cookie = "fontSize=" + size + "; expires=" + expires.toGMTString()  + "; path=/";

}



// changes font size based on user selection

function fontSize(size){

	var loc = location.href.indexOf("fs"); // finds current directory (based on /fs/)

	var dir = location.href.substring(0, loc) + "fs/textresize/images/"; // image directory

	createCookie(size); // makes a cookie

	for(var i = 0; i < div.length; i++){

		if(document.getElementById(div[i])){ // checks to see if div exists

			switch(size){

				case "fsmall": // if user selects small font size

					if(div[i] == "breadcrumb"){  // breadcrumb breaks template if it goes to small, lets ignore it for this size

						document.getElementById(div[i]).style.fontSize = 1.1+"em"; // sets breadcrumb to 11px

					}

					else{

						document.getElementById(div[i]).style.fontSize = 0.9+"em"; // sets divs to 9px

					}

					// images changes based on font size

					document.getElementById("font_small").src = dir + "o_font_small.jpg";

					document.getElementById("font_normal").src = dir + "font_normal.jpg";

					document.getElementById("font_medium").src = dir + "font_medium.jpg";

					document.getElementById("font_large").src = dir + "font_large.jpg";

					break;

				case "fmedium": // if user selects medium font size

					document.getElementById(div[i]).style.fontSize = 1.4+"em"; // sets divs to 14px

					document.getElementById("font_small").src = dir + "font_small.jpg";

					document.getElementById("font_normal").src = dir + "font_normal.jpg";

					document.getElementById("font_medium").src = dir + "o_font_medium.jpg";

					document.getElementById("font_large").src = dir + "font_large.jpg";

					break;

				case "flarge": // if user selects large font size

					document.getElementById(div[i]).style.fontSize = 1.6+"em"; // sets divs to 16px

					document.getElementById("font_small").src = dir + "font_small.jpg";

					document.getElementById("font_normal").src = dir + "font_normal.jpg";

					document.getElementById("font_medium").src = dir + "font_medium.jpg";

					document.getElementById("font_large").src = dir + "o_font_large.jpg";

					break;

				default: // if user selects normal font size

					document.getElementById(div[i]).style.fontSize = 1.1+"em"; // sets divs to 11px

					document.getElementById("font_small").src = dir + "font_small.jpg";

					document.getElementById("font_normal").src = dir + "o_font_normal.jpg";

					document.getElementById("font_medium").src = dir + "font_medium.jpg";

					document.getElementById("font_large").src = dir + "font_large.jpg";

				break;

			}

		}

	}

}

 

// reads the cooie

function readCookie(){

	if(document.cookie.length > 0){ // checks to see if cookie exists and is not empty

  		var name = "fontSize=";

  		var pa = document.cookie.split(';'); // makes array from cookie

  		for(var i = 0 ; i < pa.length; i++) {

  			var current = pa[i];

   	 		while(current.charAt(0) == ' '){ // gets rid of spaces

				current = current.substring(1, current.length);

			}

    		if(current.indexOf(name) == 0){ // checks current position

				fontSize(current.substring(name.length, current.length)); // sets text to user setting

			}

  		}

	}

  	return null; // return null if cookie does not exist

}