////////////////////////////////////////////////
// This script will protect this file
// from being accessed from outside the allowed domains
// [electrified.com] and [electrifieddiscounters.com]
//
// If you've downloaded this file purposely, good for you!
// We don't mind sharing our source code but not our bandwidth.
////////////////////////////////////////////////
var accepted_domains=new Array("electrified.com","http://Desktop","electrifieddiscounters.com","server","localhost","http://68.63.102.173/electrifieddiscounters","electrified.clientstaging.com")

//retrieve the current URL of user browser
var domaincheck=document.location.href

//set acess to false by default
var accepted_ok=false

//if this is a http request
if (domaincheck.indexOf("http")!=-1){ 
for (r=0;r<accepted_domains.length;r++){

//if a match is found
if (domaincheck.indexOf(accepted_domains[r])!=-1){ 

//set access to true, and break out of loop
accepted_ok=true 
break
}
}
}
else
accepted_ok=true

if (!accepted_ok){
//alert("WARNING:\nThis website is illegally attempting to use source code.\n\nhttp://www.MadisonColby.com")
//history.back(-1)
}
////////////////////////////////////////////////
// Function SetDefaultStatusBar()
// Sets the default text for the status bar.
////////////////////////////////////////////////
	function SetDefaultStatusBar()
	{
	window.status = "Electrified Discounters, Inc.  Micro-Computer Products & Consumer Electronics.";
	}
////////////////////////////////////////////////
// Function SetCustomStatusBar()
// Sets a custom message in the status bar.
// Incase we don't want to use the Default status bar.
////////////////////////////////////////////////
	function SetStatusBar(CustomMessage)
	{
	window.status = (CustomMessage)
	}
////////////////////////////////////////////////
// OpenNewWindow()
// Opens a new browser pop up window
////////////////////////////////////////////////
function Display(URL,WindowName,AllowedFeatures)
{
  window.open(URL,WindowName,AllowedFeatures);
}
////////////////////////////////////////////////
// checkCapsLock()
// Checks to see if the user has Caps Lock on
// This is for user registration or password entry
////////////////////////////////////////////////
function checkCapsLock( e ) {
	var myKeyCode=0;
	var myShiftKey=false;
	var myMsg='Is your Caps Lock key On?\n\nTo help prevent entering your password incorrectly,\nyou should press the Caps Lock key to turn it off.\n\nIf you wish to use capaital letters, please use [SHIFT + Letter].';

	// Internet Explorer 4+
	if ( document.all ) {
		myKeyCode=e.keyCode;
		myShiftKey=e.shiftKey;

	// Netscape 4
	} else if ( document.layers ) {
		myKeyCode=e.which;
		myShiftKey=( myKeyCode == 16 ) ? true : false;

	// Netscape 6
	} else if ( document.getElementById ) {
		myKeyCode=e.which;
		myShiftKey=( myKeyCode == 16 ) ? true : false;

	}

	// Upper case letters are seen without depressing the Shift key, therefore Caps Lock is on
	if ( ( myKeyCode >= 65 && myKeyCode <= 90 ) && !myShiftKey ) {
		alert( myMsg );

	// Lower case letters are seen while depressing the Shift key, therefore Caps Lock is on
	} else if ( ( myKeyCode >= 97 && myKeyCode <= 122 ) && myShiftKey ) {
		alert( myMsg );
		

	}
}
//////////////////////////////////////////////////////////////////////
// function currencyFormat(fld, milSep, decSep, e)
// This function formats a text field to ensure that the currency fields
// are entered in the proper format
//////////////////////////////////////////////////////////////////////
function currencyFormat(fld, milSep, decSep, e) {
	var sep = 0;
	var key = '';
	var i = j = 0;
	var len = len2 = 0;
	var strCheck = '0123456789';
	var aux = aux2 = '';
	var whichCode = (window.Event) ? e.which : e.keyCode;
		if (whichCode == 13) return true;  // Enter
			key = String.fromCharCode(whichCode);  // Get key value from key code
		if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
			len = fld.value.length;
				for(i = 0; i < len; i++)
					if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
						aux = '';
				for(; i < len; i++)
					if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
						aux += key;
						len = aux.length;
		if (len == 0) fld.value = '';
		if (len == 1) fld.value = '0'+ decSep + '0' + aux;
		if (len == 2) fld.value = '0'+ decSep + aux;
		if (len > 2) {
				aux2 = '';
				for (j = 0, i = len - 3; i >= 0; i--) {
					if (j == 3) {
				aux2 += milSep;
				j = 0;
	}
						aux2 += aux.charAt(i);
						j++;
	}
			fld.value = '';
			len2 = aux2.length;
				for (i = len2 - 1; i >= 0; i--)
				fld.value += aux2.charAt(i);
				fld.value += decSep + aux.substr(len - 2, len);
	}
		return false;
	}
	
//////////////////////////////////////////////////////////////////////
// Enable the process order button
// if the user has accepted the terms
// and conditions of sale.
//////////////////////////////////////////////////////////////////////
	function AcceptTermsAndConditions(form)
	{
	if (form.cbAcceptTerms.checked)
		{
		form.btnProcessOrder.disabled=false
		}
	else
		{
		form.btnProcessOrder.disabled=true
		}
	}
	
//////////////////////////////////////////////////////////////////////
// Disable the credit card fields if the user chooses
// paypal as a payment method
//////////////////////////////////////////////////////////////////////
function CheckPaymentMethod() 
{ 

	if (eval("document.frmBilling.rblPaymentMethods[4].checked")) 
			{ 
			document.frmBilling.txtCCNumber.disabled=true
			document.frmBilling.ddlCCExpMonth.disabled=true
			document.frmBilling.ddlCCExpYear.disabled=true
			document.frmBilling.txtFullNameOnCard.disabled=true
			document.frmBilling.txtCCCustomerServiceNumber.disabled=true
			document.frmBilling.txtSICCode.disabled=true
			tblCreditCardInformation.style.display="none"
			} 
		else
			{
			document.frmBilling.txtCCNumber.disabled=false
			document.frmBilling.ddlCCExpMonth.disabled=false
			document.frmBilling.ddlCCExpYear.disabled=false
			document.frmBilling.txtFullNameOnCard.disabled=false
			document.frmBilling.txtCCCustomerServiceNumber.disabled=false
			document.frmBilling.txtSICCode.disabled=false
			tblCreditCardInformation.style.display=""

			}
} 
//////////////////////////////////////////////////////////////////////
//  Check Credit card fields if paypal is not used as a payment method
//////////////////////////////////////////////////////////////////////
function ValidateCreditCard()
{
	// IF LTL, there is no [4] - Causes Error on load
	if (!eval("document.frmBilling.rblPaymentMethods[4].checked")) 
{
	if (document.frmBilling.txtCCNumber.value == "" || document.frmBilling.txtSICCode.value == "" || document.frmBilling.txtFullNameOnCard.value == "" || document.frmBilling.txtCCCustomerServiceNumber.value == "")
	{
		alert('Missing Required Fields\n\nPlease note all required credit card fields marked with a red (*).');
		return false;
	}
}
}




