// JavaScript Document
var IE = document.all?true:false

function findObj(n, d) { //v4.01
	var p,i,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 (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); 
	return x;
}

function mySubmit(mdowhat, maction) {
	var dowhat = findObj("dowhat");
	dowhat.value = mdowhat;
	if ((maction != null) || (maction = "undefined")) {
		document.frm.action = maction;
	}
	document.frm.submit()
}

var Opacity = 100;
var t;
var lastIndex = 0;
mimages = new Array();

function addImage(path){
	var img = new Image;
	img.src = path;
	mimages.push(img);
}

addImage('images/lion.png');
addImage('images/cheetah.png');
addImage('images/elephant.png');
addImage('images/rhino.png');
addImage('images/buffalo.png');


function selectImages() {
	var img1 = document.all?document.all("img1"):document.getElementById("img1");
	if (lastIndex == (mimages.length)) {
		lastIndex = 0;
	}
	img1.src = mimages[lastIndex].src;
	lastIndex++;;
	fadeIn();
}

function fadeIn() {
	var mlayer = document.all?document.all("filmstrip"):document.getElementById("filmstrip");
	Opacity = Opacity+5;
	if (Opacity <= 100) {
		if (IE) {
			mlayer.filters["alpha"].opacity = Opacity;	
		} else {
			mlayer.style.opacity = (Opacity/100);
		}
		setTimeout("fadeIn()", 5);
	} else {
		clearTimeout(t);
		Opacity = 100;
		t = null;
	}	
}

function fadeOut() {
	var mlayer = document.all?document.all("filmstrip"):document.getElementById("filmstrip");
	Opacity = Opacity-5;
	if (Opacity >= 0) {
		if (IE) {
			mlayer.filters["alpha"].opacity = Opacity;	
		} else {
			mlayer.style.opacity = (Opacity/100);
		}
		setTimeout("fadeOut()", 5);
	} else {
		clearTimeout(t);
		t = null;
		selectImages();
	}	
}

function fadeSlowly() {
	var mlayer = document.all?document.all("filmstrip"):document.getElementById("filmstrip");
	if (IE) { //Internet Explorer
		mlayer.style.filter = "alpha(opacity=100);";
	} else { //Safari & Mozilla
		mlayer.style.opacity = 1;
	}
	fadeOut();
}

function autoFade() {
	var mlayer = document.all?document.all("filmstrip"):document.getElementById("filmstrip");
	setTimeout("autoFade()", 5000);
	fadeSlowly();
	mlayer.style.visibility = "visible";
}

function preloadImages() { //v3.0
	var images = new Array();
	images[0] = 'templates/kings.co.za/images/filmstrip_background.jpg';
	images[1] = 'images/lion.png';
	images[2] = 'images/cheetah.png';
	images[3] = 'images/elephant.png';
	images[4] = 'images/rhino.png';
	images[5] = 'images/buffalo.png';
	
	var load_images = new Array();
	if (images) { 
		for(i=0; i < images.length; i++) {
			load_images[i] = new Image; 
			load_images[i].src = images[i];
		}
	}
}

function onLoad() {
}