function filenameOnly (InString)  {
	LastSlash=InString.lastIndexOf ('/', InString.length-1)
	OutString=InString.substring  (LastSlash+1, InString.length)
	return (OutString);
}

function backgroundSwap(background, column, repeat) {

	loading = document.getElementById? parent.document.getElementById('loading'): document.all? parent.document.all['loading']: null;
	gallery = document.getElementById? parent.document.getElementById('gallery'): document.all? parent.document.all['gallery']: null;
	galleryCopy = document.getElementById? parent.document.getElementById('galleryCopy'): document.all? parent.document.all['galleryCopy']: null;
	eyeCandy = document.getElementById? parent.document.getElementById('eyeCandy'): document.all? parent.document.all['eyeCandy']: null;
	columnFrame = document.getElementById? parent.document.getElementById('displayColumn'): document.all? parent.document.all['displayColumn']: null;
	
	try {
		loading.style.visibility="visible";
	}
	catch(oException) {document.location.href="http://www.kzink.com/?url="+document.location.pathname+"";return false;}

	
	newColumn = column;



	if (typeof newColumn == "undefined" | newColumn==""){newColumn="/newsC.html";}

	var checkNewColumn = filenameOnly(newColumn);
	var checkCurrentFrame = filenameOnly(columnFrame.src);

	if (checkNewColumn==checkCurrentFrame){
		newColumn="none";
	}
	
	if (window == parent) return;
	else {
		newImage = background;
		if (repeat!="no"){
			if (newColumn!="none"){
				columnFrame.src=newColumn;
			}
			galleryCopy.innerHTML="";
			backgroundImage=new Image();
			backgroundImage.src="/images/eyeCandy/"+background;
	    }

	    if (backgroundImage.complete){
			//var globalTransition="blendTrans(duration=1.5)";
			var globalTransition="progid:DXImageTransform.Microsoft.Pixelate(MaxSquare=30,Duration=1, Enabled=false)";
			if (document.all){
	      			eyeCandy.style.filter=globalTransition;
	      			eyeCandy.filters[0].Apply();
	      			//document.body.style.filter=globalTransition;
	      			//document.body.filters[0].Apply();
				gallery.style.filter=globalTransition;
	      			gallery.filters[0].Apply();
				galleryCopy.style.filter=globalTransition;
	      			galleryCopy.filters[0].Apply();
	   		}
	   		eyeCandy.src="/images/eyeCandy/"+newImage;
	   		document.body.style.visibility="visible";
			gallery.src="/images/display/blank.gif";
			galleryCopy.innerHTML="";
			loading.style.visibility="hidden";
	   		if (document.all){
	      			eyeCandy.filters[0].Play();
	      			//document.body.filters[0].Play();
				gallery.filters[0].Play();
				galleryCopy.filters[0].Play();
	   		}
			gallery.style.display="none";
	   	}

	   	else {
			setTimeout ("backgroundSwap(newImage,newColumn,'no')", 100);
	   	}
	}
}
