
var dold_zaehler = 0;


function dold_js_loadMatrix(select, filter, value) {
		$(select).parent().parent().parent().parent().parent().load('../../datenblatt/pa/pa_loader.php', { 'filter': filter, 'value' : value }, function() {
			dold_js_reinit();
		});
}

function dold_change_matrix(select, filter, value) {
	//alert(family + ' - ' + filter + ' - ' + value);
	select = $('#'+select);
//alert(select);
		$(select).load('../../datenblatt/pa/pa_loader.php', { 'filter': filter, 'value' : value }, function() {
			dold_js_reinit();
		});

}

function dold_js_reinit() {
		$("#innercontent_complex .pa_filter").each(function() {
		$(this).change(function() {
				
			//alert( $(this).id() + '_' + this.value );
			
			//$( '#' + $(this).id() + '_' + $(this).attr('oldval') ).hide();
			$( '.pa_filter2' ).hide();
			
			//$( '#' + $(this).id() + '_' + this.value             ).show();

			//if (this.value == '')
			dold_js_loadMatrix(this, $(this).id() + '_' + this.value, '');

			$(this).attr('oldval', this.value);
			
			
		});
		
		});
	
	
		$("#innercontent_complex .pa_filter2").each(function() {
			$(this).change(function() {
					
				//alert( $(this).id() + '_' + this.value );
				dold_js_loadMatrix(this, $(this).id(), this.value);
	
				$(this).attr('oldval', this.value);
				
				
			});
			
		});
		
		
		
		$("ul.jd_menu").jdMenu();

}






$(document).ready(function() {


	dold_zaehler = 0;
	$("#innercontent_complex table").each(function() {
		var z = 0; z = dold_zaehler;
		if ( $(this).is('.pa_matrix') || $(this).find("colgroup").length ) {
			if (z) $(this).hide();
			$(this).addClass('produktauswahl');
			$(this).attr({ dold_num: z });
			dold_zaehler++;
			
			$('a', this).each(function() {
																			if (  $(this).attr('target') == '')
																				$(this).attr('target', '_blank');
																		});

		}
	});



	dold_js_reinit();


	if (dold_zaehler) {
			dold_zaehler = 0;
			$("#innercontent_complex img").each(function() {
				var z = 0; z = dold_zaehler;
		
				$(this).attr({ dold_num: z });
				$(this).addClass('productmatrix_selection_img_normal');
				if (!z) $(this).addClass('productmatrix_selection_img_selected');
				
				$(this).click(function() {
						dold_hide_productTable(  $(this).attr("dold_num")  );
						$("#innercontent_complex img").removeClass('productmatrix_selection_img_selected');
						
						$(this).addClass('productmatrix_selection_img_selected');
				});
				dold_zaehler++;

			});
	}


  $("ul.dropdownselect li").hover(
      function(){ $("ul", this).fadeIn("fast"); }, 
      function() { } 
  );
  if (document.all) {
      $("ul.dropdownselect li").hoverClass ("sfHover");
  }

});

$.fn.hoverClass = function(c) {
    return this.each(function(){
        $(this).hover( 
            function() { $(this).addClass(c);  },
            function() { $(this).removeClass(c); }
        );
    });
};    



// Hides a specific table
function dold_hide_productTable(  num  ) {

	// find all table-elements in #innercontent_complex
	$("#innercontent_complex table").each(function() {

		// if custom attribute "dold_num" is not null..
		if (  $(this).attr("dold_num") != null )
			// show the table, if it is the corresponding one to "num" argument, or...
			if ( $(this).attr("dold_num") == num ) {
				$(this).show();
			}
			// otherwise hide the table
			else {
				$(this).hide();
			}

	});

	
}




