var toggleProduct = function(product, check_status, doPriceUpdate) {
	doPriceUpdate = doPriceUpdate || true;
	
	var status = check_status.checked;
	if (product == 'starter_box' && status)
	{
		$('product_logo').checked = false;
		$('product_logo').disabled = true;
		$('logo_details').style.display = 'none';
	}
	if (product == 'starter_box' && !status)
	{
		$('product_logo').disabled = false;
	}
	if (product == 'starter_box_plus')
	{
		toggleProduct('starter_box', check_status, false);
		toggleProduct('webdesign', check_status, false);
		//new  Effect.BlindDown('starter_box_details');
		$('starter_box_plus').checked = status;
		
		if (status)
		{
			$('product_logo').checked = false;
			$('product_logo').disabled = true;
			$('product_starter_box').checked = false;
			$('product_starter_box').disabled = true;
			$('product_webdesign').checked = false;
			$('product_webdesign').disabled = true;
			$('logo_details').style.display = 'none';
		}
		else
		{
			$('product_logo').disabled = false;
			$('product_starter_box').disabled = false;
			$('product_webdesign').disabled = false;
		}
	}
	if (product != 'starter_box_plus')
	{
		if (status)
		{
			new  Effect.BlindDown(product + '_details', { queue: 'end' });	
		}
		else
		{
			new  Effect.BlindUp(product + '_details', { queue: 'end' });	
		}
	}
	
	if (doPriceUpdate)
	{
		updatePrice();	
	}
}

var toggleStarterBoxPlus = function(html_object)
{
	var status = html_object.checked;
	$('product_starter_box_plus').checked = status;
	toggleProduct('starter_box_plus', html_object);
}

var copyStyle = function(source)
{
	if (source == 'starterbox')
	{
		$('logo_style_serioes').checked = $('starter_box_style_serioes').checked;
		$('logo_style_ausgefallen').checked = $('starter_box_style_ausgefallen').checked;
		$('logo_style_modern').checked = $('starter_box_style_modern').checked;
		$('logo_style_schlicht').checked = $('starter_box_style_schlicht').checked;
		$('logo_style_witzig').checked = $('starter_box_style_witzig').checked;
		$('logo_style_sonstiges').checked = $('starter_box_style_sonstiges').checked;
		
		$('logo_style_sonstiges_text').value = $('starter_box_style_sonstiges_text').value;
		
		$('logo_color').value = $('starter_box_color').value;
		$('logo_claim').value = $('starter_box_claim').value;
		$('logo_target_group').value = $('starter_box_target_group').value;
	}
	if (source == 'logo')
	{
		$('starter_box_style_serioes').checked = $('logo_style_serioes').checked;
		$('starter_box_style_ausgefallen').checked = $('logo_style_ausgefallen').checked;
		$('starter_box_style_modern').checked = $('logo_style_modern').checked;
		$('starter_box_style_schlicht').checked = $('logo_style_schlicht').checked;
		$('starter_box_style_witzig').checked = $('logo_style_witzig').checked;
		$('starter_box_style_sonstiges').checked = $('logo_style_sonstiges').checked;
		
		$('starter_box_style_sonstiges_text').value = $('logo_style_sonstiges_text').value;
		
		$('starter_box_color').value = $('logo_color').value;
		$('starter_box_claim').value = $('logo_claim').value;
		$('starter_box_target_group').value = $('logo_target_group').value;
	}
}

