function doLayerSwap(strLayerID,strType){

	if(!$('#productdetail .largeimg').length>0){
		if(strType=='video'){
			$('#productdetail .info').css('display','none');
			$('#productdetail .img').css('width','100%');
		}else{
			$('#productdetail .info').css('display','block');
			$('#productdetail .img').css('width','162px');
		}
	}

	$('#imgswap').children().css('display','none');
	$('#'+strLayerID).css('display','block');
	$('#imgnav a').removeClass('selected');
	$('#'+strLayerID+'link').addClass('selected');

	drawCloseUpLink(strLayerID);
}

function initLayerNav(){
	var strLayerNav='';
	var intCount=-1; //changed to -1 to take into account thumbnail outside of usual Product Image system.
	var strSiteLoc=window.location.href;

	$('.imgcontainer').each(function(i){
		intCount=intCount+1
		if(intCount==0){
			strClass=' class="selected"';
		}else{
			strClass='';
		}

		var strAlt;
		var strImgClass;
		var strOnClick;

		if($(this).find('object').length>0){
			strImgClass='video';
			strAlt='Video '+(intCount+1);
			strOnClick=' onclick="doLayerSwap(\'img'+intCount+'\',\''+strImgClass+'\');return false;"';
		}else{
			strImgClass='image';
			strAlt='Image '+(intCount+1);
			strOnClick=' onclick="doLayerSwap(\'img'+intCount+'\',\''+strImgClass+'\');return false;"';
		}

		strLayerNav+=' <a href="'+strSiteLoc+'"'+strOnClick+strClass+' id="img'+intCount+'link"><img src="/images/spacer.gif" alt="'+strAlt+'" class="'+strImgClass+'" /></a>';
	});

	if(intCount>0){
		$('#imgnav').html('<span class="imglist">'+strLayerNav+'</span>');
	}else{
		$('#prodimgnav').html('');
	}
	drawCloseUpLink('img0');
}

function drawCloseUpLink(strLayerID){
	$('#imgnav 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='';
		}
		$('#imgnav').append('<a href="'+strHref+'" class="closeup shadowbox"'+strTitle+'>Close Up</a>');

		Shadowbox.setup("a.shadowbox", {
			
		});

	}
}

