function replaceSpanText(theSpanId,theText)
{ 
	var span =  GetElement(theSpanId);
	if(span)
	{
	  span.innerHTML=theText;
	}
}

function createPriceElement(szSize, szColor, szPrice)
{
  var o = new Object ();
	
  o.Size = szSize;	
  o.Color = szColor;
  o.Price = szPrice;
	
  return (o);
}

function InitPriceAndSizes(theSpan, theLookUp, theColorId, theSizeId)
{
	var colorsElement = (document.getElementById ? document.getElementById (theColorId) : null);
	if (!colorsElement)
	{
		return;
	}
	var selectedColor = getSelectedColor (colorsElement);

	AdjustPriceReverse (theSpan, selectedColor, theLookUp, theSizeId);
}

function AdjustPriceWithValues(theSpan, theSize, theColor, theLookUp)
{
	var newPrice = LookupPrice (theLookUp, theSize, theColor);
	
	if (newPrice)
	{
		ReplaceSpanText (theSpan, newPrice);
	}
}

function AdjustPrice(theSpan, theValue, theLookUp, theColorElement)
{
	var colorsElement = (document.getElementById ? document.getElementById (theColorElement) : null);
	var newPrice = LookupPrice (theLookUp, theValue, getSelectedColor (colorsElement));

	if(newPrice)
	{
		ReplaceSpanText(theSpan,newPrice);
	}
}

function AdjustPriceReverse(theSpan, theValue, theLookUp, theSizeElement)
{
	var value = SetupSizeList (theValue, theLookUp, theSizeElement);
	var newPrice = LookupPrice (theLookUp, value, theValue);
	
	if (newPrice)
	{
		ReplaceSpanText (theSpan, newPrice);
	}
}

function getAllSizesForColor(arList, szColor)
{
	var result = new Array ();

	for (var i = 0; i < arList.length; i ++)
	{
		if (arList [i].Color == szColor)
		{
			result.push (arList [i].Size);
		}
	}
	
	return result;
}

function LookupPrice(arList, szSize, szColor)
{
	var tempElement = null;
	var iListLength = 0;
	var iSearchCount = 0;
	var iIndex = 0;

	if (arList && arList.length > 0)
	{
		iListLength = arList.length;
		iSearchCount = iListLength / 2;

		while (iIndex < iSearchCount)
		{
			tempElement = arList [iIndex];
			
			if (tempElement.Size == szSize && tempElement.Color == szColor)
			{
				return (tempElement.Price);
			}
			
			tempElement = arList [iListLength - iIndex -1];
			
			if (tempElement.Size == szSize && tempElement.Color == szColor)
			{
				return (tempElement.Price);
			}
			
			iIndex ++;
		}
	}
	
	return (null);
}

function createPriceElement(szSize, szColor, szPrice)
{
	var o = new Object ();
	
	o.Size = szSize;	
	o.Color = szColor;
	o.Price = szPrice;
	
	return (o);
}

function getSelectedSize(sizeElement)
{
	if (!sizeElement)
	{
		return (null);
	}
	return (sizeElement.value);
}

function getSelectedColor(colorElement)
{
	if (!colorElement)
	{
		return (null);
	}
	
	return (colorElement.value);
}

function getIDs () {
  for (i=0; i<document.all.length; i++ ) {
    if(document.all[i].id)
      alert(document.all[i].id);
  }
}

function FindElement(theId)
{ 
	return document.getElementById(theId) ;

}

function ToggleDisplay(el) 
{
	if (IsVisible (el)) 
	{
		Hide (el);
	}
	else
	 {
		Show (el);
	}
}

function Show(el) 
{
	var element = FindElement (el);
	
	if (element) 
	{
		  element.style.display = '';
	}
}

function Hide(el) 
{
	var element = FindElement (el);
	if (element) 
	{
		element.style.display = 'none';
	}
}

function IsVisible(el) 
{
	var element = FindElement (el);
	if(!element)
	{
	  return false;
	}
	var disp = GetElementStyle (element, "display");
	return disp != 'none';
}

function GetStyle(theId,theStyleProp)
{
	var x = FindElement(theId);
	if(!x)
	{
	  return null;
	}
	return GetElementStyle(x,theStyleProp);
}

function GetElementStyle(theElement,theStyleProp)
{
	var ret;
	if (theElement.currentStyle)	
	{	
	  ret = theElement.currentStyle[theStyleProp];
	}
	else if (window.getComputedStyle)
	{
		var y = document.defaultView.getComputedStyle(theElement,null).getPropertyValue(theStyleProp);
		
		var cs=window.getComputedStyle(theElement,null);

        if(cs[theStyleProp])
        {
          ret=cs[theStyleProp];
        }
        else  if(cs.getPropertyCSSValue)
        {
          ret=cs.getPropertyCSSValue(theStyleProp);
        }
        else
        {
          ret=cs.getPropertyValue(theStyleProp);
        }
		}
	return ret;
}

/*
Methode f�r onChange bei den EXT-DropDownLists
*/
function myMethod(args)
{
  // args.id ist die id vom hidden-field
  // args.name ist der Name vom hidden-field
  // args.index ist der index der selektiert ist
  // args.data.id =(id vom SizeAndPrice bzw ColorAndKdbnrSx
  
}
