function changeImage(source)
{
    window.document.getElementById("mainImage").src = source;
    var href = source.replace(/previews/g,'actual');
	window.document.getElementById("mainImageAnchor").href = href;
}

function disablePhotoRef()
{
	window.document.getElementById("mainImageAnchor").href = "images/signexclusive.jpg";
}
 	
function funclubChallengeAjax(){
	var xmlhttp=false;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function changeFanclub(artistName)
{
	var fanClubName = $.trim($("#eventsToSelect  :selected").text());
	var fanclubId = $("#eventsToSelect").val();
	if(fanclubId != 0)
	{
		var params = "artistName="+artistName+"&fanClubName="+fanClubName+"&fanclubId="+fanclubId;
		ajax=funclubChallengeAjax();
		ajax.open("GET", "AJAX/AJAXgetFanclubImages.php"+"?"+params,true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				$("#fanClubName").html(fanClubName);
				$("#carouselChallenger").html(ajax.responseText);
				//Select the first image through jquery
				var newImageSource = $("#carouselChallenger li:first img").attr("src");
				//change path instead of thumbs folder, set previews
				newImageSource = newImageSource.replace(/thumbs/g,'previews');
				$("#mainImage").attr("src",newImageSource);
				var newImageHref = newImageSource.replace(/previews/g,'actual');
				$("#mainImageAnchor").attr("href",newImageHref);
			}
		};
		ajax.send(null);
	}
}

