// Menu scripts for KaseysDogHouse.com
//
// 10/2004 - Tom Nelson, revised.
//
var ayAudio = new Array();
ayAudio[0] = "Sounds/click1.wav";
ayAudio[1] = "Sounds/sniff1.wav";

// Audio tested with IE 6.x, Mozilla 1.7.3, FireFox 1.0PR
//
// Will not work old versions of Netscape. Don't run old versions!
//
// There are two embeds for each sound to make them more responsive.
// This way the first sound does not have to complete before the sound
// can be started again for another graphic.
//
function StartAudio() {
	var ii,s="";
	for (ii=0; ii<ayAudio.length; ii++){
		s += "<EMBED SRC='"+ayAudio[ii]+"' AUTOSTART='FALSE' HIDDEN='TRUE' id='noisey"+ii+"a'>"
		s += "<EMBED SRC='"+ayAudio[ii]+"' AUTOSTART='FALSE' HIDDEN='TRUE' id='noisey"+ii+"b'>"
	}
	// .Play() fails if this DIV is hidden?!
	var eDiv = document.createElement("DIV");
	eDiv.style.position='absolute';
	eDiv.setAttribute('id','soundboard');
	eDiv = document.body.appendChild(eDiv);
	eDiv.innerHTML = s;
}

var fPrevPlay = false;

// Play the sound effect.
function PlayAudio(iSound) {
	var ee;
	if (fPrevPlay)
		ee = document.getElementById("noisey"+iSound+'a');
	else
		ee = document.getElementById("noisey"+iSound+'b');
	
	fPrevPlay = !fPrevPlay;
	
 	ee.Play();
}

// Rapid play/stop under Mozilla seems to break the audio plug-in.
// For this reason we don't stop the sound. Play will start a second
// copy of the sound instead which has a more satisfying effect anyway.
//
function StopAudio(iSound) { 
//	var ee = document.getElementById("noisey"+iSound);
// 	ee.Stop();
}

//
function JS_preloadImages() {
	var d=document; 
	if(d.images){ 
		if(!d.JS_p) 
			d.JS_p=new Array();
    
		var ii,jj=d.JS_p.length,arg=JS_preloadImages.arguments; 
		for(ii=0; ii<arg.length; ii++)
			if (arg[ii].indexOf("#")!=0){ 
				d.JS_p[jj]=new Image; 
				d.JS_p[jj++].src=arg[ii];
			}
	}
}

function JS_swapImgRestore() {
	var i,x,a=document.JS_sr; 
	for(i=0; a && i < a.length && (x=a[i]) && x.oSrc;i++) 
		x.src=x.oSrc;
}

function JS_findObj(n, d) {
	var p,ii,x;
	if (!d) 
		d=document; 
	
	if ((p=n.indexOf("?")) > 0 && parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	}
	if	(!(x=d[n]) && d.all) 
		x=d.all[n]; 
	
	for (ii=0; !x && ii<d.forms.length; ii++)
		x=d.forms[ii][n];
		
	for (ii=0; !x && d.layers && ii<d.layers.length;ii++)
		x=JS_findObj(n,d.layers[ii].document);
  
	if (!x && document.getElementById) 
		x=document.getElementById(n); 
		
	return x;
}

function JS_swapImage() {
	var ii,jj=0,x,arg=JS_swapImage.arguments; 
	document.JS_sr = new Array; 
	for(ii=0; ii<(arg.length-2); ii+=3)
		if ((x=JS_findObj(arg[ii]))!=null) {
			document.JS_sr[jj++]=x; 
			if (!x.oSrc)
				x.oSrc=x.src; 
			
			x.src=arg[ii+2];
		}
}

function JS_openBrWindow(theURL,winName,features) {
	window.open(theURL,winName,features);
}

// Use this method to put our address into an element in an attempt
// to hide if from web crawling spammers!
//
function JS_setcontact(id,user,domain,root,tag) {
	var e = document.getElementById(id);
	if (e!=null)
		e.innerHTML = "<A HREF=m&#97;il" + "to"+":"+user+"&#64;"+domain+"."+root+">"+tag+"</a>";
}

onload = function() {
	StartAudio(); 
	JS_preloadImages(
		'ClipArt/BoneHomeOver.gif','ClipArt/BoneHome.gif','ClipArt/BondHomeDown.gif',
		'ClipArt/BoneActiviesOver.gif','ClipArt/BoneActivities.gif','ClipArt/BondActivitiesDown.gif',
		'ClipArt/BoneGalleryOver.gif','ClipArt/BoneGallery.gif','ClipArt/BondGalleryDown.gif',
		'ClipArt/BonePedigreeOver.gif','ClipArt/BonePedigree.gif','ClipArt/BondPedigreeDown.gif',
		'ClipArt/BoneFunGamesOver.gif','ClipArt/BoneFunGames.gif','ClipArt/BondFunGamesDown.gif',
		'ClipArt/BoneResourcesOver.gif','ClipArt/BoneResources.gif','ClipArt/BondResourcesDown.gif');
	JS_setcontact('contact','tom2','kaseysdoghouse','com',"Tom & Kasey");
}