var checkOpenProducts = function()
{
	var	logo_status = $('product_logo').checked;
	var	logo_product = $('logo_details').style.display;
	var starter_box_status = $('product_starter_box').checked;
	var	starter_box_product = $('starter_box_details').style.display;
	var starter_box_plus_status = $('product_starter_box_plus').checked;
	var brochure_flyer_status = $('product_broschuere_flyer').checked;
	var	brochure_flyer_product = $('broschuere_flyer_details').style.display;
	var cd_dvd_cover_status = $('product_cd_dvd_cover').checked;
	var	cd_dvd_cover_product = $('cd_dvd_cover_details').style.display;
	var webdesign_status = $('product_webdesign').checked;
	var	webdesign_product = $('webdesign_details').style.display;
	
	if (logo_status) 
	{
		if (logo_product == 'none') 
		{
			new Effect.BlindDown('logo_details');
		}
	}
	else
	{
		$('logo_details').style.display = 'none';
	}
	
	if (starter_box_status || starter_box_plus_status)
	{
		if (starter_box_product == 'none')
		{
			new  Effect.BlindDown('starter_box_details');
		}
	}
	else
	{
		$('starter_box_details').style.display = 'none';
	}
	
	if (starter_box_status)
	{
		$('product_logo').checked = false;
		$('product_logo').disabled = true;
		$('logo_details').style.display = 'none';
	}
	if (starter_box_plus_status)
	{
		$('product_logo').checked = false;
		$('product_logo').disabled = true;
		$('logo_details').style.display = 'none';
		$('product_starter_box').checked = false;
		$('product_starter_box').disabled = true;
		$('product_webdesign').checked = false;
		$('product_webdesign').disabled = true;
	}
	
	if (brochure_flyer_status)
	{
		if (brochure_flyer_product == 'none')
		{
			new  Effect.BlindDown('broschuere_flyer_details');
		}
	}
	else
	{
		$('broschuere_flyer_details').style.display = 'none';
	}
	
	if (cd_dvd_cover_status)
	{
		if (cd_dvd_cover_product == 'none')
		{
			new  Effect.BlindDown('cd_dvd_cover_details');
		}
	}
	else
	{
		$('cd_dvd_cover_details').style.display = 'none';
	}
	
	if ((webdesign_status || starter_box_plus_status))
	{
		if (webdesign_product == 'none')
		{
			new  Effect.BlindDown('webdesign_details');
		}
	}
	else
	{
		$('webdesign_details').style.display = 'none';
	}
	
	/*** disable additional textfields ***/
	$('logo_style_sonstiges_text').disabled = !$('logo_style_sonstiges').checked;
	
	$('starter_box_style_sonstiges_text').disabled = !$('starter_box_style_sonstiges').checked;
	$('starter_box_business_cards_amount').disabled = !$('starter_box_business_cards').checked;
	$('starter_box_letter_amount').disabled = !$('starter_box_letter').checked;
	$('starter_box_envelope_amount').disabled = !$('starter_box_envelope').checked;
	$('starter_box_stamp_amount').disabled = !$('starter_box_stamp').checked;	
	
	$('broschuere_format_width').disabled = !$('broschuere_format_special').checked;
	$('broschuere_format_height').disabled = !$('broschuere_format_special').checked;
	$('broschuere_pages_amount').disabled = !$('broschuere_pages_more').checked;	
	$('brochure_additional_print_amount').disabled = !$('brochure_additional_print').checked;
	
	$('cd_dvd_print_amount').disabled = !$('cd_dvd_print').checked;
	$('cd_dvd_production_amount').disabled = !$('cd_dvd_production').checked;	
	
	$('web_style_sonstiges_text').disabled = !$('web_style_sonstiges').checked;
	$('web_additional_pages_amount').disabled = !$('web_additional_pages').checked;
	
	/*** show bill (works only with javascript, so unhide it with js) ***/
	$('price_bill').style.display = 'block';
	
	updatePrice();
}

