jQuery(document).ready(function(){
	jQuery('#technical_link').click(function() {
		jQuery('#technical_link').addClass('active');
		jQuery('#price_link').removeClass('active');
		showWaiting();
		
		jQuery.get('data/technical/index', function(data,textStatus) {
			hideWaiting();
			jQuery('#js_content').html(data);
		});
		return false;
	});
	
	jQuery('#price_link').click(function() {
		jQuery('#price_link').addClass('active');
		jQuery('#technical_link').removeClass('active');
		showWaiting();
		
		jQuery.get('data/price/index', function(data,textStatus) {
			hideWaiting();
			jQuery('#js_content').html(data);
		});
		return false;
	});
});

function showWaiting()
{
	jQuery('#waiting_icon').show();
	jQuery('#js_content').hide();
}

function hideWaiting()
{
	jQuery('#waiting_icon').hide();
	jQuery('#js_content').show();
}

function show(linkId)
{
	jQuery('#showtb').click();
	
	switch(linkId) {
		default:
			jQuery('#price_link').click();
			break;
		case '#technical_link':
			jQuery('#technical_link').click();
			break;
	}
}

function checkCombinations(whichChanged, el)
{
	var currentMotor  = jQuery('#motor').val();
	var currentNiveau = jQuery('.niveau_radio').val();
	
	if (whichChanged == 'motor') {
		var niveaus = jQuery(el).children('option[value="'+currentMotor+'"]').attr('canhave').split('###');
		
		jQuery('.niveau_radio').each(function(index) {
			var found = false;
			for(var k in niveaus) {
				if(jQuery(this).val() == niveaus[k]) {
					found = true;
					break;
				}
			}
			if (!found) {
				jQuery(this).attr('disabled','disabled');
			} else {
				jQuery(this).removeAttr('disabled');
			}
		});
	} else {
		var motors = jQuery(el).attr('canhave').split('###');
		
		jQuery('#motor').children('option').each(function(index) {
			var found = false;
			for(var k in motors) {
				if(jQuery(this).val() == motors[k]) {
					found = true;
					break;
				}
			}
			if (!found) {
				jQuery(this).attr('disabled', 'disabled');
				if (jQuery.browser.msie && jQuery.browser.version < 7) {
					jQuery(this).attr('alt',jQuery(this).html()).html('- nicht verfügbar -');
				}
			} else {
				jQuery(this).removeAttr('disabled');
				if (jQuery.browser.msie && jQuery.browser.version < 7) {
					jQuery(this).html(jQuery(this).attr('alt'));
				}
			}
		});
	}
}

function submitTechnical(e)
{
	showWaiting();
	jQuery.post('data/technical/index',jQuery('#niveau_motor').serialize(),function(data) {
			hideWaiting();
			jQuery('#js_content').html(data);
	});
}