<!--

function OptionChange(Option2Desc)
{

	//first check to see if ColorSize is not set to "Color" or "" and store text
	var ColorSizeText;
	var ColorSizeValue;

	if( document.csform1.ColorSize.selectedIndex >= 0 )
	{
		ColorSizeValue = document.csform1.ColorSize.options[document.csform1.ColorSize.selectedIndex].value;

		if (ColorSizeValue != "Color" || ColorSizeValue != "Size" || ColorSizeValue != "")
		{
			ColorSizeText = document.csform1.ColorSize.options[document.csform1.ColorSize.selectedIndex].text;
		}
	}

	//remove all options from second select besides first one
	document.csform1.ColorSize.options.length = 1;

	var newOption;
	var i;
	var j;
	var k = document.csform1.ColorSize.options.length;

	var iFirstSelectedIndex = document.csform1.selOption1.selectedIndex;

	if(document.csform1.selOption1.options[iFirstSelectedIndex].value == 'Size')
	{
		if (country == "DE")
		{
			// document.csform1.ColorSize.options[1] = new Option("Bitte zuerst2 Größe auswählen","");
			document.csform1.ColorSize.options[1] = new Option(unescape("Bitte zuerst Gr%F6%DFe ausw%E4hlen"),"");
		}		
		else
		{
			document.csform1.ColorSize.options[1] = new Option("Select Size First","");
		}
		document.csform1.ColorSize.options[0].selected = true;
	}
	else if(document.csform1.selOption1.options[iFirstSelectedIndex].value == 'Color')
	{
		document.csform1.ColorSize.options[1] = new Option("Select Color First","");
		document.csform1.ColorSize.options[0].selected = true;
	}
	else
	{
		// loop through the color codes array
		for(i=0; i < arrFirstValues.length; i++)
		{
			if(arrSecondValues[i])
			{
				// does this color code match the color code that is selected?
				if(document.csform1.selOption1.options[iFirstSelectedIndex].value == arrFirstValues[i])
				{
					// loop through the sizes available for this color code
					for(j=0; j < arrSecondValues[i].length; j++)
					{
						document.csform1.ColorSize.options[k] = new Option(arrSecondNames[i][j], arrSecondValues[i][j]);

						//if this was the previously selected color, keep it selected
						if(arrSecondNames[i][j] == ColorSizeText ||
						((arrSecondNames[i][j] + " - WAITLIST ONLY") == ColorSizeText) ||
						 (arrSecondNames[i][j] == (ColorSizeText + " - WAITLIST ONLY")))
						{
							document.csform1.ColorSize.options[k].selected = true;
						}

						k++;
					}
				}
			}
		}
	}
	
	if(Option2Desc != null || Option2Desc != "")
	{
		for(i=0; i < document.csform1.ColorSize.options.length; i++)
		{
			if(document.csform1.ColorSize.options[i].text == Option2Desc)
			{
				document.csform1.ColorSize.options[i].selected = true;
			}
		}
	}

	if (document.csform1.ColorSize.options.selectedIndex < 1)
	{
		document.csform1.ColorSize.options[0].selected = true;
	}

	if (country != "DE")
	{
		ShowHideWaitlist();
	}
}

function ShowHideWaitlist( )
{
	var img, shimsrc, wlsrc, shimimg, aodate;
	selOption = document.csform1.ColorSize.options[document.csform1.ColorSize.selectedIndex].value;
	values = new Array();
	values = selOption.split(":");

	if (country == "UK")
	{
		shimsrc="/qvc/gif/shim.gif";
		wlsrc = "/ukgif/WaitlistErrorUK.gif";
	}
	else
	{
		shimsrc="/qvc/gif/shim.gif";
		wlsrc = "/qvc/gif/waitlist3.gif";
	}

	if (document.getElementById)
	{
		img = document.getElementById("waitlist");
		if (country != "UK")
		{
			shimimg = document.getElementById("waitlistshim");
		}
		else
		{
			//only UK has advanced order
			aodate = document.getElementById("advdate");
					}
	}
	else
	{
		img = document.ids.waitlist;
		if (country != "UK")
		{
			shimimg = document.ids.waitlistshim;
		}
		else
		{
			//only UK has advord
			aodate = document.ids.advdate;
		}
	}
	
	img.src = (values[1] == 'W') ? wlsrc : shimsrc;
	
	if(country == "UK")
	{
		img.height = (values[1] == 'W') ? "19" : "0";
		img.alt = "Available on wait list";

		//advanced order
		aodate.style.display = (values[1] == 'A') ? "block" : "none";
		aodate.style.visibility = (values[1] == 'A') ? "visible" : "hidden";
		aodate.style.fontSize = (values[1] == 'A') ? "10pt" : "0";
	}
	else
	{
		img.height = (values[1] == 'W') ? "16" : "0";
		shimimg.height=(values[1] == 'W') ? "5" : "0";
	}	
}

