/*      	Grabers Javascript Library 1
*					Written by Peter Graber
*
*
*/



function frameSizer(state) {
	var theFrame = document.getElementById('orderFrame');



}


/*		Very Basic Form Checking Functions
*			Started May 29, 2005
*
*/


function checkData(data) {
		var err = '';
		
		for (i=0; i < data.elements.length; i++){
			var widget = data.elements[i];
	  	var type = widget.type;
		 		
			switch (type){
			 case "text":
				if( isEmpty(widget) || widget.value.length < 1) {
				err = 'All fields are required.\n\nPlease enter your '+beautify(widget.name)+'\n';
				alert(err);						
				widget.style.backgroundColor = "#ffffcc"
				widget.focus();
				widget.value ='';
				return false;
				}
			  break;
				
								
		  case "select-one":
			 if(widget.value == 0) {
			 err = 'All fields are required.\n\nPlease select your '+beautify(widget.name)+'\n';
			 alert(err);	
			 widget.style.backgroundColor = "#ffffcc"					
			 widget.focus();
			 return false;
			 }		
			break;
			
		}
			
 	 }

}

function isEmpty(element) {
		var a = element.value
		
		for (j=0; j < a.length+1; j++) {
		  var c = a.charAt(j);
			if(c== '\n' || c=='\t'){
			return true
			}	
		}
		return false;
}


function beautify(string) {
	var nString="";
	for(c=0; c < string.length+1; c++) {
		var car = string.charAt(c).replace("_"," ") 
		nString += car;
		}
	return nString;

}



function setBack(event) {
		this.style.backgroundColor = '#fff'
}


		
/* This is the onload Event
*/


window.onload = function() {
	if (theForm = window.document.forms[1]){

	for(i= 0; i < theForm.elements.length; i++) {
		theForm.elements[i].onblur = setBack;
		}	
		}
	else {
		return false;
		}
		
		
}



