//  =========================================
//   WebSAT JAVASCRIPT INLINE-EDITOR (V.2.1)
//    copyright 2006 off-ice applications
//  =========================================
var activeObj; //holds a reference to to focused editor

function changeFocus(obj) {
  var vis=obj.tagName!="DIV"?"none":"inline";
  for(i=1;i<6;i++) { document.getElementById("oiaedit"+i).style.display=vis; }
  activeObj=obj;
}

// rememebers the changes of an inline-editor field
function hasChanged(obj) {
  var proceed=true;
  if (window.event.keyCode==9) proceed=false;   //disable tabbing between controls
  if (obj.tagName!="DIV") {                     //block the following keyboard strokes for simple fields:
	if (window.event.shiftKey==false && window.event.keyCode==13) proceed=false; // enter (Shift+Enter as for <br> is OK)
	if (window.event.ctrlKey==true) proceed=false;                               // block all keyboard accellerators (Ctrl+_)
  }
  if (proceed==false) {
	cancelEvent();
  } else {
    changeField(obj);
} }

//changes an editor-field
function changeField(obj) {
  obj.style.borderColor="#00CC00";
  document.getElementById("oiaeditsave").style.display="inline";
}

//standard wrapper to cancel an event
function cancelEvent() {
  window.event.returnValue = false;
}

//one of the formatting buttons is clicked
function clickButton(what) {
    var tr = document.selection.createRange();
    if(what=="bold") tr.execCommand("Bold");
	if(what=="italic") tr.execCommand("Italic");
	if(what=="list") tr.execCommand("insertunorderedlist");
	if(what=="link") tr.execCommand("createlink");
	tr.select();
	activeObj.focus();
	changeField(activeObj);
}   

//saves the inline-editor changes and submits the form
function saveChanges() {
	for (var i = 0; i < document.oiaupdform.elements.length; i++) { //loop form elements
	  var f = document.oiaupdform.elements[i];
      var b = document.getElementById(f.id+"_box");
	  if (b) { 
	    if(b.style.borderColor=="#00cc00") { f.value=b.innerHTML; } //fill-in final HTML-code if field has changed (green border)
	} }
	document.oiaupdform.submit();                                   //submit form
}