/* font size change 
------------------- */

var curFontSize = 1; 	
var fontModifier = 0.1; 	

function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1) {
endstr = document.cookie.length;
}
return unescape(document.cookie.substring(offset, endstr));
}

function FixCookieDate(date) {
var base = new Date(0);
var skew = base.getTime();
if (skew > 0)  {
date.setTime (date.getTime() - skew);
}
}

function GetCookie(name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i=0;
while (i < clen) {	
var j = i + alen;
if (document.cookie.substring(i, j) == arg) {
return getCookieVal (j);
}
i = document.cookie.indexOf(" ", i) + 1;
if (i === 0) {
break;
}
}
return null;
}

function SetCookie(name,value,expires,path,domain,secure) {
document.cookie = name + "=" + escape (value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}

/* insert hi-res logo and call window print */
function printStoryPage() {
if (document.getElementById("print-logo")){
document.getElementById("print-logo").setAttribute("src", "/images/print-logo.jpg");
window.print();
}
}

function fontSize(act) {
if (document.getElementById) {
storyBody = document.getElementById("text-big");
storyLinks = document.getElementById("link-big");
if (act === 1) {
curFontSize += fontModifier;
curFontSize = Math.min(curFontSize, 1.4);
} else if (act === 0) {
curFontSize -= fontModifier;
curFontSize = Math.max(curFontSize, 1);
}
storyBody.style.fontSize = curFontSize + "em";

if(storyLinks !== null) {
for (v = 0; v < storyLinks.getElementsByTagName("A").length; v++) {
storyLinks.getElementsByTagName("A")[v].style.fontSize = curFontSize + "em";
}
}
}

// set cookie with font size
var expdate = new Date();
FixCookieDate (expdate);
expdate.setTime (expdate.getTime() + (672*60*60*1000)); // 4 weeks
SetCookie("userfontc",curFontSize,expdate);		

return(false);
}
