function validate(form) {
 var valid = true;

 for (i=0;i<form.length;i++) {
 		var tempobj=form.elements[i];
		if (tempobj.name.substring(0,9)== "required_") {
			shortFieldName=tempobj.name.substring(9,30).toUpperCase();
			// THIS IS TO CHECK TEXT BOXES AND TEXTAREA
			if (tempobj.type == 'text' || tempobj.type == 'textarea' || tempobj.type == 'hidden' || tempobj.type == 'password') {
			    if (isWhitespace(tempobj.value)) { 
					if (tempobj.type == 'hidden') { alert(mPrefix + 'Hidden' + mSuffix);valid = false; break; }
					warnEmpty(tempobj,shortFieldName); valid = false; break; }
			}
			//  THIS IS TO CHECK SELECT BOXES THAT ARE NOT SET TO THE FIRST OPTION
			if (tempobj.type.toString().charAt(0)=="s"&& tempobj.selectedIndex==0) { 
		     FieldName = tempobj.name.substring(0,30).toUpperCase();
			 cName = convert_name(FieldName);
		     alert(mPrefix + cName + mSuffix);
		     valid = false;
		     break;
            }
		}
  }

  if (!valid) { return false; } else { form.submitbutton.disabled = true; return true; }   

} // CLOSING THE VALIDATE FUNCTION

function toggle_option( node, which) {
    var target = document.getElementById(node);
    target.style.display = which;
}

function sumup(form) {
 var total = 0;
  
  for (i=0;i<form.length;i++) {
     var tempobj=form.elements[i];
	  if (tempobj.name.substring(0,6)== "price_") {
         total += parseFloat(tempobj.value.replace(/[,|$]/g, ''));
      }
      
  }
  form.total.value = formatCurrency(cent(total));
} 



function isEmpty(s)       { return ((s == null) || (s.length == 0)) }

function isWhitespace (s) { return (isEmpty(s)  || regWhitespace.test(s)); }

function warnEmpty (theField, s) { 
	theField.focus();
	cName = convert_name(s);
	alert('EMPTY:\n' + mPrefix + cName + mSuffix);
}

function cent(amount) {
   amount -= 0;
   amount = (Math.round(amount*100))/100;
 return (amount == Math.floor(amount)) ? amount + '.00' : (  (amount*10 == Math.floor(amount*10)) ? amount + '0' : amount);
}

function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + '$' + num + '.' + cents);
}


// =========================== 
//
// ===========================
function comboItemSelected(oList1,oList2,cType) {
	if (oList2!=null){
 	    alert('oList2 Not Null and need to clear it out');
		clearComboOrList(oList2);
       if (oList1.selectedIndex==-1){
         oList2.options[oList2.options.length] = new Option('SELECT','');
       } else {
	  // fillCombobox(oList2,cType + '=' + oList1.options[oList1.selectedIndex].value);
	   fillCombobox(oList2,cType + oList1.options[oList1.selectedIndex].value);
	   }
	}
}

function clearComboOrList(oList) {
   for (var i = oList.options.length-1; i>=0 ; i--) {
	   oList.options[i]=null;
   }
   oList.selectedIndex = -1;
   if (oList.onchange) oList.onchange();
}

function fillCombobox(oList,vValue){
   if (vValue!=''){
	   if (assocArray[vValue]){
		   oList.options[0] = new Option('SELECT','');
		   var arrX = assocArray[vValue];
           for ( var i = 0; i<arrX.length ; i = i+2 ){
			   if (arrX[i]!='EOF') oList.options[oList.options.length] = new Option(arrX[i+1],arrX[i]);
           }
           if (oList.options.length == 1){
			   oList.selectedIndex=0;
			   if (oList.onchange) oList.onchange();
           }
       } else {
		 oList.options[0] = new Option('None Selected','');  
	   }
   }
}

function listboxItemSelected(oList1,oList2,cType) {
   if (oList2!=null) {
	   clearComboOrList(oList2);
      if (oList1.selectedIndex==-1) {
         oList2.options[oList2.options.length] = new Option('SELECT','');
      } else {
		 fillListbox(oList2,cType + oList1.options[oList1.selectedIndex].value)
		 // fillListbox(oList2,oList1.name + '=' + oList1.options[oList1.selectedIndex].value)
	  }
   }
   else {

   }
}


function fillListbox(oList,vValue){
   if (vValue!=''){
	   if (assocArray[vValue]){
		   var arrX = assocArray[vValue];
		   for ( var i = 0; i<arrX.length ; i = i+2 ){
			   
			   if (arrX[i]!='EOF') oList.options[oList.options.length] = new Option(arrX[i+1],arrX[i]);

           }
           if (oList.options.length == 1){
			   oList.selectedIndex=0;
			   if (oList.onchange) oList.onchange();
 
           }
       } else {
		 oList.options[0] = new Option('None Selected','');  
	   }

   }
   else {
     	
   }
 
}

<!-- Idea by:  Nic Wolfe (Nic@TimelapseProductions.com) -->
<!-- Web URL:  http://fineline.xs.mw -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=1,resizable=1,width=450,height=600');");
}
// End -->

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}