// AJAX Document

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() 
{
	if(document.topform.mode.value == "forgot_password")
	{
		word = document.frmPassword.username.value+","+document.frmPassword.random_number.value+",action=forgot_password";
	}
	if(document.topform.mode.value == "cusomter_login")
	{
		word = document.frmLogin.username.value+","+document.frmLogin.password.value+",action=cusomter_login"+",remembermeCookie="+document.frmLogin.rememberme.checked;
	}
	if(document.topform.mode.value == "customer_rating")
	{
		word = document.frmRating.tbrate.value+","+document.frmRating.product_id.value+",action=customer_rating";
	}

	qstr = 'word=' + escape(word);  // NOTE: no '?' before querystring
return qstr;
}

function updatepage(str)
{
	if(document.topform.mode.value == "forgot_password")
		set_div_id = document.frmPassword.div_id.value;
	
	if(document.topform.mode.value == "cusomter_login")
		set_div_id = document.frmLogin.div_id.value;
	
	if(document.topform.mode.value == "customer_rating")
		set_div_id = document.frmRating.div_id.value;
	
	if(str == '' || str == '<div class="msg"></div>')
		location.href="myaccount.html";
    
	document.getElementById(set_div_id).innerHTML = str;
}