function init_basket(product_id, amount, add_to_cart, remove_from_cart, message) {

	var handlerFunc = function(t) {

		$('right_basket').innerHTML = t.responseText;
		if (add_to_cart == 1) {
			$('error_tag2').innerHTML = message;
			jQuery('#error_frame').fadeIn('slow', function() {
			});
		}
	}
	var errFunc = function(t) {

	}

	new Ajax.Request('ajax/init_cart.php4', {
		method : 'get',
		parameters : "product_id=" + product_id + "&amount=" + amount
		+ "&add_to_cart=" + add_to_cart + "&remove_from_cart="
		+ remove_from_cart,
		onSuccess : handlerFunc,
		onFailure : errFunc
	});

}


function check_colours(image_cloud_id){

	ic='image_cloud_'+image_cloud_id;

	if($(ic).style.display!='block'){

		//jQuery(('#image_cloud_in_'+image_cloud_id)).hide();
		jQuery('#image_cloud_out_'+image_cloud_id).fadeIn(10);
		jQuery('#image_cloud_'+image_cloud_id).fadeIn(10);
		image_cloud(image_cloud_id)
	}
	//if(('image_cloud_'+image_cloud_id).style.display != 'block'){



	//}

}


function show_more_filters() {
	if ($('more_filter_bank').style.display == 'none') {
		$('more_filter_bank').style.display = 'block';
		$('more_filter_link_off').style.display = 'block';
		$('more_filter_link_on').style.display = 'none';
	} else {
		$('more_filter_bank').style.display = 'inline';
		$('more_filter_bank').style.display = 'none';
		$('more_filter_link_off').style.display = 'none';
		$('more_filter_link_on').style.display = 'block';
	}
	;
};

//IE Workaround
function timestamp(){
	var jetzt = new Date();
	return (jetzt.getTime());
}

//Hilfsfunktion für automatischen Slideup...
function slide_up_timeout(id){
	new Effect.SlideUp(id, {});
}



function init_payment(payment_method) {

	var handlerFunc = function(t) {

		jQuery(".payment_add_info").each(function(wer){
			if(jQuery(this).attr('id') == payment_method){
				jQuery(this).html(t.responseText);
			}else{
				jQuery(this).html('');
			}

		});
		if(jQuery('#change_payment_method').val() == 'Nachnahme' || payment_method == 'Nachnahme') order_content();
		if(jQuery('#change_payment_method').val() == 'Kreditkarte' || payment_method == 'Kreditkarte') order_content();
		if(jQuery('#change_payment_method').val() == 'PayPal' || payment_method == 'PayPal') order_content();
		jQuery('#change_payment_method').val(payment_method);


	}
	var errFunc = function(t) {

	}

	new Ajax.Request('ajax/payment_method.php4', {
		method : 'get',
		parameters : "payment_method=" + payment_method+"&timestamp="+timestamp(),
		onSuccess : handlerFunc,
		onFailure : errFunc
	});

}


function update_amount() {
	var handlerFunc = function(t) {
		var technical_data = $A(t.responseXML.getElementsByTagName('content')[0]
		.getElementsByTagName('XML_Serializer_Tag'));
		technical_data
		.each( function(s, index) {
			if(document.getElementById('total_price-' + s.getElementsByTagName('product_id')[0].childNodes[0].nodeValue)){
				document.getElementById('total_price-' + s.getElementsByTagName('product_id')[0].childNodes[0].nodeValue).innerHTML = s.getElementsByTagName("total_price")[0].childNodes[0].nodeValue;
			}
		});
		document.getElementById('total_value').innerHTML = t.responseXML.getElementsByTagName('total_value')[0].childNodes[0].nodeValue;
		document.getElementById('vat_included').innerHTML = t.responseXML.getElementsByTagName('vat_included')[0].childNodes[0].nodeValue;
		init_basket('', '', -1, -1);

	};
	var errFunc = function(t) {
		huhu.funktion = 'update_amount';
		new Ajax.Request('ajax/error_logging.php4', {
			method : 'get',
			parameters : huhu});
	};

	huhu = $('cart').serialize(true);
	huhu.go_XML = 1;
	huhu.add_to_cart = -1;
	huhu.remove_from_cart = -1;
	// alert(huhu);

	new Ajax.Request('ajax/init_cart.php4', {
		method : 'get',
		parameters : huhu,
		onSuccess : handlerFunc,
		onFailure : errFunc
	});
}

