/* =========================================================================

JavaScript Source File -- Created with SAPIEN Technologies PrimalScript 4.1

NAME: 

AUTHOR: Nickolai Nickolov , Nickotrend
DATE  : 8/6/2007

COMMENT: 

============================================================================ */

function ShowSendPassword() {
	dojo.widget.byId('PasswordDialog').show();
}

function HidePasswordDialog() {
	dojo.widget.byId('PasswordDialog').hide();
	document.getElementById('Message').innerHTML='Must be a valid email address registered with our sustem.';
}

function SendPassword () {
	document.getElementById('Message').innerHTML='Processing...';
	xmlhttpPost('send_password.asp');
}

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) {
        	var str = self.xmlHttpReq.responseText.split("|");
  
           if (str[0]=='1') {
            	alert('Password sent.\nPlease check your mail.');	
            	HidePasswordDialog();
            }
            else {
            	document.getElementById('Message').innerHTML='No active account for this email address.';
            }
            
            
        }
    }
    self.xmlHttpReq.send(getquerystring());
} 


function getquerystring() {

	var EmailAddress = document.getElementById('SendEmailAddress').value;
    qstr = 'EmailAddress=' + escape(EmailAddress)

	return qstr;
}
