// ----------------------------------------------
// StyleSwitcher functions written by Paul Sowden
// http://www.idontsmoke.co.uk/ss/
// - - - - - - - - - - - - - - - - - - - - - - -
// For the details, visit ALA:
// http://www.alistapart.com/stories/alternate/
// ----------------------------------------------

function setActiveStyleSheet(title, reset) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
  if (reset == 1) {
  createCookie("wstyle", title, 365);
  }
}


function setStyle() {
var style = readCookie("wstyle");
if (style != null) {
setActiveStyleSheet(style, 0);
}
}

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+"="+escape(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 unescape(c.substring(nameEQ.length,c.length));
  }
  return null;
}

// Scarlet Blaze Article Tool 
// By: Jose Mulia
// http://www.scarletblaze.com
// Version: 1.1

ns4 = document.layers;
ie = document.all;
moz = document.getElementById && !document.all;
	 
function changeFontSize (id, isIncrease) {
// 1 = increase
// 0 = decrease
var obj;
var size; 

if (ns4) { alert ("Sorry, but NS4 does not allow font changes."); return false;

} else if (ie) { 
 	// tested on ie6
	// the font value is increased/decreased in em;
	obj = document.getElementById(id);
	size = obj.currentStyle.fontSize;
	
	if (isIncrease) { size = parseFloat(size) + .1;	// increase 
	} else { size = parseFloat(size) - .1;  // decrease 
	}  
	obj.style.fontSize = size + "em";

} else if (moz) {
 	// only tested on firefox
 	// The next 2 lines work, but only return font size in px!
 	// So the font value is increased/decreased in px;
	obj = window.getComputedStyle(document.getElementById(id), ''); 
	size = obj.getPropertyValue('font-size');  // value only in px
	
	 if (isIncrease) { size = size = parseFloat(size) + 1; // increase 	
	 } else { size = size = parseFloat(size) - 1; // decrease
	 }

	document.getElementById(id).style['fontSize'] = size + "px";
}

if (!obj) { alert("unrecognized ID"); return false; }
   
return true;
}

function changeAlignment (id, alignment) {
// align: "right", "left", "justify"	
var obj;

if (ns4) { alert ("Sorry, but NS4 does not allow alignment change."); return false;

} else if (ie) { 
 	// tested on ie6
	// the font value is increased/decreased in em;
	obj = document.getElementById(id);
	obj.style.textAlign = alignment;

} else if (moz) {
 	// only tested on firefox
	obj = window.getComputedStyle(document.getElementById(id), ''); 
	document.getElementById(id).style['textAlign'] = alignment;
}

if (!obj) { alert("unrecognized ID"); return false; }
  
return true;
}

function Bookmark(docUrl, docTitle) {
	if(document.all) 
	{
		window.external.AddFavorite(docUrl, docTitle);
	}
	else
	{
		alert ("I'm sorry.  Your browser: "+navigator.appName+" "+navigator.appVersion+ "\n doesn't support automatic bookmarking.\n  You have to manually bookmark this page.");
	}
}

function toPrint() {
	window.print();
}