function check_credentials_top() {

 var handlerFunc = function(t) {
                $('error_tag2').innerHTML = '';
                var error = $A(t.responseXML.getElementsByTagName('error')[0].getElementsByTagName('XML_Serializer_Tag'));
            
                error
                .each( function(s, index) {
                
                        $('error_tag2').innerHTML = s.getElementsByTagName("error")[0].childNodes[0].nodeValue;
                });
                if ($('error_tag2').innerHTML == '') {
                        document.login.submit();
                        $('error_frame').style.display = 'none';
                } else {
                        jQuery('#error_frame').fadeIn('slow', function() {});
                }
        };

	var errFunc = function(t) {
		huhu.funktion = 'check_credentials_top';
		new Ajax.Request('ajax/error_logging.php4', {
			method : 'get',
			parameters : huhu});
	}

	huhu = $('login').serialize(true);
	huhu.go_XML = 1;
	huhu.add_to_cart = -1;
	huhu.remove_from_cart = -1;
	// alert(huhu);

	new Ajax.Request('ajax/init_cart.php4', {
		method : 'get',
		parameters : huhu,
		onSuccess : handlerFunc,
		onFailure : errFunc
	});

}

function remove_express() {

	var handlerFunc = function(t) {
		order_content()
		$('right_basket').innerHTML = t.responseText;
	}
	var errFunc = function(t) {

		new Ajax.Request('ajax/error_logging.php4', {
			method : 'get',
			parameters : 'funktion=remove_express&remove_express=1'});
	}
	//	huhu = $('cart').serialize(true);


	new Ajax.Request('ajax/init_cart.php4', {
		method : 'get',
		parameters :'remove_express=1'+"&timestamp="+timestamp(),
		onSuccess : handlerFunc,
		onFailure : errFunc
	});
}

function get_delivery_time(){
	var handlerFunc = function(t) {

		if($('stock_'+t.responseXML.getElementsByTagName('product_id')[0].firstChild.nodeValue)){
			$('stock_'+t.responseXML.getElementsByTagName('product_id')[0].firstChild.nodeValue).innerHTML = t.responseXML.getElementsByTagName('attractor')[0].firstChild.nodeValue;
			if(t.responseXML.getElementsByTagName('indicator')[0].firstChild.nodeValue == "green"){
				$('stock_'+t.responseXML.getElementsByTagName('product_id')[0].firstChild.nodeValue).style.color = "green";
				$('stock_'+t.responseXML.getElementsByTagName('product_id')[0].firstChild.nodeValue).style.fontWeight = "bold";
			}
			if(t.responseXML.getElementsByTagName('indicator')[0].firstChild.nodeValue == "red"){
				$('stock_'+t.responseXML.getElementsByTagName('product_id')[0].firstChild.nodeValue).style.color = "black";
				$('stock_'+t.responseXML.getElementsByTagName('product_id')[0].firstChild.nodeValue).style.fontWeight = "bold";
			}
			if(t.responseXML.getElementsByTagName('indicator')[0].firstChild.nodeValue == "yellow"){
				$('stock_'+t.responseXML.getElementsByTagName('product_id')[0].firstChild.nodeValue).style.color = "orange";
				$('stock_'+t.responseXML.getElementsByTagName('product_id')[0].firstChild.nodeValue).style.fontWeight = "bold";
			}
		}

		//		if($('date_'+t.responseXML.getElementsByTagName('product_id')[0].firstChild.nodeValue)) $('date_'+t.responseXML.getElementsByTagName('product_id')[0].firstChild.nodeValue).innerHTML = t.responseXML.getElementsByTagName('date')[0].firstChild.nodeValue;
		//		if($('indicator_'+t.responseXML.getElementsByTagName('product_id')[0].firstChild.nodeValue)) $('indicator_'+t.responseXML.getElementsByTagName('product_id')[0].firstChild.nodeValue).src = t.responseXML.getElementsByTagName('indicator')[0].firstChild.nodeValue;
		//		if($('indicator_'+t.responseXML.getElementsByTagName('product_id')[0].firstChild.nodeValue)) $('indicator_'+t.responseXML.getElementsByTagName('product_id')[0].firstChild.nodeValue).title = t.responseXML.getElementsByTagName('date')[0].firstChild.nodeValue;
		//		if($('delivery_time_'+t.responseXML.getElementsByTagName('product_id')[0].firstChild.nodeValue)) $('delivery_time_'+t.responseXML.getElementsByTagName('product_id')[0].firstChild.nodeValue).innerHTML = t.responseXML.getElementsByTagName('delivery_time')[0].firstChild.nodeValue;

	}

	var errFunc = function(t) {
		new Ajax.Request('ajax/error_logging.php4', {
			method : 'get',
			parameters : 'funktion=get_delivery_time'});
	}

	var delivery_times = $A(jQuery('.date'));
	//alert(delivery_times)
	var product_id;
	delivery_times.each(function(t){

		if(t.id.substr(0,4)=="date") product_id = t.id.substr(5);
		if(t.id.substr(0,5)=="stock") product_id = t.id.substr(6);
		if(t.id.substr(0,9)=="indicator") product_id = t.id.substr(10);
		if(t.id.substr(0,13)=="delivery_time") product_id = t.id.substr(14);

		new Ajax.Request('ajax/get_delivery_time.php4', {
			method : 'get',
			parameters :'product_id='+product_id,
			onSuccess : handlerFunc,
			onFailure : errFunc
		});
	});


}