var updatePrice = function()
{
	var total_price = 0;
	var display_anyway = false;
	
	// logo
	var logo_price = 0;
	if ($('product_logo').checked)
	{
		logo_price = 490;
		$('price_logo').innerHTML = number_format(logo_price, 2, ',', '.');
		$('item_logo').style.display = 'block';
		total_price += logo_price;
	}
	else
	{
		$('item_logo').style.display = 'none';
	}
	
	// starter box
	var starter_box_price = 0;
	var starter_box = false;
	if ($('product_starter_box').checked)
	{
		starter_box_price = 1290;
		$('price_starter_box').innerHTML = number_format(starter_box_price, 2, ',', '.');
		$('item_starter_box').style.display = 'block';
		total_price += starter_box_price;
		starter_box = true;
	}
	else
	{
		$('item_starter_box').style.display = 'none';
	}
	
	// starter box plus
	var starter_box_plus_price = 0;
	if ($('product_starter_box_plus').checked)
	{
		starter_box_plus_price = 2690;
		$('price_starter_box_plus').innerHTML = number_format(starter_box_plus_price, 2, ',', '.');
		$('item_starter_box_plus').style.display = 'block';
		total_price += starter_box_plus_price;
		starter_box = true;
		
		total_price -= starter_box_price;
		starter_box_price = 0;
	}
	else
	{
		$('item_starter_box_plus').style.display = 'none';
	}
	
	// starter_box_print
	var starter_box_print_price = 0;
	if ($('starter_box_print').checked && starter_box)
	{
		starter_box_print_price = 360;
		$('price_starter_box_print').innerHTML = number_format(starter_box_print_price, 2, ',', '.');
		$('item_starter_box_print').style.display = 'block';
		total_price += starter_box_print_price;
	}
	else
	{
		$('item_starter_box_print').style.display = 'none';
	}
	
	// add_business_cards
	var starter_box_business_cards_price = 0;
	var add_business_cards = $('starter_box_business_cards_amount').value;
	if (isNaN(parseInt(add_business_cards)))
	{
		add_business_cards = 0;
	}
	if ($('starter_box_business_cards').checked && add_business_cards > 0 && starter_box)
	{
		starter_box_business_cards_price = 49 * add_business_cards;
		$('price_add_business_cards').innerHTML = number_format(starter_box_business_cards_price, 2, ',', '.');
		$('item_add_business_cards').style.display = 'block';
		total_price += starter_box_business_cards_price;
		// additional print prices
		if ($('starter_box_print').checked)
		{
			total_price -= starter_box_print_price;
			starter_box_print_price += (50 * add_business_cards);
			$('price_starter_box_print').innerHTML = number_format(starter_box_print_price, 2, ',', '.');
			$('item_starter_box_print').style.display = 'block';
			total_price += starter_box_print_price;
		}
	}
	else
	{
		$('item_add_business_cards').style.display = 'none';
	}
	
	//add_letters
	var starter_box_letters_price = 0;
	var add_letters = $('starter_box_letter_amount').value;
	if (isNaN(parseInt(add_letters)))
	{
		add_letters = 0;
	}
	if ($('starter_box_letter').checked && add_letters > 0 && starter_box)
	{
		starter_box_letters_price = 49 * add_letters;
		$('price_add_letters').innerHTML = number_format(starter_box_letters_price, 2, ',', '.');
		$('item_add_letters').style.display = 'block';
		total_price += starter_box_letters_price;
		// additional print prices
		if ($('starter_box_print').checked)
		{
			total_price -= starter_box_print_price;
			starter_box_print_price += (90 * add_letters);
			$('price_starter_box_print').innerHTML = number_format(starter_box_print_price, 2, ',', '.');
			$('item_starter_box_print').style.display = 'block';
			total_price += starter_box_print_price;
		}
	}
	else
	{
		$('item_add_letters').style.display = 'none';
	}
	
	// add_envelopes
	var starter_box_envelopes_price = 0;
	var add_envelopes = $('starter_box_envelope_amount').value;
	if (isNaN(parseInt(add_envelopes)))
	{
		add_envelopes = 0;
	}
	if ($('starter_box_envelope').checked && add_envelopes > 0 && starter_box)
	{
		starter_box_envelopes_price = 49 * add_envelopes;
		$('price_add_envelopes').innerHTML = number_format(starter_box_envelopes_price, 2, ',', '.');
		$('item_add_envelopes').style.display = 'block';
		total_price += starter_box_envelopes_price;
		// additional print prices
		if ($('starter_box_print').checked)
		{
			total_price -= starter_box_print_price;
			starter_box_print_price += (150 * add_envelopes);
			$('price_starter_box_print').innerHTML = number_format(starter_box_print_price, 2, ',', '.');
			$('item_starter_box_print').style.display = 'block';
			total_price += starter_box_print_price;
		}
	}
	else
	{
		$('item_add_envelopes').style.display = 'none';
	}
	
	// add_stamp
	var starter_box_stamps_price = 0;
	var add_stamps = $('starter_box_stamp_amount').value;
	if (isNaN(parseInt(add_stamps)))
	{
		add_stamps = 0;
	}
	if ($('starter_box_stamp').checked && add_stamps > 0 && starter_box)
	{
		starter_box_stamps_price = 49 * add_stamps;
		$('price_add_stamp').innerHTML = number_format(starter_box_stamps_price, 2, ',', '.');
		$('item_add_stamp').style.display = 'block';
		total_price += starter_box_stamps_price;
		// additional print prices
		if ($('starter_box_print').checked)
		{
			total_price -= starter_box_print_price;
			starter_box_print_price += (60 * add_stamps);
			$('price_starter_box_print').innerHTML = number_format(starter_box_print_price, 2, ',', '.');
			$('item_starter_box_print').style.display = 'block';
			total_price += starter_box_print_price;
		}
	}
	else
	{
		$('item_add_stamp').style.display = 'none';
	}
	
	// brochure
	var brochure_price = 0;
	if ($('product_broschuere_flyer').checked) 
	{
		selected_brochure = getCheckedValue(document.forms['order_form'].elements['broschure_pages']);

		switch (selected_brochure)
		{
			case 'more':
				$('price_brochure').innerHTML = 'a.A.';
				$('item_brochure').style.display = 'block';
				display_anyway = true;
				break;
			case '1':
			case '2':
			case '4':
			case '6':
			case '8':
			case '12':
			case '16':
			case '20':
				pages = parseInt(selected_brochure);
				brochure_price = 390 + ((pages-1) * 80);
				$('price_brochure').innerHTML = number_format(brochure_price, 2, ',', '.');
				$('item_brochure').style.display = 'block';
				total_price += brochure_price;
				break;
		}
	}
	else
	{
		$('item_brochure').style.display = 'none';
	}
	
	// brochure_print
	if ($('product_broschuere_flyer').checked && $('brochure_additional_print').checked) 
	{
		display_anyway = true;
		$('item_brochure_print').style.display = 'block';
	}
	else
	{
		$('item_brochure_print').style.display = 'none';
	}
	
	// cd_dvd
	var cd_dvd_price = 0;
	if ($('product_cd_dvd_cover').checked) 
	{
		selected_cd_dvd = getCheckedValue(document.forms['order_form'].elements['cd_dvd_cover_what']);

		switch (selected_cd_dvd)
		{
			case 'CD-Cover':
			case 'DVD-Cover':
			case 'Digipack':
				cd_dvd_price = 690;
				break;
			case 'CD-Booklet-4':
			case 'DVD-Booklet-4':
				cd_dvd_price = 930;
				break;
			case 'CD-Booklet-8':
			case 'DVD-Booklet-8':
				cd_dvd_price = 1250;
				break;
			case 'Digipack-Booklet-4':
				cd_dvd_price = 1010;
				break;
			case 'Digipack-Booklet-8':
				cd_dvd_price = 1330;
				break;
		}
		$('price_cd_dvd').innerHTML = number_format(cd_dvd_price, 2, ',', '.');
		$('item_cd_dvd').style.display = 'block';
		total_price += cd_dvd_price;
	}
	else
	{
		$('item_cd_dvd').style.display = 'none';
	}
	
	// disc_label
	var disc_label_price = 0;
	if ($('cd_dvd_label').checked && $('product_cd_dvd_cover').checked)
	{
		disc_label_price = 80;
		$('price_disc_label').innerHTML = number_format(disc_label_price, 2, ',', '.');
		$('item_disc_label').style.display = 'block';
		total_price += disc_label_price;
	}
	else
	{
		$('item_disc_label').style.display = 'none';
	}
	
	// cd_dvd_print
	if ($('product_cd_dvd_cover').checked && $('cd_dvd_print').checked) 
	{
		display_anyway = true;
		$('item_cd_dvd_print').style.display = 'block';
	}
	else
	{
		$('item_cd_dvd_print').style.display = 'none';
	}
	
	// cd_dvd_production
	if ($('product_cd_dvd_cover').checked && $('cd_dvd_production').checked) 
	{
		display_anyway = true;
		$('item_cd_dvd_production').style.display = 'block';
	}
	else
	{
		$('item_cd_dvd_production').style.display = 'none';
	}
	
	// webdesign
	var webdesign_price = 0;
	if ($('product_webdesign').checked)
	{
		webdesign_price = 790;
		$('price_webdesign').innerHTML = number_format(webdesign_price, 2, ',', '.');
		$('item_webdesign').style.display = 'block';
		total_price += webdesign_price;
	}
	else
	{
		$('item_webdesign').style.display = 'none';
	}
	
	// webdesign_html
	var webdesign_html_price = 0;
	if ($('web_html_templates').checked && $('product_webdesign').checked)
	{
		webdesign_html_price = 790;
		$('price_webdesign_html').innerHTML = number_format(webdesign_html_price, 2, ',', '.');
		$('item_webdesign_html').style.display = 'block';
		total_price += webdesign_html_price;
	}
	else
	{
		$('item_webdesign_html').style.display = 'none';
	}
	
	// webdesign_add
	var webdesign_add_price = 0;
	var add_pages = $('web_additional_pages_amount').value;
	if (isNaN(parseInt(add_pages)))
	{
		add_pages = 0;
	}
	if ($('web_additional_pages').checked && add_pages > 0 && ($('product_webdesign').checked || $('product_starter_box_plus').checked))
	{
		webdesign_add_price = 80 * add_pages;
		$('price_webdesign_add').innerHTML = number_format(webdesign_add_price, 2, ',', '.');
		$('item_webdesign_add').style.display = 'block';
		total_price += webdesign_add_price;
		// additional html prices
		if ($('web_html_templates').checked)
		{
			total_price -= webdesign_html_price;
			webdesign_html_price += (120 * add_pages);
			$('price_webdesign_html').innerHTML = number_format(webdesign_html_price, 2, ',', '.');
			$('item_webdesign_html').style.display = 'block';
			total_price += webdesign_html_price;
		}
	}
	else
	{
		$('item_webdesign_add').style.display = 'none';
	}	
	
	// wordpress
	var wordpress_price = 0;
	if ($('web_wordpress').checked && $('product_webdesign').checked)
	{
		wordpress_price = 1490;
		$('price_wordpress').innerHTML = number_format(wordpress_price, 2, ',', '.');
		$('item_wordpress').style.display = 'block';
		total_price += wordpress_price;
		
		total_price -= webdesign_price;
		webdesign_price = 0;
		$('price_webdesign').innerHTML = number_format(webdesign_price, 2, ',', '.');
		$('item_webdesign').style.display = 'block';
		
		if ($('web_additional_pages').checked)
		{
			total_price -= webdesign_add_price;
			webdesign_add_price = 0;
			$('price_webdesign_add').innerHTML = 'a.A.';
		}
	}
	else
	{
		$('item_wordpress').style.display = 'none';
	}
	
	$('price_sum').innerHTML = number_format(total_price, 2, ',', '.');
	$('price_total').style.display = 'block';
	
	if (total_price != 0 || display_anyway)
	{
		$('sumup').style.display = 'inline';
		$('nothing_selected').style.display = 'none';
	}
	else
	{
		$('sumup').style.display = 'none';
		$('nothing_selected').style.display = 'inline';
	}
}