function ResetLabelColor()
{
	var lblSize = document.getElementById("sizelabel");
	var lblColor = document.getElementById("colorlabel");
	var lblOption = document.getElementById("optionlabel");

	if(lblSize)
		lblSize.style.color = "#636563";

	if(lblColor)
		lblColor.style.color = "#636563";

	if(lblOption)
		lblOption.style.color = "#636563";
}

var activated = 1;

function CheckForColorSize()
{
	var tmpElement = document.getElementById("ColorErrorImg");
	if (tmpElement != null )
	{
		tmpElement.height = "0";
	}
	
	tmpElement = document.getElementById("OptionErrorImg");
	if (tmpElement != null )
	{
		tmpElement.height = "0";
	}
	
	tmpElement = document.getElementById("SizeErrorImg");
	if (tmpElement != null )
	{
		tmpElement.height = "0";
	}

	tmpElement = document.getElementById("colorNbr");
	if (tmpElement != null )
	{
		tmpElement.style.color = "#000000";
	}

	tmpElement = document.getElementById("colorNbrBorder");
	if (tmpElement != null )
	{
		tmpElement.style.borderColor = "#000000";
	}

	tmpElement = document.getElementById("sizeNbr");
	if (tmpElement != null )
	{
		tmpElement.style.color = "#000000";
	}

	tmpElement = document.getElementById("sizeNbrBorder");
	if (tmpElement != null )
	{
		tmpElement.style.borderColor = "#000000";
	}
	
	ResetLabelColor();

	var form = document.csform1;
	var ret = true;

	if (activated != 1){
		return false;
	}

	if( form.ColorSize != null )
	{
		document.tmpVars.SelectedColorSize.value = form.ColorSize.selectedIndex;
	}

	if(document.getElementById)
	{

		if(form.ColorSize != null && form.ColorSize.options != null)
		{
			
			if(form.ColorSize.options[form.ColorSize.selectedIndex].value == "Size")				
			{
				ret = ShowSizeError(form.ColorSize);
			}

			if(form.ColorSize.options[form.ColorSize.selectedIndex].value == "Color")
			{
				ret = ShowColorError(form.ColorSize);
			}
		}

		if(form.selOption1 != null)
		{
			//look for unselected size
			if(form.selOption1.options[form.selOption1.selectedIndex].value == "Size" )
			{
				ret = ShowSizeError(form.selOption1);
			}				
			//look for unselected error
			else if(form.selOption1.options[form.selOption1.selectedIndex].value == "Color")
			{
				ret = ShowColorError(form.selOption1);
			}
		}

		if(ret)
		{
			activated = 0;
			return true;
		}
		else
		{
			return false;
		}
	}
	else
	{
		activated = 0;
		return true;
	}
}

var bCheckedForSwappedItem = false;

function CountErrors()
{
	var nCnt = 0;
	var selSize = document.csform1.selOption1;
	var selColor = document.csform1.ColorSize;		// Same thing when we just have an option box

	if(selSize != null && selSize.selectedIndex == 0)
		nCnt++;

	if(selColor != null && selColor.selectedIndex == 0)
		nCnt++;
		
	return(nCnt);
}

function IsSwappedItem()
{
	if(document.csform1.ColorSizeSwapFlag.value == 0)
		return(false);
	else
		return(true);
}

