var statusmsg=""

function hidestatus(){
window.status=statusmsg
return true
}

function validateRegistrationReqFields() {
	pass = true;
	
	if (document.getElementById('txtFirstName').value == "") {
		pass = false;
		indicatorSwitch('alrtFirstName', 1);
	} else {
		indicatorSwitch('alrtFirstName', 0);
	}
	if (document.getElementById('txtLastName').value == "") {
		pass = false;
		indicatorSwitch('alrtLastName', 1);
	} else {
		indicatorSwitch('alrtLastName', 0);
	}
	if (document.getElementById('txtHomePhone').value == "") {
		pass = false;
		indicatorSwitch('alrtHomePhone', 1);
	} else {
		indicatorSwitch('alrtHomePhone', 0);
	}
	if (document.getElementById('txtEmailAddress').value == "") {
		pass = false;
		indicatorSwitch('alrtEmailAddress', 1);
	} else {
		indicatorSwitch('alrtEmailAddress', 0);
		if (!checkMail(document.getElementById('txtEmailAddress').value)) {
			alert('The email address you entered does not appear to be valid. Please check the address.');
			pass = false;	
		}
	}
	if (document.getElementById('txtDeliveryAddress').value == "") {
		pass = false;
		indicatorSwitch('alrtDeliveryAddress', 1);
	} else {
		indicatorSwitch('alrtDeliveryAddress', 0);
	}
	if (document.getElementById('txtDeliveryCity').value == "") {
		pass = false;
		indicatorSwitch('alrtDeliveryCity', 1);
	} else {
		indicatorSwitch('alrtDeliveryCity', 0);
	}
	if (document.getElementById('txtDeliveryState').value == "") {
		pass = false;
		indicatorSwitch('alrtDeliveryState', 1);
	} else {
		indicatorSwitch('alrtDeliveryState', 0);
	}
	if (document.getElementById('txtDeliveryZip').value == "") {
		pass = false;
		indicatorSwitch('alrtDeliveryZip', 1);
	} else {
		indicatorSwitch('alrtDeliveryZip', 0);
	}
	if (document.getElementById('txtRemitTo').value == "") {
		pass = false;
		indicatorSwitch('alrtRemitTo', 1);
	} else {
		indicatorSwitch('alrtRemitTo', 0);
	}
	if (document.getElementById('txtRemitAddress').value == "") {
		pass = false;
		indicatorSwitch('alrtRemitAddress', 1);
	} else {
		indicatorSwitch('alrtRemitAddress', 0);
	}
	if (document.getElementById('txtRemitCity').value == "") {
		pass = false;
		indicatorSwitch('alrtRemitCity', 1);
	} else {
		indicatorSwitch('alrtRemitCity', 0);
	}
	if (document.getElementById('txtRemitState').value == "") {
		pass = false;
		indicatorSwitch('alrtRemitState', 1);
	} else {
		indicatorSwitch('alrtRemitState', 0);
	}
	if (document.getElementById('txtRemitZip').value == "") {
		pass = false;
		indicatorSwitch('alrtRemitZip', 1);
	} else {
		indicatorSwitch('alrtRemitZip', 0);
	}
	
	return pass;
}

function checkMail(email)
{
	var x = email;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) return true;
	else return false;
}

function indicatorSwitch(valFieldIndicator, iState) // 1 visible, 0 hidden
{
try {
    if(document.layers) {
       document.layers[valFieldIndicator].visibility = iState ? "show" : "hide";
    } else if(document.getElementById) {
        var obj = document.getElementById(valFieldIndicator);
        obj.style.visibility = iState ? "visible" : "hidden";
    } else if(document.all) {
        document.all[valFieldIndicator].style.visibility = iState ? "visible" : "hidden";
    }
} catch(err) {
	//Do nothing
}
}

function getObject(obj) {
  var theObj;
  if(document.all) {
    if(typeof obj=="string") {
      return document.all(obj);
    } else {
      return obj.style;
    }
  }
  if(document.getElementById) {
    if(typeof obj=="string") {
      return document.getElementById(obj);
    } else {
      return obj.style;
    }
  }
  return null;
}

function Contar(entrada,salida,texto,caracteres) {
  var entradaObj=getObject(entrada);
  var salidaObj=getObject(salida);
  var longitud=caracteres - entradaObj.value.length;
  if(longitud <= 0) {
    longitud=0;
    texto='<span class="disable"> '+texto+' </span>';
    entradaObj.value=entradaObj.value.substr(0,caracteres);
  }
  salidaObj.innerHTML = texto.replace("{CHAR}",longitud);
}

function captureAgreement() {
	if (document.getElementById('chkAgreeToTerms').checked) {
		document.getElementById('completeLink').style.display = "inline";
	} else {
		document.getElementById('completeLink').style.display = "none";
	}
}

function sameAsAbove() {
	if (document.getElementById('chkSameAsAbove').checked) {
		document.getElementById('txtRemitAddress').value = document.getElementById('txtDeliveryAddress').value;
		document.getElementById('txtRemitCity').value = document.getElementById('txtDeliveryCity').value;
		document.getElementById('txtRemitState').value = document.getElementById('txtDeliveryState').value;
		document.getElementById('txtRemitZip').value = document.getElementById('txtDeliveryZip').value;
	} else {
		document.getElementById('txtRemitAddress').value = "";
		document.getElementById('txtRemitCity').value = "";
		document.getElementById('txtRemitState').value = "";
		document.getElementById('txtRemitZip').value = "";
	}
}