var clickWordPress = function(html_object)
{
	$('web_html_templates').checked = false;
	$('web_html_templates').disabled = html_object.checked; 
	
	updatePrice();
}

function checkOrderForm()
{	
	// error found?
	var error = false;
	var err_data = false;
	
	// Products
	var product_logo = $('product_logo').checked;
	var product_broschuere_flyer = $('product_broschuere_flyer').checked;
	var product_starter_box = $('product_starter_box').checked;
	var product_starter_box_plus = $('product_starter_box_plus').checked;
	var product_cd_dvd_cover = $('product_cd_dvd_cover').checked;
	var product_webdesign = $('product_webdesign').checked;
	
	if (!product_logo && !product_broschuere_flyer && !product_starter_box && !product_starter_box_plus && !product_cd_dvd_cover && !product_webdesign)
	{
		$('err_products').style.display = 'block';
		error = true;
	}
	else
	{
		$('err_products').style.display = 'none';
	}
	
	// Logo
	if (product_logo)
	{
		var logo_style = getCheckedValue(document.forms['order_form'].elements['logo_style']);
		var logo_style_other = $('logo_style_sonstiges_text').value;
		
		if (logo_style == false || logo_style == '')
		{
			$('err_logo_style').style.display = 'block';
			error = true;
		}
		else
		{
			$('err_logo_style').style.display = 'none';
		}
		
		if (logo_style == 'sonstiges' && logo_style_other == '')
		{
			$('err_logo_style_other').style.display = 'block';
			$('logo_style_sonstiges_text').className = 'error text_short';
			error = true;
		}
		else
		{
			$('err_logo_style_other').style.display = 'none';
			$('logo_style_sonstiges_text').className = 'text_short';
		}
	}
	
	// Starter Box
	if (product_starter_box || product_starter_box_plus)
	{
		var starter_box_style = getCheckedValue(document.forms['order_form'].elements['starter_box_style']);
		var starter_box_style_other = $('starter_box_style_sonstiges_text').value;
		
		if (starter_box_style == false || starter_box_style == '')
		{
			$('err_starter_box_style').style.display = 'block';
			error = true;
		}
		else
		{
			$('err_starter_box_style').style.display = 'none';
		}
		
		if (starter_box_style == 'sonstiges' && starter_box_style_other == '')
		{
			$('err_starter_box_style_other').style.display = 'block';
			$('starter_box_style_sonstiges_text').className = 'error text_short';
			error = true;
		}
		else
		{
			$('err_starter_box_style_other').style.display = 'none';
			$('starter_box_style_sonstiges_text').className = 'text_short';
		}
	}
	
	// Brochure
	if (product_broschuere_flyer)
	{
		// format
		var brochure_format = getCheckedValue(document.forms['order_form'].elements['broschuere_format']);
		var brochure_format_other_width = parseInt($('broschuere_format_width').value);
		var brochure_format_other_height = parseInt($('broschuere_format_height').value);
		
		if (brochure_format == false || brochure_format == '')
		{
			$('err_broschuere_format').style.display = 'block';
			error = true;
		}
		else
		{
			$('err_broschuere_format').style.display = 'none';
		}

		if (brochure_format == 'sonderformat' && (isNaN(brochure_format_other_width) || isNaN(brochure_format_other_height)))
		{
			$('err_broschuere_format_other').style.display = 'block';
			if (isNaN(brochure_format_other_width))
				$('broschuere_format_width').className = 'error text_mini';
			else
				$('broschuere_format_width').className = 'text_mini';
			
			if (isNaN(brochure_format_other_height))
				$('broschuere_format_height').className = 'error text_mini';
			else
				$('broschuere_format_height').className = 'text_mini';
			error = true;
		}
		else
		{
			$('err_broschuere_format_other').style.display = 'none';
			$('broschuere_format_width').className = 'text_mini';
			$('broschuere_format_height').className = 'text_mini';
		}
		
		// pages
		var brochure_pages = getCheckedValue(document.forms['order_form'].elements['broschure_pages']);
		var borchure_pages_other = parseInt($('broschuere_pages_amount').value);
		
		if (brochure_pages == false || brochure_pages == '')
		{
			$('err_broschuere_pages').style.display = 'block';
			error = true;
		}
		else
		{
			if (brochure_pages == 'more' && isNaN(borchure_pages_other))
			{
				$('err_broschuere_pages').style.display = 'block';
				$('broschuere_pages_amount').className = 'error text_mini';
				error = true;
			}
			else
			{
				$('err_broschuere_pages').style.display = 'none';
				$('broschuere_pages_amount').className = 'text_mini';
			}
		}
		
		// fold
		var brochure_fold = getCheckedValue(document.forms['order_form'].elements['broschuere_fold']);
		
		if ((parseInt(brochure_pages) > 2 || brochure_pages == 'more') && (brochure_fold == false || brochure_fold == ''))
		{
			$('err_broschuere_fold').style.display = 'block';
			error = true;
		}
		else
		{
			$('err_broschuere_fold').style.display = 'none';
		}
		
		// print
		var brochure_print = $('brochure_additional_print').checked;
		var brochure_print_amount = parseInt($('brochure_additional_print_amount').value);
		
		if (brochure_print && isNaN(brochure_print_amount))
		{
			$('err_brochure_additional_print_amount').style.display = 'block';
			$('brochure_additional_print_amount').className = 'error text_mini';
			error = true;
		}
		else
		{
			$('err_brochure_additional_print_amount').style.display = 'none';
			$('brochure_additional_print_amount').className = 'text_mini';
		}
	}
	
	// CD / DVD Cover
	if (product_cd_dvd_cover)
	{
		var cd_dvd_cover_what = getCheckedValue(document.forms['order_form'].elements['cd_dvd_cover_what']);

		if (cd_dvd_cover_what == false || cd_dvd_cover_what == '')
		{
			$('err_cd_dvd_cover_what').style.display = 'block';
			error = true;
		}
		else
		{
			$('err_cd_dvd_cover_what').style.display = 'none';
		}
		
		// print
		var cd_print = $('cd_dvd_print').checked;
		var cd_print_amount = parseInt($('cd_dvd_print_amount').value);
		
		if (cd_print && isNaN(cd_print_amount))
		{
			$('err_cd_additional_print_amount').style.display = 'block';
			$('cd_dvd_print_amount').className = 'error text_mini';
			error = true;
		}
		else
		{
			$('err_cd_additional_print_amount').style.display = 'none';
			$('cd_dvd_print_amount').className = 'text_mini';
		}
		
		// production
		var cd_production = $('cd_dvd_production').checked;
		var cd_production_amount = parseInt($('cd_dvd_production_amount').value);
		
		if (cd_production && isNaN(cd_production_amount))
		{
			$('err_cd_additional_production_amount').style.display = 'block';
			$('cd_dvd_production_amount').className = 'error text_mini';
			error = true;
		}
		else
		{
			$('err_cd_additional_production_amount').style.display = 'none';
			$('cd_dvd_production_amount').className = 'text_mini';
		}
	}
	
	// Webdesign
	if (product_webdesign)
	{
		var webdesign_style = getCheckedValue(document.forms['order_form'].elements['web_style']);
		var webdesign_style_other = $('web_style_sonstiges_text').value;
		
		if (webdesign_style == false || webdesign_style == '')
		{
			$('err_webdesign_style').style.display = 'block';
			error = true;
		}
		else
		{
			$('err_webdesign_style').style.display = 'none';
		}
		
		if (webdesign_style == 'sonstiges' && webdesign_style_other == '')
		{
			$('err_webdesign_style_other').style.display = 'block';
			$('web_style_sonstiges_text').className = 'error text_short';
			error = true;
		}
		else
		{
			$('err_webdesign_style_other').style.display = 'none';
			$('web_style_sonstiges_text').className = 'text_short';
		}
		
		// production
		var web_additional_pages = $('web_additional_pages').checked;
		var web_additional_pages_amount = parseInt($('web_additional_pages_amount').value);
		
		if (web_additional_pages && isNaN(web_additional_pages_amount))
		{
			$('err_webdesign_additional_pages_amount').style.display = 'block';
			$('web_additional_pages_amount').className = 'error text_mini';
			error = true;
		}
		else
		{
			$('err_webdesign_additional_pages_amount').style.display = 'none';
			$('web_additional_pages_amount').className = 'text_mini';
		}
	}
	
	
	/*** CLIENT DATA ***/	
	// get data
	var company = $('company').value;
	var first_name = $('first_name').value;
	var last_name = $('last_name').value;
	var street = $('street').value;
	var city = $('city').value;
	var phone = $('phone').value;
	var email = $('email').value;
	
	// first name
	if (first_name == '')
	{
		$('first_name').className = 'text error';
		error = true;
		err_data = true;
	}
	else
	{
		$('first_name').className = 'text';
	}
	
	// last name
	if (first_name == '')
	{
		$('last_name').className = 'text error';
		error = true;
		err_data = true;
	}
	else
	{
		$('last_name').className = 'text';
	}
	
	// street
	if (street == '')
	{
		$('street').className = 'text error';
		error = true;
		err_data = true;
	}
	else
	{
		$('street').className = 'text';
	}
	
	// city
	if (city == '')
	{
		$('city').className = 'text error';
		error = true;
		err_data = true;
	}
	else
	{
		$('city').className = 'text';
	}
	
	// phone
	if (phone == '')
	{
		$('phone').className = 'text error';
		error = true;
		err_data = true;
	}
	else
	{
		$('phone').className = 'text';
	}
	
	// email
	if (email == '' || email.indexOf('@') < 0 || email.indexOf('.') < 0)
	{
		$('email').className = 'text error';
		error = true;
		err_data = true;
	}
	else
	{
		$('email').className = 'text';
	}
	
	// when find error, give response to visitor	
	if (err_data)
	{
		$('err_data').style.display = 'block';
		error = true;
	}
	else
	{
		$('err_data').style.display = 'none';
	}
	
	// contact media
	var contact_media = getCheckedValue(document.forms['order_form'].elements['contact_media']);

	if (contact_media == false || contact_media == '')
	{
		$('err_contact_media').style.display = 'block';
		error = true;
	}
	else
	{
		$('err_contact_media').style.display = 'none';
	}
	
	// terms of agreement
	var accept_tog = $('accept_tog').checked;
	
	if (!accept_tog)
	{
		$('err_tog').style.display = 'block';
		error = true;
	}
	else
	{
		$('err_tog').style.display = 'none';
	}
	
	// when find error, give response to visitor	
	if (error)
	{
		$('err_found').style.display = 'block';
	}
	else
	{
		$('err_found').style.display = 'none';
	}
	
	// return opposite of error found (no error = good!)
	return !error;
}

