//Add these two soundes to your page body (this is the only step absolutely required)
//<embed name='shooting' src="effects\splam.wav" loop=false autostart=false mastersound hidden=true width=0 height=0 volume=70></embed>
//<embed name='empty' src="effects\emptyClip.wav" loop=false autostart=false mastersound hidden=true width=0 height=0 volume=70></embed>

//make sure you call makeClip(xpos,ypos) to initialize bullets
//function init(){
//	makeClip(bullits,posX,posY)
//}

//you need to add shootBuulit to your onclick routine like so...
document.onclick = function rhsbullits(){
	shootBullit()
}
var bullit = new Array()
var numBullits = 5
var bullits = numBullits
var reloadDiv
var explosionCounter = 0
var explosions = new Array()
var bh = "http://www.speakeasy.org/~nochance/Bullet%20Curser/bullitHole.gif"
var explode = new Array()
explode[0] = "http://www.speakeasy.org/~nochance/Bullet%20Curser/gexpl1.gif"
explode[1] = "http://www.speakeasy.org/~nochance/Bullet%20Curser/gexpl8.gif"
function makeClip(bull,px,py){
	numBullits = bull
	bullits = numBullits
	for(i=0;i<=numBullits;i++){
		bullit[i] = document.createElement("IMG")
		bullit[i].src = "http://www.speakeasy.org/~nochance/Bullet%20Curser/bullit.gif"
		bullit[i].style.position = "absolute"
		bullit[i].style.visibility = "visible"
		bullit[i].style.left = px + i*10
		bullit[i].style.top = py
		bullit[i].width = "10"
		bullit[i].height = "40"
		document.body.appendChild(bullit[i])
	}
	reloadDiv = document.createElement("DIV")
	reloadDiv.id = "reload"
	reloadDiv.style.position = "absolute"
	reloadDiv.style.top = py
	reloadDiv.style.left = px
	reloadDiv.style.cursor = "hand"
	reloadDiv.style.width = 50
	reloadDiv.style.visibility = "hidden"
	reloadDiv.style.background = "black"
	reloadDiv.setAttribute("onclick",function anonymous(){reloadGun()})
	reloadDiv.style.fontWeight = "bold"
	reloadDiv.innerText = "RELOAD"
	document.body.appendChild(reloadDiv)
}
function shootBullit(){
	if(bullits>-1){
		bullit[bullits--].style.visibility = "hidden"
		explosions[explosionCounter] = new oneShotSprite("explosion" + explosionCounter,explode)
		x = window.event.x - 40
		y = window.event.y - 40

		var oo = document.elementFromPoint(x+40,y+40)
		if(oo!==null){
			if(oo.id!=""){
				jsobjectmessaging(oo)
			}
		}

		explosions[explosionCounter].start("explosions[" + explosionCounter++ + "]",70,x,y)
		shooting.play()
		if(explosionCounter>10) explosionCounter=0
		if((oo!=null) && (oo.target=="true")){
			//do nothing
		}
		else{
			var d = document.createElement("IMG")
			d.src = bh
			d.style.position = "absolute"
			d.style.left = x + 24
			d.style.top = y + 24
			document.body.appendChild(d)
		}
	}
	else {
		empty.play()
		reload.style.visibility = "visible"
	}
}
function reloadGun(){
	for(i=0;i<=numBullits;i++){
		bullit[++bullits].style.visibility = "visible"
	}
	window.event.cancelBubble = true
	reload.style.visibility = "hidden"
}
//copy this messaging function and use it to control what events to respond to
//function jsobjectmessaging(obj){
//}
