﻿// text resizing
var currentTextSize = null;
var currentLineHeight = null;
// check for cookie
if (get_text_cookie("pressroomfontsize")) {
	currentTextSize = parseInt(get_text_cookie("pressroomfontsize"));
} else {
	currentTextSize = 10;
	createCookie("pressroomfontsize",currentTextSize,1000);
}
currentLineHeight = currentTextSize + 5;
	
function textSize(dir) {
    if (dir == 'up') {
        if (currentTextSize <= 14) {
            currentTextSize += 2;
        }
    } else if (dir == 'down') {
        if (currentTextSize >= 12) {
            currentTextSize -= 2;
        }
    }
    currentLineHeight = currentTextSize + 5;
    document.getElementById('bodyText').style.fontSize = currentTextSize + 'px';
    document.getElementById('bodyText').style.lineHeight = currentLineHeight + 'px';
    
    if (currentTextSize == 10) {
		if (document.getElementById('ctl00_Main_cvMain_tbTop_imgSmallFont')) {
			document.getElementById('ctl00_Main_cvMain_tbTop_imgSmallFont').src = '/images/d_font_small.gif';
			document.getElementById('ctl00_Main_cvMain_tbTop_imgLargeFont').src = '/images/font_large.gif';
		} else if (document.getElementById('ctl00_Main_MainArticle_atbTop_imgSmallFont')) {
			document.getElementById('ctl00_Main_MainArticle_atbTop_imgSmallFont').src = '/images/d_font_small.gif';
			document.getElementById('ctl00_Main_MainArticle_atbTop_imgLargeFont').src = '/images/font_large.gif';
		}
	} else if (currentTextSize == 16) {
		if (document.getElementById('ctl00_Main_cvMain_tbTop_imgSmallFont')) {
			document.getElementById('ctl00_Main_cvMain_tbTop_imgSmallFont').src = '/images/font_small.gif';
			document.getElementById('ctl00_Main_cvMain_tbTop_imgLargeFont').src = '/images/d_font_large.gif';
		} else if (document.getElementById('ctl00_Main_MainArticle_atbTop_imgSmallFont')) {
			document.getElementById('ctl00_Main_MainArticle_atbTop_imgSmallFont').src = '/images/font_small.gif';
			document.getElementById('ctl00_Main_MainArticle_atbTop_imgLargeFont').src = '/images/d_font_large.gif';
		}
	} else if (currentTextSize > 10 && currentTextSize < 16) {
		if (document.getElementById('ctl00_Main_cvMain_tbTop_imgSmallFont')) {
			document.getElementById('ctl00_Main_cvMain_tbTop_imgSmallFont').src = '/images/font_small.gif';
			document.getElementById('ctl00_Main_cvMain_tbTop_imgLargeFont').src = '/images/font_large.gif';
		} else if (document.getElementById('ctl00_Main_MainArticle_atbTop_imgSmallFont')) {
			document.getElementById('ctl00_Main_MainArticle_atbTop_imgSmallFont').src = '/images/font_small.gif';
			document.getElementById('ctl00_Main_MainArticle_atbTop_imgLargeFont').src = '/images/font_large.gif';
		}
	}
	    
    // write/rewrite cookie
    createCookie("pressroomfontsize",currentTextSize,1000);
}

function swapSizes() {
	if (currentTextSize == 16) {
        currentTextSize = 10;
        if (document.getElementById('ctl00_Main_cvMain_tbTop_imgSmallFont')) {
			document.getElementById('ctl00_Main_cvMain_tbTop_imgSmallFont').src = '/images/d_font_small.gif';
			document.getElementById('ctl00_Main_cvMain_tbTop_imgLargeFont').src = '/images/font_large.gif';
		} else if (document.getElementById('ctl00_Main_MainArticle_atbTop_imgSmallFont')) {
			document.getElementById('ctl00_Main_MainArticle_atbTop_imgSmallFont').src = '/images/d_font_small.gif';
			document.getElementById('ctl00_Main_MainArticle_atbTop_imgLargeFont').src = '/images/font_large.gif';
		}
    } else {
		currentTextSize = 16;
		if (document.getElementById('ctl00_Main_cvMain_tbTop_imgSmallFont')) {
			document.getElementById('ctl00_Main_cvMain_tbTop_imgSmallFont').src = '/images/font_small.gif';
			document.getElementById('ctl00_Main_cvMain_tbTop_imgLargeFont').src = '/images/d_font_large.gif';
		} else if (document.getElementById('ctl00_Main_MainArticle_atbTop_imgSmallFont')) {
			document.getElementById('ctl00_Main_MainArticle_atbTop_imgSmallFont').src = '/images/font_small.gif';
			document.getElementById('ctl00_Main_MainArticle_atbTop_imgLargeFont').src = '/images/d_font_large.gif';
		}
    }
    currentLineHeight = currentTextSize + 5;
    document.getElementById('bodyText').style.fontSize = currentTextSize + 'px';
    document.getElementById('bodyText').style.lineHeight = currentLineHeight + 'px';
    // write/rewrite cookie
    createCookie("pressroomfontsize",currentTextSize,1000);
}

function get_text_cookie ( cookie_name )
{
  var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );

  if ( results ) {
    return ( unescape ( results[1] ) );
  }
  else { return null; }
}

// JScript File
/**
This file contains all the functions related to the cookie
and how it functions.  Most of the things in here are 
functions but there are some function calls and global variables
that are set and the order of the execution is very important.
*/

// creates a cookie with the given parameters
function createCookie(name,value,days){
	if (days){
		var date = new Date();
		date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
		var expires = "; expires=" + date.toGMTString();
	} else {
		var expires = "";
	}
	document.cookie = name + "=" + value + expires + "; path=/";
}

// locates and reads the value of a cookie with a specified name
function readCookie(name){
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

// deletes a cookie with a specified name
function eraseCookie(name){
	createCookie(name,"",-1);
}

// parses the value of the cookie
// returns an array of the different values
function parseCookie(cookievalues){
	if (cookieValues.length > 0){
		var cookieValuesArray = new Array(3);
		var CookiesArray = cookievalues.split("&");
		for (var i = 0; i < CookiesArray.length; i++){
			var v = CookiesArray[i].split(":");
			cookieValuesArray[i] = v[1];
		}
		return cookieValuesArray;
	} else {
		return null;
	}
}