function tos_valid(decide){ // start function
if ( decide == 'no' ) { // if(decide)
// start if/else  --  old --  Well, now that you have read it, and selected 'No' I have to ask:\n
if (confirm("Are you sure?\nSelect 'Ok' to consent to the TOS and Register, or 'Cancel' to leave the Registration System.")){
document.forms.f1.step.value=2;
document.forms.f1.submit();
} else {
document.location.href = 'index.php'
} // end if/else
} else {
document.forms.f1.step.value=2;
document.forms.f1.submit();
return true;
} // end if(decide)
} // end function

function re_edit(newAction){ // start function
document.forms.f1.action = newAction;
document.forms.f1.submit();
} // end function

function check_step2(){ // start function
var inputArray = new Array('s_fname','s_lname','s_address1','s_city','s_zip','s_phone','s_email','s_security_answer');
var textArray = new Array('First Name','Last Name','Street Address','City','Zip','Phone','E-Mail','Security Answer');
var baseText = "You have neglected to fill out essential parts of this form\nPlease check the following:\n";
var tempVal = '';
var toStep3 = true;

for (var i=0;i<inputArray.length;i++){
tempVal = eval('document.forms.f1.'+inputArray[i]+'.value');
if (tempVal.length < 2 || tempVal == ''){
baseText = baseText + textArray[i] + "\n";
toStep3 = false;
} // endif
} // endfor

if (toStep3 == true){
return true;
} else {
alert(baseText);
return false;
} // endif

} // end function


function testform(inputs,regexs,messages){ // start function testform
var arrayCount = inputs.length;

var message = "Your data entry includes the following errors:\n\n";
var pass = true;

for (xx=0;xx<arrayCount;xx++){
name = inputs[xx];
eval('regx = ' + regexs[xx]);
// alert (name + ': ' + test);
tempval = eval('document.forms.f1.'+name+'.value');
if (regx.test(tempval)){
} else {
message += messages[xx] + "\n";
pass = false;
}
} // end for
if (pass == false){ // start if
alert (message);
} else if (pass == true) {
document.forms.f1.submit();
}// end if
} // end function testform

function showcard (side,picture){ // start function 
var dropindex = eval('document.forms.f1.' + side + '_manufacturer.selectedIndex');
if(dropindex == 0) { // start if 1
alert ('You must first select a manufacturer from the dropdown to use this function');
} else { 
var dropval = eval('document.forms.f1.' + side + '_manufacturer.options[' + dropindex + '].value');
NewWindow('showcard.php?id=' + dropval + '_' + picture,'card',480,480,'true');
} // end if 1
} // end function 

function showdef(num,side){ // start function 
NewWindow('showdef.php?id=' + num,'def',480,240,'false');
} // end function 

function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function fill_catalog(side){ // start function 
var dropindex = eval('document.forms.f1.' + side + '_manufacturer.selectedIndex');
var selectObj = eval('document.forms.f1.' + side + '_catalog');

if(dropindex == 0) { // start if 1
alert ('You must first select a manufacturer from the dropdown to use this function');
var selectObj = eval('document.forms.f1.' + side + '_catalog');
selectObj.options.length = 0;
} else { 
var dropval = eval('document.forms.f1.' + side + '_manufacturer.options[' + dropindex + '].value');
eval('var myArray = catalog_' + dropval);
selectObj.options.length = 0;
var cnt = myArray.length;
for (i=0;i<cnt;i++){ // start for 
myText = myArray[i];
selectObj.options[i] = new Option(myText,myText);
} // end for 
} // end if 1

} // end function 

function check_discount(){ // start function 
var tempVal = document.forms.f1.discount_code.value;
// alert (tempVal);
// alert (document.forms.f1.x_test_request.value);
if( tempVal == "asps" || tempVal == "ASPS"){ // start if 
// alert ('TRUE');
document.forms.f1.x_test_request.value = 'TRUE';
} else {
document.forms.f1.x_test_request.value = 'FALSE';
} // end if 
// alert (document.forms.f1.x_test_request.value);
} // end function 