function order_content(){

	var handlerFunc = function(t) {
		//alert(t.responseText);
		jQuery('#order_content').html(t.responseText);
		get_delivery_time();
	}
	var errFunc = function(t) {
		new Ajax.Request('ajax/error_logging.php4', {
			method : 'get',
			parameters : 'funktion=order_content&add_express=1'});
	}

	huhu = new Object();
	huhu.add_express=1;
	huhu.timestamp=timestamp();

	new Ajax.Request('ajax/cart.php4', {
		method : 'get',
		parameters :huhu,
		onSuccess : handlerFunc,
		onFailure : errFunc
	});
}




function add_express() {
	//alert("express");
	var handlerFunc = function(t) {
		order_content()
		//	$('right_basket').innerHTML = t.responseText;
	}
	var errFunc = function(t) {
		new Ajax.Request('ajax/error_logging.php4', {
			method : 'get',
			parameters : 'funktion=add_express&add_express=1'});
	}


	new Ajax.Request('ajax/init_cart.php4', {
		method : 'get',
		parameters :'add_express=1'+"&timestamp="+timestamp(),
		onSuccess : handlerFunc,
		onFailure : errFunc
	});
}
function add_saturday() {
	//alert("saturday");
	var handlerFunc = function(t) {
		order_content()
		//	$('right_basket').innerHTML = t.responseText;
	}
	var errFunc = function(t) {
		new Ajax.Request('ajax/error_logging.php4', {
			method : 'get',
			parameters : 'funktion=add_saturday&add_saturday=1'});
	}
	new Ajax.Request('ajax/init_cart.php4', {
		method : 'get',
		parameters :'add_saturday=1'+"&timestamp="+timestamp(),
		onSuccess : handlerFunc,
		onFailure : errFunc
	});

}

function check_credentials() {

	var handlerFunc = function(t) {

		$('error_tag').innerHTML = '';
		var technical_data = $A(t.responseXML.getElementsByTagName('error')[0]
		.getElementsByTagName('XML_Serializer_Tag'));
		technical_data
		.each( function(s, index) {
			$('error_tag').innerHTML = s.getElementsByTagName("error")[0].childNodes[0].nodeValue;
		});

		if ($('error_tag').innerHTML == '') {

			document.cart.submit();

		}

	};
	var errFunc = function(t) {
		huhu.funktion = 'check_credentials';
		new Ajax.Request('ajax/error_logging.php4', {
			method : 'get',
			parameters : huhu});
	}

	huhu = $('cart').serialize(true);
	huhu.go_XML = 1;
	huhu.add_to_cart = -1;
	huhu.remove_from_cart = -1;

	// alert($('ca);

	if (huhu.customer == "existing") {
		new Ajax.Request('ajax/init_cart.php4', {
			method : 'get',
			parameters : huhu,
			onSuccess : handlerFunc,
			onFailure : errFunc
		});
	} else if (huhu.customer == "new") {
		window.location.href = huhu.register;
  } else if (huhu.customer == "no_register") {
    window.location.href = huhu.register;
	}else if(huhu.customer=="logged_in"){
		//alert("etf");
		document.cart.submit();
	} else {
		alert("Bitte wählen Sie, ob Sie Neukunde oder Bestandskunde sind.");
		huhu.not_selected=1;
		new Ajax.Request('ajax/init_cart.php4', {
			method : 'get',
			parameters : huhu,
			onSuccess : handlerFunc,
			onFailure : errFunc
		});

	}

}

function remove_from_cart(product_id) {
	init_basket(product_id, '', -1, 1);

	var handlerFunc = function(t) {
		var index = 'cart_element-' + product_id;

		document.getElementById(index).innerHTML = '';

		var technical_data = $A(t.responseXML.getElementsByTagName('content')[0]
		.getElementsByTagName('XML_Serializer_Tag'));
		technical_data
		.each( function(s, index) {
			document
			.getElementById('total_price-' + s
			.getElementsByTagName('product_id')[0].childNodes[0].nodeValue).innerHTML = s
			.getElementsByTagName("total_price")[0].childNodes[0].nodeValue;
		});
		document.getElementById('total_value').innerHTML = t.responseXML
		.getElementsByTagName('total_value')[0].childNodes[0].nodeValue;
		document.getElementById('vat_included').innerHTML = t.responseXML
		.getElementsByTagName('vat_included')[0].childNodes[0].nodeValue;

	};
	var errFunc = function(t) {
		huhu.funktion = 'remove_from_cart';
		new Ajax.Request('ajax/error_logging.php4', {
			method : 'get',
			parameters : huhu});
	}

	huhu = new Object();
	huhu.go_XML = 1;
	huhu.add_to_cart = -1;
	huhu.remove_from_cart = -1;

	new Ajax.Request('ajax/init_cart.php4', {
		method : 'get',
		parameters : huhu,
		onSuccess : handlerFunc,
		onFailure : errFunc
	});
}

