// JavaScript Document

// Jump Menu ==================================================
	
function jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

// Search Box
var active_color = '#000'; // Color of user provided text
var inactive_color = '#666'; // Color of default text

$(document).ready(function() {

	// Search Box
	$("input.default-value").css("color", inactive_color);
		var default_values = new Array();
		$("input.default-value").focus(function() {
		if (!default_values[this.id]) {
		  default_values[this.id] = this.value;
		}
		if (this.value == default_values[this.id]) {
		  this.value = '';
		  this.style.color = active_color;
		}
		$(this).blur(function() {
		  if (this.value == '') {
			this.style.color = inactive_color;
			this.value = default_values[this.id];
		  }
		});
	});
	
	
	/*var popUpWin=0;
	function popUpWindow(URLStr, left, top, width, height)
	{
	  if(popUpWin)
	  {
		if(!popUpWin.closed) popUpWin.close();
	  }
	  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
	}*/
	
	// Quote/Sample Request Form Toggleing ========================

	$('#msgLit').hide();
	$('#litCheck').click(function() {
		$('#msgLit').toggle();
	});
	
	// Toggleing
	$('#msgSample').hide();
	$('#sampleCheck').click(function() {
		$('#msgSample').toggle();
	});
	
	// Toggleing
	$('#msgQuote').hide();
	$('#quoteCheck').click(function() {
		$('#msgQuote').toggle();
	});
	
	// Toggleing
	$('#thefile').hide();
	$('#uploader').hide();
	$('#uploadCheck').click(function() {
		$('#thefile').toggle();
		$('#uploader').toggle();
		$('#msgUpload').toggle();
	});
	
	
	// PSM System Stuff ===========================================
	
	function validateFormOnSubmit(theForm) {
	var reason = "";
	
	  reason += validateName(theForm.name);
	  // reason += validatePassword(theForm.pwd);
	  // reason += validateEmail(theForm.email);
	  // reason += validatePhone(theForm.phone);
	  // reason += validateEmpty(theForm.from);
		  
	  if (reason != "") {
		alert("Some fields need correction:\n" + reason);
		return false;
	  }
	
	  // alert("All fields are filled correctly");
	  return true;
	}
	
	function validateName(fld) {
		var error = "";
	 
		if (fld.value == "") {
			fld.style.background = 'Yellow'; 
			error = "You didn't enter a name.\n";
		} else if ((fld.value.length < 3) || (fld.value.length > 60)) {
			fld.style.background = 'Yellow'; 
			error = "The name is the wrong length. Must be between 3 and 60 characters.\n";
		} else {
			fld.style.background = 'White';
		}
		return error;
	}
	
	
	
	
	
}); // END Ready Function
