function trim(s) 
{
	return s.replace(/^\s+|\s+$/g,'');
}

var timeout = false;
var image_slot = 1;
function fadeOut(opac)
{
	if (opac > 0) {
		changeOpac('current-img-' + image_slot, opac);
		opac--;
		clearTimeout(timeout);
		timeout = setTimeout('fadeOut('+opac+')', fade_speed * 10);
	} else {
		index++; 
		caption_index++;
		
		if (index >= img.length) { index = 0; }
		
		document.getElementById('image-box-'+image_slot).innerHTML = "<img src='" + document.getElementById('next-img-'+image_slot).src + "' style='width: 200px; height: 150px; ' id='current-img-" + image_slot + "' />";
		document.getElementById('next-img-'+image_slot).src = img[index].src;		
		clearTimeout(timeout);
		image_slot = image_slot == 1 ? 2 : 1;
		timeout = setTimeout('fadeOut(100)', 1000);
	}

}

function changeOpac(id, opac)
{
	var object = document.getElementById(id).style;
	object.opacity = (opac / 100);
	object.MozOpacity = (opac / 100);
	object.KhtmlOpacity = (opac / 100);
	object.filter = "alpha(opacity=" + opac + ")";
}

function changeTotal(total)
{
	var qty = parseInt(document.getElementById('qty').options[document.getElementById('qty').selectedIndex].value);
	alert(qty);
	total = isNaN(qty) ? 0 : qty * total;
	document.getElementById('event_total_price').innerHTML = total;
}
