/* http://www.white-hat-web-design.co.uk/articles/js-fontsize.php */
var min=8;
var max=18;
function increaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
      	//alert(p[i].style.fontSize);
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 11;
      }
      if(s!=max) {
         s += 1;
      }
      
      
      p[i].style.fontSize = s+"px";
      
   }
   alert(s);
   store('fontSize', s);
}

function setFontSize(s) {
	//alert(s);
	var p;
	var els = new Array (2)
  els[0]='p';
  els[1]='div';
  for(j=0;j<els.length;j++) {
    p = document.getElementsByTagName(els[j]);
    for(i=0;i<p.length;i++) {
      p[i].style.fontSize = s+"px"
    }
    store('fontSize', s);
  }
}

function decreaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 11;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }  
   alert(s);
   store('fontSize', s); 
}

function setFonts() {
	alert(getCookie('fontSize'));
}

function store(data,value) {
  var today = new Date();
  var expires = new Date();
  // set it for a short time
  expires.setTime(today.getTime() + 1000*60*60*24);
  setCookie(data, value, expires);
}

function setCookie(name, value, expire) {
  document.cookie = name + "=" + escape(value)  + ((expire == null) ? "" : ("; expires=" + expire.toGMTString())) + '; path=/';
}

function getCookie(Name) {
	var search = Name + "=";
	if (document.cookie.length > 0) { // if there are any cookies
  	offset = document.cookie.indexOf(search);
  	if (offset != -1) { // if cookie exists
    	offset += search.length;
    	// set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1) end = document.cookie.length;
      return unescape(document.cookie.substring(offset, end))
  	}
	}
	return null;
}

// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
	document.cookie = name + "=" + ( ( path ) ? ";path=" + path : "") + ( ( domain ) ? ";domain=" + domain : "" ) + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function toggleNews(strID){
	
	var target = new getMainObj(strID);
	if (target.style.display == "none"){
  	target.style.display = "";
		/* seems not not fuck up so bad if the reset footer thing is conditional */
		//setFooter();

  }else {
  	target.style.display = "none";

  }
 // setFooter();
}

function getMainObj(name){
  if (document.getElementById) {
  	this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
  } else if (document.all) {
		this.obj = document.all[name];
		this.style = document.all[name].style;
  } else if (document.layers) {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}