function freeSample(params){
		$swatchID = params.swatchID;
		$imageSource = params.swatchImage;
		
		$imageDesc = params.swatchDesc;
		img = document.createElement('img');
		img.src = '/'+$imageSource;
		//img.style.width='70px';
		img.style.height='90px';
		
		img.title=$imageDesc;
		img.alt=$imageDesc;

		$swatchList = $('swatchList').value;
		//console.debug($swatchList);	
		
		$swatchList = ($swatchList!='') ? $swatchList.split(',') : new Array();
		if($swatchList.length>4) return false;
		//console.debug($swatchList);
		
		//loop the swatch list - if our swatchID is already in there break out
		//silently
		for($i=0;$i< $swatchList.length; $i++)
		{
			if($swatchList[$i] == $swatchID) return false;
		}
		
		$nextTarget = $swatchList.length+1;
		//$nextTarget=1;
		//console.debug($nextTarget);
		
		target = $$('#fabric'+$nextTarget+' div');
		control = $$('#fabric'+$nextTarget+' p.fabricName');
		
		nameDiv = document.createElement('div');
		nameDiv.innerHTML = '<div class="freeSamplesSmallText">'+$imageDesc;+'</div>';
		//console.debug( $nextTarget  );
		//$('fabric1').childNodes
		if(target[0])
		{
			target[0].appendChild(img);
			target[0].appendChild(nameDiv);

			$swatchList[$swatchList.length] = $swatchID;
			$('swatchList').value = $swatchList.join(',');
		}
	
		if($swatchList.length == 5)
		{
			document.getElementById('showSamplesLink').style.visibility = 'visible'; 
		}
		
		
		
		//console.debug(control);
		if(control[0]){
		control[0].innerHTML = '<a href="#" onclick="removeSample('+$nextTarget+'); return false;">Remove</a>';
		}
		//console.debug(img);
}

function removeSample(targetID){
	//need to know all the targets in the list
	//console.debug(targetID);
	
	$swatchList = $('swatchList').value;
	$swatchList = $swatchList.split(',');
	
	$refactoredList = new Array();
	$refactoredContents = new Array();

	for($i=0;$i<$swatchList.length;$i++){
		if(targetID != $i+1){
			//console.debug(targetID);
			target = $$('#fabric'+($i+1)+' div');
			control = $$('#fabric'+($i+1)+' p.fabricName');
						
			$refactoredList[$refactoredList.length] = $swatchList[$i];
			if(target[0]) $refactoredContents[$refactoredContents.length] = target[0].innerHTML;
		}
		$('swatchList').value = $refactoredList.join(',');
	}
	
	for($i=0; $i<5; $i++){
			target = $$('#fabric'+($i+1)+' div');
			control = $$('#fabric'+($i+1)+' p.fabricName');
			if($refactoredContents[$i]){
				if(target[0]) target[0].innerHTML = $refactoredContents[$i];
				if(control[0]) control[0].innerHTML = '<a href="#" onclick="removeSample('+($i+1)+'); return false;">Remove</a>';
			}
			else{
				if(target[0]) target[0].innerHTML = '';
				if(control[0]) control[0].innerHTML = '&nbsp;';
			}
			//console.debug($refactoredContents[$i]);
	}
}
