/********************* Begin slideshow module *********************/
var currPic = 0;
var paused = false;
var ssTxt = new Array(5);
var ssPh = new Array(5);
var ssBtns = new Array(5); 
var ppBtn;
var timer1;

try {
	document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}

function initPageComponents() {
	/*  Used to load all components on the page */
	ssTxt = new Array();
	ssPh = new Array();
	ssBtns = new Array();
	ssTxt[0] = document.getElementById('txt1');
	ssTxt[1] = document.getElementById('txt2');
	ssTxt[2] = document.getElementById('txt3');
	ssTxt[3] = document.getElementById('txt4');
	ssTxt[4] = document.getElementById('txt5');
	ssPh[0] = document.getElementById('ph1');
	ssPh[1] = document.getElementById('ph2');
	ssPh[2] = document.getElementById('ph3');
	ssPh[3] = document.getElementById('ph4');
	ssPh[4] = document.getElementById('ph5');
	ssBtns[0] = document.getElementById('a1'); 
	ssBtns[1] = document.getElementById('a2');
	ssBtns[2] = document.getElementById('a3');
	ssBtns[3] = document.getElementById('a4');
	ssBtns[4] = document.getElementById('a5');
	ppBtn = document.getElementById('ppBtn');
	timer1 = setTimeout('timedStory()', 3000);
}



function change(num) {
	currPic = num;
	if (ssTxt[0] == null || ssTxt[0] == null || ssTxt[0] == null) {
		return;
	}
	ssTxt[0].style.display = (num == 0 ? "block" : "none"); 
	ssTxt[1].style.display = (num == 1 ? "block" : "none"); 
	ssTxt[2].style.display = (num == 2 ? "block" : "none");
	ssTxt[3].style.display = (num == 3 ? "block" : "none");
	ssTxt[4].style.display = (num == 4 ? "block" : "none");
	ssPh[0].style.display = (num == 0 ? "block" : "none"); 
	ssPh[1].style.display = (num == 1 ? "block" : "none"); 
	ssPh[2].style.display = (num == 2 ? "block" : "none");
	ssPh[3].style.display = (num == 3 ? "block" : "none");
	ssPh[4].style.display = (num == 4 ? "block" : "none");
	ssBtns[0].className = "onActive";
	ssBtns[1].className = "onFamily";
	ssBtns[2].className = "onCultural";
	ssBtns[3].className = "onRomantic";
	ssBtns[4].className = "onBusiness";
	ssBtns[0].className = "offActive";
	ssBtns[1].className = "offFamily";
	ssBtns[2].className = "offCultural";
	ssBtns[3].className = "offRomantic";
	ssBtns[4].className = "offBusiness";
    ssBtns[0].className = (num == 0 ? "onActive" : "offActive");
	ssBtns[1].className = (num == 1 ? "onFamily" : "offFamily");
	ssBtns[2].className = (num == 2 ? "onCultural" : "offCultural"); 
	ssBtns[3].className = (num == 3 ? "onRomantic" : "offRomantic");
	ssBtns[4].className = (num == 4 ? "onBusiness" : "offBusiness");
}



/* change picture, wait some seconds, repeat */

function timedStory() {
	currPic = (currPic + 1)%5;
	change(currPic);
	timer1 = setTimeout('timedStory()', 3000);
}



/* executed when the play/pause button is selected */


function doButton() {
	paused=!paused;
	doImageSwap();
	if (paused==true) {
		clearTimeout(timer1); /* stop the image loop */
	}else{
		timedStory(); /* restart the image loop */
	}
}



/*executed when a number link is selected */

function doNumber(num) {
	paused = true;
	doImageSwap();
	change(num);
        clearTimeout(timer1);
} 



/* swap the play/pause button image */

function doImageSwap() {
    if (paused==true){
        ppBtn.style.backgroundPosition = "-75px -66px";
        }else{
        ppBtn.style.backgroundPosition = "-75px -22px";
         }
        //ppBtn.style.backgroundPosition = (paused ? "-75px -66px" : "-75 -22px");
}
/********************* End slideshow module *********************/


function tii_callFunctionOnElementLoad (targetId, functionToCall)
{
	var myArguments = arguments;
	addLoadEvent (function ()
		{
			window.loaded = true;
		});
	var targetElement = document.getElementById (targetId);
	if (targetElement == null && !window.loaded)
	{
		var pollingInterval = setInterval (function ()
			{
				if (window.loaded)
				{
					clearInterval (pollingInterval);
				}
				targetElement = document.getElementById (targetId);
				if (targetElement != null)
				{
					clearInterval (pollingInterval);
					var argumentsTemp = new Array ();
					var argumentsTempLength = myArguments.length - 2;
					for (var i = 0; i < argumentsTempLength; i++)
					{
						argumentsTemp [i] = myArguments [i + 2];
					}		
					functionToCall.apply (this, argumentsTemp);
				}
			}, 10);
	}
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function doIt_wallpaper()
{
  var wall   = "wa_l="+document.wallpaper.wa_l.value+"&"+"wa_h="+document.wallpaper.wa_h.value;
/*  window.location="/aolhome/calculator/wallpaper/results/0,21655,,00.html"+"?"+wall+"&"+h_window+"&"+door; */
  window.location="/aolhome/calculator/wallpaper/results/0,21655,,00.html"+"?"+wall; 

}
//tii_callFunctionOnElementLoad ('footer',function(){initPageComponents();});
//addLoadEvent(function(){initPageComponents();});