function getCookie(NameOfCookie){
  if (document.cookie.length > 0) {              
  begin = document.cookie.indexOf(NameOfCookie+"=");       
  if (begin != -1) {           
    begin += NameOfCookie.length+1;       
    end = document.cookie.indexOf(";", begin);
    if (end == -1) end = document.cookie.length;
      return unescape(document.cookie.substring(begin, end));
    } 
  }
  return null;
}

function setCookie(NameOfCookie, value, expiredays) {
  var ExpireDate = new Date ();
  ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
  document.cookie = NameOfCookie + "=" + escape(value) + 
  ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

function mod_graphics() { 
  obj = document.getElementById('pict');
  var num = (Math.round(Math.random() * 10)) + 10;
  newBg = 'url(images/pict' + num + '.jpg)';    
  if (preBg == newBg) { mod_graphics(); } else { obj.style.backgroundImage = newBg; }  
  return newBg;
}

function change_graphics() {
  preBg=getCookie('preBg');
  if (preBg==null) { setCookie('preBg','url(images/pict10.jpg)',null) }    
  newBg = mod_graphics();   
  setCookie('preBg',newBg,null);
}

function mod_dee() {
  obj = document.getElementById('deeimg');
  var num = (Math.round(Math.random() * 2)) + 2;
  newDee = 'images/dwe' + num + '.jpg';
  if (preDee == newDee) { mod_dee(); } else { obj.setAttribute("src", newDee); }
  return newDee;
}

function change_dee() {
  preDee=getCookie('preDee');
  if (preDee==null) { setCookie('preDee','url(images/dwe3.jpg)',null) }
  newDee = mod_dee();
  setCookie('preDee',newDee,null);
}

var num = 0;

function new_index() {
  var now = new Date();
  num = (now.getSeconds()) % 5;
}

function change_saying() {
  var sayings = new Array();

  sayings[0] = 'We have to keep moving forward (improve ourselves) because the world is changing everyday.';
  sayings[1] = 'One person at a time, one by one by one...';
  sayings[2] = 'Programs should focus on whole person instead of individual risks.';
  sayings[3] = 'Focus on whole person, not just their individual risks.';
  sayings[4] = 'Rather than fixing defects, we need to fix the process that produces the defects.';
  sayings[5] = 'We need to change the environment to help people to change.';

  new_index();

  document.getElementById("deeism").innerHTML = sayings[num];
}

function change_abstract() {
  var abstracts = new Array();

  abstracts[0] = 'Effect of Health Risk Appraisal Frequency on Change in Health Status';
  abstracts[1] = 'Effects of an Incentive-Based Online Physical Activity Intervention on Health Care';
  abstracts[2] = 'The Association between a Tiered Pharmacy Benefit Plan and Medication Usage, Health Status and Disability Absence Days';
  abstracts[3] = 'The Prevalence of Metabolic Syndrome in an Employed Population and the Impact on Health and Productivity';
  abstracts[4] = 'Association between Behavioral Intention and Actual Change for Physical Activity, Smoking and Body Weight among an Employed Population';
  abstracts[5] = 'Effectiveness of Employee Internet-Based Weight Management Program';

  new_index();

  document.getElementById("abstract").innerText = abstracts[num];
}
