
// Password Reminder

function xmlhttpPost2(strURL) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send(getquerystring2());
}

function getquerystring2() {
    var form     = document.forms['login'];
    var email = form.email.value;

    
    qstr = 'email=' + escape(email) + '&do=ajaxemailpass';  // NOTE: no '?' before querystring
    return qstr;
}



//---------------------------------------------------




function xmlhttpPost(strURL) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send(getquerystring());
}

function getquerystring() {
    var form     = document.forms['login'];
    var username = form.username.value;
    var password = form.password.value;

    
    qstr = 'username=' + escape(username) + '&do=loginlimited&password=' +  escape(password) ;  // NOTE: no '?' before querystring
    return qstr;
}

function updatepage(str){
    document.getElementById("logindiv").innerHTML = str;
}


function tryagain() {

	var str = '  <div id="logindiv"><form name="login" id="login" method="post"><div class="ibseparate"><label>Username: </label><input class="inputbox" type="text" size="15" name="username" /></div><div class="ibseparate"><label>Password: </label><input class="inputbox" type="password" size="15" name="password" /></div><div class="ibseparate"><input  class="abutton" size="15" name="submit" value="login"  type="button" onclick=\'JavaScript:xmlhttpPost("/app/user.cgi")\' /><input name="do" type="hidden" id="do" value="userlogin">        </div></form>';
    
    document.getElementById("logindiv").innerHTML = str;

}


function remindme() {

	var str = '  <div id="logindiv"><form name="login" id="login" method="post"><div class="ibseparate"><label>Email Address: </label><input class="inputbox" type="text" size="30" name="email" /></div><div class="ibseparate"></div><div class="ibseparate"><input  class="abutton" size="15" name="submit" value="login"  type="button" onclick=\'JavaScript:xmlhttpPost2("/app/user.cgi")\' /><input name="do" type="hidden" id="do" value="ajaxemail">        </div></form>';
    
    document.getElementById("logindiv").innerHTML = str;

}



function Set_Cookie( name, value, expires, path, domain, secure ) 
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct 
expires time, the current script below will set 
it for x number of days, to make it for hours, 
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
( ( path ) ? ";path=" + path : "" ) + 
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}