function setAttributeList( aAttributes)
{
	$( '#_filterlist input[type="checkbox"]').attr( 'disabled', 'disabled');
	$( '#_filterlist input[id*="attributeprices"]').removeAttr( 'disabled');
	$( '#_filterlist input[id*="attributeweights"]').removeAttr( 'disabled');
	$( '#_filterlist input[id*="attributevolume"]').removeAttr( 'disabled');
	//$( '#_filterlist input[id*="attributecolors"]').removeAttr( 'disabled');
	for ( i = 0; i < aAttributes.length; ++i)
	{
		$( '#'+aAttributes[ i]).removeAttr( 'disabled');
	}
}

function showAllAttrib( sId)
{
	oUl = $( '#'+sId);
	toggleAttribShow( oUl);
}

function toggleAttribShow( oUl)
{
	$( '.more_attr', oUl).toggleClass( 'show_more_attr');
	oA = $( '.attr_show_more', oUl);
	if( $( oA).html() == 'weitere anzeigen')
	{
		$( oA).html( 'weniger anzeigen');
	}
	else
	{
		$( oA).html( 'weitere anzeigen');
	}
}

$(document).ready( function() 
{
	// Klickhandler für ide Attribute
	$( "[rel=attributecheckbox]").click( function() 
	{
		$( this).parent().toggleClass( 'selected');
		post_data = $( "#_filterlist").serialize();
		post_data = post_data.replace( "alist", "dd_list_content");
		
		/*$.ajax({
			  type: 'POST',
			  url: sShopUrl,
			  data: post_data,
			  contentType: "application/x-www-form-urlencoded;charset=ISO-8859-15",
			  success: function(data)
				{
				 	$( "#list").html( data);
		   		},
			  dataType: 'html'
			});*/

		
		$.post( sShopUrl, post_data, function(data)
		{
		 	$( "#list").html( data);
   		});
		$( this).blur();
	});
	
	// Klickhandler für den Reset der Attribute
	$( "#filter_reset").click( function() 
	{
		post_data = $( "#_reset_filterlist_form").serialize();
		post_data = post_data.replace( "alist", "dd_list_content");
		
		$( "#_reset_filterlist_form").submit( function() { return false; });
		
		$.post( sShopUrl, post_data, function(data)
		{
		 	$( "#list").html( data);
		 	$( "[rel=attributecheckbox]").removeAttr('disabled');
   		}
		);
		
		$( "[rel=attributecheckbox]").attr('checked', false);
		
		$( 'ul[id^="attrlist"] li').removeClass( 'selected');
		$( this).blur();
		return false;
	});
	// Klickhandler für "weitere Attribute anzeigen"
	$( '.attr_show_more').click( function()
	{
		oUl = $( this).parent().parent();
		toggleAttribShow( oUl);
		/*
		$( '.more_attr', oUl).toggleClass( 'show_more_attr');
		if( $( this).html() == 'weitere anzeigen')
		{
			$( this).html( 'weniger anzeigen');
		}
		else
		{
			$( this).html( 'weitere anzeigen');
		}
		*/
		$( this).blur();
		return false;
	});
});

function ajax_load( blSwitch)
{
	if( blSwitch == 'on')
	{
		$( '#mask').addClass( 'ajax');
	}
	else
	{
		$( '#mask').removeClass( 'ajax');			
	}
		
}

function setSearch( sDefaultText)
{
	var default_val = sDefaultText;
	$( '#searchparam').click( function () 
			{ 
				if ( $( this).val() == default_val)
				{
					$(this).val('');
				}								 
			} );
	$( '#searchparam').blur( function () 
			{ 
				if ($( this).val() == '')
				{
					$(this).val( default_val);
				}								 
			} );
	$( '#f_search').submit( function () 
			{
				if ( $('#searchparam').val() == default_val)
				{
					return false;
				}
			});
	$(document).ready( function()
			{
				CelebrosAutoComplete("Markenkoffer","searchparam",onSelect);
			}
	);
}

//Celebros-Autocomplete
function onSelect(aParameter)
{ 
	if ((aParameter["SelectedURL"]!="")&&(aParameter["IsAutoComplete"]))
	{
		window.location = aParameter["SelectedURL"];
	}
	else
	{ 
		window.location="http://www.markenkoffer.de?cl=qwiser&searchparam="+escape(aParameter["SelectedQuery"]);	
	}
}

