////////////////////////////////////////////////////////////////////////////////////////////////////////
// CONFIG SETTINGS
////////////////////////////////////////////////////////////////////////////////////////////////////////

var shsCONFIG = new Array();

shsCONFIG['IE'] = (navigator.appName == "Microsoft Internet Explorer");
shsCONFIG['IE6'] = (navigator.appVersion.indexOf("MSIE 6.0") >= 0)


////////////////////////////////////////////////////////////////////////////////////////////////////////
// FUNCTIONS
////////////////////////////////////////////////////////////////////////////////////////////////////////


function shsChangeWeather(thisObj)
{
	if(thisObj)
	{
		var oIframeWeather = document.getElementById("iframe_wetter");
		if(oIframeWeather)
		{
			oIframeWeather.src = oIframeWeather.src.replace(/WMO=([^&]*)&PLZN=([^&]*)/, thisObj.options[thisObj.selectedIndex].value);
		}
	}
}


function shsShopSelectShirtSize(thisObj)
{
	if(thisObj)
	{
		var checkboxName = thisObj.name.replace("_Groesse", "");
		var oCheckbox = document.getElementsByName(checkboxName)[0];
		if(oCheckbox)
		{
			oCheckbox.value = oCheckbox.value.replace(/ - Größe.*/, "");
			oCheckbox.value = oCheckbox.value + " - Größe: " + thisObj.options[thisObj.selectedIndex].value;
		}
	}
}


function shsShopDisableItems(thisObj, aItems, arrayPrefix)
{
	if(thisObj && aItems)
	{
		arrayPrefix = (arrayPrefix) ? arrayPrefix : "Prospekt";
		for(var i=0; i<aItems.length; i++)
		{
			var oItem = document.getElementsByName(arrayPrefix+"["+aItems[i]+"]")[0];
			if(oItem)
			{
				var oTR = shsGetParent(oItem, "TR");
				
				oItem.disabled = thisObj.checked;
				
				if(oItem.disabled)
					oTR.className = oTR.className + " artikel_disable";
				else
					oTR.className = oTR.className.replace(/ artikel_disable/g, "");
			}
		}
	}
}


function shsCalculateDistance()
{
	var oFrom = document.getElementById("select_from");
	var oTo = document.getElementById("select_to");
	
	if(oFrom && oTo)
	{
		if(shsGetFormFieldValue(oFrom) && shsGetFormFieldValue(oTo))
		{
			var oForm = shsGetParent(oFrom, "FORM");
			if(oForm)
			{
				oForm.submit();
				return true;
			}
		}
	}
	
	return false;
}


function shsGetFormFieldValue(thisObj)
{
	if(!thisObj)
		return;
	
	var tagName = thisObj.tagName.toUpperCase();
	
	if(tagName == "SELECT")
	{
		if(thisObj.selectedIndex >= 0)
			return thisObj.options[thisObj.selectedIndex].value;
		else
			return;
	}
	else
		return thisObj.value;
}


function shsGetParent(thisObj, tagName)
{
	tagName = tagName.toUpperCase();
	
	thisObj = thisObj.parentNode;
	while(thisObj.parentNode.tagName != null && thisObj.tagName.toUpperCase() != tagName)
		thisObj = thisObj.parentNode;
		
	return thisObj;
}


function shsFade(dir, amount, step, name)
{
	var navImg1 = document.getElementById(name);
	var f_amount = 0;
	var delay = 50;
	
	if (!navImg1)
	{
		setTimeout('shsFade(\''+dir+'\', '+ amount +', '+ step +', \''+ name +'\')', delay);
		return;
	}
	
	if (amount < 0)
	{
		dir = 'in';
		amount = 0;
		delay = 5000;
	}
	else if (amount > 100)
	{
		dir = 'out';
		amount = 100;
		delay = 5000;
	}
	
	f_amount = amount / 100;
	navImg1.style.opacity = f_amount;
	navImg1.style.filter = 'alpha(opacity='+amount+')';
	
	if (dir == 'in') setTimeout('shsFade(\''+dir+'\', '+ (amount+step) +', '+ step +', \''+ name +'\')', delay);
	else if (dir == 'out') setTimeout('shsFade(\''+dir+'\', '+ (amount-step) +', '+ step +', \''+ name +'\')', delay);
}

function shsStartFade()
{
	if(!shsCONFIG['IE6'])
	{
		setTimeout('shsFade(\'out\', 100, 1, \'header2\')', 2000);
		setTimeout('shsFade(\'out\', 100, 1, \'footer2\')', 2000);
		setTimeout('shsFade(\'out\', 100, 1, \'div_bildergalerie2\')', 2000);
	}
}