// Validation for "free stampform"
function verifyIt(check){
df = document.freestamp;
if (document.images){
for (i=0;i<check.length;i++){
var tempobj=check.elements[i];
var jumpTo = df.elements[i];
if (tempobj.name.substring(0,3)=="req"){
if(((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex=="")||(tempobj.type == "checkbox" && !tempobj.checked)){
alert("Please complete ALL required fields or (in red) and re-submit the form."); 
jumpTo.focus();
return false;
}
}
}
if(df.reqAddlQuest.value.toLowerCase() != "stamp" || df.reqAddlQuest.value == ""){
alert('The answer is incorrect, please answer the question correctly and submit.');
df.reqAddlQuest.focus();
jumpTo.focus();
return false;
}
}
}
/*
function Ddown(){
df = document.freestamp;
if(df.frontArea1.value != "" && df.frontType1.options[0].selected){
alert('Please select phone number type for Phone 1');
df.frontType1.focus()
return false;
}
else if(df.frontArea2.value != "" && df.frontType2.options[0].selected){
alert('Please select phone number type for Phone 2');
df.frontType2.focus()
return false;
}
else if(df.frontArea1.value == "" && !df.frontType1.options[0].selected){
alert('You have selected a phone type for Phone 1, but not specified a number.\nPlease fill in the number or deselect the phone type');
df.frontType1.focus()
return false;
}
else if(df.frontArea2.value == "" && !df.frontType2.options[0].selected){
alert('You have selected a phone type for Phone 2, but not specified a number.\nPlease fill in the number or deselect the phone type');
df.frontType2.focus()
return false;
}
else
return true;
}

function Xtra(){ // Checks the Extra checkbox, and message 
df = document.freestamp;
if(df.ExtraMsg.checked && df.ExtraMsgWhat.value==""){
alert('Please indicate personal message');
df.ExtraMsgWhat.focus()
return false;
}
else if (!df.ExtraMsg.checked && !df.ExtraMsgWhat.value==""){
alert('You have indicated a personal message, please verify by checking the box');
df.ExtraMsg.focus()
return false;
}
return true;
}

function Pymnt() { // plows through the radios to see if one is checked
df = document.freestamp;
for(i=0; i<df.Payment.length; i++) {
var jumpTo = df.Payment[i];
if(df.Payment[i].checked) break;
}
if(i==df.Payment.length) { // yells if no radios are checked
alert('Please indicate form of payment for shipping fee');
jumpTo.focus()
return false;
}
return true;
}
if(!Pymnt())  // init Pymnt function 
return false;
}

if(!Xtra())  // init Xtra function 
return false;

if(!Ddown())  // init Xtra function 
return false;

}
}
// clears textbox
function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
}
*/

// validation for Current Client Form
function verifyCurr(check){
dc = document.CurrentClient;
if (document.images){
for (i=0;i<check.length;i++){
var tempobj=check.elements[i];
var jumpTo = dc.elements[i];
if (tempobj.name.substring(0,3)=="req"){
if(((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex=="")){
alert("Please complete ALL required fields (in red) and re-submit the form."); 
jumpTo.focus();
return false;
}
}
}
//if(dc.reqAddlQuest.value.toLowerCase() != "stamp" || dc.reqAddlQuest.value == ""){
//alert('The answer is incorrect, please answer the question correctly and submit.');
//dc.reqAddlQuest.focus()
//jumpTo.focus();
//return false;
//}
}
}

// Current Client ddown function - check if "Other is checked"
function dDownShip(){
dc = document.CurrentClient;
if(dc.reqShipType.options[3].selected){
alert('Please make sure to specify the Shipping Address below in the Special Instructions');
dc.specialInstructions.focus()
return false;
}
}




// Validation for "New Client Order"
function verifyNewOrder(check){
df = document.NewClient;
if (document.images){
for (i=0;i<check.length;i++){
var tempobj=check.elements[i];
var jumpTo = df.elements[i];
if (tempobj.name.substring(0,3)=="req"){
if(((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex=="")){
alert("Please complete ALL required fields (in red) and re-submit the form."); 
jumpTo.focus()
return false;
}
}
}

function Ddown(){
df = document.NewClient;
if(df.frontArea1.value != "" && df.frontType1.options[0].selected){
alert('Please select phone number type for Phone 1');
df.frontType1.focus()
return false;
}
else if(df.frontArea2.value != "" && df.frontType2.options[0].selected){
alert('Please select phone number type for Phone 2');
df.frontType2.focus()
return false;
}
else if(df.frontArea1.value == "" && !df.frontType1.options[0].selected){
alert('You have selected a phone type for Phone 1, but not specified a number.\nPlease fill in the number or deselect the phone type');
df.frontType1.focus()
return false;
}
else if(df.frontArea2.value == "" && !df.frontType2.options[0].selected){
alert('You have selected a phone type for Phone 2, but not specified a number.\nPlease fill in the number or deselect the phone type');
df.frontType2.focus()
return false;
}
else if(df.reqAddlQuest.value.toLowerCase() != "stamp" || df.reqAddlQuest.value == ""){
alert('The answer is incorrect, please answer the question correctly and submit.');
df.reqAddlQuest.focus()
return false;
}
else
return true;
}


function PayOption() { // plows through the radios to see if one is checked
df = document.NewClient;
for(i=0; i<df.price.length; i++) {
var jumpTo = df.price[0];
if(df.price[i].checked) break;
}
if(i==df.price.length) { // yells if no radios are checked
alert('Please indicate Payment Option: Single Unit or Prepay And Save Special');
jumpTo.focus()
return false;
}
return true;
}


function freeInfo() { // checks for values in free stamp form part if price is not "singleunit" (newclient.asp)
df = document.NewClient;
if(!df.price[0].checked) {
	if(df.freeName.value == "" || df.freeAddress.value == "" || df.freeCity.value == "" || df.freeState.value == "" || df.freeZip.value == ""){
		alert('Please fill out all Free Stamp Information');
		df.freeName.focus()
		return false;
		}
	}
	return true;
}



if(!PayOption())  // init Pymnt function 
return false;

if(!Ddown())  //  init Ddown
return false;

if(!freeInfo())  // init freeInfo
return false;
}
}



//this stuff is outside of validation finction
// clears textbox
function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
}

//shows/hides FREE stamo info in newclient.asp depending on 
function toggleVis(param)
{
if(param == false)
{
document.getElementById("freeForm").style.visibility = "visible";
document.getElementById("freeForm").style.display = "block";
param = true;
}
else
if(param == true)
{
document.getElementById("freeForm").style.visibility = "hidden";
document.getElementById("freeForm").style.display = "none";
document.getElementById("freeName").value = "";
document.getElementById("freeAddress").value = "";
document.getElementById("freeCity").value = "";
document.getElementById("freeState").value = "";
document.getElementById("freeZip").value = "";
param = false;
}
}



