if(dom.browser()=='ie') {
  dom.loadStyle('css/ie.css');
}

function fixFooter() {
  var avail_h = dom.getViewportDimensions().height;
  var page_h = dom.el('pageholder').offsetHeight;
  if(page_h < avail_h) {
    dom.el('pageholder').style.height = '100%';
    dom.el('page').style.height = '100%';
    dom.el('footer').style.position = 'absolute';
    dom.el('footer').style.bottom = '0px';
  } else {
    dom.el('pageholder').style.height = 'auto';
    dom.el('page').style.height = 'auto';
    dom.el('footer').style.position = 'static';
  }
}

dom.addEvent(window,'load',fixFooter);
dom.addEvent(window,'resize',fixFooter);

function getCookie(name){
    var cookie=' '+document.cookie;
    var search=' '+name+'=';
    var setStr=null;
    var offset=0;
    var end=0;
    if(cookie.length>0){
        offset=cookie.indexOf(search);
        if(offset!=-1){
            offset+=search.length;
            end=cookie.indexOf(';',offset);
            if(end==-1){
                end=cookie.length;
            }
            setStr=unescape(cookie.substring(offset,end));
        }
    }
    return(setStr);
};
function setCookie(name,value,expires,path,domain,secure){
    exp=expires?expires:'01-Jan-2038 12:00:00 GMT';
    document.cookie=name+'='+escape(value)+((expires)?'; expires='+expires:'')+((path)?'; path='+path:'')+((domain)?'; domain='+domain:'')+((secure)?'; secure':'');
};
function deleteCookie(name,path,domain){
  if(getCookie(name))document.cookie=name+"="+((path)?";path="+path:"")+((domain)?";domain="+domain:"")+";expires=Thu, 01-Jan-1970 00:00:01 GMT";
};

function popup(url,w,h) {
   if(!w) w=400;
   if(!h) h=350;
   if(screen.width) x = (screen.width-w)/2;
   if(screen.height) y = (screen.height-h)/2;
   identity_window=window.open(url, "Check", "width="+w+",height="+h+",resizable=yes"+(x?(",screenX="+x):"")+(y?(",screenY="+y):""));
   identity_window.focus();
   return false;
}


var submitButtonFix = function() {
  /*
  * watch over text input fields and submit their form, when they are focussed and enter is pressed
  */
  var inputs = document.getElementsByTagName('input');
  for (var i=0; i<inputs.length; i++) {
    var inp = inputs[i];
    if(inp['type']=='password'){
      inp.checkKey = function(e) {
        var code;
        if(e && e.which){e = e;code = e.which;}else{e = event;code = e.keyCode;}
        if(code == 13){if(this.form){this.form.submit();} }
      };
      inp.watchMe = function() {this.onkeyup = this.checkKey};
      inp.unwatchMe = function() {this.onkeyup = null};
      dom.addEvent(inp, 'focus',  inp.watchMe);
      dom.addEvent(inp, 'blur',   inp.unwatchMe);
    }
  }
}
dom.addEvent(window,'load',submitButtonFix);

/* sets width for an element, used in age_ver pic step 2*/
function maxwidth(el, w) {
  if(el.offsetWidth>w) {
    el.style.height = 'auto';
    el.style.width = w +'px';
  }
}
