function UpdateColor()
{
	var color = "";
	var price = 0;
	var priceClient = 0;
	if(document.productform.color.length)
	{
		for (i=0; i<document.productform.color.length; i++)
		{
			if (document.productform.color[i].checked==true)
			{
				color = document.productform.color[i].value;
				break;
			}
		}
	}
	else
	{
		color = document.productform.color.value;
	}
	if(this.type == 0)
	{
		var selectedSize = document.productform.size[document.productform.size.selectedIndex].value;
		var objOption = null;
		document.getElementById('cboSize').innerHTML = '';
		for(var i=0; i<this.arrProduct.length; i++)
		{
			if(this.arrProduct[i].Color == color)
			{
				if(price == 0)
					price = arrProduct[i].Price;
				if(priceClient == 0 && isClient)
					priceClient = arrProduct[i].WPrice;	
				objOption = document.createElement('option');
				objOption.text = arrProduct[i].Size;
				objOption.value = arrProduct[i].Size;
				if(arrProduct[i].Size == selectedSize)
				{
					//objOption.checheck = true;
					price = arrProduct[i].Price;
					if(isClient)
						priceClient = arrProduct[i].WPrice;	
				}
				  try {
					document.getElementById('cboSize').add(objOption, null);
				  }
				  catch(ex) {
					document.getElementById('cboSize').add(objOption);
				  }
			}
		}
	}
	if(price == 0)
	{
		for(var i=0; i<this.arrProduct.length; i++)
		{
			if(this.arrProduct[i].Color == color)
			{
				price = this.arrProduct[i].Price;
				if(isClient)
						priceClient = arrProduct[i].WPrice;	
				break;
			}
		}
	}
	if(isClient)
	{
		document.getElementById('itemPrice').innerHTML = priceClient;
		document.getElementById('itemPriceSuggest').innerHTML = price;
	}
	else
	{
		document.getElementById('itemPrice').innerHTML = price;
	}
}

function UpdateSize()
{
	var size = document.productform.size[document.productform.size.selectedIndex].value;
	var price = 0;
	var priceClient = 0;
	if(this.type == 0)
	{
		var colorInnerHTML = "";
		var selectedColor = "";
		var checked = false;
		for (i=0; i<document.productform.color.length; i++)
		{
			if (document.productform.color[i].checked==true)
			{
				selectedColor = document.productform.color[i].value;
				break;
			}
		}
		for(i=0; i<arrProduct.length; i++)
		{
			if(this.arrProduct[i].Size == size)
			{
				if(price == 0)
					price = arrProduct[i].Price;
				if(priceClient == 0 && isClient)
					priceClient = arrProduct[i].WPrice;	
				if(this.arrProduct[i].Color == selectedColor)
				{
					colorInnerHTML += '<input type="radio" name="color" value="' + arrProduct[i].Color  + '" id="chk' + arrProduct[i].Color + '"  onClick="UpdateColor();" checked="checked"/> <label for="chk' + arrProduct[i].Color + '">' + arrProduct[i].FullColor + '</label><br />';
					price = arrProduct[i].Price;
					if(isClient)
						priceClient = arrProduct[i].WPrice;	
					checked = true;
				}
				else
				{
					colorInnerHTML += '<input type="radio" name="color" value="' + arrProduct[i].Color  + '" id="chk' + arrProduct[i].Color + '"  onClick="UpdateColor();"/> <label for="chk' + arrProduct[i].Color + '">' + arrProduct[i].FullColor + '</label><br />';
				}
			}
		}
		document.getElementById('chkColors').innerHTML = colorInnerHTML;
		if(!checked && document.productform.color.length)
			document.productform.color[0].checked = true;
		else if(!checked)
			document.productform.color.checked = true;
	}
	if(price == 0)
	{
		for(i=0; i<this.arrProduct.length; i++)
		{
			if(this.arrProduct[i].Size == size)
			{
				price = this.arrProduct[i].Price;
				if(isClient)
						priceClient = arrProduct[i].WPrice;	
				break;
			}
		}
	}
	if(isClient)
	{
		document.getElementById('itemPrice').innerHTML = priceClient;
		document.getElementById('itemPriceSuggest').innerHTML = price;
	}
	else
	{
		document.getElementById('itemPrice').innerHTML = price;
	}
}

function Update()
{
	if(this.type == 2)
		UpdateSize();
	else
		UpdateColor();
}
	
