// Content.html custom JavaScript

// include appropriate javascript.  NOTE: these scripts won't be loaded until onPageLoad is called
includeScript( "scripts/shared/utilities.js" );
includeScript( "scripts/shared/imageutil.js" );
includeScript( "scripts/shared/ajaxwrapper.js" );
includeScript( "scripts/sgisite/sgiscript.js" );
includeScript( "scripts/sgisite/sound.js" );
includeScript( "scripts/external/soundmanager.js" );

function scriptMain()
{
	soundSetup( "muteButton" );
	
	var mainbody = document.getElementById( "mainbody" );
	autoAlignElemToWindowHorozontal( mainbody, -488, 0 );
	
	// setup the on mouse hover any hover images
	setupHoverImages( "(swap_hover)|(link_hover)" );
	
	// make this image animated
	//var leftbase = document.getElementById( "left_anim1" );
	//var animleft = new AnimatedImageElem( mainbody, leftbase, 0, 274, "images/main_15.jpg", 10, true, 50 );

	//var rightbase = document.getElementById( "right_anim1" );
	//var animright = new AnimatedImageElem( mainbody, rightbase, 768, 274, "images/main_17.jpg", 10, true, 50 );

	// swap the links to our AJAX loaded content page
	var l1elem = document.getElementById("l1");
	l1elem.href = "content.html#news";
	var l2elem = document.getElementById("l2");
	l2elem.href = "content.html#about";
	var l3elem = document.getElementById("l3");
	l3elem.href = "content.html#careers";
	var l4elem = document.getElementById("l4");
	l4elem.href = "content.html#contact";
	
	// load sound, then images
	var sndWait = new WaitForSoundToLoad( soundLoadedCB );
}

function soundLoadedCB()
{
	// make the body visible after loading all of the document images
	var wait = new WaitForImagesToLoad( onImagesLoadedCB );
}

function onImagesLoadedCB()
{
	// hide the loading image
	var loading = document.getElementById("loading");
	loading.style.display = "none";

	// hide the loading image
	var body = document.getElementById("mainbody");
	body.style.display = "block";

    getUrlFile( "images/main_16.gif", onAnimatedTitleLoaded );
    preloadContentFromFile( "preload.xml", onPreloadDone );
    
    var musicCB = bindCB( sndPlayMusic, "background" );
    setTimeout( musicCB, 1000 );
}

function onPreloadDone()
{
}

function onAnimatedTitleLoaded()
{
	var titleImg = document.getElementById( "logoimg" );
	titleImg.src = "images/main_16.gif";
}