
    function setcolorpicidx_with_inventory(idx)
    {
        setcolorpicidx(idx);
        updateSizeBasedOnColorSelectionAddToCartForm_16505_17186( 'AddToCartForm_16505_17186', $('AddToCartForm_16505_17186').Color[idx].value );
    }
    function setcolorpic_with_inventory(color)
    {
        setcolorpic(color);
        updateSizeBasedOnColorSelectionAddToCartForm_16505_17186( 'AddToCartForm_16505_17186', color);
    }

    function updateSizesAddToCartForm_16505_17186(formName, color, sizes)
    {      // sizes are S,M,L
		if( false )	// do not update
			return;
			
        $('AddToCartForm_16505_17186').Size.options.length = 0;   // remove all
		if( sizes == '' )	// if no sizes, no need to update.
		{
			$('AddToCartForm_16505_17186_AddToCart').disabled=1;		// disable add to cart			
			$('AddToCartForm_16505_17186_AddToCart').src = '/images/imagelib/addtocart_disabled.gif';
			if( $('AddToCartForm_16505_17186_WishList') )
				$('AddToCartForm_16505_17186_WishList').disabled=1;		// disable wishlist button
			return;
		}
		$('AddToCartForm_16505_17186_AddToCart').disabled=0;
		$('AddToCartForm_16505_17186_AddToCart').src = '/images/imagelib/addtocart.gif';
		if( $('AddToCartForm_16505_17186_WishList') )
			$('AddToCartForm_16505_17186_WishList').disabled=0;		// disable wishlist button						
		
        var sizes_array = sizes.split(',');
		
				if( true )
				{
					if( sizes == '' )
						sizes = '';
					else if( sizes_array.length >= 2 ) // only when 2 or more selection
						sizes = ',' + sizes;			
				}
				
        for( var i = 0; i < sizes_array.length; i++ )
        {
            $('AddToCartForm_16505_17186').Size.options[i] = new Option(sizes_array[i], sizes_array[i], false );
        }
		
		if( sizes_array.length == 0 )	// if no size, disable add to cart
		{
			$('AddToCartForm_16505_17186_' + 'AddToCart').disabled = 1;
			$('AddToCartForm_16505_17186_' + 'WishList').disabled = 1;
		}
    }
    function updateSizeBasedOnColorSelectionAddToCartForm_16505_17186(formName, color)
    {
        color = color.replace(',','');  // get rid of comma
        if( color == '-' || color == '--' ) 
        {
            updateSizesAddToCartForm_16505_17186(formName, '','');
            return;
        }
        switch(color)
        {

                case 'red': updateSizesAddToCartForm_16505_17186('AddToCartForm_16505_17186', 'red',''); break;
    
                case 'brown': updateSizesAddToCartForm_16505_17186('AddToCartForm_16505_17186', 'brown',''); break;
       
        }
    }


							function enableDisableProduct(btn, obj, pid, vid, col)
							{
								var cmd = 'unpublish';
								if( btn.value == 'Publish' )
									cmd = 'publish';
									
								AJAX.open('GET', 'ajax.aspx?cmd=' + cmd + '&pid=' + pid + '&vid=' + vid + '&color=' + col, false);  
								AJAX.send(null);   
								var serverResponse = AJAX.responseText;
								
								if( serverResponse.startsWith('Y') )
								{
									if( btn.value == 'Unpublish' )		// unpublish item
									{
										obj.style.opacity = 0.3;
										obj.style.filter = 'alpha(opacity=30)';
										btn.value = 'Publish';
									}
									else 		// Publish back
									{
										obj.style.opacity = 1.0;
										obj.style.filter = 'alpha(opacity=100)';
										btn.value = 'Unpublish';		
									}
									alert(serverResponse);
								}
								else
									alert('ERROR: ' + serverResponse + ' pid=' + pid + ' vid=' + vid);
								
								//alert(obj);
							//	alert('test');
							//	alert(pid + ',' + col);
							}

							
