// JavaScript Document
var min=11;
var defaultbody=13;
var max=19;
/*	Shorten News Results	*/
function reduceparasize()	{
  var minpara = 120;	/* min string length */
  var maxpara = 150;		/* max string length */
  var wrapperdivid = 'totalnewslist';	/* name of wrapper div - this is #id */
  var element = document.getElementsByTagName('p');
  for (j = 0; j <= (element.length-1); j++)	{
    if (element[j].firstChild) {
      if (element[j].firstChild.nodeValue) {			
		if ((element[j].firstChild.nodeValue.length >= maxpara)&&(element[j].parentNode.parentNode.id == wrapperdivid))	{ 
			element[j].firstChild.nodeValue = element[j].firstChild.nodeValue.substring(0,(element[j].firstChild.nodeValue.substring(minpara,maxpara).search(/ /)+minpara))+'... ';	
		}	else if	((element[j].firstChild.nodeValue.length >= maxpara)&&(element[j].parentNode.parentNode.id == 'longnewslist'))	{ 
			element[j].firstChild.nodeValue = element[j].firstChild.nodeValue.substring(0,(element[j].firstChild.nodeValue.substring(300,330).search(/ /)+300))+'... ';	
		}
	  }
	}
  }
}
/*	Resizing scripts	*/
function increaseFontSize() {
   var p = document.getElementsByTagName('body');
      if(p[0].style.fontSize) {
         var s = parseInt(p[0].style.fontSize.replace("px",""));
      } else {
         var s = defaultbody;
      }
      if(s!=max) {
         s += 2;
      }
      p[0].style.fontSize = s+"px"
}
function defaultFontSize() {
  var p = document.getElementsByTagName('body');
  var s = defaultbody;
  p[0].style.fontSize = s+"px"
}
function decreaseFontSize() {
   var p = document.getElementsByTagName('body');
      if(p[0].style.fontSize) {
         var s = parseInt(p[0].style.fontSize.replace("px",""));
      } else {
         var s = defaultbody;
      }
      if(s!=min) {
         s -= 2;
      }
      p[0].style.fontSize = s+"px"
}
function setActiveFontSize(title) {	// Get the font size that is currently in play
	var p = document.getElementsByTagName('body');
  	p[0].style.fontSize = title;
}
function getActiveFontSize() {
	var p = document.getElementsByTagName('body');
	if(p[0].style.fontSize) {
	  return p[0].style.fontSize;
	}
	return null;  
}
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 expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}
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;
}
window.onload = function(e) {
  reduceparasize();
  var cookie = readCookie("style");
  var title = cookie ? cookie : (defaultbody+'px');
  setActiveFontSize(title);
}
window.onunload = function(e) {
  var title = getActiveFontSize();
  createCookie("style", title, 365);
}