
// ajax loading swirl for B8D0E5 background
var loadingGraphicB8D0E5 = '<img src="' + imgDir + '/store/ajax_loader_B8D0E5.gif" alt="loading" />';

var img1 = new Image;
img1.src = imgDir + '/store/ajax_loader_B8D0E5.gif';

function affiliationLearnMore () {

	trackClick(storeURL + '/affiliate/tellmemore');

	window.open(storeURL + '/affiliation/help', 'affiliationHelpPopup',
	'height = 600, width = 400, scrollbars = 1');

}

function termsPopup () {

	window.open( storeURL + '/ajax/terms', 'termsPopup',
	'height = 600, width = 730, scrollbars = 1')

}

function licensePopup (type) {

	window.open( storeURL + '/ajax/license/' + type, 'licensePopup',
	'height = 600, width = 730, scrollbars = 1')

}

function checkCustomerID(form) {

	var xmlHttp=getXmlHttpObject()

	xmlHttp.onreadystatechange = function() {

		if (xmlHttp.readyState == 4) {

			//alert(xmlHttp.responseText);return false;

			if (xmlHttp.responseText == 'success') {

				form.submit();

				return true;

			} else {

				document.getElementById('oldMaterialsLoginLoader').innerHTML = '';

				var msg = xmlHttp.responseText.split('|');

				if (msg[1]) {

					document.getElementById('oldMaterialsLoginText').innerHTML = msg[1];

				} else {

					document.getElementById('oldMaterialsLoginText').innerHTML = msg[0];

				}

				return false;
			}

		} else {
			document.getElementById('oldMaterialsLoginLoader').innerHTML = loadingGraphicB8D0E5;
		}
	}

	var url = siteURL;

	url=url+'/login/checkcustomeridajax';

	var customerID = escape(form.customerID.value);

	// For some reason, this variable is not being instantiated properly in
	// header.2.tpl.html.
	//var redirectURL = escape(storePageURL);

	var redirectURL = '/materials';

	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send('customerID=' + customerID + '&redirectURL=' + redirectURL);

	return false;

}
