function revealOptions(stock_id) {
	objCurrent = document.variant_selector.selected_shirt;
	objFirstCheckBox = document.getElementById('first_checkbox_opt_'+stock_id);
	
	if (stock_id != objCurrent.value) {
		intCurrentSelected = objCurrent.value;
		objCurrentDiv = document.getElementById('opt_'+intCurrentSelected);
		objNewDiv = document.getElementById('opt_'+stock_id);
		
		objCurrentPrevImg = document.getElementById('img_shirt_preview_'+intCurrentSelected);
		objNewPrevImg = document.getElementById('img_shirt_preview_'+stock_id);
			
		objCurrentShirtLink = document.getElementById('shirt_link_'+intCurrentSelected);
		objNewShirtLink = document.getElementById('shirt_link_'+stock_id);
				
		// Change the link style
		objCurrentShirtLink.className = "shirt_type_link";
		objNewShirtLink.className = "selected_shirt_type_link";
		
		// Show the variant options
		objNewDiv.style.display = '';
		objCurrentDiv.style.display = 'none';
		
		// Show the correct preview img
		objNewPrevImg.style.display = '';
		objCurrentPrevImg.style.display = 'none';
		
		objCurrent.value = stock_id;
		
		objFirstCheckBox.checked = true;
		
		
		// Highlight the cell		
		highlightCell(objFirstCheckBox.value);
	}
}

function updatePrice(price) {
	document.getElementById('price').innerHTML  = price;
	document.getElementById('price2').innerHTML = price;
}

function highlightCell(prod_stock_id) {
	objCurrent = document.variant_selector.selected_stock_variant_id;
	if (objCurrent.value != 0) {
		objCurrentSelectedCell = document.getElementById('cell_'+objCurrent.value);
	}
	objNewSelectedCell = document.getElementById('cell_'+prod_stock_id);
	
	objNewSelectedCell.style.background = 'url(/static/img/bgs/purple_light_grad_up.gif) repeat-x top';

	if (objCurrent.value != 0&&prod_stock_id!=objCurrent.value) {
		objCurrentSelectedCell.style.background = 'url(/static/img/bgs/silver_grad_up.gif) repeat-x top';
	}			
	objCurrent.value = prod_stock_id;				
}

function InStr(strSearch, charSearchFor)
{
            for (i=0; i < strSearch.length; i++)
            {
                  if (charSearchFor == Mid(strSearch, i, 1))
                  {
                        return i;
                  }
            }
            return -1;
}

function hideVariants() {
	if (!document.getElementsByTagName) return; 
		arr_nodes = document.getElementsByTagName('div');
		var intOptCount = 0;
		for (i = 0; i < arr_nodes.length; i++) { 
		obj_node = arr_nodes[i];
			if (obj_node.id.indexOf('opt_') > -1) {
				if (intOptCount > 0) {
					obj_node.style.display = 'none';
				} else {
					intOptCount++;
				}
			}
		}
}

function showImg(filename, image_id) {
	document.getElementById('product_image').src = filename;
	
	var strCurrentlySelectedThumbnail = document.getElementById('selected_thumbnail_img').value;
	
	document.getElementById('thumbnail_'+image_id).className = 'product_image_extra_selected';
	
	if (strCurrentlySelectedThumbnail!=image_id){ 
		document.getElementById('thumbnail_'+strCurrentlySelectedThumbnail).className = 'product_image_extra';
	}
	
	document.getElementById('selected_thumbnail_img').value = image_id;
	
}