function change_country(value) {

	var handlerFunc = function(t) {
		document.getElementById('vat_no').innerHTML = t.responseXML
		.getElementsByTagName('vat_no')[0].childNodes[0].nodeValue;
		document.getElementById('vat_no2').innerHTML = t.responseXML
		.getElementsByTagName('vat_no')[0].childNodes[0].nodeValue;
		document.getElementById('vat_number').value = t.responseXML
		.getElementsByTagName('code')[0].childNodes[0].nodeValue;
	};
	var errFunc = function(t) {
		huhu.funktion = 'change_country';
		new Ajax.Request('ajax/error_logging.php4', {
			method : 'get',
			parameters : huhu});
	}

	huhu = new Object();
	huhu.go_XML = 1;
	huhu.check_country = 1;
	huhu.country = value;

	new Ajax.Request('ajax/check_register_form.php4', {
		method : 'get',
		parameters : huhu,
		onSuccess : handlerFunc,
		onFailure : errFunc
	});

}

function change_vat_display() {
	if (document.getElementById('vat').style.display == 'block') {
		document.getElementById('vat').style.display = 'none';
	} else {
		document.getElementById('vat').style.display = 'block';
	}
}

function check_express(value){

	if(value=="remove_express"){

		remove_express()
	}
	if(value=="add_express"){
		add_express()
	}
	if(value=="add_saturday"){
		add_saturday()
	}

}


function address_content(){


	var handlerFunc = function(t) {
		$('address').innerHTML = t.responseText;
	}
	var errFunc = function(t) {
		huhu.funktion = 'address_content';
		new Ajax.Request('ajax/error_logging.php4', {
			method : 'get',
			parameters : huhu});
	}

	huhu = $('register_form').serialize(true);

	//huhu="crap";
	new Ajax.Request('ajax2/address.php4', {
		method : 'get',
		parameters :huhu,
		onSuccess : handlerFunc,
		onFailure : errFunc
	});
}

function submit_address(form){


	var handlerFunc = function(t) {
		$('address').innerHTML = t.responseText;
	}
	var errFunc = function(t) {
		huhu.funktion = 'submit_address';
		new Ajax.Request('ajax/error_logging.php4', {
			method : 'get',
			parameters : huhu});
	}

	huhu = $(form).serialize(true);

	//huhu="crap";
	new Ajax.Request('ajax2/address.php4', {
		method : 'get',
		parameters :huhu,
		onSuccess : handlerFunc,
		onFailure : errFunc
	});
}

function submit_general(){

	var handlerFunc = function(t) {
		$('address').innerHTML = t.responseText;
	}
	var errFunc = function(t) {
		huhu.funktion = 'submit_general';
		new Ajax.Request('ajax/error_logging.php4', {
			method : 'get',
			parameters : huhu});
	}

	huhu = $('general_data').serialize(true);

	new Ajax.Request('ajax2/address.php4', {
		method : 'get',
		parameters :huhu,
		onSuccess : handlerFunc,
		onFailure : errFunc
	});
}


function logoff() {
	var handlerFunc = function(t) {
		location.href = 'http://www.y-o-w.com'
	}
	var errFunc = function(t) {
		new Ajax.Request('ajax/error_logging.php4', {
			method : 'get',
			parameters : 'funktion=logoff'});
	}

	new Ajax.Request('ajax/logoff.php4', {
		method : 'get',
		onSuccess : handlerFunc,
		onFailure : errFunc
	});

}

function hide_id(id){
	var handlerFunc = function(t) {
	};
	var errFunc = function(t) {
		new Ajax.Request('ajax/error_logging.php4', {
			method : 'get',
			parameters : 'funktion=hide_id'});
	}

	new Ajax.Request('ajax/hide_id.php4', {method: 'get', parameters:"id=" + id, onSuccess:handlerFunc, onFailure:errFunc});

}

//Check vom Kontaktformular
function CheckForm_contact() {
	var send;
	if(document.contact_form.salutation.value == false){
		send = 0;
		document.contact_form.salutation.style.border =  '1px #BC091B solid';
	}else{
		send = 1;
		document.contact_form.salutation.style.border =  '0px';
	}

	if(document.contact_form.surname.value == ""){
		send = 0;
		document.contact_form.surname.style.border =  '1px #BC091B solid';
	}else{
		send = 1;
		document.contact_form.surname.style.border =  '0px';
	}

	if(document.contact_form.street.value == ""){
		send = 0;
		document.contact_form.street.style.border =  '1px #BC091B solid';
	}else {
		send = 1;
		document.contact_form.street.style.border =  '0px';
	}

	if(document.contact_form.postcode.value == ""){
		send = 0;
		document.contact_form.postcode.style.border =  '1px #BC091B solid';
	}else{
		send = 1;
		document.contact_form.postcode.style.border =  '0px';
	}

	if(document.contact_form.town.value == ""){
		send = 0;
		document.contact_form.town.style.border =  '1px #BC091B solid';
	}else{
		send = 1;
		document.contact_form.town.style.border =  '0px';
	}

	if(document.contact_form.country.value == "none"){
		send = 0;
		document.contact_form.country.style.border =  '1px #BC091B solid';
	}else{
		send = 1;
		document.contact_form.country.style.border =  '0px';
	}

	if(document.contact_form.country.value == ""){
		send = 0;
		document.contact_form.country.style.border =  '1px #BC091B solid';
	}else{
		send = 1;
		document.contact_form.country.style.border =  '0px';
	}

	if(document.contact_form.email.value == ""){
		send = 0;
		document.contact_form.email.style.border =  '1px #BC091B solid';
	}else{
		send = 1;
		document.contact_form.email.style.border =  '0px';
	}

	if(document.contact_form.message.value == ""){
		send = 0;
		document.contact_form.message.style.border =  '1px #BC091B solid';
	}else{
		send = 1;
		document.contact_form.message.style.border =  '0px';
	}

	if(send==1){
		document.contact_form.submit();
	}
}

