﻿function divShow(id)
{
	if (document.getElementById(id))
	{
		document.getElementById(id).style.display = 'block';
	}
}

function divHide(id)
{
	if (document.getElementById(id))
	{
		document.getElementById(id).style.display = 'none';
	}
}

function divToggle(id)
{
	if (document.getElementById(id))
	{
		if (document.getElementById(id).style.display == 'none')
		{
			document.getElementById(id).style.display = 'block';
		}
		else
		{
			document.getElementById(id).style.display = 'none';
		}
	}
}

function h2d(h)
{
	return parseInt(h,16);
}

function descodeHex (value)
{
	valueOut	= '';
	if (value != null && value.length > 0)
	{
		for (i = 0; i < value.length; i += 2)
		{
			valHex	= value.substr(i, 2);
			
			valueOut	+= String.fromCharCode(h2d(valHex));
		}
	}
	
	return valueOut;
}

jQuery(document).ready(function() {
	//popup

	window.pop = true;
//	alert(123);
//	alert(window.pop);
	var url = "";
	url1 = document.URL;
//    alert(url1);
	if(url1 == "http://www.wallenfels.com/checkout/onepage/"){
//		alert("hier in onepage");
		window.pop = true;
		window.isPopupURL = false;
//					alert(urlOld + " - " + qString + " - " + document.URL);
//					var activ =

//					alert("klick - " + this.URL + " - ");
//				    alert("1 - " + window.pop + " isPopupURL - " + isPopupURL);



		jQuery('a').click(function(){
//			alert(456)
			url = this.href;
			if (url1 == "http://www.wallenfels.com/checkout/onepage/"){
//							alert("klick - " + url);
//							if(){
//
//							}
				window.isPopupURL = true;
				window.pop = false
//						alert("2 - " + window.pop);
				window.open('http://www.wallenfels.com/popup/index.php', 'pop', 'height=870,width=750');

			}else{
				window.isPopupURL = true;
				window.pop = true
//						alert("3 - " + window.pop);
//				window.open('http://www.google.de', 'height=400,width=200');
			}
		})
	}
	else{
		window.pop = false;
//		window.isPopupURL = false;
//				alert( "4 " + window.pop);
	}

	// popup Ende




	// E-Mails
	$jq('a.tpyrc-liame').each(
		function()
		{
			var url		= this.href;
			var urlSeg	= url.split('/');
			var urlSize	= urlSeg.length;
			if (urlSize > 0)
			{
				value		= descodeHex(urlSeg[urlSize - 1]);
				value		= value.replace(/\//g, "");
				value		= value.replace(/\?/g, "@");
				value		= value.replace(/\&/g, ".");
				this.href	= 'mailto:' + value;
				jQuery(this).addClass('email');
				jQuery(this).removeClass('tpyrc-liame');
			}
		}
	);
	
	$jqLightBox($jq);
	$jq.Lightbox.construct(
		{
			download_link: false,
			text: {
				image:		'Bild',
				of:			'von',
				close:		'Schliessen',
				closeInfo:	'You can also click anywhere outside the image to close.',
				download:	'Download xxxx',
				help: {
					close:		'Klicken Sie hier zum Schliessen',
				},
				about: {
					text: 	'',
					title:	'',
					link:	''
				}
			},
			files: {
				images: {
					prev:		'skin/frontend/default/wallenfels/images/hintergrund_links.gif',
					next:		'skin/frontend/default/wallenfels/images/hintergrund_rechts.gif',
				}
			},
			show_info: true,
			show_extended_info: true
		}
	);
	/* Detailseite: Lightbox */
	$jq('div.more-views ul.image-gallery a').lightbox();

	//$jq(".accordion").accordion( { disabled: true } );
	/* Startseite: Slider */
//	$jq("#slider").easySlider( { auto: true, continuous: true, nextText: '&nbsp;', prevText: '&nbsp;' } );
	$jq('#slider').cycle({
		fx: 'scrollLeft',
		width: 265,
		height: 275,
		fit: 1,
		next: '#next2',
		prev: '#prev2'
	});
	
	/* Menu: Layer */
	$jq("#nav > LI").mouseover( function() { $jq(".submenu1", this).show(); $jq(".submenu1 ul:last").addClass("last"); $jq(this).addClass("selected"); } );
	$jq("#nav > LI").mouseout( function(){ $jq(".submenu1", this).hide(); $jq(this).removeClass("selected"); } );
	/* Ende Menu: Layer */
	$jq("button, select, input[type='checkbox'], input[type='radio'], input[type='file']").uniform();
	$jq("select").change( function() { $jq.uniform.update("select"); } );
	
	$jq('div.footerMenu li.menuCompare a').click( function() { $jq('div.compare-footer').slideToggle(); return false; } );

	// Bestellprozess Bugfix fuer Select-Boxen
	if ($jq.find('#checkoutSteps').length > 0)
	{
		
//		$jq('#checkoutSteps div.input-box div.selector span').html('<span class="select-trim">' + $jq('#checkoutSteps div.input-box div.selector span').html() + '</span>');
		$jq('#checkoutSteps div.input-box div.selector span').each(
			function(i)
			{
				if ($jq(this).find("span").length == 0)
				{
					$jq(this).html('<span class="select-trim">' + $jq(this).html() + '</span>');
				}
			}
		);		
		$jq('#shipping-address-select, #billing-address-select').change(
			function()
			{
				$jq(this).parent().children('span:first').html('<span class="select-trim">'+$jq(this).parent().children('span:first').html()+'</span>');
			}
		);
	}

	// Automatische Änderung der Artikelnummer
	if ($jq.find('.product-options').length > 0)
	{
		$jq('.product-options select').change(
			function()
			{
				if ("ProductSkuMap" in window)
				{
					if (window.ProductSkuMap !== undefined)
					{
						tmpSkuCode	= [];
						for (i = 0; i < window.ProductSkuMap.attributes.length; i++)
						{
							attrId		= window.ProductSkuMap.attributes[i];
							field		= 'attribute'+attrId;
							if (document.getElementById(field))
							{
								
								tmpSkuCode.push(attrId+'_'+document.getElementById(field).value);
							}
						}
						
						tmpCode		= tmpSkuCode.join('-');
						
						if (window.ProductSkuMap.map && document.getElementById('display-item-sku'))
						{
							result		= ' ';
							if (window.ProductSkuMap.map)
							{
								if (window.ProductSkuMap.map[tmpCode])
								{
									result		= window.ProductSkuMap.map[tmpCode];
								}
								else if (window.ProductSkuMap.map['_default'])
								{
									result		= window.ProductSkuMap.map['_default'];
								}
							}
							
							document.getElementById('display-item-sku').innerHTML	= result;
						}
						
						// Produktbeschreibung ergaenzen
						if ("ProductDescriptionMap" in window)
						{
							if (window.ProductDescriptionMap !== undefined)
							{
								if (document.getElementById('variant-description'))
								{
									result		= '';
									if (window.ProductDescriptionMap[tmpCode])
									{
										result		= window.ProductDescriptionMap[tmpCode];
									}
									
									document.getElementById('variant-description').innerHTML	= result;
									
									if (document.getElementById('variant-description-box'))
									{
										if (result.length > 0)
										{
											document.getElementById('variant-description-box').style.display = 'block';
										}
										
										else
										{
											document.getElementById('variant-description-box').style.display = 'none';
										}
									}
								}
							}
						}
					}
				}
			}
		);
	}
	
	

	/* Detailseite: Tabulatoren */
	
	if (jQuery.find(".jquery_tabs").length > 0)
	{
		$jq(".jquery_tabs").accessibleTabs(
			{
				fx: "fadeIn", //"slideDown",
				tabbody: '.tabbody'
			}
		);
		
		tabs		= jQuery.find(".jquery_tabs > ul");
		if (tabs.length > 0)
		{
			$jq(".jquery_tabs > ul:first").addClass('tab-menu');
		}
	}
	
	/* Produkt-Detailansicht: Aktiven Tab selektieren */
	if (document.getElementById('product-view'))
	{
		tabToActivate			= -1;
		tabCurrent				= -1;
		foundWhatIMLookingFor	= 0;
		tabs					= jQuery.find("div.jquery_tabs div.tabbody");
		for (i = 0; i < tabs.length; i++)
		{
			// Aktiven Tab merken
			if (tabs[i].style.display == 'block')
			{
				tabCurrent		= i;
			}
			
			jElement	= jQuery(tabs[i]);
			
			if (jElement.hasClass('tab-bundle'))
			{
				tabToActivate	= i;
				foundWhatIMLookingFor	= 1;
				break;
			}

			else if (jElement.hasClass('tab-varianten'))
			{
				tabToActivate	= i;
				foundWhatIMLookingFor	= 1;
				break;
			}
			else if (jElement.hasClass('tab-grouped'))
			{
				tabToActivate	= i;
				foundWhatIMLookingFor	= 1;
				break;
			}

			else if (jElement.hasClass('tab-images'))
			{
				tabToActivate	= i;
				foundWhatIMLookingFor	= 1;
			}
		}
		
		if (foundWhatIMLookingFor == 1 && tabToActivate >= 0)
		{
			tabMenu		= jQuery.find("#tab-product ul.tab-menu li");
			
			if (tabCurrent >= 0)
			{
				tabs[tabCurrent].style.display = 'none';
				if (tabMenu.length > tabCurrent)
				{
					jQuery(tabMenu[tabCurrent]).removeClass('current');
				}
			}
			tabs[tabToActivate].style.display = 'block';
			if (tabMenu.length > tabToActivate)
			{
				jQuery(tabMenu[tabToActivate]).addClass('current');
			}
		}

	}

	/* Tabulator aktivieren in der Markenwelt */
	if (jQuery.find(".tab-manufacturer").length > 0)
	{
		autoTabSelect("tab-manufacturer", "div.autotabManufacturer div.jquery_tabs ul.tab-menu li");
		autoTabDeactivate("tab-manufacturer", "div.autotabManufacturer div.jquery_tabs ul.tab-menu li");
	}
	
	/* Tabulator aktivieren in der Markenwelt/Produktlinien */
	if (jQuery.find(".tab-productline").length > 0)
	{
		autoTabSelect("tab-productline", "div.autotabProductLine div.jquery_tabs ul.tab-menu li");
		autoTabDeactivate("tab-productline", "div.autotabProductLine div.jquery_tabs ul.tab-menu li");
	}
	
	/* Tabulator aktivieren in der Markenwelt/Warengruppen */
	if (jQuery.find(".tab-category").length > 0)
	{
		autoTabSelect("tab-category", "div.autotabCategory div.jquery_tabs ul li");
		autoTabDeactivate("tab-category", "div.autotabCategory div.jquery_tabs ul li");
	}
	
	/* Tabulator aktivieren in der Markenwelt/Warengruppen */
	if (jQuery.find(".tab-folder").length > 0)
	{
		autoTabSelect("tab-folder", "div.autotabFolder div.jquery_tabs ul li");
		autoTabDeactivate("tab-folder", "div.autotabFolder div.jquery_tabs ul li");
	}
	
	/* Produkt-Detailansicht: Slider Varianten und Bundles */
	if (jQuery.find(".slider .images-variants").length > 0)
	{
		// LiveQuery Fix für Internet-Explorer
		$jq('.slider .images-variants').serialScroll(
			{
				items:'li',
				prev:'#buttons a.prev',
				next:'#buttons a.next',
				offset:0,									// Sotpposition beim Scrollen (x Pixel von links)
				start:0,									// Nummer des Startelements (beginnend mit 0)
				duration:1200,								// Geschwindigkeit des Slides in Millisekunden
				force:true,
				stop:true,
				lock:false,
				cycle:false,								// Cycle (true, false)
				easing:'easeOutQuart',						// jQuery.easing Effekt
				jump: false									// Springe zu Element wenn angeklickt (true, false)
			}
		);
	}
	
	/* Produkt-Detailansicht: Slider Varianten und Bundles */
	if (jQuery.find(".slider .images-product").length > 0)
	{
		// LiveQuery Fix für Internet-Explorer
		$jq('.slider .images-product').serialScroll(
			{
				items:'li',
				prev:'.tab-images .slider .buttons a.prev',
				next:'.tab-images .slider .buttons a.next',
				offset:0,									// Sotpposition beim Scrollen (x Pixel von links)
				start:0,									// Nummer des Startelements (beginnend mit 0)
				duration:1200,								// Geschwindigkeit des Slides in Millisekunden
				force:true,
				stop:true,
				lock:false,
				cycle:false,								// Cycle (true, false)
				easing:'easeOutQuart',						// jQuery.easing Effekt
				jump: false									// Springe zu Element wenn angeklickt (true, false)
			}
		);
	}

	if (jQuery.find(".spinfield").length > 0)
	{
		$jq.spin.imageBasePath = '/skin/frontend/default/wallenfels/images/';
		if (document.getElementById('skin-url'))
		{
			$jq.spin.imageBasePath = document.getElementById('skin-url').value;
		}
		
		$jq('.spinfield').spin({
			spinBtnImage: 'spinbtn.png',
			btnClass: 'spinbtn',
			btnCss: '',
			max: 100,
			min: 0,
		});
	}
	
	if (jQuery.find(".price-request").length > 0)
	{
		if (!document.getElementById('price-request-form'))
		{
			// Haupt-Div
			div					= document.createElement("div");
			div.style.display	= 'none';
			div.id				= 'price-request-form';
			document.getElementsByTagName("body")[0].appendChild(div);
			$jq("#price-request-form").load(
				"/pricerequest/ajax/form/",
				'',
				function()
				{
					$jq("button.price-request-submit").click(
						function()
						{
							validation		= new VarienForm('price-request');
							if(validation.validator && validation.validator.validate()){
								
								document.getElementById('price-request-formular').style.dispay = 'none';
								document.getElementById('price-request-wait').style.dispay = 'block';
								
								dataToSubmit	= '';
								
								first			= true;
								// Daten für den Formular-Versand einfügen
								fields			= jQuery.find("form.price-request input");
								for (i = 0; i < fields.length; i++)
								{
									if (!first)
										dataToSubmit	+= '&';
									dataToSubmit	+= encodeURI(fields[i].name)+"="+encodeURI(fields[i].value);
									first			= false;
								}
								
								fields			= jQuery.find("form.price-request textarea");
								for (i = 0; i < fields.length; i++)
								{
									dataToSubmit	+= '&';
									dataToSubmit	+= encodeURI(fields[i].name)+"="+encodeURI(fields[i].value);
								}
								
								$jq.post(
									"/pricerequest/ajax/request/",
									dataToSubmit,
									function (data)
									{
										document.getElementById('pricerequest-contact-frame').innerHTML = data;
										$jq("button.simplemodal-close").click(
											function()
											{
												$jq.modal.close();
											}
										);
									}
								);
							}
						}
					);
				}
			);
		}
		
		$jq("a.contact-link").click(function() {
			if (document.getElementById('priceRequestProductTitle'))
			{
				var productDescription	= $jq(this).attr('title');
				var elements			= productDescription.split(":");
				var sku					= elements.shift();
				
				document.getElementById('priceRequestProductId').value		= sku;
				document.getElementById('priceRequestProductTitle').value	= elements.join(':');
			}
					
			$jq("#price-request-form").modal({
				opacity:80,
				overlayId:'price-request-form',
				overlayCss: {backgroundColor:"#000000"},
				onOpen: function (dialog) {
					dialog.overlay.fadeIn('slow', function () {
						dialog.data.hide();
						dialog.container.fadeIn('slow', function () {
							dialog.data.slideDown('slow');
						});
					});
				},
				onClose: function (dialog) {
					dialog.data.fadeOut('slow', function () {
						dialog.container.slideUp('slow', function () {
							dialog.overlay.fadeOut('slow', function () {
								$jq.modal.close();
							});
						});
					});
				}
			});
		});
	}

	$jq("form").submit(
		checkForValidationError
	);
	
	$jq("button").click(
		checkForValidationError
	);
	
	// Auto Class
		prefix			= '';
		req				= new Object();
		req.Platform	= "Unknown Platform";
		req.Os			= "Unknown OS";
		req.OsName		= "Unknown";
		req.OsBit		= "32";
		req.OsMajor		= "0";
		req.OsMinor		= "0";
		req.Engine		= "Engine";
		req.Ua			= "Unknown Agent";
		req.UaVer		= "0";
		req.UaMajor		= "0";
		req.UaMinor		= "0";
		req.UaBit		= "32";
		req.Platform	= navigator.platform.toLowerCase();
		jQuery.each(
			jQuery.browser,
			function(i, val) {
				if (i.toLowerCase() == 'version')
				{
					req.UaVer	= val;
				}
				
				else
				{
					req.Ua	= i.toLowerCase();
				}
			}
		);
		
		reqUaVerAry	= req.UaVer.split(".");
		
		if (reqUaVerAry.length > 0)
		{
			req.UaMajor	= reqUaVerAry[0];
			if (reqUaVerAry.length > 1)
			{
				req.UaMinor	= reqUaVerAry[1];
			}
		}
		
		// UserAgent-Parsen
		reqUaStr		= navigator.userAgent.split("");
//		$("<strong>" + reqUaStr + "</strong><br/>").appendTo(document.body);
		tmpData			= "";
		tmpBraked		= false;
		tmpDataAry		= [];
		 
		for (i = 0; i < reqUaStr.length; i++)
		{
			tmpSeperator	= (tmpBraked) ? ';' : ' ';
			
			if (reqUaStr[i] == tmpSeperator)
			{
				tmpDataAry.push(tmpData);
				tmpData		= '';
			}
			
			else if (reqUaStr[i] == '(' && !tmpBraked)
			{
				tmpBraked	= true;
				if (tmpData.length > 0)
				{
					tmpDataAry.push(tmpData);
					tmpData		= '';
				}
			}
			
			else if (reqUaStr[i] == ')' && tmpBraked)
			{
				tmpBraked	= false;
				if (tmpData.length > 0)
				{
					tmpDataAry.push(tmpData);
					tmpData		= '';
				}
			}
			
			else
			{
				tmpData		+= reqUaStr[i];
			}
			
			
//			$("<strong>" + reqUaStr[i] + "</strong><br/>").appendTo(document.body);
		}
		
		if (tmpData.length > 0)
		{
			tmpDataAry.push(tmpData);
			tmpData		= '';
		}
		
		// Betriebsystem suchen und Version ermitteln
		for (i = 0; i < tmpDataAry.length; i++)
		{
//			$("<strong>" + tmpDataAry[i] + "</strong><br/>").appendTo(document.body);
		
			// Betriebsystem: Windows allgemein (95,98 +)
			if (tmpDataAry[i].match(/Windows( NT)? \d/))
			{
				req.Os			= "windows";
				tmpDataAry[i]	= tmpDataAry[i].replace(/Windows( NT)? /,"");
				
				if (tmpDataAry[i].match(/(95|98)/))
				{
					req.Os			= "windows-"+tmpDataAry[i];
				}
				
				else
				{
					vers		= tmpDataAry[i].split(".");
					req.OsName		= "Unknown";
					req.OsMajor		= vers[0];
					req.OsMinor		= vers[1];
					
					if (vers[0] == 5)
					{
						req.OsName		= "xp";
					}
					else if (vers[0] == 6)
					{
						req.OsName		= "vista";
					}
					
					else
					{
						req.OsName		= vers[0];
					}
					
				}
			}
			
			// Browser Version mit Leerzeichen getrennt
			else if (tmpDataAry[i].match(/MSIE/))
			{
				uaData		= tmpDataAry[i].split(" ");
				req.Ua		= uaData[0].toLowerCase();
				req.UaVer	= uaData[1].toLowerCase();
				
				reqUaVerAry	= uaData[1].split(".");
		
				if (reqUaVerAry.length > 0)
				{
					req.UaMajor	= reqUaVerAry[0];
					if (reqUaVerAry.length > 1)
					{
						req.UaMinor	= reqUaVerAry[1];
					}
				}
			}
			// Browser Version mit / getrennt
			else if (tmpDataAry[i].match(/(Firefox|Chrome|Safari)/))
			{
				uaData		= tmpDataAry[i].split("/");
				req.Ua		= uaData[0].toLowerCase();
				req.UaVer	= uaData[1].toLowerCase();
				
				reqUaVerAry	= uaData[1].split(".");
		
				if (reqUaVerAry.length > 0)
				{
					req.UaMajor	= reqUaVerAry[0];
					if (reqUaVerAry.length > 1)
					{
						req.UaMinor	= reqUaVerAry[1];
					}
				}
			}
		}
		
		$jq('body').addClass(prefix+req.Ua.replace(/\./g, '_'));
		$jq('body').addClass(prefix+req.Ua.replace(/\./g, '_')+'-'+req.UaVer.replace(/\./g, '_'));
		$jq('body').addClass(prefix+req.Ua.replace(/\./g, '_')+'-'+req.UaMajor.replace(/\./g, '_'));
		$jq('body').addClass(prefix+req.Ua.replace(/\./g, '_')+'-'+req.UaMajor.replace(/\./g, '_')+'_'+req.UaMinor.replace(/\./g, '_'));
		$jq('body').addClass(prefix+req.Platform.replace(/\./g, '_'));
		$jq('body').addClass(prefix+req.Os.replace(/\./g, '_'));
		$jq('body').addClass(prefix+req.Os.replace(/\./g, '_')+'-'+req.OsName.replace(/\./g, '_'));

	// show/hide outside germany delivery message
		var countrySelectField = $jq(document.getElementById('billing:country_id'));
		if (countrySelectField) {
			countrySelectField.change(function() {
				if (countrySelectField.val() != 'DE') {
					$jq('#shipOutsideGermany').show();
				} else {
					$jq('#shipOutsideGermany').hide();
				}
			});
		}
});



function displayOptionDetails(id)
{
	if (document.getElementById(id))
	{
		if (document.getElementById(id).style.display == 'block')
		{
			document.getElementById(id).style.display = 'none';
		}
		else
		{
			document.getElementById(id).style.display = 'block';
		}
	}
}

function displayOptionDetailsSelect(id, optionId)
{
	if (document.getElementById(id))
	{
		for (i = 0; i < document.getElementById(id).options.length; i++)
		{
			divId		= optionId + '-' + document.getElementById(id).options[i].value;
			if (document.getElementById(divId))
			{
				if (document.getElementById(id).options[i].selected)
				{
					if (document.getElementById(divId).style.display == 'block')
					{
						document.getElementById(divId).style.display = 'none';
					}
					
					else
					{
						document.getElementById(divId).style.display = 'block';
					}
				}
				
				else
				{
					document.getElementById(divId).style.display = 'none';
				}
			}
		}
	}
}

function checkForValidationError(i)
{
	$jq(".validate-select").each(
		checkPostPrepare
	);
	
	$jq(".required-entry").each(
		checkPostPrepare
	);
}

function checkPostPrepare(x)
{
	objParent		= $jq(this).parent();
	appendMessage		= false;
	removeMessage		= false;
	if ($jq(this).hasClass('validation-failed'))
	{
		if (!objParent.hasClass('validation-error'))
		{
			objParent.addClass('validation-error');
			appendMessage		= true;
		}
	}
	
	else if (objParent.hasClass('validation-error'))
	{
		objParent.removeClass('validation-error');
		removeMessage	= true;
	}

	advices		= objParent.find(".validation-advice");
	if (advices.length > 0)
	{
		
		objGrandfather	= objParent.parent();
		if (objParent.hasClass('multiselect'))
		{
			appendMessage	= false;
		}
		
		if (objGrandfather)
		{
			if (appendMessage)
			{
				tmpHtml		= '<div id="'+$jq(advices[0]).attr('id')+'" class="'+$jq(advices[0]).attr('class')+' auto-append">'+$jq(advices[0]).html()+'</div>';
				$jq(advices[0]).replaceWith('');
				$jq(objGrandfather).append(tmpHtml);
			}
		}
	}
}

function autoTabSelect(classContent, pathHeader)
{
	$tabCurrent			= 0;
	$tabToSelect		= 0;
	$_found				= false;
	$tabContentCurrent	= null;
	$tabContentToSelect	= null;
	$jq("input."+classContent).each(
		function(i)
		{
			if ($tabToSelect == 0)
			{
				$tabContentCurrent	= $jq(this).parent();
			}
			
			if (!$_found && $jq(this).hasClass('tab-with-content'))
			{
				$_found		= true;
				$tabContentToSelect	= $jq(this).parent().parent();

			}

			else if (!$_found)
			{
				$tabToSelect++;
			}
		}
	);
	
	
	//alert($tabCurrent+" != "+$tabToSelect);
	if ($tabCurrent != $tabToSelect)
	{
		tabMenu		= jQuery.find(pathHeader);
//		alert(tabMenu.length);
		if (tabMenu.length > 0)
		{
			$tabContentCurrent.hide();
			// Header
			$jq(tabMenu[$tabCurrent]).removeClass('current');
		
			$tabContentToSelect.show();
			// Header
			$jq(tabMenu[$tabToSelect]).addClass('current');
		}
	}
}

function autoTabDeactivate(classContent, pathHeader)
{
	$tabContentToSelect	= null;
	tabMenu				= jQuery.find(pathHeader);
	$tabToSelect		= 0;
	$jq("input."+classContent).each(
		function(i)
		{
			
			if ($jq(this).hasClass('tab-without-content'))
			{
				$tabContentToSelect	= $jq(this).parent().parent();
				if (tabMenu.length > 0)
				{
					// Header
					$jq(tabMenu[$tabToSelect]).addClass('empty');
				}
			}
			$tabToSelect++;
		}
	);
}



/**
 * Status des Submenues :
 * 0 - Nicht shließen
 * 1 - Sofort schließen
 * 2 - Verzögert schließen
 */
var submenuStatus		= new Array();
var submenuHideCounter	= 0;

var submenuCurrent	= '';

function submenuShow(code)
{
	if (submenuCurrent.length > 0)
	{
		submenuHide(submenuCurrent, false);
	}
	
	submenuCurrent		= code;
	
	$jq('#'+code).addClass('show');
}

function submenuHide(code, delay)
{
	if (delay == null)
	{
		delay	= true;
	}
	
	if (delay)
	{
		submenuStatus[code]	= 2;
		submenuHideCounter++;
		window.setTimeout("submenuHideExecute('"+code+"', '"+submenuHideCounter+"')", 1500);
	}
	
	else
	{
		submenuStatus[code]	= 1;
		submenuHideCounter++;
		submenuHideExecute(code, submenuHideCounter);
	}
}

function submenuBlockHide(code)
{
	submenuStatus[code]	= 0;
}

function submenuUnblockHide(code)
{
	submenuStatus[code]	= 2;
	submenuHideCounter++;
	window.setTimeout("submenuHideExecute('"+code+"', '"+submenuHideCounter+"')", 750);
}

function submenuHideExecute(code, counter)
{
	if (submenuStatus[code] != 0 && submenuStatus[code]	!= 3)
	{
		submenuStatus[code]	= 3;
		$jq('#'+code).removeClass('show');
	}
}

