function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

addLoadEvent(changeSecImg);


function changeSecImg() {
  img = (document.images && document.images.secimg) ? document.images.secimg :
        (document.getElementById && document.getElementById('secimg')) ? document.getElementById(secimg) :
        (document.getElementsByName && document.getElementsByName('secimg').length > 0) ? document.getElementsByName('secimg')[0] :
        (document.all && document.all['secimg']) ? document.all['secimg'] : '';
  if(img) {
    id = randomvalue(0,0xFFFFFF);
    img.src = 'secimg.php?id=' + id;
    document.form.secid.value = id;
    document.form.sectxt.value = "";
  }
}
function randomvalue(low, high) { return Math.floor(Math.random() * (1 + high - low) + low); }