//Check vom Feedback Formular
function CheckForm_feedback() {
	var send;
	if(document.feedback_form.message.value == ""){
		send = 0;
		document.feedback_form.message.style.border =  '1px #BC091B solid';
	}else{
		send = 1;
		document.feedback_form.message.style.border =  '0px';
	}

	if(send==1){
		document.feedback_form.submit();
	}
}

//Check vom Farbkarten Formular
function CheckForm_cards() {
	var send = 0;
	if((document.colour_card_form.card_1.checked == false)  && (document.colour_card_form.card_3.checked == false)) {
		document.colour_card_form.card_1.style.border =  '1px #BC091B solid';
		send = 0;
	}else{
		send = 1;
		document.colour_card_form.card_1.style.border =  '0px';
	}
	if(document.colour_card_form.salutation.value == false){
		send = 0;
		document.colour_card_form.salutation.style.border =  '1px #BC091B solid';
	}else{
		send = 1;
		document.colour_card_form.salutation.style.border =  '0px';
	}
	if(document.colour_card_form.surname.value == ""){
		send = 0;
		document.colour_card_form.surname.style.border =  '1px #BC091B solid';
	}else{
		send = 1;
		document.colour_card_form.surname.style.border =  '0px';
	}
	if(document.colour_card_form.street.value == ""){
		send = 0;
		document.colour_card_form.street.style.border =  '1px #BC091B solid';
	}else{
		send = 1;
		document.colour_card_form.street.style.border =  '0px';
	}
	if(document.colour_card_form.postcode.value == ""){
		send = 0;
		document.colour_card_form.postcode.style.border =  '1px #BC091B solid';
	}else{
		send = 1;
		document.colour_card_form.postcode.style.border =  '0px';
	}
	if(document.colour_card_form.town.value == ""){
		send = 0;
		document.colour_card_form.town.style.border =  '1px #BC091B solid';
	}else{
		send = 1;
		document.colour_card_form.town.style.border =  '0px';
	}
	if(document.colour_card_form.country.value == "none"){
		send = 0;
		document.colour_card_form.country.style.border =  '1px #BC091B solid';
	}else{
		send = 1;
		document.colour_card_form.country.style.border =  '0px';
	}
	if(send==1){
		document.colour_card_form.submit();
	}
}


function CheckForm_newsletter() {
	var send = 0;
	if((document.newsletter_form.topic_1.checked == false) && (document.newsletter_form.topic_2.checked == false) && (document.newsletter_form.topic_3.checked == false) && (document.newsletter_form.topic_4.checked == false) && (document.newsletter_form.topic_5.checked == false) && (document.newsletter_form.topic_6.checked == false)){
		document.newsletter_form.topic_1.style.border =  '1px #BC091B solid';
		send = 0;
	}else{
		send = 1;
		document.newsletter_form.topic_1.style.border =  '0px';
	}

	if(document.newsletter_form.email.value == ""){
		document.newsletter_form.email.style.border =  '1px #BC091B solid';
		send = 0;
	}else{
		send = 1;
		document.newsletter_form.email.style.border =  '0px';
	}

	if(send==1){
		document.newsletter_form.submit();
	}
}

