﻿function resizeIT(el)
{
    var h, w;
    h = el.height;
    w = el.width;
    if (w > 100)
    {
        el.className = '';
        h = parseInt(h*(100/w));
        el.height = h;
        el.width = 100;
    }
}
function ChangeFoto(src)
{
	var foto;
	foto = document.getElementById("bigFoto");
	foto.style.display = 'none';
	foto.src = src;
	foto.style.display = 'inline';
}
function RemoveText(ctrl, origValue, pass)
{
    if (ctrl.value == origValue)
    {
        ctrl.value = '';
    }
}
function AddText(ctrl, origValue)
{
    if (ctrl.value == '')
    {
        ctrl.value = origValue;
    }
}

function changeInputType(oldElm,iType,iValue,noFocus) {
  if(!oldElm || !oldElm.parentNode || (iType.length<4) || 
    !document.getElementById || !document.createElement) return;
  var newElm = document.createElement('input');
  newElm.type = iType;
  if(oldElm.name) newElm.name = oldElm.name;
  if(oldElm.id) newElm.id = oldElm.id;
  if(oldElm.className) newElm.className = oldElm.className;
  newElm.onfocus = function() {
    if(this.hasFocus) return;
    if(this.value =='' || this.value.toLowerCase()==iValue.toLowerCase()) 
    {
        var newElm = changeInputType(this,'password', iValue, false);
        if(newElm) newElm.hasFocus=true;
    }
  }
  newElm.onblur = function() {
    if(this.hasFocus)
    if(this.value=='' || this.value.toLowerCase()==iValue.toLowerCase()) {
      changeInputType(this,'text',iValue,true);
    }
  }
 
  newElm.hasFocus=false;
  oldElm.parentNode.replaceChild(newElm,oldElm);
  if(iValue) newElm.value = iValue;
  
  if(oldElm.value == iValue) newElm.value = '';
  
  if(!noFocus || typeof(noFocus)=='undefined') {
    window.tempElm = newElm;
    setTimeout("tempElm.hasFocus=true;tempElm.focus();",1);
  }
  return newElm;
}
