//custom checkbox
check = []; //this is an array that stores all the true/false values for each checkbox
function checkBox(id)	{
if(check[id] != true) //if a value is not true, use this rather than == false, 'cos the first time no value will be set and it will be undefined, not true or false
	{
	document.getElementById('imgCheck' + id).src = "../img/interface/checkbox_ticked.gif"; //change the image
	document.getElementById('inputCheck' + id).value = "true"; //change the field value
	check[id] = true; //change the value for this checkbox in the array
	}
else
	{
	document.getElementById('imgCheck' + id).src = "../img/interface/checkbox.gif";
	document.getElementById('inputCheck' + id).value = "false";
	check[id] = false;
	}
}
function checkBox_blue(id)	{
if(check[id] != true) //if a value is not true, use this rather than == false, 'cos the first time no value will be set and it will be undefined, not true or false
	{
	document.getElementById('imgCheck' + id).src = "../img/interface/checkbox_ticked_blue.gif"; //change the image
	document.getElementById('inputCheck' + id).value = "true"; //change the field value
	check[id] = true; //change the value for this checkbox in the array
	}
else
	{
	document.getElementById('imgCheck' + id).src = "../img/interface/checkbox_blue.gif";
	document.getElementById('inputCheck' + id).value = "false";
	check[id] = false;
	}
}
function checkBox_radio(id)	{
if(check[id] != true) //if a value is not true, use this rather than == false, 'cos the first time no value will be set and it will be undefined, not true or false
	{
	document.getElementById('imgCheck' + id).src = "_img/cirkel_8C8C77.gif"; //change the image
	document.getElementById('inputCheck' + id).value = "true"; //change the field value
	check[id] = true; //change the value for this checkbox in the array
	}
else
	{
	document.getElementById('imgCheck' + id).src = "_img/cirkel_FFFFFF.gif";
	document.getElementById('inputCheck' + id).value = "false";
	check[id] = false;
	}
}
function checkBox_radio_on(id)	{
	document.getElementById('imgCheck' + id).src = "_img/cirkel_8C8C77.gif"; //change the image
	document.getElementById('inputCheck' + id).value = "true"; //change the field value
	check[id] = true; //change the value for this checkbox in the array
}

function checkBox_radio_off(id)	{
	document.getElementById('imgCheck' + id).src = "_img/cirkel_FFFFFF.gif";
	document.getElementById('inputCheck' + id).value = "false";
	check[id] = false;
}

//end custom checkbox

//coloured buttons
function changeBorderStyle(widget, style){
  widget.style.borderStyle=style;
  return false;
}
//end coloured buttons
//custom pulldown
function selectReplacement(obj) {
      var previousclassname=obj.className;
      var ul = document.createElement('ul');
      ul.className =previousclassname + 'selectReplacement';
	  obj.className += ' replaced';
	  ul.onclick = function() {
		 //alert(obj.id);
		 thisDiv=obj.id;
		prevDiv= document.getElementById(thisDiv)[0].parentNode.parentNode.id;
		if(prevDiv=="letterstop") {
			//test=document.getElementById('lettersbottom').style.display;
			toggleDiv2('lettersdown',0);
		}
		//alert(prevDiv);
		//document.getElementById('');
	  }
      var opts = obj.options;
      for (var i=0; i<opts.length; i++) {
        var selectedOpt;
        if (opts[i].selected) {
          selectedOpt = i;
          break;
        } else {
          selectedOpt = 0;
        }
      }
      for (var i=0; i<opts.length; i++) {
        var li = document.createElement('li');
        var txt = document.createTextNode(opts[i].text+"");
        li.appendChild(txt);
        li.selIndex = opts[i].index;
        li.selectID = obj.id;
        li.onclick = function() {
          selectMe(this);
        }
        if (i == selectedOpt) {
          li.className = 'selected';
          li.onclick = function() {
            this.parentNode.className += ' selectOpen';
            this.onclick = function() {
			  selectMe(this);
            }
          }
        }
        if (window.attachEvent) {
          li.onmouseover = function() {
            this.className += ' hover';
          }
          li.onmouseout = function() {
            this.className = 
              this.className.replace(new RegExp(" hover\\b"), '');
          }
        }
        ul.appendChild(li);
      }
      obj.parentNode.insertBefore(ul,obj);
    }
    function selectMe(obj) {
      var lis = obj.parentNode.getElementsByTagName('li');
      for (var i=0; i<lis.length; i++) {
        if (lis[i] != obj) {
          lis[i].className='';
          lis[i].onclick = function() {
            selectMe(this);
          }
        } else {
          setVal(obj.selectID, obj.selIndex);
		  
          obj.className='selected';
          obj.parentNode.className = obj.parentNode.className.replace(new RegExp(" selectOpen\\b"), '');
          obj.onclick = function() {
            obj.parentNode.className += ' selectOpen';
            this.onclick = function() {
              selectMe(this);
            }
          }
        }
      }
    }
    function setVal(objID, selIndex) {
      var obj = document.getElementById(objID);
      obj.selectedIndex = selIndex;
	 // alert(obj.value);
	  window.location.href = obj.value;
    }
    function setForm() {
      var s = document.getElementsByTagName('select');
      for (var i=0; i<s.length; i++) {
        selectReplacement(s[i]);
      }
    }
    window.onload = function() {
      (document.all && !window.print) ? null : setForm();
    }
	//end custom pulldown