/* 


*/

//Global variables used through out this file.

var app_folder = "";


/* 
  swap images by placing off/on flags according to what reference is passed 0/1 
*/
function rollOver(imageName, ref){
  var imageName, ref;
	var image_obj;
	
	image_obj = eval("document." + imageName);
	
	switch (ref){
	  case 1: image_obj.src = eval(imageName + "_on"+ ".src"); break;
	  case 0: image_obj.src = eval(imageName + "" + ".src"); break;
	  default: // do nothing here . . . . 
	}
}

/*----------------------------------------------------------------
Write status text to browser status bar on bottom
----------------------------------------------------------------*/
function setStatusBarText(strText){
  var strText;
  
  window.defaultStatus = "Welcome to Ralia Sports Center";  
  window.status = strText;
  
}

/*----------------------------------------------------------------
Open pop up window
----------------------------------------------------------------*/
function popWindow(urlText){
  var urlText;
  window.open(urlText,'APPL','width=750,top=50,left=350,resizable,scrollbars');
}
function popWindowGallery(urlText){
  var urlText;
  window.open(urlText,'APPL','width=450,height=400,top=50,left=350,resizable,scrollbars');
}

/*----------------------------------------------------------------
Replace the current URI of any web page with a new one using the
following function
----------------------------------------------------------------*/
function directUser(refURL){
  var refURL;
  
  location.replace(refURL);
}


/*----------------------------------------------------------------
Verify if the email address value passed is valid.
We are not using an SMTP validation. We cann't control totally
what people actually write down as email addresses
----------------------------------------------------------------*/
function isEmail(refEmail){
  var refEmail;
  
  if(refEmail.indexOf("@") == -1 || refEmail.indexOf(".") == -1){
     return false;
    }
  return true;
}

/*----------------------------------------------------------------
Homepage banner rotation script
----------------------------------------------------------------*/
//Global variable(s) used for Homepage rotating image function below.

//var img1 = "images/rotating1.jpg";
var img2 = "images/rotating2.jpg";
var img3 = "images/rotating3.jpg";
var img4 = "images/rotating4.jpg";
var img5 = "images/rotating5.jpg";

//var arrayImages = new Array(img1, img2, img3, img4, img5);
var arrayImages = new Array(img2, img3, img4, img5);
var imageID = 0;
var imgCount = arrayImages.length;

function rotateHomepagePic() {
	if (document.images) {
		imageID++
		if (imageID == imgCount) {
			imageID = 0
		}
		if(document.homepage_pic){
		  document.homepage_pic.src=arrayImages[imageID]
		  }
	  	setTimeout("rotateHomepagePic()", 3500)
	}
}
/*----------------------------------------------------------------
Validate form input on the contact us form <content_contact.php>
----------------------------------------------------------------*/
function validateForm(refForm){
  var refForm;
  var objForm;
  
  objForm = eval("document." + refForm);
  
  if(objForm.contact_lname && objForm.contact_lname.value == ""){
    alert("Please enter your Last Name!");
	objForm.contact_lname.focus();
    return false
  }
  
  if(objForm.contact_fname && objForm.contact_fname.value == ""){
    alert("Please enter your First Name!");
	objForm.contact_fname.focus();
    return false
  }
  
  if(objForm.address1 && objForm.address1.value == ""){
    alert("Please enter your Street Address!");
	objForm.address1.focus();
    return false
  }
  
  if(objForm.city && objForm.city.value == ""){
    alert("Please enter your City Name!");
	objForm.city.focus();
    return false
  }
  
  if(objForm.state && objForm.state.value == "NA"){
    alert("Please select your State Name!");
	objForm.state.focus();
    return false
  }
   
  if(objForm.zip_code && objForm.zip_code.value == ""){
    alert("Please Enter your Zip Code!");
	objForm.zip_code.focus();
    return false
  }
  
  if(objForm.country && objForm.country.value == "NA"){
    alert("Please select your Country Name!");
	objForm.country.focus();
    return false
  }
  
  if(objForm.phone && objForm.phone.value == ""){
    alert("Please enter your Phone Number!");
	objForm.phone.focus();
    return false
  }
  
  if((objForm.email && objForm.email.value == "") || !isEmail(objForm.email.value)){
    alert("Please enter your Email Account!");
	objForm.email.focus();
    return false
  }
  
   if(objForm.note && objForm.note.value == ""){
    alert("Please type in your request or comment!");
	objForm.note.focus();
    return false
  }
  return true;
  
}