WriteLayer('ColorVariationWindow', '', "<table border=0 cellpadding=1 cellspacing=1><tr><td colspan=2>Color Choices:<hr size=1 color=#F6ABD5></td></tr><tr><td align='center'><table border='0' cellpadding='0' cellspacing='0' id='ColorVariationTable1' class='ColorVariation' onMouseOver='jscss(\"swap\",this,\"ColorVariationHover\",\"ColorVariation\")'  onMouseOut='jscss(\"swap\",this,\"ColorVariation\",\"ColorVariationHover\")' ><tr><td><img src='/g.gif' width='2' height='2'/></td><td><img src='/g.gif' width='2' height='2'/></td><td><img src='/g.gif' width='2' height='2'/></td></tr><tr><td><img src='/g.gif' width='2' height='2'/></td><td class='ColorVariation'><table border='0' cellpadding='0' cellspacing='0'><tr><td align='center'><a href='#'   onclick='javascript:saveCurrPicColor();setcolorpicidx(1);setcolorpic_with_inventory(\"red\");restoreColorChoice();jscss(\"add\",$(\"ColorVariationTable1\"),\"ColorChoiceSelected\");return false;'><img src='https://www.wavefashion.com/ShowImage.aspx?s=icon&c=red&pid=16505&n=1' border='0' width=140 height=140/></a></td></tr><tr><td align='center'><table border=0 cellpadding=0 cellspacing=0><tr><td></td></tr></table></td></tr><tr><td align=center class='ColorVariation'><a href='#' id='colorChoice1'   onclick='javascript:saveCurrPicColor();setcolorpicidx(1);setcolorpic_with_inventory(\"red\");restoreColorChoice();jscss(\"add\",$(\"ColorVariationTable1\"),\"ColorChoiceSelected\");return false;' class='ColorChoice'>red</a></td></tr></table></td><td><img src='/g.gif' width='2' height='2'/></td></tr><tr><td><img src='/g.gif' width='2' height='2'/></td><td><img src='/g.gif' width='2' height='2'/></td><td><img src='/g.gif' width='2' height='2'/></td></tr></table></td><td align='center'><table border='0' cellpadding='0' cellspacing='0' id='ColorVariationTable2' class='ColorVariation' onMouseOver='jscss(\"swap\",this,\"ColorVariationHover\",\"ColorVariation\")'  onMouseOut='jscss(\"swap\",this,\"ColorVariation\",\"ColorVariationHover\")' ><tr><td><img src='/g.gif' width='2' height='2'/></td><td><img src='/g.gif' width='2' height='2'/></td><td><img src='/g.gif' width='2' height='2'/></td></tr><tr><td><img src='/g.gif' width='2' height='2'/></td><td class='ColorVariation'><table border='0' cellpadding='0' cellspacing='0'><tr><td align='center'><a href='#'   onclick='javascript:saveCurrPicColor();setcolorpicidx(1);setcolorpic_with_inventory(\"brown\");restoreColorChoice();jscss(\"add\",$(\"ColorVariationTable2\"),\"ColorChoiceSelected\");return false;'><img src='https://www.wavefashion.com/ShowImage.aspx?s=icon&c=brown&pid=16505&n=1' border='0' width=140 height=140/></a></td></tr><tr><td align='center'><table border=0 cellpadding=0 cellspacing=0><tr><td></td></tr></table></td></tr><tr><td align=center class='ColorVariation'><a href='#' id='colorChoice2'   onclick='javascript:saveCurrPicColor();setcolorpicidx(1);setcolorpic_with_inventory(\"brown\");restoreColorChoice();jscss(\"add\",$(\"ColorVariationTable2\"),\"ColorChoiceSelected\");return false;' class='ColorChoice'>brown</a> [Sold out]</td></tr></table></td><td><img src='/g.gif' width='2' height='2'/></td></tr><tr><td><img src='/g.gif' width='2' height='2'/></td><td><img src='/g.gif' width='2' height='2'/></td><td><img src='/g.gif' width='2' height='2'/></td></tr></table></td></tr></table>");