function ShowColorError(select)
{
	if(!bCheckedForSwappedItem) {
		if(IsSwappedItem()) {
			bCheckedForSwappedItem = true;
			return(ShowSizeError());
		}
		else // reset the flag
			bCheckedForSwappedItem = false;
	}
	else	// reset the flag
		bCheckedForSwappedItem = false;
	
	var opt;
	var redir;
	var bIsSwapped = document.csform1.ColorSizeSwapFlag.value;

	var img = document.getElementById("OptionErrorImg");
	if (img == null)
	{
		img = document.getElementById("ColorErrorImg");
		opt = false;
	}
	else
	{
		opt = true;
	}

	if(img != null)
	{
		// Set the error image
		if(!opt)
		{
			if(CountErrors() == 2)
			{
				document.getElementById("SizeErrorImg").innerHTML = "<img src=\"/degif/ColorErrorDE_SizeErrorDE.gif\" height=\"42\" width=\"384\">";
			}
			else
			{
				document.getElementById("SizeErrorImg").innerHTML = "<img src=\"/degif/ColorErrorDE.gif\" height=\"22\" width=\"384\">";
			}
			
			redir="#ColorError";
		}
		else
		{
			document.getElementById("OptionErrorImg").innerHTML = "<img src=\"/degif/OptionErrorDE.gif\" height=\"22\" width=\"384\">";
			redir="#OptionError";
		}
		
		
		// Highlight the label of the offending field in red
		if(!opt)
		{
			document.getElementById("colorlabel").style.color = "#DE2029";
		}
		else
		{
			document.getElementById("optionlabel").style.color = "#DE2029";
		}
	}

	document.location.href = redir;
	return false;
}

function ShowSizeError(select)
{
	if(!bCheckedForSwappedItem) {
		if(IsSwappedItem()) {
			bCheckedForSwappedItem = true;
			return(ShowColorError());
		}
		else // reset the flag
			bCheckedForSwappedItem = false;
	}
	else	// reset the flag
		bCheckedForSwappedItem = false;
	
	var opt;
	var img;
	var redir;

	img = document.getElementById("OptionErrorImg");
	if (img == null)
	{
		img = document.getElementById("SizeErrorImg");
		opt = false;
	}
	else
	{
		opt = true;
	}

	if(img != null)
	{		
		if(!opt)
		{
			if(CountErrors() == 1)
			{
				document.getElementById("SizeErrorImg").innerHTML = "<img src=\"/degif/SizeErrorDE.gif\" height=\"22\" width=\"384\">";
			}
			redir="#SizeError";
		}
		else
		{
			document.getElementById("OptionErrorImg").innerHTML = "<img src=\"/degif/OptionErrorDE.gif\" height=\"22\" width=\"384\">";
			redir="#OptionError";
		}

		if(!opt)
		{
			document.getElementById("sizelabel").style.color = "#DE2029";
		}
		else
		{
			document.getElementById("optionlabel").style.color = "#DE2029";
		}
	}
	
	document.location.href=redir;
	return false;
}

function SelectOption(Option1Desc, Option2Desc)
{
	var i, form;

	form = document.csform1;	
	if( form.selOption1 != null)
	{	
		for(i=0; i < form.selOption1.options.length; i++)
		{		
			if(form.selOption1.options[i].text == Option1Desc)
			{
				form.selOption1.options[i].selected = true;
				OptionChange(Option2Desc);				
				break;
			}
		}
	}
	else
	{
		for(i=0; i < form.ColorSize.options.length; i++)
		{
			if(form.ColorSize.options[i].text == Option1Desc)
			{
				form.ColorSize.options[i].selected = true;
				if (country != "DE")
				{
					ShowHideWaitlist();
				}
				break;
			}
		}
	} 	
}

function checkDropDowns( )
{
	if( ( document.csform1.selOption1 != null ) && ( document.csform1.selOption1.selectedIndex != 0 ) && ( document.tmpVars.SelectedColorSize.value != "" ) )
	{
		OptionChange();

		document.csform1.ColorSize.selectedIndex = document.tmpVars.SelectedColorSize.value;
		if (country != "DE")
		{
			ShowHideWaitlist();
		}
	}
	
	return false;
}
// -->