
/*
	setConfiguratorOptions()
		Befuellt aus einem Array das zweite Select des Konfigurators
*/
var setConfiguratorOptions = function()
{
	var configForm = document.forms['Configurator'];
	var selects = [configForm.elements['ConfigOptions[1]'],configForm.elements['ConfigStep2']];
	var chosenIndex = selects[0].selectedIndex;
	Ease.DOM.removeAllChildNodes(selects[1]);
	
	for (var property in secondOptionsArr[chosenIndex])
	{
		Ease.DOM.createElement('option',{'value' : property},secondOptionsArr[chosenIndex][property],selects[1],null);
	}
};

var checkConfiguratorOptions = function()
{
	var noticeElem = Ease.DOM.getElems('noticeConfigurator');
	var configForm = document.forms['Configurator'];
	var selects = [configForm.elements['ConfigOptions[1]'],configForm.elements['ConfigStep2']];
	
	if (selects[0].selectedIndex < 1)
	{
		setConfiguratorNoticeOpacity(noticeElem,'Please select a product category.',1,1,true)
		return false
	}
	else if (selects[1].selectedIndex < 1)
	{
		setConfiguratorNoticeOpacity(noticeElem,'Please refine selection.',1,1,true)
		return false
	}
	
	return true;
};

var setConfiguratorNoticeOpacity = function(elem,notice,opac,start,first,fadeOut)
{
	var elem = Ease.DOM.getElems(elem);
	var fadeOut = fadeOut || null;
	
	if (first)
	{
		Ease.CSS.setOpacity(elem,opac);
	}
	
	var newOpac;
	if (start == 1)
	{
		newOpac = parseFloat(opac-0.1);
	}
	else
	{
		newOpac = parseFloat(opac+0.1);
	}
	
	if (start == 1)
	{
		if (opac > 0)
		{
			Ease.CSS.setOpacity(elem,newOpac);
			window.setTimeout(function(){setConfiguratorNoticeOpacity(elem,notice,newOpac,start,false,fadeOut)},20);
		}
		else
		{
			elem.innerHTML = notice;
			newOpac = 0;
			start = 0;
			if (!fadeOut)
			{
				window.setTimeout(function(){setConfiguratorNoticeOpacity(elem,notice,newOpac,start,false,fadeOut)},20);
			}
		}
	}
	else
	{
		if (opac < 1)
		{
			Ease.CSS.setOpacity(elem,newOpac);
			window.setTimeout(function(){setConfiguratorNoticeOpacity(elem,notice,newOpac,start,false,fadeOut)},20);
		}
	}
}

var setConfiguratorNotice = function(obj)
{
	if (obj.selectedIndex != 0)
	{
		if (obj.name != 'ConfigOptions[1]')
		{
			setConfiguratorNoticeOpacity('noticeConfigurator','Now click on "search".',0,1,true,false);
		}
		else
		{
			setConfiguratorNoticeOpacity('noticeConfigurator','Please refine selection.',0,1,true,false);
		}
	}
	else
	{
		var msg = obj.name == 'ConfigOptions[1]' ? 'Please select a product category.' : 'Please refine selection.';
		setConfiguratorNoticeOpacity('noticeConfigurator',msg,0,1,true,false);
	}
}
