/*
var nowShown = 0;
var nowActive = 0;
var	OverImages = new Array();
var	OutImages = new Array();

function init() {
	TotalImages = init.arguments.length;
	for (i=0;i<TotalImages;i++) {
		OverImages.push(new Image());
		OutImages.push(new Image());
		OverImages[i].src = '/pics/buttons/' + init.arguments[i] + '%20on.jpg';
		OutImages[i].src = '/pics/buttons/' + init.arguments[i] + '.jpg';
	}
	scrollpos = 0;
	scrollpos2 = 0;
	scroll();
}

function activate(i,iname) {
	nowActive = i;
	document.getElementById('roll' + i).setAttribute('src','/pics/buttons/' + iname + '%20active.jpg');
}

function rollOver(i) {
	if (nowActive != i) {
		document.getElementById('roll' + i).setAttribute('src',OverImages[i].src);
	}
}

function rollOut(i) {
	if (nowActive != i) {
		document.getElementById('roll' + i).setAttribute('src',OutImages[i].src);
	}
}

function scroll() {
	if (scrollpos <= -1300) scrollpos = 1300;
	scrollpos -= 1;
	if (scrollpos2 <= -2600) scrollpos2 = 0;
	scrollpos2 -= 1;

	document.getElementById('scrollertext').style.top = scrollpos + 'px';
	document.getElementById('scrollertext2').style.top = scrollpos2 + 'px';
	setTimeout('scroll()', 50);
}
*/

function showFixed(num) {
	if (nowShown > 0) {
		document.getElementById('fixed' + nowShown).style.visibility='hidden';
	}
	document.getElementById('fixed' + num).style.visibility='visible';
	nowShown = num;
	document.cookie = "fixed=" + nowShown;
}

function showRandom(num) {
	yummy = getCookie('fixed');
	if (yummy > 0) {
		showme = yummy;
	} else {
		showme = Math.round(Math.random()*(num-1))+1;
	}
	showFixed(showme);
}


function createGallery(baseName, startImg, endImg) {
	var row=0;
	document.write('<table class="gallery"><tr>');
	for (i=startImg; i<=endImg; i++) {
		uri = '/pics/thumbs/' + baseName;
		if (i < 10) uri = uri + '0';
		uri = uri + i + '.jpg';

		uri2 = '/pics/photos/' + baseName;
		if (i < 10) uri2 = uri2 + '0';
		uri2 = uri2 + i + '.jpg';

		document.write('<td><a href="'+uri2+'"><img src="' + uri + '" width="128" height="96" alt="Photo" /></a></td>');
		row++;
		if (row==3) {
			document.write('</tr>');
			if (i < endImg) document.write('<tr>');
			row = 0;
		}

	}
	document.write('</table>');
}

function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}



window.addEventListener?window.addEventListener('load',so_init,false):window.attachEvent('onload',so_init);

var d=document, imgs = new Array(), zInterval = null, current=0, pause=false;

function so_init()
{
	if(!d.getElementById || !d.createElement)return;

	//css = d.createElement('link');
	//css.setAttribute('href','slideshow2.css');
	//css.setAttribute('rel','stylesheet');
	//css.setAttribute('type','text/css');
	//d.getElementsByTagName('head')[0].appendChild(css);

	imgs = d.getElementById('rotator').getElementsByTagName('img');
	for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0;
	imgs[0].style.display = 'block';
	imgs[0].xOpacity = .99;

	setTimeout(so_xfade, 4000);
}

function so_xfade()
{

//var rand_no = Math.random();
//rand_no = rand_no * 15;
//rand_no = Math.ceil(rand_no);
//alert(rand_no);

	cOpacity = imgs[current].xOpacity;
	nIndex = imgs[current+1]?current+1:0;
	nOpacity = imgs[nIndex].xOpacity;

	cOpacity-=.05;
	nOpacity+=.05;

	imgs[nIndex].style.display = 'block';
	imgs[current].xOpacity = cOpacity;
	imgs[nIndex].xOpacity = nOpacity;

	setOpacity(imgs[current]);
	setOpacity(imgs[nIndex]);

	if(cOpacity<=0)
	{
		imgs[current].style.display = 'none';
		current = nIndex;
		setTimeout(so_xfade,4000);
	}
	else
	{
		setTimeout(so_xfade,50);
	}

	function setOpacity(obj)
	{
		if(obj.xOpacity>.99)
		{
			obj.xOpacity = .99;
			return;
		}

		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = 'alpha(opacity=' + (obj.xOpacity*100) + ')';
	}
}



