/* The following script is owned by media-i 2006 */
/* You may not use this without the permission of media-i in any digital form */


function createRequestObject(){
         var http_request = false;

        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                // See note below about this line
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
        return http_request; //return the object

}

/* Function called to get the product categories list */
function getmyPassword(){
        /* Create the request. The first argument to the open function is the method (POST/GET),
                and the second argument is the url...
                document contains references to all items on the page
                We can reference document.form_category_select.select_category_select and we will
                be referencing the dropdown list. The selectedIndex property will give us the
                index of the selected item.
        */

        http.open('post','getpassword.php');
        /* Define a function to call once a response has been received. This will be our
                handleProductCategories function that we define below. */
        http.onreadystatechange = passwordreminder;
        /* Send the data. We use something other than null when we are sending using the POST
                method. */
        /* use this for the post method */
        http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

        // get the data from the login html form changes variables according to the data comming in from the form
        usernameold=document.login2.usernameold.value;


        http.send('usernameold='+usernameold);

}

/* Function called to handle the list that was returned from the internal_request.php file.. */
function passwordreminder(){
        /* Make sure that the transaction has finished. The XMLHttpRequest object
                has a property called readyState with several states:
                0: Uninitialized
                1: Loading
                2: Loaded
                3: Interactive
                4: Finished */
				if(http.readyState != 4 ) {
        		document.getElementById("loading").style.display = 'block';
        }
        if(http.readyState == 4){ //Finished loading the response
                /* using the responseText property of
                        the XMLHttpRequest object. */
                var response = http.responseText;
                /* And now we want to change the  <div> content.
                        we do this using an ability to get/change the content of a page element
                        that we can find: innerHTML. */
				document.getElementById("login").style.display = 'none';
				document.getElementById("loading").style.display = 'none';
                document.getElementById('passwordoutput').innerHTML = response;
                                /* Check to see if the response to login was successfull by testing the returning string */
                                
                                
        }
}

/* The variable http will hold our new XMLHttpRequest object. */
        var http = createRequestObject();
 /* use to supree form sending on the action parameter */

 function validate(){
  return false;
 }
 
 function clear_response() {
	 document.getElementById('passwordoutput').innerHTML = ""
	 document.getElementById('loginmessage').innerHTML = ""
 }
/* clean up pointer variables */
window.onunload = freemem;

function freemem() {
	
	http = null;

}