//********************************************************************
//* JavaScript support for Tiger Heron
//********************************************************************

initSite();

function initSite()
{
    baseInitSite();
}

function homeNav()
{
    var nav = ["books", "characters", "author", "parents"];

    for (var i = 0; i < nav.length; i++) {
	var name = nav[i];
	$("#" + name + " img").get(0).myName = name;
	$("#" + name + " img").hover(
	    function(e) {
		name = this.myName;
		swapImageObj(this, "images/home-" + name + "-hover.png");
	    },
	    function(e) {
		swapImageObjRestore(this);
	    });
    }
}

function interiorNav()
{
    var nav = ["books-trans", "characters", "author", "parents", "home-trans"];

    for (var i = 0; i < nav.length; i++) {
	var name = nav[i];
	$("#" + name + " img").get(0).myName = name;
	$("#" + name + " img").hover(
	    function(e) {
		name = this.myName;
		swapImageObj(this, "images/" + name + "-hover.png");
	    },
	    function(e) {
		swapImageObjRestore(this);
	    });
    }
}

function slideShow(name)
{
    var elem = $("#" + name);
    elem.get(0).curId = 0;
    setTimeout("nextSlide('" + name + "')", 4000);
}

function nextSlide(name)
{
    var elem = $("#" + name);
    var curId = elem.get(0).curId;
    var nextId = (curId + 1) % elem.children().length;
    $("#" + name + " > img:eq(" + curId + ")").fadeOut(2000);
    $("#" + name + " > img:eq(" + nextId + ")").fadeIn(2000);

    elem.get(0).curId = nextId;

    setTimeout("nextSlide('" + name + "')", 10000);
}

function characterInformation()
{
    $("#char-table").get(0).curText = 0;
    for (var i = 1; i < 25; i++) {
	$("#char" + i + " img").get(0).i = i;
	$("#char" + i + " img").hover(
	    function(e) {
		var i = this.i;
		swapImageObj(this, "images/char" + i + "-large.png");
		var old = $("#char-table").get(0).curText;
		$("#char-table #char" + old + "-text").hide();
		$("#char-table #char" + i + "-text").show();
		$("#char-table").get(0).curText = i;
	    },

	    function(e) {
		swapImageObjRestore(this);
	    });
    }
}

function needsPNGFix()
{
    if (!$.browser.msie) return false;
    return (!window.XMLHttpRequest);
}

