/* =========================================================================

JavaScript Source File -- Created with SAPIEN Technologies PrimalScript 4.1

NAME: 

AUTHOR: Nickolai Nickolov , Nickotrend
DATE  : 7/26/2007

COMMENT: 

============================================================================ */
function LoginCustomer () {
	xmlhttpPost('customer_login_process.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) {
           
            updatepage(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send(getquerystring());
} 	


function getquerystring() {

	var EmailAddress = document.getElementById('EmailAddressLogin').value;
	var Password = document.getElementById('Password').value; 
    qstr = 'EmailAddress=' + escape(EmailAddress) + '&Password=' + escape(Password)

	return qstr;
}

function updatepage(CustomerID){
	if (CustomerID!=='0') {	
		document.getElementById('CustomerID').value = CustomerID;
		dojo.widget.byId("tabReturningCustomer").setUrl("shipping_addresses.asp?CustomerID=" + CustomerID);
		document.getElementById('BillingAddress').checked=false;
		document.getElementById('trBilling').style.display='none';
	}
	else {
		document.getElementById('InvalidLogin').style.display='block';
	}

}

function ShowContactInfo() {
	dojo.widget.byId('Customer').show();
}