function setFooterNewsletter( sDefaultText)
{
	var default_val = sDefaultText;
	$( '#newsletter_param').click( function () 
			{ 
				if ( $( this).val() == default_val)
				{
					$(this).val('');
					$( this).addClass( 'black');
				}								 
			} );
	$( '#newsletter_param').blur( function () 
			{ 
				if ($( this).val() == '')
				{
					$( this).removeClass( 'black');
					$(this).val( default_val);
				}								 
			} );
}

$(document).ready(
		function()
		{
			$('#service').hover( function()
            {
                $('#service_cnt').css('display', 'block');
            },
            function()
            {
                $('#service_cnt').css('display', 'none');
            });
			/*$('#service_cnt').mouseleave( function()
					{
						$('#service_cnt').css('display', 'none');				
					});*/
			$('#service_cnt').hover( function()
            {
                $('#service_cnt').css('display', 'block');
            },
            function()
            {
                $('#service_cnt').css('display', 'none');
            });
			
			$('#vorteile').hover( function()
					{
						$('#vorteile_cnt').css('display', 'block');				
					},
					function()
					{
						$('#vorteile_cnt').css('display', 'none');
					});
			
			$('#vorteile_cnt').hover( function()
					{
						$('#vorteile_cnt').css('display', 'block');								
					});
			$('#vorteile_cnt').mouseleave( function()
					{
						$('#vorteile_cnt').css('display', 'none');
					});
			
			window.name = 'markenkoffer';
		}
);

function escapeHTML (str)
{
   var div = document.createElement('div');
   var text = document.createTextNode(str);
   div.appendChild(text);
   return div.innerHTML;
}

function showVarLayer( sOxid, fromclass)
{
	if( oMask = $( '#mask'))
	{
		$( oMask).addClass( 'on');
	}
	if( oVarLoad = $( '#var_load'))
	{
		$( oVarLoad).addClass( 'on');
	}
	
	if( oVarSelect = $( '#var_select'))
	{
		if( sShopUrl)
		{
			$( oVarSelect).load( sShopUrl + "cl=dd_varselect&anid=" + sOxid + '&fromclass=' + fromclass, function()
					{
						$( oVarLoad).removeClass( 'on');
						$( oVarSelect).addClass( 'on');
						if( oJsDiv = $( '#oxscript'))
						{
							js_script = $( oJsDiv).text();
							$( 'body').append('<script type="text/javascript">' + js_script + '</script>');
							$( oJsDiv).remove();
						}
						document.getElementById( 'var_select').scrollIntoView( false);
					}
			);
		}
	}
	return false;
}

function closeVarLayer( oBtn)
{
	isAmInp = false;
	if( oVarSelect = $( '#var_select'))
	{
		$( oVarSelect).removeClass( 'on');
		aAmInps = $( '.am_amount');
		for( i = 0; i < aAmInps.length; ++i)
		{
			isAmInp = $( aAmInps[ i]).val() > 0 ? true : isAmInp;
		}
	}
	if( oMask = $( '#mask'))
	{
		$( oMask).removeClass( 'on');
	}
	if( $( oBtn).attr( 'id') == 'var_tobasket' && isAmInp)
	{
		oxid.popup.load();
	}
}

function setAmountBtns( sId)
{
	oLi = $( '#' + sId);
	oMinus = $( '.am_minus', oLi);
	oPlus = $( '.am_plus', oLi);
	oInp = $( '.am_amount', oLi);
	if( oMinus && oPlus && oInp)
	{
		$( oMinus).click( function()
				{
					oLi = $( '#' + sId);
					oInp = $( '.am_amount', oLi);
					oldVal = $( oInp).val()
					if( oldVal > 0)
					{
						$( oInp).val( --oldVal);
					}
					$( this).blur();
				}
		);
		$( oPlus).click( function()
				{
					oLi = $( '#' + sId);
					oInp = $( '.am_amount', oLi);
					oldVal = $( oInp).val()
					$( oInp).val( ++oldVal);
					$( this).blur();
				}
		);
	}
}

jQuery.preloadImages = function()
{
	for( var i = 0; i < arguments.length; i++)
	{
		jQuery("<img>").attr("src", arguments[i]);
	}
}

function setHs( title, width, height)
{
	hs.lang.creditsText = title;
	hs.creditsHref = 'javascript: return false;';
	hs.width = width;
	hs.height = height;
	
}
