
function popup(URL, width, height) {
	var winl = (screen.width - width) / 2;
	var wint = (screen.height - height) / 2;
	day = new Date();
	id = day.getTime();
	window.open(URL, id, 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=' + width + ',height=' + height + ',left=' + winl + ',top=' + wint);
}

function popout(URL, width, height) {
	var winl = (screen.width - width) / 2;
	var wint = (screen.height - height) / 2;
	day = new Date();
	id = day.getTime();
	window.open(URL, id, 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=' + width + ',height=' + height + ',left=' + winl + ',top=' + wint);
}


function helppopup(topic) {
	popup('/helppopup.asp?Topic='+topic, 400, 300);
}

function checkIfNumber(key) {

	// control keys
	if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 || key==37 || key==39 || key==46)
	   return true;

	if (!isNaN(String.fromCharCode(key)) && key != 32)
		return true;

	if (key >= 96 && key <= 105)
		return true;

	return false;

}

function toggleDisplay(showHideObject) {
	if (showHideObject.style.display == '') {
		showHideObject.style.display = 'none';
	}
	else {
		showHideObject.style.display = '';
	}
}

function displayShow(showhideobject) {
	showhideobject.style.display = '';
}

function displayHide(showhideobject) {
	showhideobject.style.display = 'none';
}

// getCCType()
// Figure CC Type and return string

function getCCType(ccnumber) {

	if (ccnumber != '' & ccnumber.length >= 4) {
		left4 = ccnumber.substr(0, 4);
		left4 = parseInt(left4);
		if ((left4 >= 3000 && left4 <= 3059) || (left4 >= 3600 && left4 <= 3699) || (left4 >= 3800 && left4 <= 3899)) {
			return "Diners Club";
		} else if ((left4 >= 3400 && left4 <= 3499) || (left4 >= 3700 && left4 <= 3799)) {
			return "American Express";
		} else if (left4 >= 3528 && left4 <= 3589) { 
			return "JCB";
		} else if (left4 >= 3890 && left4 <= 3899) {
			return "Carte Blanche";
		} else if (left4 >= 4000 && left4 <= 4999) {
			return "Visa";
		} else if (left4 >= 5100 && left4 <= 5599) {
			return "MasterCard";
		} else if (left4 == 5610) {
			return "Australian BankCard";
		} else if (left4 == 6011) {
			return "Discover/Novus";
		}
	}
	return '';
}

function enteringCCMessage(ccnumber) {
	cc = getCCType(ccnumber);
	if (cc != '') {
		return ' Entering card type: ' + cc;
	}
	return '';
}
