

// ****** MouseOver Function ******

function swapImage()
{
  browserName = navigator.appName;
  browserVer = parseInt(navigator.appVersion);
  if (browserName == "Netscape"  && browserVer >= 3) version = "n3";
  else if (browserName == "Microsoft Internet Explorer" && browserVer >= 4.0) version = "n3";
  else version = "n2";
  if (version == "n3")
    {

      img1 = new Image;
      img1.src = "images/nav_events_on.gif";
      img2 = new Image;
      img2.src = "images/nav_halfprice_on.gif";
      img3 = new Image;
      img3.src = "images/nav_ticketbooth_on.gif";
      img4 = new Image;
      img4.src = "images/nav_aboutus_on.gif";
      img5 = new Image;
      img5.src = "images/nav_home_on.gif";
	  img6 = new Image;
      img6.src = "images/nav_buyonline_on.gif";
      img7 = new Image;
      img7.src = "images/contact_us_on.gif";
      img8 = new Image;
      img8.src = "images/print_page_on.gif";
      img9 = new Image;
      img9.src = "images/email_friend_on.gif";
	  img10 = new Image;
      img10.src = "images/nav_contest_on.gif";
	  img11 = new Image;
      img11.src = "images/button_ticketsBlack_on.gif";


      var i,theObj,j=0,swapArray=new Array,oldArray=document.swapImgData;
      for (i=0; i < (swapImage.arguments.length-2); i+=3) {
	theObj = eval(swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1])
	  if (theObj != null) {
	    swapArray[j++] = theObj;
	    swapArray[j++] = (oldArray==null || oldArray[j-1]!=theObj)?theObj.src:oldArray[j];
	    theObj.src = swapImage.arguments[i+2];
	  } }
      document.swapImgData = swapArray; //used for restore
    }
}

// ****** MouseOver Restore Function ******

function swapImgRestore() {
  if (document.swapImgData != null)
    for (var i=0; i<(document.swapImgData.length-1); i+=2)
      document.swapImgData[i].src = document.swapImgData[i+1];
}


// ****** Pre-Loading Images Function  ******

function preloadImages() {
  if (document.images) {
    if (typeof document == 'undefined'){
      document = new Object();
    }
    document.loadedImages = new Array();
    var argLength = preloadImages.arguments.length;
    for(arg=0;arg<argLength;arg++) {
      document.loadedImages[arg] = new Image();
      document.loadedImages[arg].src = preloadImages.arguments[arg];}
  }
}

// ****** opens link in popup window 
function openWin(url) { 
  // default values for window:
  topL=185;
  leftL=80;
  width=350;
  height=382;    
  bar=0;      
  wName='popUp';
    
  width = (arguments.length>1)?arguments[1]:width; // option to pass in width
  bar = (arguments.length>2)?arguments[2]:bar; // option to turn scrollbar on
  wName = (arguments.length>3)?arguments[3]:wName; // option to pass in window name 
  height = (arguments.length>4)?arguments[4]:height; // option to pass in height 
    
  var str="toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars="+ bar +",width="+ width +",height="+ height +",screenX="+ leftL +",screenY="+ topL +",left="+ leftL +",top="+ topL +",resizable=0";
  var Pwin = window.open(url,wName,str,true)
    Pwin.focus();
  
}


// Function to validate form text fields.
function ValidateSubscribe() {
  // This is a list of the text fields to check:
  val_flds = new Array("Name",
		       "Email",
		       "City",
		       "ProvinceState",
			   "Postal",
		       "Country");	
  // This is the corresponding wording to use when a alert box is presented:
  full_name = new Array("Name",
			"Email address",
			"City",
			"Region, Province or State",
			"Postal/Zip Code",
			"Country");								 

  // This var will be used to store the missed fields;
  var err_flds = '';
  for(var i=0;i<val_flds.length;i++) {
    if (document.subscribe.elements[val_flds[i]].value=="") {
      err_flds += full_name[i]+"\n";
    }
  }
						
  if(err_flds != '') {
    alert("Please fill out the following fields:\n\n"+
	  err_flds+"\n\nPlease try again. Thank you.");
    return false;
  }

  if(!verifyEmail(document.subscribe.Email.value)) {
    alert("There seems to be a problem with your email address you have entered.  Please try again.");
    return false;
  }

  return true;
}

// Function to test email address.
function verifyEmail(email) {
  if ((email == "") || (email.indexOf("@") < 1) || 
      (email.lastIndexOf(".") < (email.indexOf("@")+2)) ||
      (email.lastIndexOf(".") > (email.length-2))) {
    return false;
  } else {
    return true;
  }
}


  
// Used in Admin tools
function deleteConfirm(name,url) {
  if(confirm('Are you sure you want to delete '+name+'? \nSelect "OK" to continue, or "Cancel" to go back.')){
    top.document.location = url;
    return true;
  }
}  

// Used by Event admin tools
function deleteFeatureSubmit(form,eventId)
{
  form.eventId.value = eventId;
  form.submit();
} // end: deleteFeatureSubmit
