// $Id: functions.js 48 2009-05-25 16:39:00Z hweber $// Effekte der Website initialisieren, sobald das Dokument fertig geladen ist$(document).ready(function(){	// Globale Variablen definieren	var XMLHttpError			= 0;	var xhttpCalculatorActive	= 0;	var xhttpBullpointsActive	= 0;	var xhttpWeightActive		= 0;	// Inhalte der Website aktualisieren, wenn der Besucher eine Auswahl getroffen hat	$("select[name='format'], select[name='paper'], select[name='cover'], select[name='page'], select[name='edition'], select[name='payment'], input[name='discountpoints']").livequery( 'change',		function(){			// Auswahl-Listen des Konfigurators neu einlesen			$.ajax({				url: '/cgi-bin/broschueren.pl',				data:	{					action:			'xhttp_configurator',					fid:			$("input[name='fid']").val(),					format:			$("select[name='format']").val(),					paper:			$("select[name='paper']").val(),					cover:			$("select[name='cover']").val(),					page:			$("select[name='page']").val(),					edition:		$("select[name='edition']").val(),					payment:		$("select[name='payment']").val(),					discountpoints:	$("input[name='discountpoints']").val()				},				cache: false,				dataType: 'html',				beforeSend: function( html ){					$('body').css('cursor', 'wait');					XMLHttpError			= 0;					xhttpCalculatorActive	= 0;					xhttpBullpointsActive	= 0;					xhttpWeightActive		= 0;				},				success: function( data, textStatus ){					$('#configurator').replaceWith( data );										// Gewicht des Produktes neu einlesen					xhttpWeight();					// Rabatt-Punkte neu einlesen					xhttpBullpoints();					// Preis-Berechnung des Produktes neu einlesen					xhttpCalculator();				},				error: function( XMLHttpRequest, textStatus, errorThrown ){					xhttpError();				}			});				}	);	// Preis-Berechnung per AJAX neu einlesen	function xhttpCalculator() {		$.ajax({			url: '/cgi-bin/broschueren.pl',			data:	{				action:			'xhttp_calculator',				fid:			$("input[name='fid']").val(),				format:			$("select[name='format']").val(),				paper:			$("select[name='paper']").val(),				cover:			$("select[name='cover']").val(),				page:			$("select[name='page']").val(),				edition:		$("select[name='edition']").val(),				payment:		$("select[name='payment']").val(),				discountpoints:	$("input[name='discountpoints']").val()			},			cache: false,			dataType: 'html',			success: function( data, textStatus ){				$('#calculator').replaceWith( data );			},			complete: function( XMLHttpRequest, textStatus ){				xhttpCalculatorActive	= 1;				xhttpReady();			},			error: function( XMLHttpRequest, textStatus, errorThrown ){				xhttpError();			}		});	}	// Rabatt-Punkte per AJAX neu einlesen	function xhttpBullpoints() {		$.ajax({			url: '/cgi-bin/broschueren.pl',			data:	{				action:			'xhttp_bullpoints',				fid:			$("input[name='fid']").val(),				format:			$("select[name='format']").val(),				paper:			$("select[name='paper']").val(),				cover:			$("select[name='cover']").val(),				page:			$("select[name='page']").val(),				edition:		$("select[name='edition']").val(),				payment:		$("select[name='payment']").val(),				discountpoints:	$("input[name='discountpoints']").val()			},			cache: false,			dataType: 'html',			success: function( data, textStatus ){				$('#bullpoints').replaceWith( data );			},			complete: function( XMLHttpRequest, textStatus ){				xhttpBullpointsActive	= 1;				xhttpReady();			},			error: function( XMLHttpRequest, textStatus, errorThrown ){				xhttpError();			}		});	}	// Gewicht per AJAX neu einlesen	function xhttpWeight() {		$.ajax({			url: '/cgi-bin/broschueren.pl',			data:	{				action:			'xhttp_weight',				format:			$("select[name='format']").val(),				paper:			$("select[name='paper']").val(),				cover:			$("select[name='cover']").val(),				page:			$("select[name='page']").val(),				edition:		$("select[name='edition']").val()			},			cache: false,			dataType: 'html',			success: function( data, textStatus ){				$('#weight').replaceWith( data );			},			complete: function( XMLHttpRequest, textStatus ){				xhttpWeightActive	= 1;				xhttpReady();			},			error: function( XMLHttpRequest, textStatus, errorThrown ){				xhttpError();			}		});	}	// Fehler bei der AJAX-Kommunikation anzeigen	function xhttpError() {		if ( XMLHttpError == 0 ) {			$('body').css('cursor', 'auto');			alert( 'Die Daten konnten nicht vollständig aktualisiert werden.\nBitte versuchen Sie es erneut.' );			XMLHttpError	= 1;		}	}	// AJAX-Kommunikation abgeschlossen	function xhttpReady() {		if ( (xhttpCalculatorActive == 1) && (xhttpBullpointsActive == 1) && (xhttpWeightActive == 1) ) {			$('body').css('cursor', 'auto');			xhttpCalculatorActive	= 0;			xhttpBullpointsActive	= 0;			xhttpWeightActive		= 0;		}	}});
