

function setNav(navItem){
	var nav = document.getElementById(navItem);
	nav.setAttribute("src","/assets/img/nav_" + navItem + "On.gif");
	nav.setAttribute("onmouseout","return false;");
	nav.setAttribute("onmouseover","return false;");
}



//Menu IE Fix
navHover = function() {
	var lis = document.getElementById("navmenu").getElementsByTagName("LI");
	for (var i=0; i<lis.length; i++) {
		lis[i].onmouseover=function() {
			this.className+=" iehover";
		}
		lis[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", navHover);

function setActiveTextSize(activetSize){
    Csize=document.getElementById('articleBody').style.fontSize;
    if(Csize)
    document.getElementById(Csize).className=Csize;    
    document.getElementById(activetSize).className='active';
    document.getElementById('articleBody').style.fontSize = activetSize;
	td = document.getElementsByTagName('td');
        for(i=0;i<td.length;i++) {  
        	if(td[i].id != "navTd")
            		td[i].style.fontSize = activetSize;
            	
        } 
        
        divs = document.getElementsByTagName('div');
	for(i=0;i<divs.length;i++) {            
		if(divs[i].id != "content")
			divs[i].style.fontSize = activetSize;
        }
        
	if(document.getElementById('bullet'))
	document.getElementById('bullet').style.fontSize = activetSize;
	if(document.getElementById('bulletw'))
	document.getElementById('bulletw').style.fontSize = activetSize;
	if(document.getElementById('question'))
	document.getElementById('question').style.fontSize = activetSize;
	if(document.getElementById('faq'))
	document.getElementById('faq').style.fontSize = activetSize;
	
    // write/rewrite cookie
    createCookie("ActiveFontSize",activetSize,1000);
}
function createCookie(cookie_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 = cookie_name+"="+value+expires+"; path=/";
}
function readCookie(cooke_name) {
    regexpr = cooke_name+ '=(.*?)(;|$)';
    var results = document.cookie.match (regexpr);
    if ( results ) {
        return ( unescape ( results[1] ) );
    }
    else { return null; }
    }
 
function applystyle(){
    var Currentfontsize ='small';
    if (readCookie('ActiveFontSize')) {
      	var Currentfontsize = readCookie('ActiveFontSize');
        setActiveTextSize(Currentfontsize);
    } else {      
        setActiveTextSize(Currentfontsize);
        }
    document.getElementById(Currentfontsize).className  ='active';
}

var testImg = new Array();

  testImg[0]="4";
  testImg[1]="1";
  testImg[2]="2";
  testImg[3]="3";

var newTest = 0;
var totalTest = testImg.length;

function cycleTest() {
  newTest++;
  if (newTest == totalTest) {
    newTest = 0;
  }

  document.testA.src="assets/img/test" + testImg[newTest] + "_h.jpg";
  document.testB.src="assets/img/test" + testImg[newTest] + "_htxt.gif";
  setTimeout("cycleTest()", 4*1000);
}

//set todays date
Now = new Date();
NowDay = Now.getDate();
NowMonth = Now.getMonth();
NowYear = Now.getYear();

//function for returning how many days there are in a month including leap years
function DaysInMonth(WhichMonth, WhichYear)
{
  var DaysInMonth = 31;
  if (WhichMonth == "4" || WhichMonth == "6" || WhichMonth == "9" || WhichMonth == "11") DaysInMonth = 30;
  if (WhichMonth == "2" && (WhichYear/4) != Math.floor(WhichYear/4))	DaysInMonth = 28;
  if (WhichMonth == "2" && (WhichYear/4) == Math.floor(WhichYear/4))	DaysInMonth = 29;
  return DaysInMonth;
}

//function to change the available days in a months
function ChangeOptionDays(formName,field)
{
  eval("DaysObject = document." + formName + "." + field + "DD");
  eval("MonthObject = document." + formName + "." + field + "MM");
  eval("YearObject = document." + formName + "." + field + "YYYY");

  Month = MonthObject[MonthObject.selectedIndex].text;
  Year = YearObject[YearObject.selectedIndex].text;

  DaysForThisSelection = DaysInMonth(Month, Year);
  CurrentDaysInSelection = DaysObject.length - 1;

  if (CurrentDaysInSelection > DaysForThisSelection)
  {
    for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++)
    {
      DaysObject.options[DaysObject.options.length - 1] = null
    }
  }
  if (DaysForThisSelection > CurrentDaysInSelection)
  {
    for (i=0; i<(DaysForThisSelection-CurrentDaysInSelection); i++)
    {
      NewOption = new Option(DaysObject.options.length + 1,DaysObject.options.length + 1);
      DaysObject.appendChild(NewOption);
    }
  }
    if (DaysObject.selectedIndex < 0) DaysObject.selectedIndex == 0;
}

//function to set options to today
function SetToToday(formName,field)
{
  eval("DaysObject = document." + formName + "." + field + "Day");
  eval("MonthObject = document." + formName + "." + field + "Month");
  eval("YearObject = document." + formName + "." + field + "Year");

  YearObject[0].selected = true;
  MonthObject[NowMonth].selected = true;

  ChangeOptionDays();

  DaysObject[NowDay-1].selected = true;
}

//function to write option years plus x
function WriteYearOptions(YearsAhead,selected)
{
  var line = "";
	var endYear = 1900;
  for (i=NowYear; i>=endYear; i--){
		if(i == selected)
			line += "<option value=\"" + i + "\"  selected>" + i + "</option>";
    else
			line += "<option value=\"" + i + "\" >" + i + "</option>";
  }
  return line;
} 

