//*****************************
// Rollover scripts
//*****************************

// Global variables 

// slideshow

var myPix = new Array("images/products/Pualani/page1.gif",
		      "images/products/Pualani/page7.gif");
var thisPic = 0;
imgCt = myPix.length - 1;


//************************
// function chgSlide:
//
// Displays next image in 
// slideshow array
//************************

function chgSlide( dir )
{
    if (document.images) {
	thisPic = thisPic + dir;
	if (thisPic > imgCt) {
		thisPic = 0;
	}
	if (thisPic < 0) {
		thisPic = imgCt;
	}
	
	document.myPicture.src = myPix[thisPic];
    }
}
function allTrim(s) {
  	while (s.substring(0,1) == ' ') {
    	s = s.substring(1,s.length);
  	}
  	while (s.substring(s.length-1,s.length) == ' ') {
    	s = s.substring(0,s.length-1);
  	}
  return s;
}
function validateForm() {
	var regExp = /[^0-9]/;
	var field = document.formValidate.qty;
	var qty = allTrim(field.value);
	var err = "";
	if (qty == "" || qty == 0) {
		err = "You must enter a quantity";
	}
	else if (regExp.test(qty) ) {
		err = "You must enter a valid quantity (from 1 to 999)";
	}
	if (err == "") {
		document.formValidate.qty.value = qty;
		return true;
	} else {
		alert( err );
		field.focus();
		field.select();
		document.formValidate.qty.value = "";
		  return false;
	}
}

