function startAnim()
{
	swapImage(Math.floor(Math.random()*maxImages));
	setTimeout('startAnim()', 5000);
}

var timerID=-1, w, imgNum, imgCnt=maxImages;
var img;
var newW,newH;
function swapImage(num)
{
	imgCnt++;
	imgNum = num;
	img = window.document.getElementById("img"+num);
	w = img.width;
//alert(w);
	timerID = setInterval('decImg()', 50);
}


function decImg()
{
//	w = img.width;
//alert(w);
	if(w<=0)
	{
		clearInterval(timerID);
		//img.src = 'http://192.168.1.32/animTest_files/8803-6183.jpg?w=65&h=86';
		//img.src = 'http://192.168.1.32/animTest_files/8031-10249.jpg?w=59&h=90';
		doPull_Sync("/S/com.spiff.ajax.S_AJAX_HomePhoto?n="+imgCnt, "img"+imgNum);

		newW = gup(img.src, 'w');
		newH = gup(img.src, 'h');
		uid = gup(img.src, 'u');

		link = window.document.getElementById("lnk"+imgNum);
		link.href = "/S/com.spiff.member.S_M_View?id="+uid;

		img = window.document.getElementById("img"+imgNum);
//alert(gup(img.src, 'w')+" "+gup(img.src, 'h'));
		img.width = 0;
		img.height = newH;
		timerID = setInterval('incImg()', 50);
	}
	else
	{
		w -= 9;
		img.width = (w);
	}


	h = img.height;
//alert(w);
	if(h>0)
	{
//		img.height = (h-8);
	}
}


function incImg()
{
//	w = img.width;
//alert(w);
	if(w>=newW || w>=60)
	{
		clearInterval(timerID);
	}
	else
	{
		w += 8;
		img.width = (w);
	}
}

function gup( url, name )
{
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( url );
	if( results == null )
	{
		return "";
	}
	else
	{
		return results[1];
	}
}

