function doLayerSwap(strLayerID){
	$('#productdetail .productimages').children().not('#prodimgnav').css('display','none');
	$('#'+strLayerID).css('display','block');
	$('#prodimgnav a').removeClass('selected');
	$('#'+strLayerID+'link').addClass('selected');

	drawCloseUpLink(strLayerID);
}

function initLayerNav(){
	var strLayerNav='';
	var intCount=0;
	var strSiteLoc=window.location.href;

	$('.imgcontainer').each(function(i){
		intCount=intCount+1
		if(intCount==1){
			strClass=' class="selected"';
		}else{
			strClass='';
		}
		strLayerNav+=' <a href="'+strSiteLoc+'" onclick="doLayerSwap(\'img'+intCount+'\');return false;"'+strClass+' id="img'+intCount+'link">'+intCount+'</a>';
	});

	if(intCount>1){
		$('#prodimgnav').html('<span class="imglist">'+strLayerNav+'</span>');
	}else{
		$('#prodimgnav').html('');
	}
	drawCloseUpLink('img1');
}

function drawCloseUpLink(strLayerID){
	$('#prodimgnav a.closeup').replaceWith('');

	var strHref=$('#'+strLayerID+' a.shadowbox').attr('href');
	var strTitle=$('#'+strLayerID+' a.shadowbox').attr('title');

	if(strHref){
		if(strTitle){
			strTitle=' title="'+strTitle+'"';
		}else{
			strTitle='';
		}
		$('#prodimgnav').append('<a href="'+strHref+'" class="closeup shadowbox"'+strTitle+'>Close Up</a>');

		Shadowbox.setup("a.shadowbox", {
			
		});

		//tb_init('a.closeup');
	}
}