function CheckForm_workshop() {
	var send;
	if(document.workshop_form.salutation.value == false){
		send = 0;
		document.workshop_form.salutation.style.border =  '1px #BC091B solid';
	}else{
		send = 1;
		document.workshop_form.salutation.style.border =  '0px';
	}

	if(document.workshop_form.surname.value == ""){
		send = 0;
		document.workshop_form.surname.style.border =  '1px #BC091B solid';
	}else{
		send = 1;
		document.workshop_form.surname.style.border =  '0px';
	}

	if(document.workshop_form.street.value == ""){
		send = 0;
		document.workshop_form.street.style.border =  '1px #BC091B solid';
	}else {
		send = 1;
		document.workshop_form.street.style.border =  '0px';
	}

	if(document.workshop_form.postcode.value == ""){
		send = 0;
		document.workshop_form.postcode.style.border =  '1px #BC091B solid';
	}else{
		send = 1;
		document.workshop_form.postcode.style.border =  '0px';
	}

	if(document.workshop_form.town.value == ""){
		send = 0;
		document.workshop_form.town.style.border =  '1px #BC091B solid';
	}else{
		send = 1;
		document.workshop_form.town.style.border =  '0px';
	}

	if(document.workshop_form.country.value == "none"){
		send = 0;
		document.workshop_form.country.style.border =  '1px #BC091B solid';
	}else{
		send = 1;
		document.workshop_form.country.style.border =  '0px';
	}

	if(document.workshop_form.country.value == ""){
		send = 0;
		document.workshop_form.country.style.border =  '1px #BC091B solid';
	}else{
		send = 1;
		document.workshop_form.country.style.border =  '0px';
	}

	if(document.workshop_form.phone.value == ""){
		send = 0;
		document.workshop_form.phone.style.border =  '1px #BC091B solid';
	}else{
		send = 1;
		document.workshop_form.phone.style.border =  '0px';
	}

	if(document.workshop_form.email.value == ""){
		send = 0;
		document.workshop_form.email.style.border =  '1px #BC091B solid';
	}else{
		send = 1;
		document.workshop_form.email.style.border =  '0px';
	}

	if(document.workshop_form.workshop.value == false){
		send = 0;
		document.workshop_form.workshop.style.border =  '1px #BC091B solid';
	}else{
		send = 1;
		document.workshop_form.workshop.style.border =  '0px';
	}

	if(document.workshop_form.no_participant.value == ""){
		send = 0;
		document.workshop_form.no_participant.style.border =  '1px #BC091B solid';
	}else{
		send = 1;
		document.workshop_form.no_participant.style.border =  '0px';
	}

	if(send==1){
		document.workshop_form.submit();
	}
}

function init_tag_cloud() {
	var handlerFunc = function(t) {
		$('tag_cloud').innerHTML = t.responseText;
	}
	var errFunc = function(t) {
		new Ajax.Request('ajax/error_logging.php4', {
			method : 'get',
			parameters : 'funktion=init_tag_cloud'});
	}
	new Ajax.Request('ajax/tag_cloud.php4', {method: 'get', onSuccess:handlerFunc, onFailure:errFunc});
}

function init_twitter() {
	var handlerFunc = function(t) {
		$('twitter').innerHTML = t.responseText;
	}
	var errFunc = function(t) {
		new Ajax.Request('ajax/error_logging.php4', {
			method : 'get',
			parameters : 'funktion=init_twitter'});
	}

	new Ajax.Request('ajax/twitter.php4', {method: 'get', onSuccess:handlerFunc, onFailure:errFunc});
}

function image_cloud(product_id) {
	var handlerFunc = function(t) {
		$('image_cloud_' + product_id).innerHTML = t.responseText;
	}
	var errFunc = function(t) {
		new Ajax.Request('ajax/error_logging.php4', {
			method : 'get',
			parameters : 'funktion=image_cloudd'});
	}

	huhu = new Object();
	huhu.product_id = product_id;

	new Ajax.Request('ajax/image_cloud.php4', {method: 'get', parameters : huhu, onSuccess:handlerFunc, onFailure:errFunc});
}

