function remoteLogin(spotlet) {
	var newPost = "http://" + spotlet + ".spotlets.com/login.php";
	document.spotletsLogin.action = newPost;
	document.spotletsLogin.submit();
}

function makePassword(obj) {
	var newO=document.createElement('input');
	newO.setAttribute('type','password');
	newO.setAttribute('size','15');
	newO.setAttribute('name',obj.getAttribute('name'));
	newO.setAttribute('id','password');
	obj.parentNode.replaceChild(newO,obj);
	newO.focus();
	newO.select();
}

function showForgot() {
	document.getElementById('loginBox').style.display = "none";
	document.getElementById('forgotBox').style.display = "block";
	document.getElementById('bottomText').innerHTML = "<a href='#' onclick='revert()'>try again?<\/a>";
}

function revert() {
	document.getElementById('loginBox').style.display = "block";
	document.getElementById('forgotBox').style.display = "none";
	document.getElementById('bottomText').innerHTML = "<a href='#' onclick='showForgot()'>forgot your password?<\/a>";
}

function passwordSent() {
	document.getElementById('loginLabel').style.display = "none";
	document.getElementById('resetLabel').style.display = "block";
	document.getElementById('loginBox').style.display = "block";
	document.getElementById('forgotBox').style.display = "none";
	document.getElementById('bottomText').innerHTML = "<a href='#' onclick='showForgot()'>forgot your password?<\/a>";
}

function clearField(loginField) {
	document.getElementById(loginField).value = "";
	document.getElementById(loginField).focus();
	document.getElementById(loginField).select();
}

function getCookieVal (offset) {
	  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
  endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
    return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
  return null;
}

function SetCookie (name, value) {
  var argv = SetCookie.arguments;
  var argc = SetCookie.arguments.length;
  var expires = (argc > 2) ? argv[2] : null;
  var path = (argc > 3) ? argv[3] : null;
  var domain = (argc > 4) ? argv[4] : null;
  var secure = (argc > 5) ? argv[5] : false;
  document.cookie = name + "=" + escape (value) +
   ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
   ((path == null) ? "" : ("; path=" + path)) +
   ((domain == null) ? "" : ("; domain=" + domain)) +
   ((secure == true) ? "; secure" : "");
}

function set_name(form) {
  var expdate = new Date ();
  expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000 * 31));
  var username = document.login_form.uid.value;
  if (username != "") {
      SetCookie ("editspot_username", username, expdate);
      window.history.go(0);
  }
 }

function getCookie(c_name) {
	if (document.cookie.length>0) {
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1) { 
			c_start=c_start + c_name.length+1; 
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return "";
}

function checkCookie() {
	username=getCookie('editspot_username');
	if (username!=null && username!="") {
		document.getElementById('uid').value = username;
		document.getElementById('reset').value = username;
		document.getElementById('password').focus();
		document.getElementById('password').select();
	}
}