function checkRequestForm()
{	
	// error found?
	var error = false;
	var err_data = false;

	// get data
	var comment = $('comment').value;
	var contact_person = $('contact_person').value;
	var contact = $('contact').value;
	
	// comment
	if (comment.length < 3)
	{
		$('err_comment').style.display = 'block';
		error = true;
	}
	else
	{
		$('err_comment').style.display = 'none';
	}
	
	// contact_person
	if (contact_person.length < 3)
	{
		$('contact_person').className = 'text error';
		error = true;
		err_data = true;
	}
	else
	{
		$('contact_person').className = 'text';
	}
	// contact
	if (contact.length < 3)
	{
		$('contact').className = 'text error';
		error = true;
		err_data = true;
	}
	else
	{
		$('contact').className = 'text';
	}
	
	// when find error, give response to visitor	
	if (err_data)
	{
		$('err_data').style.display = 'block';
		error = true;
	}
	else
	{
		$('err_data').style.display = 'none';
	}
	
	// return opposite of error found (no error = good!)
	return !error;
}

function checkContactForm()
{
	var contact_person = $('contact_person').value;
	var contact = $('contact_person').value;
	
	// contact_person
	if (contact_person == '')
	{
		$('contact_person').className = 'error';
		error = true;
	}
	else
	{
		$('contact_person').className = 'text';
	}
	
	// contact
	if (contact == '')
	{
		$('contact').className = 'error';
		error = true;
	}
	else
	{
		$('contact').className = 'text';
	}
	
	// when find error, give response to visitor	
	if (error)
	{
		$('err_found').style.display = 'block';
	}
	else
	{
		$('err_found').style.display = 'none';
	}
	
	// return opposite of error found (no error = good!)
	return error;
}