function get_product_info(product_id,wrap_id) {
	
	var handlerFunc = function(t) {
		//alert(JQuery('.product_name_'+product_id).text);
		//alert(t.responseXML.getElementsByTagName('is_in_compare_array')[0].firstChild.nodeValue);
		jQuery('.product_name_'+product_id).html(t.responseXML.getElementsByTagName('product_name')[0].firstChild.nodeValue);
		
	// START this block is for compare and some important parts for adding product to cart
		if(jQuery('#compare_'+product_id).attr('id') != undefined){
			$('add_to_cart_product_id_'+product_id).value = t.responseXML.getElementsByTagName('product_id')[0].firstChild.nodeValue;
			jQuery('#compare_'+product_id).attr('id', 'compare_'+$('add_to_cart_product_id_'+product_id).value);
			
			if(t.responseXML.getElementsByTagName('is_in_compare_array')[0].firstChild.nodeValue == 'no'){
				jQuery('#compare_'+$('add_to_cart_product_id_'+product_id).value).attr("checked", false);
				
			}else{
				
				jQuery('#compare_'+$('add_to_cart_product_id_'+product_id).value).attr("checked", true);
			}
			
	    } else {
	    	
	    	jQuery('#compare_'+$('add_to_cart_product_id_'+product_id).value).attr('id', 'compare_'+t.responseXML.getElementsByTagName('product_id')[0].firstChild.nodeValue);	
	    	$('add_to_cart_product_id_'+product_id).value = t.responseXML.getElementsByTagName('product_id')[0].firstChild.nodeValue;
	    	
	    	if(t.responseXML.getElementsByTagName('is_in_compare_array')[0].firstChild.nodeValue == 'no'){
				jQuery('#compare_'+$('add_to_cart_product_id_'+product_id).value).attr("checked", false);
			}else{
			
				jQuery('#compare_'+$('add_to_cart_product_id_'+product_id).value).attr("checked", true);
			}
	    } 
	// END 
		if($('product_desc_'+product_id))	$('product_desc_'+product_id).innerHTML = t.responseXML.getElementsByTagName('product_desc')[0].firstChild.nodeValue;
		$('price_'+product_id).innerHTML = t.responseXML.getElementsByTagName('price')[0].firstChild.nodeValue;
		if($('sqm_price_'+product_id)) $('sqm_price_'+product_id).innerHTML = t.responseXML.getElementsByTagName('sqm_price')[0].firstChild.nodeValue;
		if($('image_'+product_id)) $('image_'+product_id).src = t.responseXML.getElementsByTagName('image')[0].firstChild.nodeValue;
		if($('color_image_'+product_id)) $('color_image_'+product_id).src = t.responseXML.getElementsByTagName('product_color_id')[0].firstChild.nodeValue;
		if($('size_image_'+product_id)) $('size_image_'+product_id).src = t.responseXML.getElementsByTagName('product_size')[0].firstChild.nodeValue;
		if($('image_large_'+product_id)) $('image_large_'+product_id).src = t.responseXML.getElementsByTagName('image_large')[0].firstChild.nodeValue;
		if($('product_desc_long'+product_id)) $('product_desc_long'+product_id).innerHTML = t.responseXML.getElementsByTagName('product_desc_long')[0].firstChild.nodeValue;
		if($('product_id_'+product_id)) $('product_id_'+product_id).innerHTML = t.responseXML.getElementsByTagName('product_id')[0].firstChild.nodeValue;
		if(jQuery('.link_'+product_id).size() > 0) jQuery('.link_'+product_id).attr('href',t.responseXML.getElementsByTagName('link')[0].firstChild.nodeValue);
		if($('date_'+product_id)) $('date_'+product_id).innerHTML = t.responseXML.getElementsByTagName('date')[0].firstChild.nodeValue;
		if($('indicator_'+product_id)) $('indicator_'+product_id).src = t.responseXML.getElementsByTagName('indicator')[0].firstChild.nodeValue;
		if($('indicator_'+product_id)) $('indicator_'+product_id).title = t.responseXML.getElementsByTagName('date')[0].firstChild.nodeValue;
		if($('delivery_time_'+product_id)) $('delivery_time_'+product_id).innerHTML = t.responseXML.getElementsByTagName('delivery_time')[0].firstChild.nodeValue;
		//if($('prod_price_after_discount1_id_'+product_id)) $('prod_price_after_discount1_id_'+product_id).innerHTML = t.responseXML.getElementsByTagName('discount1')[0].childNodes.item(3).childNodes.item(0).nodeValue;
		//if($('prod_price_after_discount2_id_'+product_id)) $('prod_price_after_discount2_id_'+product_id).innerHTML = t.responseXML.getElementsByTagName('discount2')[0].childNodes.item(3).childNodes.item(0).nodeValue;	
	
		
		if (t.responseXML.getElementsByTagName('discount1')[0].firstChild.firstChild.nodeValue != 0){
		if($('prod_price_after_discount1_id_'+product_id)) $('prod_price_after_discount1_id_'+product_id).innerHTML = t.responseXML.getElementsByTagName('discount1')[0].childNodes.item(3).childNodes.item(0).nodeValue;
		}else{
		if($('prod_price_after_discount1_id_'+product_id)) $('prod_price_after_discount1_id_'+product_id).innerHTML = "";
		}
		
		if (t.responseXML.getElementsByTagName('discount2')[0].firstChild.firstChild.nodeValue != 0){
		if($('prod_price_after_discount2_id_'+product_id)) $('prod_price_after_discount2_id_'+product_id).innerHTML = t.responseXML.getElementsByTagName('discount2')[0].childNodes.item(3).childNodes.item(0).nodeValue;
		}else{
		if($('prod_price_after_discount2_id_'+product_id)) $('prod_price_after_discount2_id_'+product_id).innerHTML = "";
		}
		
		if (t.responseXML.getElementsByTagName('discount3')[0].firstChild.firstChild.nodeValue != 0){
		if($('prod_price_after_discount3_id_'+product_id)) $('prod_price_after_discount3_id_'+product_id).innerHTML = t.responseXML.getElementsByTagName('discount3')[0].childNodes.item(3).childNodes.item(0).nodeValue;
		}else{
		if($('prod_price_after_discount3_id_'+product_id)) $('prod_price_after_discount3_id_'+product_id).innerHTML = "";
		}


		
		
			//if($('prod_price_after_discount2_id_'+product_id)) alert(t.responseXML.getElementsByTagName('discount2')[0].childNodes.item(1).childNodes.item(0).nodeValue); 
		//shopping button ausblenden falls Textil Lieferzeit unbekannt 
		//alert(t.responseXML.getElementsByTagName('prevent_purchase')[0].firstChild.nodeValue);
		if($('add_to_basket_'+product_id)){
			if(t.responseXML.getElementsByTagName('prevent_purchase')[0].firstChild.nodeValue=="1"){
				if($('add_to_basket_'+product_id)) $('add_to_basket_'+product_id).style.visibility="hidden";
			}else{
				if($('add_to_basket_'+product_id)) $('add_to_basket_'+product_id).style.visibility="visible";
			}
		}
		if($('stock_'+product_id)){
			$('stock_'+product_id).innerHTML = t.responseXML.getElementsByTagName('attractor')[0].firstChild.nodeValue;
			if(t.responseXML.getElementsByTagName('indicator')[0].firstChild.nodeValue == "green"){
				$('stock_'+product_id).style.color = "green";
				$('stock_'+product_id).style.fontWeight = "bold";
			}
			if(t.responseXML.getElementsByTagName('indicator')[0].firstChild.nodeValue == "red"){
				$('stock_'+product_id).style.color = "black";
				$('stock_'+product_id).style.fontWeight = "bold";
			}
			if(t.responseXML.getElementsByTagName('indicator')[0].firstChild.nodeValue == "yellow"){
				$('stock_'+product_id).style.color = "orange";
				$('stock_'+product_id).style.fontWeight = "bold";
			}
		}

		$('formats_'+product_id).length = 1;
		var format = $A(t.responseXML.getElementsByTagName('format'));
		format.each(function(s) {
			//alert(huhu.format);
			if(s.childNodes[0].nodeValue == huhu.format ){
				NeuerEintrag = new Option(s.childNodes[0].nodeValue, s.childNodes[0].nodeValue, false, true);
			}else{
				NeuerEintrag = new Option(s.childNodes[0].nodeValue, s.childNodes[0].nodeValue, false, false);
			}

			$('formats_'+product_id).options[$('formats_'+product_id).length] = NeuerEintrag;
		});
		if($('formats_'+product_id).length == 2)  $('formats_'+product_id).options[1].selected = true;
	};

	var errFunc = function(t) {
		huhu.funktion = 'get_product_info';
		new Ajax.Request('ajax/error_logging.php4', {
			method : 'get',
			parameters : huhu});
	}

	huhu = $('form_'+product_id).serialize(true);
	huhu.wrap_id = wrap_id;
	new Ajax.Request('ajax/get_product_info.php4', {
		method : 'get',
		parameters : huhu,
		onSuccess : handlerFunc,
		onFailure : errFunc
	});
}

