//============================================================================
// Primary javascript file for the web site wwww.q-ballagility.ca
//
// Copyright (c) Wild Hare Productions 2008. All rights reserved.
// Portions of this file are copyright their respective owners.
// Copyright notice for these sections is give as appropriate.
//============================================================================


//============================================================================
// This function masks e-mail addresses so spam-bots can't farm the addresses 
// This code is based on something I saw somewhere and modified for this use.
//============================================================================
function makemail(name,domain)
{ 
	document.location.href = "mail" + "to:" + name + "@" + domain + "?subject=Q-Ball Agility"; 
}


//============================================================================
// This script and many more are available free online at
// The JavaScript Source!! http://javascript.internet.com
//============================================================================
// Copyright 2003 by jsCode.com
// Source: jsCode.com
// Author: etLux
// Free for all; but please leave in the header.
//============================================================================

// Set up the image files to be used.
// To add more image files, continue with the
// pattern below, adding to the array. Rememeber
// to increment the theImages[x] index!

var theImages = new Array();
theImages[0] = 'images/SideBar/DSC_0150.jpg';
theImages[1] = 'images/SideBar/JillMadcRibbon.jpg';
theImages[2] = 'images/SideBar/april08-2.jpg';
theImages[3] = 'images/SideBar/Jill.jpg';
theImages[4] = 'images/SideBar/MADdog.jpg';
theImages[5] = 'images/SideBar/dana.jpg';
theImages[6] = 'images/SideBar/acermad.jpg';
theImages[7] = 'images/SideBar/Megan.jpg';
theImages[8] = 'images/SideBar/april08-4.jpg';
theImages[9] = 'images/SideBar/DSC00539.jpg';
theImages[10] = 'images/SideBar/Banditjump.jpg';
theImages[11] = 'images/SideBar/TrynJump2.jpg';
theImages[12] = 'images/SideBar/Sadie.jpg';
theImages[13] = 'images/SideBar/JessieGold.jpg';
theImages[14] = 'images/SideBar/bella_new.jpg';
theImages[15] = 'images/SideBar/Cinderatch.jpg';
theImages[16] = 'images/SideBar/AvisBronzeAwardOfMerit.jpg';

// ======================================
// do not change anything below this line
// ======================================

var j = 0
var p = theImages.length;

var preBuffer = new Array()
for (i = 0; i < p; i++)
{
   preBuffer[i] = new Image()
   preBuffer[i].src = theImages[i]
}

// Unique Random Numbers Picker
// -Picks a number of unique random numbers from an array
// (c) 2002 Premshree Pillai
// http://www.qiksearch.com, http://javascript.qik.cjb.net
// E-mail : qiksearch@rediffmail.com

var numArr = new Array("0","1","2","3","4","5","6","7","8","9","10","11","12","13","14",
"15","16"); // Add elements here
var pickArr = new Array(); // The array that will be formed
var count=0;
var doFlag=false;
var iterations=0;

function pickNums(nums)
{
 iterations+=1;
 var currNum = Math.round((numArr.length-1)*Math.random());
 if(count!=0)
 {
  for(var i=0; i<pickArr.length; i++)
  {
   if(numArr[currNum]==pickArr[i])
   {
    doFlag=true;
    break;
   }
  }
 }
 if(!doFlag)
 {
  pickArr[count]=numArr[currNum];
 // document.write('<b>' + numArr[currNum] + '</b> <font color="#808080">|</font> ');
  count+=1;
 }
 if(iterations<(numArr.length*4)) // Compare for max iterations you want
 {
  if((count<nums))
  {
   pickNums(nums);
  }
 }
 else
 {
  location.reload();
 }
}
function showImage(mynum)
{

	var whichImage = pickArr[mynum];

	document.write('<img src="'+theImages[whichImage]+'">');
}


//============================================================================
// This copyright notice must be kept untouched in the stylesheet at all times.
//
// The original version of this script and the associated (x)html is available
// at http://www.stunicholls.com/menu/pro_drop_1.html
//
// Copyright (c) 2005-2007 Stu Nicholls. All rights reserved.
// This script and the associated (x)html may be modified in any way
// to fit your requirements.
//============================================================================
stuHover = function()
{
	var cssRule;
	var newSelector;
	for (var i = 0; i < document.styleSheets.length; i++)
		for (var x = 0; x < document.styleSheets[i].rules.length ; x++)
		{
			cssRule = document.styleSheets[i].rules[x];
			if (cssRule.selectorText.indexOf("LI:hover") != -1)
			{
				newSelector = cssRule.selectorText.replace(/LI:hover/gi, "LI.iehover");
				document.styleSheets[i].addRule(newSelector , cssRule.style.cssText);
			}
		}
		
	var getElm = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<getElm.length; i++)
	{
		getElm[i].onmouseover=function()
		{
			this.className += " iehover";
		}
		getElm[i].onmouseout=function()
		{
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", stuHover);

pickNums(5);