function checkCallbackForm()
{
	var contact = $('contact').value;
	var phone = $('phone').value;
	
	if (contact.length < 3 || phone.length < 5)
	{
		alert('Bitte geben Sie Ihren Namen und eine Telefonnummer ein!');
		return false;
	}
	else
	{
		return true;
	}
}

function number_format( number, decimals, dec_point, thousands_sep ) {
    // Formats a number with grouped thousands
    //
    // version: 906.1806
    // discuss at: http://phpjs.org/functions/number_format
    var n = number, prec = decimals;

    var toFixedFix = function (n,prec) {
        var k = Math.pow(10,prec);
        return (Math.round(n*k)/k).toString();
    };

    n = !isFinite(+n) ? 0 : +n;
    prec = !isFinite(+prec) ? 0 : Math.abs(prec);
    var sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep;
    var dec = (typeof dec_point === 'undefined') ? '.' : dec_point;

    var s = (prec > 0) ? toFixedFix(n, prec) : toFixedFix(Math.round(n), prec); //fix for IE parseFloat(0.55).toFixed(0) = 0;

    var abs = toFixedFix(Math.abs(n), prec);
    var _, i;

    if (abs >= 1000) {
        _ = abs.split(/\D/);
        i = _[0].length % 3 || 3;

        _[0] = s.slice(0,i + (n < 0)) +
              _[0].slice(i).replace(/(\d{3})/g, sep+'$1');
        s = _.join(dec);
    } else {
        s = s.replace('.', dec);
    }

    var decPos = s.indexOf(dec);
    if (prec >= 1 && decPos !== -1 && (s.length-decPos-1) < prec) {
        s += new Array(prec-(s.length-decPos-1)).join(0)+'0';
    }
    else if (prec >= 1 && decPos === -1) {
        s += dec+new Array(prec).join(0)+'0';
    }
    return s;
}

// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

// set the radio button with the given value as being checked
// do nothing if there are no radio buttons
// if the given value does not exist, all the radio buttons
// are reset to unchecked
function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}
