//cookie script
if (document.getElementById) { // kosher
	// read cookie for font size, set to 12 no cookie
	fs = parseInt(readCookie('fontSize'));
	if (!fs>0) fs=12;


	// set the appropriate font sizes for the relevant HTML elements
	// any other elements that you want to have a changeable font size must be added to this list
	// in the form "element_fs" and then also added to the setSizes and changeType functions

	var p_fs;
	var h1_fs;
	var h2_fs;	
	var h3_fs;
	var h4_fs;
	
setSizes();
	// write out styles with changeable values from cookies for display
	document.writeln('<style>');
	document.writeln('h1{font-size:'+h1_fs+'px;}');
	document.writeln('h2{font-size:'+h2_fs+'px;}');
	document.writeln('h3{font-size:'+h3_fs+'px;}');
	document.writeln('h4{font-size:'+h4_fs+'px;}');
	document.writeln('p{font-size:'+p_fs+'px;}');
	document.writeln('li{font-size:'+p_fs+'px;}');
	document.writeln('<\/style>');
	}

// this changes the sizes of the various elements relative to the fs
function setSizes() {
	p_fs=fs;
	h1_fs=fs+4;
	h2_fs=fs+3;
	h3_fs=fs+2;
	h4_fs=fs+1;
	}

function changeType() {
	if (!document.getElementsByTagName) {return false;} // unclean! unclean!
	// because NS6 seems to freak out on abs. positionined divs
	// when you change a style property of the body, we have to
	// set the fontFamily and fontSize on div elements and not the body
	
	setStyleByTag('h1','fontSize',h1_fs+'px');
	setStyleByTag('h2','fontSize',h2_fs+'px');
	setStyleByTag('h3','fontSize',h3_fs+'px');
	setStyleByTag('h4','fontSize',h4_fs+'px');
	setStyleByTag('p','fontSize',p_fs+'px');
	setStyleByTag('li','fontSize',p_fs+'px');

			
	// store these values in cookies for subsequent page loads and adds the root path for style
	
        //setCookie('fontSize',fs,'/','.toysaregoodfood.com');

setCookie('fontSize',fs,'/');	
	}

// this function is called from the Larger text button
function increaseSize() {
	fs+=2;
	setSizes();
	changeType();
	}

// this function is called from the smaller text button
function decreaseSize() {
	if (p_fs>1) {
		fs-=2;
		setSizes();
		changeType();
		}
	}


// cookie functions
function setCookie(cookieName,cookieValue,path,domain) {
	var today = new Date();
	var expire = new Date();
	expire.setTime(today.getTime() + 3600000*24*3000);
	document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString() + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:'');
	 
	
        }
	
function readCookie(cookieName) {
	var theCookie=""+document.cookie;
	var ind=theCookie.indexOf(cookieName);
	if (ind==-1 || cookieName=="") return ""; 
	var ind1=theCookie.indexOf(';',ind);
	if (ind1==-1) ind1=theCookie.length; 
	return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
	}


// setStyleByTag: given an element type, style property and value
// args:
//  e - element type or id
//  p - property
//  v - value
function setStyleByTag(e, p, v) {
	var elements = document.getElementsByTagName(e);
	for(var i = 0; i < elements.length; i++) {
		elements.item(i).style[p] = v;
		}
	}



//universal print function

function printit(){  
if (window.print) {
    window.print() ;  
} else {
    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
    WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";  
}
}



function toggle(e) {
  if (e.style.display == "inline") {
     e.style.display = "none";
  } else {
     e.style.display = "inline";
  }
}


function bookMark(argVal)
{
var bookData = new Array();
bookData = argVal.split("|");
if (document.all)
window.external.AddFavorite(bookData[0], bookData[1]);
else
alert("Dang. This only works in IE. Other browsers should bookmark the pages manually by hitting <Ctrl-D>");
}
	