var detect = navigator.userAgent;
var msie = checkIt('MSIE');
function checkIt(string) {
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

function imgAnim (n,img,m,t) {
// n = start image number
// img = name of image object
// m = number of the last image in the animation sequence
// t = delay in seconds

	pic = "/images/"+img+n+".jpg";
//alert (pic)
	oImg = document.getElementById(img)
//	alert (oImg.src);
	if (msie) {
		d = t - 1; if (d < 0) {d = 1;}
		oImg.style.filter = "progid:DXImageTransform.Microsoft.Fade(Duration="+d+")";
	    oImg.filters[0].apply();
	}
	oImg.src = pic;
	if (msie) {oImg.filters[0].play()}

	if (n < m) {n++} else {n=0}
	delay = t * 1000;
	setTimeout("imgAnim("+n+",'"+img+"',"+m+","+t+");", delay);
}

var filters = [
//"progid:DXImageTransform.Microsoft.RadialWipe(Duration=2)"
//,
//"progid:DXImageTransform.Microsoft.GradientWipe(Duration=2)",
"progid:DXImageTransform.Microsoft.Fade(Duration=2)"
];
var Nfilter = filters.length;

function swappic(img, wsiz, hsiz) {

	var result = img.split("/");
	filename = result[result.length-1]
	src = "url(/images/gallery/"+filename+")";
	oImg = document.getElementById("mainpic")
	oImg2 = document.getElementById("blankMain")
	if (msie) {
		n = Math.floor(Math.random()*(Nfilter));
		filterFunctionName = filters[n];
		oImg.style.filter = filterFunctionName;
	    oImg.filters[0].apply();
	 	oImg.style.backgroundImage = src;
		oImg.filters[0].play();
	} else {
		oImg.style.backgroundImage = src;
	}
	oImg.style.width = wsiz; oImg.style.height = hsiz;
	oImg2.style.width = wsiz; oImg2.style.height = hsiz;
}