function get_voucher_info(customer_no) {
	var handlerFunc = function(t) {
		$('voucher_info').style.display = 'block';
		$('voucher_percentage').innerHTML = '';
		$('voucher_value').innerHTML = '';

		$('voucher_info').innerHTML = t.responseXML.getElementsByTagName('voucher_code')[0].firstChild.nodeValue;
		$('voucher_percentage').innerHTML = t.responseXML.getElementsByTagName('percentage')[0].firstChild.nodeValue;
		$('voucher_value').innerHTML = t.responseXML.getElementsByTagName('value')[0].firstChild.nodeValue;
	};

	var errFunc = function(t) {
		huhu.funktion = 'get_voucher_info';
		new Ajax.Request('ajax/error_logging.php4', {
			method : 'get',
			parameters : huhu});
	}

	huhu = new Object();
	huhu.voucher_id = $('voucher_code').value;
	huhu.customer_no = customer_no;

	new Ajax.Request('ajax/check_voucher.php4', {
		method : 'get',
		parameters : huhu,
		onSuccess : handlerFunc,
		onFailure : errFunc
	});
}

function wishlist(product_id,project,mode,message,amount) {

	var handlerFunc = function(t) {
		if (message != ''){
			$('error_tag2').innerHTML = message;
			jQuery('#error_frame').fadeIn('slow', function() {
			});
		};
	};

	var errFunc = function(t) {
		huhu.funktion = 'wishlist';
		new Ajax.Request('ajax/error_logging.php4', {
			method : 'get',
			parameters : huhu});
	}

	huhu = new Object();

	huhu.product_id = product_id;
	huhu.mode = mode;
	huhu.project = project;
	huhu.amount= amount;

	new Ajax.Request('ajax/wishlist.php4', {
		method : 'get',
		parameters : huhu,
		onSuccess : handlerFunc,
		onFailure : errFunc
	});
}

function show_loading(id) {
	$(id).style.display = 'block';
}

function init_wishlist() {
	var handlerFunc = function(t) {
		$('wishlist_header').innerHTML = t.responseText;
	}
	var errFunc = function(t) {
	}
	huhu = new Object();
	new Ajax.Request('ajax/top_wishlist.php4', {
		method : 'get',
		parameters : huhu,
		onSuccess : handlerFunc,
		onFailure : errFunc
	});

}

function get_turnover(date,customer_no){

	var handlerFunc = function(t) {

		$('address_revenue').innerHTML = t.responseText;
	}

	var errFunc = function(t) {

	}

	new Ajax.Request('ajax/address_revenue.php4', {
		method : 'get',
		parameters : "customer_no=" + customer_no + "&date=" + date,
		onSuccess : handlerFunc,
		onFailure : errFunc

	}) ;
}
function clear_turnover(){
	$('address_revenue').innerHTML = '';

}
