function displayMainImage(url, width){
	var slideimage = document.createElement("div");
	var clear = document.createElement("div");
	var image = document.createElement("img");

	slideimage.setAttribute("id", "slideimage");

	if(document.all) clear.className = "clear";
        else clear.setAttribute("class", "clear");

	image.setAttribute("id", "mainWphoto");
	image.setAttribute("src", url);
	image.setAttribute("alt", "");
	image.setAttribute("style", "opacity: 0");
	image.setAttribute("width", width);
	image.style.height = "auto";
	image.setAttribute("onload", "slideShow.fadeMainPhoto(); sellablePhoto(this.src);");
	image.onload = function(){
		slideShow.fadeMainPhoto();
		sellablePhoto(this.src);
	}
	
	var sellLink = document.createElement("div");
	sellLink.setAttribute("id", "sellLink");
	
	slideimage.appendChild(image);
	slideimage.appendChild(sellLink);
	slideimage.appendChild(clear);

	document.getElementById("slideimagearea").appendChild(slideimage);
}
function sellablePhoto(url){
	var urlString = url.split("/");
	var filename = urlString[urlString.length-1];

	if(filename.toLowerCase().match("mc_") != null){
		var sellLink = document.getElementById("sellLink")
		while(sellLink.firstChild){
			sellLink.removeChild(sellLink.firstChild);
		}

		var link = document.createElement("a");

		link.setAttribute("href", "http://northjersey.mycapture.com/mycapture/lookup.asp?originalname="+filename+"&page=image");
		link.setAttribute("target", "_blank");
		if(document.all) link.className = "buyphoto";
		else link.setAttribute("class", "buyphoto");
		
		var image = document.createElement("img");
		image.setAttribute("src", "/images/buy-photo.jpg");
		image.setAttribute("alt", "Buy This Image test");
		
		link.appendChild(image);

		document.getElementById("sellLink").appendChild(link);
	}else{
		var sellLink = document.getElementById("sellLink")
		while(sellLink.firstChild){
			sellLink.removeChild(sellLink.firstChild);
		}
	}
}