function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}



// Dean Edwards/Matthias Miller/John Resig
function init() {
  if (arguments.callee.done) return;
  arguments.callee.done = true;
  if (_timer) {
      clearInterval(_timer);
      _timer = null;
  }
  if(document.getElementById) {
    anistock.addEvent(window, 'load', anistock.init, false);
  }
};
/* for Mozilla/Opera9 */
if (document.addEventListener) {
    document.addEventListener("DOMContentLoaded", init, false);
}

/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
    document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
    var script = document.getElementById("__ie_onload");
    script.onreadystatechange = function() {
        if (this.readyState == "complete") {
            init(); // call the onload handler
        }
    };
/*@end @*/

/* for Safari */
if (/WebKit/i.test(navigator.userAgent)) { // sniff
    var _timer = setInterval(function() {
        if (/loaded|complete/.test(document.readyState)) {
            init(); // call the onload handler
        }
    }, 10);
}

/* for other browsers */
window.onload = init;
var anistock = {
  init: function() {
    anistock.liveForm = null;
    var login = document.getElementById('login_link');
    anistock.addEvent(login, 'click', anistock.toggleLogin, false);
		anistock.stopSafari(this.toggleLogin);
  },
  toggleLogin : function(e) {
    // first check to see if either form is open
    if(!anistock.liveForm || anistock.liveForm == 'login') {
      anistock.setDisplay('login_message');
      anistock.setDisplay('frm_login');
      if(anistock.liveForm == 'login') {
        anistock.liveForm = null;
      } else {
        anistock.liveForm = 'login';
      }
    }

    anistock.stopPropagation(e);
    return false;
  },

  setDisplay : function(el) {
    target = document.getElementById(el);
    if(target.style.display == 'inline') {
      target.style.display = 'none';
    } else {
      target.style.display = 'inline';
    }
  },
	stopSafari : function(el) {
//		el.onclick = function() { return false; }; // Safari
	},
	stopPropagation : function(e) {
		if (window.event){
			window.event.cancelBubble = true;
			window.event.returnValue = false;
			return;
		}
		if(e) {
			e.stopPropagation();
			e.preventDefault();
		}
	},
	addEvent: function(elm, evType, fn, useCapture) {
		if(elm.addEventListener) {
			elm.addEventListener(evType, fn, useCapture);
			return true;
		}
    else if(elm.attachEvent) {
			var r = elm.attachEvent('on' + evType, fn);
			return r;
		}
    else {
			elm['on' + evType] = fn;
		}
	}
}