var whiteboardscroll = 0;
function textScroll(v) {
    whiteboardscroll = v;
    var e = $('textcontent');
    e.setStyle({top: -v+'px'});
    e = $('scrolldownimg');
    if (e) {
      if (v == 0) {
	  e.src="/images/scrolldown.gif";
	  $('scrolldown2').innerHTML="See More";
      } else {
	  e.src="/images/scrollup.gif";
	  $('scrolldown2').innerHTML="Back to Top";
      }
    }
}

function scrolldown() {
    if (whiteboardscroll == 0) {
	$('textscrollthumb').setStyle({top: (h*460/$('actualcontent').offsetHeight)+'px'});
	textScroll(460);
    } else {
	$('textscrollthumb').setStyle({top: '0px'});
	textScroll(0);
    }
}

function scrollwheel(e) {
    e = e ? e : window.event;
    var v = e.detail ? e.detail : e.wheelDelta;
    pageslider.setValue(whiteboardscroll + v*2);
}

function setFormat(v) {
    if (v == 'raw') {
	$('rawdiv').display = "block";
	$('formdiv').display = "none";
    } else {
	$('rawdiv').display = "none";
	$('formdiv').display = "block";
    }
}

function toggleAnimation(v) {
    nextyear = new Date();
    nextyear.setFullYear(nextyear.getFullYear()+1);
    if (document.cookie.indexOf("skipanimation=1") != -1) {
	document.cookie = "skipanimation=0;path=/;expires="+nextyear.toGMTString();
	$('animationlabel').innerHTML = 'off';
	$('aniicon').src = '/images/animationon.gif';
    } else {
	document.cookie = "skipanimation=1;path=/;expires="+nextyear.toGMTString();
	$('animationlabel').innerHTML = 'on';
	$('aniicon').src = '/images/animationoff.gif';
    }
}

var jobroles = [
		0,
		['c21','c26','c210'],
		['c216', 'c25'],
		['c26','c217','c23'],
		['c214','c215','c22','c28','c27','c29'],
		['c25','c210'],
		['c212','c24','c26','c213'],
		['c27','c24'],
		['c29','c211'],
		['c27','c22'],
		0,
		];
function jobRole(i,v) {
    if (i == lastJobRole && v == 0) { 
      return; 
    }
    for (j = 0; j < jobroles[i].length; j++) {
	$(jobroles[i][j]).className = v?'itemb':'item';
    }
}
var lastJobRole = 0;
function setJobRole(i) {
    if (lastJobRole > 0) {
      for (j = 0; j < jobroles[lastJobRole].length; j++) {
	  $(jobroles[lastJobRole][j]).className = 'item';
      }
      $('c1'+lastJobRole).className = 'item2';
    }
    lastJobRole = i;
    for (j = 0; j < jobroles[i].length; j++) {
	$(jobroles[i][j]).className = 'itemb';
    }
    $('c1'+i).className = 'item2b';
}

function showEmp(t, v) {
  var y;
  if (v) {
    $(t+'h').hide();
    $(t+'b').show();
    y = $(t+'b').offsetTop;
  } else {
    $(t+'b').hide();
    $(t+'h').show();
    y = 0;
  }
  if (pageslider) {
    pageslider.dispose();
  }
  ah = $('actualcontent').offsetHeight;
  $('textscrollthumb').style.height = (h*h/ah)+'px';
  pageslider = new Control.Slider('textscrollthumb', 'textscroll', {
    axis: 'vertical',
    range: $R(0, ah - h),
    maximum: h,
    onSlide: textScroll,
    onChange: textScroll});
  pageslider.setValue(y);
}

function maybeClear(t, s) {
    var e = $(t);
    if (e.value == s) {
	e.value = "";
    }
    e.style.backgroundColor = '#ffffff';
    e.style.color = '#000000';
}

function maybeSet(t, s) {
    var e = $(t);
    if (e.value == '') {
	e.value = s;
    }
    e.style.backgroundColor = '#cccccc';
    e.style.color = '#ffffff';
}

function doSearch() {
    document.searchform.submit();
}
