/*FUNCTION JS*/


/* tx-dd-contact: */
;(function($) {
	$('document').ready(function() {
			//get rid of the dotted outline of the links (blurring links)
			$('a').click(function() {
			  this.blur();
			});
			
			//get the tabs working
			$('.tx-ddcontact-tab').each(function(){
				var link = $(this).children('a');
				$(link).click(function(e) {
					var id = $(this).parent().attr('id');
					var value = id.split('_');

					$('.tx-ddcontact-tab').each(function(){
						var link_ = $(this).children('a');
						$(link_).removeClass('active');						
					});
					$(this).addClass('active');
					
					$('.tx-ddcontact-box').each(function(){
						$(this).removeClass('active');
						$(this).addClass('tx-ddcontact-box');						
					});
					var activeBox = '#tx-ddcontact-content_'+value[1];
					$(activeBox).addClass('active');
					$("#tx-ddcontact-time").selectbox();
					
					e.preventDefault();
				});
			});

			//toggle in and out for the cat holder
			$('.fold').each(function(){
				$(this).click(function(e) {
					var cat = $(this).parents('.cat');
					var catbody = $(cat).children('.catbody');
					var img = $(this).children('img');

					if ($(img).attr('src') == 'fileadmin/templates/img/unfolded.gif') {
						$(img).attr('src','fileadmin/templates/img/folded.gif');
					} else {
						$(img).attr('src','fileadmin/templates/img/unfolded.gif');
					}
					
					$(catbody).slideToggle('300');
					e.preventDefault();
				});
			});

			//set up functionalities for the main categories (checked, unchecked, foldout tab)
			$('.topic').each(function(){
				$(this).click(function(e) {
					var cat = $(this).parents('.cat');
					var foldhref = $(cat).find('.fold');
					var img = $(foldhref).children('img');
					var catbody = $(cat).children('.catbody');
					if ($(this).data('checked') == 'checked') {
						$(this).css('background','url(fileadmin/templates/img/unchecked.gif) 0 0 no-repeat');
						$(this).data('checked','');	
						$('.'+$(cat).attr('id')).each(function(){
							$(this).css('background','url(fileadmin/templates/img/unchecked.gif) 0 0 no-repeat');
							$(this).data('checked','');					
						});
						//console.log($(cat).attr('id'));				
					} else {
						$(this).css('background','url(fileadmin/templates/img/checked.gif) 0 0 no-repeat');
						$(this).data('checked','checked');
						
						if ($(catbody).css('display') == 'none') {
							$(img).attr('src','fileadmin/templates/img/unfolded.gif');
							$(catbody).slideDown('300');					
						}
					}
					e.preventDefault();
				});
			});

			//set up functionalities for the subcategories (checked, unchecked, uncheck or check main category)
			for (var i=1; i<=4; i++) {
				$('.cat_'+i).each(function(){
					var Id = i;
					$(this).click(function(e) {
						if ($(this).data('checked') == 'checked') {
							$(this).css('background','url(fileadmin/templates/img/unchecked.gif) 0 0 no-repeat');
							$(this).data('checked','');	
						} else {
							$(this).css('background','url(fileadmin/templates/img/checked.gif) 0 0 no-repeat');
							$(this).data('checked','checked');
						
							if ($('#topic_'+Id).data('checked') != 'checked') {
								$('#topic_'+Id).css('background','url(fileadmin/templates/img/checked.gif) 0 0 no-repeat');
								$('#topic_'+Id).data('checked','checked');
							}
						}
						e.preventDefault();
					});
				});
			}
			
			//init datepicker & time selectbox
			$('#tx-ddcontact-date').datepick({minDate: 0, showTrigger: '#dateTrigger', alignment: 'top', showAnim: 'fadeIn', showSpeed: 'fast'});
			$("#tx-ddcontact-time").selectbox();
			
			//empty input fields on click
			$('.empty').each(function(){
				$(this).emptyonclick();
			});

			//set up functionalities for the radiobuttons
			for (var i=1; i<=3; i++) {
				$('#tx-ddcontact-mrs_'+i).click(function(e) {
					if ($(this).hasClass('tx-ddcontact-radio')) {
						$(this).removeClass('tx-ddcontact-radio');
						$(this).addClass('tx-ddcontact-radio-checked');
						var Id = $(this).attr('id').split('_');
						$('#tx-ddcontact-mr_'+Id[1]).removeClass('tx-ddcontact-radio-checked');
						$('#tx-ddcontact-mr_'+Id[1]).addClass('tx-ddcontact-radio');
					}
					e.preventDefault();
				});
				$('#tx-ddcontact-mr_'+i).click(function(e) {
					if ($(this).hasClass('tx-ddcontact-radio')) {
						$(this).removeClass('tx-ddcontact-radio');
						$(this).addClass('tx-ddcontact-radio-checked');
						var Id = $(this).attr('id').split('_');
						$('#tx-ddcontact-mrs_'+Id[1]).removeClass('tx-ddcontact-radio-checked');
						$('#tx-ddcontact-mrs_'+Id[1]).addClass('tx-ddcontact-radio');
					}
					e.preventDefault();
				});
			}

			//submit post form
			$('#tx-ddcontact-button-post').click(function(e){
				$('.error').remove();				
				$('.tx-ddcontact-response').remove();
				$('.fieldError').each(function(){
					$(this).removeClass('fieldError');
				});				

				var validate = 1;
				if ($('#tx-ddcontact-name_3').val() == 'Vorname, Name' || $('#tx-ddcontact-name_3').val() == '') {
					validate = 0;
					$('<p class="error">Bitte geben Sie Ihren Namen an.</p>').appendTo('#tx-ddcontact-content_3 .tx-ddcontact-boxcontent');
					$('#tx-ddcontact-name_3').addClass('fieldError');
				} else {
					$('#tx-ddcontact-name_3').removeClass('fieldError');
				}
				if ($('#tx-ddcontact-address').val() == 'Straße und Hausnummer' || $('#tx-ddcontact-address').val() == '') {
					validate = 0;
					$('<p class="error">Bitte geben Sie Ihre Straße und Hausnummer an.</p>').appendTo('#tx-ddcontact-content_3 .tx-ddcontact-boxcontent');
					$('#tx-ddcontact-address').addClass('fieldError');
				} else {
					$('#tx-ddcontact-address').removeClass('fieldError');
				}
				if ($('#tx-ddcontact-zip').val() == 'PLZ' || $('#tx-ddcontact-zip').val() == '') {
					validate = 0;
					$('<p class="error">Bitte geben Sie Ihre PLZ an.</p>').appendTo('#tx-ddcontact-content_3 .tx-ddcontact-boxcontent');
					$('#tx-ddcontact-zip').addClass('fieldError');
				} else {
					$('#tx-ddcontact-zip').removeClass('fieldError');
				}
				if ($('#tx-ddcontact-city').val() == 'Ort' || $('#tx-ddcontact-city').val() == '') {
					validate = 0;
					$('<p class="error">Bitte geben Sie Ihren Ort an.</p>').appendTo('#tx-ddcontact-content_3 .tx-ddcontact-boxcontent');
					$('#tx-ddcontact-city').addClass('fieldError');
				} else {
					$('#tx-ddcontact-city').removeClass('fieldError');
				}
				
				if (validate == 1) {
					var salutation = '';
					if ($('#tx-ddcontact-mrs_3').hasClass('tx-ddcontact-radio-checked')) {
						salutation = 'Frau';
					} else {
						salutation = 'Herr';						
					}

					var subject = '';
					if ($('.tx-ddcontact-pi1').length > 0) {
						subject = $('#tx-ddcontact-subject').html();
					} else {
						subject = 'Allgemeine Anfrage';
						var topics = '';
						
						if ($('#topic_1').data('checked') == 'checked') {
							topics = topics + $('#topic_1').attr('rel') + '\n';
							$('.cat_1').each(function(){
								if ($(this).data('checked') == 'checked') {
									topics = topics + $(this).attr('rel') + '\n';
								}
							});							
						}
						if ($('#topic_2').data('checked') == 'checked') {
							topics = topics + $('#topic_2').attr('rel') + '\n';
							$('.cat_2').each(function(){
								if ($(this).data('checked') == 'checked') {
									topics = topics + $(this).attr('rel') + '\n';
								}
							});							
						}
						if ($('#topic_3').data('checked') == 'checked') {
							topics = topics + $('#topic_3').attr('rel') + '\n';
							$('.cat_3').each(function(){
								if ($(this).data('checked') == 'checked') {
									topics = topics + $(this).attr('rel') + '\n';
								}
							});							
						}
						if ($('#topic_4').data('checked') == 'checked') {
							topics = topics + $('#topic_4').attr('rel') + '\n';
							$('.cat_4').each(function(){
								if ($(this).data('checked') == 'checked') {
									topics = topics + $(this).attr('rel') + '\n';
								}
							});							
						}
					}
					
					$.post("index.php?eID=tx_ddcontact", { tx_ddcontact: 'post', subject: subject, Url: window.location.href, Anrede: salutation, Name: $('#tx-ddcontact-name_3').val(), Strasse: $('#tx-ddcontact-address').val(), Plz: $('#tx-ddcontact-zip').val(), Ort: $('#tx-ddcontact-city').val(), Land: $('#tx-ddcontact-country').val(), Nachricht: $('#tx-ddcontact-message_2').val(), topics: topics },
						function(data){
     						$(data).appendTo('#tx-ddcontact-content_3 .tx-ddcontact-boxcontent');
							$('#tx-ddcontact-name_3').val('Vorname, Name');
							$('#tx-ddcontact-address').val('Straße und Hausnummer');
							$('#tx-ddcontact-zip').val('PLZ');
							$('#tx-ddcontact-city').val('Ort');
							$('#tx-ddcontact-country').val('Land (optional)');
							$('#tx-ddcontact-message_2').val('Nachricht (optional)');
							
							_gaq.push (['_gat._anonymizeIp']);
							_gaq.push(['_trackPageview', '/kontakt/post.html']);
							_gaq.push(['_trackEvent', 'Kontaktformular', 'Kontaktanfrage', 'Post']);
   					});					
				}
				e.preventDefault();
			});
			
			//submit email form
			$('#tx-ddcontact-button-email').click(function(e){
				$('.error').remove();				
				$('.tx-ddcontact-response').remove();
				$('.fieldError').each(function(){
					$(this).removeClass('fieldError');
				});				

				var validate = 1;
				if ($('#tx-ddcontact-name_2').val() == 'Vorname, Name' || $('#tx-ddcontact-name_2').val() == '') {
					validate = 0;
					$('<p class="error">Bitte geben Sie Ihren Namen an.</p>').appendTo('#tx-ddcontact-content_2 .tx-ddcontact-boxcontent');
					$('#tx-ddcontact-name_2').addClass('fieldError');
				} else {
					$('#tx-ddcontact-name_2').removeClass('fieldError');
				}
				if ($('#tx-ddcontact-email').val() == 'E-Mail Adresse' || $('#tx-ddcontact-email').val() == '') {
					validate = 0;
					$('<p class="error">Bitte geben Sie Ihre E-Mail Adresse an.</p>').appendTo('#tx-ddcontact-content_2 .tx-ddcontact-boxcontent');
					$('#tx-ddcontact-email').addClass('fieldError');
				} else {
					$('#tx-ddcontact-email').removeClass('fieldError');
				}
				
				if (validate == 1) {
					var salutation = '';
					if ($('#tx-ddcontact-mrs_2').hasClass('tx-ddcontact-radio-checked')) {
						salutation = 'Frau';
					} else {
						salutation = 'Herr';						
					}

					var subject = '';
					if ($('.tx-ddcontact-pi1').length > 0) {
						subject = $('#tx-ddcontact-subject').html();
					} else {
						subject = 'Allgemeine Anfrage';
						var topics = '';
						
						if ($('#topic_1').data('checked') == 'checked') {
							topics = topics + $('#topic_1').attr('rel') + '\n';
							$('.cat_1').each(function(){
								if ($(this).data('checked') == 'checked') {
									topics = topics + $(this).attr('rel') + '\n';
								}
							});							
						}
						if ($('#topic_2').data('checked') == 'checked') {
							topics = topics + $('#topic_2').attr('rel') + '\n';
							$('.cat_2').each(function(){
								if ($(this).data('checked') == 'checked') {
									topics = topics + $(this).attr('rel') + '\n';
								}
							});							
						}
						if ($('#topic_3').data('checked') == 'checked') {
							topics = topics + $('#topic_3').attr('rel') + '\n';
							$('.cat_3').each(function(){
								if ($(this).data('checked') == 'checked') {
									topics = topics + $(this).attr('rel') + '\n';
								}
							});							
						}
						if ($('#topic_4').data('checked') == 'checked') {
							topics = topics + $('#topic_4').attr('rel') + '\n';
							$('.cat_4').each(function(){
								if ($(this).data('checked') == 'checked') {
									topics = topics + $(this).attr('rel') + '\n';
								}
							});							
						}
					}
					
					$.post("index.php?eID=tx_ddcontact", { tx_ddcontact: 'email', subject: subject, Url: window.location.href, Anrede: salutation, Name: $('#tx-ddcontact-name_2').val(), Email: $('#tx-ddcontact-email').val(), Nachricht: $('#tx-ddcontact-message_1').val(), topics: topics },
						function(data){
     						$(data).appendTo('#tx-ddcontact-content_2 .tx-ddcontact-boxcontent');
							$('#tx-ddcontact-name_2').val('Vorname, Name');
							$('#tx-ddcontact-email').val('E-Mail Adresse');
							$('#tx-ddcontact-message_1').val('Nachricht (optional)');
							
							_gaq.push (['_gat._anonymizeIp']);
							_gaq.push(['_trackPageview', '/kontakt/email.html']);
							_gaq.push(['_trackEvent', 'Kontaktformular', 'Kontaktanfrage', 'Email']);
   					});					
				}
				e.preventDefault();
			});

			//submit phone form
			$('#tx-ddcontact-button-phone').css('z-index','1');
			$('#tx-ddcontact-button-phone').click(function(e){
				$('.error').remove();				
				$('.tx-ddcontact-response').remove();
				$('.fieldError').each(function(){
					$(this).removeClass('fieldError');
				});				

				var validate = 1;
				if ($('#tx-ddcontact-name_1').val() == 'Name' || $('#tx-ddcontact-name_1').val() == '') {
					validate = 0;
					$('<p class="error">Bitte geben Sie Ihren Namen an.</p>').appendTo('#tx-ddcontact-content_1 .tx-ddcontact-boxcontent');
					$('#tx-ddcontact-name_1').addClass('fieldError');
				} else {
					$('#tx-ddcontact-name_1').removeClass('fieldError');
				}
				if ($('#tx-ddcontact-phone').val() == 'Rufnummer' || $('#tx-ddcontact-phone').val() == '') {
					validate = 0;
					$('<p class="error">Bitte geben Sie Ihre Rufnummer an.</p>').appendTo('#tx-ddcontact-content_1 .tx-ddcontact-boxcontent');
					$('#tx-ddcontact-phone').addClass('fieldError');
				} else {
					$('#tx-ddcontact-phone').removeClass('fieldError');
				}
				if ($('#tx-ddcontact-date').val() == 'Datum' || $('#tx-ddcontact-date').val() == '') {
					validate = 0;
					$('<p class="error">Bitte geben Sie ein Datum an.</p>').appendTo('#tx-ddcontact-content_1 .tx-ddcontact-boxcontent');
					$('#tx-ddcontact-date').addClass('fieldError');
				} else {
					$('#tx-ddcontact-date').removeClass('fieldError');
				}
				if ($('#tx-ddcontact-time').val() == '--' || $('#tx-ddcontact-date').val() == '') {
					validate = 0;
					$('<p class="error">Bitte geben Sie eine Uhrzeit an.</p>').appendTo('#tx-ddcontact-content_1 .tx-ddcontact-boxcontent');
					$('.jquery-selectbox').addClass('fieldError');
				} else {
					$('.jquery-selectbox').removeClass('fieldError');
				}
				
				if (validate == 1) {
					var salutation = '';
					if ($('#tx-ddcontact-mrs_1').hasClass('tx-ddcontact-radio-checked')) {
						salutation = 'Frau';
					} else {
						salutation = 'Herr';						
					}

					var subject = '';
					if ($('.tx-ddcontact-pi1').length > 0) {
						subject = $('#tx-ddcontact-subject').html();
					} else {
						subject = 'Allgemeine Anfrage';
						var topics = '';
						
						if ($('#topic_1').data('checked') == 'checked') {
							topics = topics + $('#topic_1').attr('rel') + '\n';
							$('.cat_1').each(function(){
								if ($(this).data('checked') == 'checked') {
									topics = topics + $(this).attr('rel') + '\n';
								}
							});							
						}
						if ($('#topic_2').data('checked') == 'checked') {
							topics = topics + $('#topic_2').attr('rel') + '\n';
							$('.cat_2').each(function(){
								if ($(this).data('checked') == 'checked') {
									topics = topics + $(this).attr('rel') + '\n';
								}
							});							
						}
						if ($('#topic_3').data('checked') == 'checked') {
							topics = topics + $('#topic_3').attr('rel') + '\n';
							$('.cat_3').each(function(){
								if ($(this).data('checked') == 'checked') {
									topics = topics + $(this).attr('rel') + '\n';
								}
							});							
						}
						if ($('#topic_4').data('checked') == 'checked') {
							topics = topics + $('#topic_4').attr('rel') + '\n';
							$('.cat_4').each(function(){
								if ($(this).data('checked') == 'checked') {
									topics = topics + $(this).attr('rel') + '\n';
								}
							});							
						}
					}
					
					$.post("index.php?eID=tx_ddcontact", { tx_ddcontact: 'phone', subject: subject, Url: window.location.href, Anrede: salutation, Name: $('#tx-ddcontact-name_1').val(), Rufnummer: $('#tx-ddcontact-phone').val(), Datum: $('#tx-ddcontact-date').val(), Uhrzeit: $('#tx-ddcontact-time').val(), topics: topics },
						function(data){
     						$(data).appendTo('#tx-ddcontact-content_1 .tx-ddcontact-boxcontent');
							$('#tx-ddcontact-name_1').val('Name');
							$('#tx-ddcontact-phone').val('Rufnummer');
							$('#tx-ddcontact-date').val('Datum');
							$('#tx-ddcontact-time').selectbox();
							$('.jquery-selectbox-currentItem').text('Tageszeit');
							$("select[name='tx-ddcontact-time'] option:selected").attr("selected", false);
							$("select[name='tx-ddcontact-time'] option[value='--']").attr("selected", true);
							
							_gaq.push (['_gat._anonymizeIp']);
							_gaq.push(['_trackPageview', '/kontakt/telefon.html']);
							_gaq.push(['_trackEvent', 'Kontaktformular', 'Kontaktanfrage', 'Telefon']);
   					});					
				}
				e.preventDefault();
			});

	});
})(jQuery);







// Global Properties
var shadermode_op_opacity = 0.7;
var shadermode_op_bg = '#040404';
var sendallPage = false;
var sendPageClip = false;


// alternative color for MacFF2
var shadermode_neutral = 'gray';

$(document).ready(function(){


/*if($('.tx-editpagetools-pi1').css('display') != 'none'){
   if(($('#bel-leftmenu ul').length == 0) && (($('#bel-col-teaser-content').html().length == 11) || ($('#bel-col-teaser-content').html().length == 0))){
      $('#bel-col-main').addClass('full');
   }
   else if(($('#bel-leftmenu ul').length == 1) && (($('#bel-col-teaser-content').html().length == 11) || ($('#bel-col-teaser-content').html().length == 0))){
      $('#bel-col-main').addClass('full-no-teaser');	
   }
   else if(($('#bel-leftmenu ul').length == 0) && (($('#bel-col-teaser-content').html().length != 11) || ($('#bel-col-teaser-content').html().length != 0))){
      $('#bel-col-main').addClass('full-no-left');	
   }
}
*/

// Position Pagetool with Filter (begin)
if($('.tx-editfiltersystem-pi1').length == 1){
    if(($('.bel-filter-search').css('display') != 'none') && ($('.bel-filter-search').length != 0)){
        $('.newPagetools').css('top','70px'); 
    }else{
	$('.newPagetools').css('top','45px'); 
    }
    
    /*else{
      if($('.tx-editfiltersystem-pi1').length == 1){
      	if($('#bel-filter-layerform').css('display') == 'block'){
           $('.newPagetools').css('top','280px'); 
      	}else{
      	   $('.newPagetools').css('top','45px');
      	}
      }else{
	$('.newPagetools').css('top','70px');
      }
    } 
    */
}
// Position Pagetool with Filter (end)




if($('.bel-paging').html() == ''){
	$('.bel-paging').css('display','none');
}
    //empty on click...
    $('#bel-search-form').emptyonclick();
    $('input[name^="tx_eapsshop_pi2[payment_"]').emptyonclick();  

    $("#bel-search-form").keypress(function (e) {
        if (e.which == 13){
            $("#ind-search").submit();
        }
    });




    $('#ind-search-form').focus(function(){
        $('#ind-search').keypress(function(key){
            alert(key);
        });
    });


	// PNG Fix
   	$(document).pngFix(); 

	// Matrix Teaser Rechts
	$('div.bel-teaser-head').each(function() {
		if($(this).attr("close") == 'true'){
			$(this).next("div.bel-smallteaser-content").hide();	
			$(this).next("div.bel-smallteaser-content").next("div.bel-smallteaser-bottom").hide();
			$(this).next("div.bel-teaser-content").hide();	
			$(this).next("div.bel-teaser-content").next("div.bel-teaser-bottom").hide();
			$(this).css("margin-bottom", "16px");
		}
	});

	$("div.bel-teaser-head").click(function(){
		if(typeof(isHomeSite) == "undefined"){
            $(this).next("div.bel-smallteaser-content").slideToggle(100);
            $(this).next("div.bel-teaser-content").slideToggle(100);

            if ($(this).find(":nth-child(2) > div.bel-teaser-head-m-content").find(":first").hasClass("bel-teaser-arrow-up")) {
                $(this).next("div.bel-smallteaser-content").next("div.bel-smallteaser-bottom").hide();
                $(this).next("div.bel-teaser-content").next("div.bel-teaser-bottom").hide();
                $(this).find(":nth-child(2) > div.bel-teaser-head-m-content").find(":first").removeClass("bel-teaser-arrow-up");
                $(this).find(":nth-child(2) > div.bel-teaser-head-m-content").find(":first").addClass("bel-teaser-arrow-down");
                $(this).css("margin-bottom", "16px");

            } else if ($(this).find(":nth-child(2) > div.bel-teaser-head-m-content").find(":first").hasClass("bel-teaser-arrow-down")) {
                $(this).next("div.bel-smallteaser-content").next("div.bel-smallteaser-bottom").show();
                $(this).next("div.bel-teaser-content").next("div.bel-teaser-bottom").show();
                $(this).find(":nth-child(2) > div.bel-teaser-head-m-content").find(":first").removeClass("bel-teaser-arrow-down");
                $(this).find(":nth-child(2) > div.bel-teaser-head-m-content").find(":first").addClass("bel-teaser-arrow-up");
                $(this).css("margin-bottom", "0px");

            }
        }
	});




loadSubmitViaAjax();

});



function startUserChange(){
    $('#bel-reg-shader').showshader_register_main('bel-reg-shader');
}

function startRegisterForm(){
    $('#bel-reg-shader').showshader_register_main('bel-reg-shader');
}

function submitRegForm(){
    userRfields = new Array(
                    'tx_beluserreg_pi1[name]',
                    'tx_beluserreg_pi1[email]'
                    );
    var userReqOk = checkUserRegFields(userRfields);
    var selected = $("select[@name='tx_beluserreg_pi1[gender]'] option:selected");

   
    if(selected.val() == 0){
       var item = $("select[@name='tx_beluserreg_pi1[gender]'] option:selected").parent().parent().parent();
       $(item).find('td').css('color','red');
       userReqOk == false;
    }

    var matchPos = $("input[name='tx_beluserreg_pi1[email]']").val().search('@');
    if(matchPos == -1){
       var matchPos = $("input[name='tx_beluserreg_pi1[email]']").parent().parent();
       $(matchPos).find('td').css('color','red');
       userReqOk == false;
    }

    if(userReqOk == true){
        $('#frm-bel-reg').submit();
    }
}

function checkUserRegFields(userRfields){
    var status = true;
    $.each(userRfields,function(key,name){
        if($("input[name='"+name+"']").val().length < 1){
             var item = $("input[name='"+name+"']").parent().parent();
             $(item).find('td').css('color','red');
             setTimeout("$('#frm-bel-reg td').css({color:'#000'});",3000);
             status = false;
        }
    })
    return status;
}

// Filter Seminare Anmelden...
function startSemRegister(semUid){
    $('#semRegister').showsem();
}

jQuery.fn.eUnblock = function(){
    $.unblockUI();
    return this;
}



// Filtersearch by Ajax...
jQuery.fn.submitViaAjax = function(){
    $('div.tx-editfiltersystem-pi1').block({
        message: '<img src="fileadmin/templates/img/ajax-loader.gif" />',
        css: {
            border: '0px solid orange',
            background: 'transparent'
        },
        overlayCSS:  {
            backgroundColor:'#fff',
            opacity:        '0.6'
        }
    });
    var detailInUrl = document.URL.search("detail");
    var postData = this.serializeAnything();
    var postDataArray = this.serializeArray();
    if(detailInUrl == '-1'){
        $.get(document.URL +'?'+ postData+'&no_cache=1&type=555&date=' +  new Date().getTime(), function(data){
            var tempData = data;
            $('div.tx-editfiltersystem-pi1').unblock();
            $('div.tx-editfiltersystem-pi1').empty();
            $('div.tx-editfiltersystem-pi1').append($(tempData).find('div.tx-editfiltersystem-pi1').html());
            loadSubmitViaAjax();
        });
    }else{
    
        //location.href = "http://"+ window.location.host + "/" + postDataArray[3]['value'] +'?'+ postData;
        location.href = "http://" + window.location.host +"/"+ postDataArray[3]['value'] +'?'+ postData;
    }
        return this;
}

function loadSubmitViaAjax(){
 
   $(".bel-teaser-search-m-content").click(function(){
		$("#bel-filter-layerform").slideToggle(100);
	});
	$('#bel-filter-layerform').each(function() {
		if($(this).attr("close") == 'true'){
			$(this).hide();	
		}
	});	
	
    $(".bel-teaser-search").click(function(){
        if ($(this).find(":nth-child(2) > div.bel-teaser-search-m-content").find(":first").hasClass("bel-teaser-search-up")) {
			$(this).find(":nth-child(2) > div.bel-teaser-search-m-content").find(":first").removeClass("bel-teaser-search-up");
			$(this).find(":nth-child(2) > div.bel-teaser-search-m-content").find(":first").addClass("bel-teaser-search-down");
			
		} else if ($(this).find(":nth-child(2) > div.bel-teaser-search-m-content").find(":first").hasClass("bel-teaser-search-down")) {
			$(this).find(":nth-child(2) > div.bel-teaser-search-m-content").find(":first").removeClass("bel-teaser-search-down");
			$(this).find(":nth-child(2) > div.bel-teaser-search-m-content").find(":first").addClass("bel-teaser-search-up");

		}	
	});

    $('a').click(function(e){
        if($(this).attr('href') == '#'){
            //Cancel the link behavior
            e.preventDefault();
        }
    });

    $("#filter_system").submit(function(){
        $('#filter_system').submitViaAjax();
        return false;
    })

    $("#filter_system input:checkbox").click(function(){
        $('#filter_system').submitViaAjax();
        return false;
    })


    $("#filter_system input:radio").click(function(){
        $('#filter_system').submitViaAjax();
        return false;
    })


    $("#filter_system select.bel-form-pulldown").change(function(){
        $('#filter_system').submitViaAjax();
        return false;
    })

    $(".bel-form-wide input select").mouseup(function(){
        setTimeout(function(){$('#filter_system').submitViaAjax();},300);
        return false;
    })


    // serach manuell ausführen...
    $("#filter_system").keypress(function (e) {
        if (e.which == 13){
            $('#filter_system').submitViaAjax();
      }
    });




}
function clearForm(){
    $('#filter_system').resetForm();
    setTimeout(function(){$('#filter_system').submit();},200);
}

$.fn.resetForm = function() {
    return this.each(function() {
    var type = this.type, tag = this.tagName.toLowerCase();
    if (tag == 'form')
        return $(':input',this).resetForm();
    if (type == 'text' || type == 'password' || tag == 'textarea')
        this.value = '';
    else if (type == 'checkbox' || type == 'radio')
        this.checked = false;
    else if (tag == 'select')
        this.selectedIndex = 0;
    });
}

$.fn.serializeAnything = function() {
    var toReturn    = [];
    var els         = $(this).find(':input').get();
    $.each(els, function() {
        if (this.name && !this.disabled && (this.checked || /select|textarea/i.test(this.nodeName) || /text|hidden|password/i.test(this.type))) {
            var val = $(this).val();
            //toReturn.push( encodeURIComponent(this.name) + "=" + encodeURIComponent( val ) );
            toReturn.push( this.name + "=" +  val  );
        }
    });
    return toReturn.join("&").replace(/%20/g, "+");
};


/*EDIT SHADER JS*/

function Fensterweite () {
  if (window.innerWidth) {
    return window.innerWidth;
  } else if (document.body && document.body.offsetWidth) {
    return document.body.offsetWidth;
  } else {
    return 0;
  }
}

function Fensterhoehe () {
  if (window.innerHeight) {
    return window.innerHeight;
  } else if (document.body && document.body.offsetHeight) {
    return document.body.offsetHeight;
  } else {
    return 0;
  }
}

jQuery.fn.showshader = function(divItem) {
    //Screen Berechnung mitte
                                                var formWidthPX = $('#'+divItem).css("width");
                                                var formHeightPX = $('#'+divItem).css("height");
                                                var formWidth = formWidthPX.split('p');
                                                var formHeight = formHeightPX.split('p');
                                                
                                                var element = $(divItem) //.attr('id')
                                                
                                             //   var fhoehe = ((Fensterhoehe()/2)-(formHeight[0]/2));
                                             //   var fweite = ((Fensterweite()/2)-(formWidth[0]/2));

                                                var fhoehe = ((Fensterhoehe()/2)-(600/2));
                                                var fweite = ((Fensterweite()/2)-(850/2));

                                                $.blockUI.defaults = { 
                                                // styles for the message when blocking; if you wish to disable 
                                                // these and use an external stylesheet then do this in your code: 
                                                // $.blockUI.defaults.css = {}; 
                                                css: {  
                                                padding:        0, 
                                                margin:         0,
                                                height:         '600px',
                                                width:          '850px',
                                                top:            fhoehe,  
                                                left:           fweite,
                                                textAlign:      'center',  
                                                color:          '#000',  
                                                border:         '0px solid #aaa', 
                                                backgroundColor:'', 
                                                cursor:         'default' 
                                                }, 
                                                
                                                // styles for the overlay 
                                                overlayCSS:  {  
                                                backgroundColor:'#000',  
                                                opacity:        '0.5'  
                                                }, 
                                                
                                                // z-index for the blocking overlay 
                                                baseZ: 1000, 
                                                
                                                // set these to true to have the message automatically centered 
                                                centerX: true, // <-- only effects element blocking (page block controlled via css above) 
                                                centerY: true, 
                                                
                                                // allow body element to be stetched in ie6; this makes blocking look better 
                                                // on "short" pages.  disable if you wish to prevent changes to the body height 
                                                allowBodyStretch: true, 
                                                
                                                // be default blockUI will supress tab navigation from leaving blocking content; 
                                                constrainTabKey: true, 
                                                
                                                // fadeOut time in millis; set to 0 to disable fadeout on unblock 
                                                fadeOut:  400, 
                                                
                                                // suppresses the use of overlay styles on FF/Linux (due to significant performance issues with opacity) 
                                                applyPlatformOpacityRules: true 
                                                }; 
                                          
                                                
                                                $.blockUI({ message: $('#'+divItem), css: {  cursor: 'pointer'}});
    //--------------------------------------------------------------------------
}


jQuery.fn.showcontact = function(divItem) {
    //Screen Berechnung mitte
                                                var formWidthPX = $('#'+divItem).css("width");
                                                var formHeightPX = $('#'+divItem).css("height");
                                                var formWidth = formWidthPX.split('p');
                                                var formHeight = formHeightPX.split('p');

                                                var element = $(divItem) //.attr('id')

                                             //   var fhoehe = ((Fensterhoehe()/2)-(formHeight[0]/2));
                                             //   var fweite = ((Fensterweite()/2)-(formWidth[0]/2));

                                                var fhoehe = ((Fensterhoehe()/2)-(430/2));
                                                var fweite = ((Fensterweite()/2)-(634/2));

                                                $.blockUI.defaults = {
                                                // styles for the message when blocking; if you wish to disable
                                                // these and use an external stylesheet then do this in your code:
                                                // $.blockUI.defaults.css = {};
                                                css: {
                                                padding:        0,
                                                margin:         0,
                                                height:         '430px',
                                                width:          '634px',
                                                top:            fhoehe,
                                                left:           fweite,
                                                textAlign:      'center',
                                                color:          '#000',
                                                border:         '0px solid #aaa',
                                                backgroundColor:'',
                                                cursor:         'default',
                                                position:       'absolute'
                                                },

                                                // styles for the overlay
                                                overlayCSS:  {
                                                backgroundColor:'#000',
                                                opacity:        '0.5'
                                                },

                                                // z-index for the blocking overlay
                                                baseZ: 1000,

                                                // set these to true to have the message automatically centered
                                                centerX: true, // <-- only effects element blocking (page block controlled via css above)
                                                centerY: true,

                                                // allow body element to be stetched in ie6; this makes blocking look better
                                                // on "short" pages.  disable if you wish to prevent changes to the body height
                                                allowBodyStretch: true,

                                                // be default blockUI will supress tab navigation from leaving blocking content;
                                                constrainTabKey: true,

                                                // fadeOut time in millis; set to 0 to disable fadeout on unblock
                                                fadeOut:  400,

                                                // suppresses the use of overlay styles on FF/Linux (due to significant performance issues with opacity)
                                                applyPlatformOpacityRules: true
                                                };


                                                $.blockUI({ message: $('#'+divItem), css: {  cursor: 'pointer'}});
    //--------------------------------------------------------------------------
}

jQuery.fn.showshader_485 = function(divItem) {
                                                //Screen Berechnung mitte
                                                var formWidthPX = $('#'+divItem).css("width");
                                                var formHeightPX = $('#'+divItem).css("height");
                                                var formWidth = formWidthPX.split('p');
                                                var formHeight = formHeightPX.split('p');
                                                
                                                var element = $(divItem) //.attr('id')

                                             //   var fhoehe = ((Fensterhoehe()/2)-(formHeight[0]/2));
                                             //   var fweite = ((Fensterweite()/2)-(formWidth[0]/2));

                                                var fhoehe = ((Fensterhoehe()/2)-(325/2));
                                                var fweite = ((Fensterweite()/2)-(485/2));

                                                $.blockUI.defaults = {
                                                // styles for the message when blocking; if you wish to disable
                                                // these and use an external stylesheet then do this in your code:
                                                // $.blockUI.defaults.css = {};
                                                css: {
                                                padding:        0,
                                                margin:         0,
                                                height:         '325px',
                                                width:          '485px',
                                                top:            fhoehe,
                                                left:           fweite,
                                                textAlign:      'center',
                                                color:          '#000',
                                                border:         '0px solid #aaa',
                                                backgroundColor:'',
                                                cursor:         'default'
                                                },

                                                // styles for the overlay
                                                overlayCSS:  {
                                                backgroundColor:'#000',  
                                                opacity:        '0.5'
                                                },

                                                // z-index for the blocking overlay
                                                baseZ: 1000,

                                                // set these to true to have the message automatically centered
                                                centerX: true, // <-- only effects element blocking (page block controlled via css above)
                                                centerY: true,

                                                // allow body element to be stetched in ie6; this makes blocking look better
                                                // on "short" pages.  disable if you wish to prevent changes to the body height
                                                allowBodyStretch: true,

                                                // be default blockUI will supress tab navigation from leaving blocking content;
                                                constrainTabKey: true,

                                                // fadeOut time in millis; set to 0 to disable fadeout on unblock
                                                fadeOut:  400,

                                                // suppresses the use of overlay styles on FF/Linux (due to significant performance issues with opacity)
                                                applyPlatformOpacityRules: true
                                                };


                                                $.blockUI({ message: $('#'+divItem), css: {  cursor: 'pointer'}});
    //--------------------------------------------------------------------------
}

jQuery.fn.showshader_shop_main = function(divItem) {
                                                //Screen Berechnung mitte
                                                var formWidthPX = $('#'+divItem).css("width");
                                                var formHeightPX = $('#'+divItem).css("height");
                                                var formWidth = formWidthPX.split('p');
                                                var formHeight = formHeightPX.split('p');

                                                var element = $(divItem) //.attr('id')

                                               // var fhoehe = ((Fensterhoehe()/2)-(formHeight[0]/2));
                                               // var fweite = ((Fensterweite()/2)-(formWidth[0]/2));

                                                var fhoehe = ((Fensterhoehe()/2)-(600/2));
                                                var fweite = ((Fensterweite()/2)-(704/2));

                                                $.blockUI.defaults = {
                                                // styles for the message when blocking; if you wish to disable
                                                // these and use an external stylesheet then do this in your code:
                                                // $.blockUI.defaults.css = {};
                                                css: {
                                                padding:        0,
                                                margin:         0,
                                                height:         'auto',
                                                width:          'auto',
                                                top:            '100px',
                                                left:           fweite,
                                                textAlign:      'center',
                                                color:          '#000',
                                                border:         '0px solid #aaa',
                                                backgroundColor:'#fff',
                                                cursor:         'default',
                                                position:       'absolute'

                                                },

                                                // styles for the overlay
                                                overlayCSS:  {
                                                backgroundColor:'#000',
                                                opacity:        '0.5'
                                                },

                                                // z-index for the blocking overlay
                                                baseZ: 1000,

                                                // set these to true to have the message automatically centered
                                                centerX: true, // <-- only effects element blocking (page block controlled via css above)
                                                centerY: true,

                                                // allow body element to be stetched in ie6; this makes blocking look better
                                                // on "short" pages.  disable if you wish to prevent changes to the body height
                                                allowBodyStretch: true,

                                                // be default blockUI will supress tab navigation from leaving blocking content;
                                                constrainTabKey: true,

                                                // fadeOut time in millis; set to 0 to disable fadeout on unblock
                                                fadeOut:  400,

                                                // suppresses the use of overlay styles on FF/Linux (due to significant performance issues with opacity)
                                                applyPlatformOpacityRules: true
                                            };


                                                $.blockUI({ message: $('#'+divItem), css: {  cursor: 'pointer'}});
    //--------------------------------------------------------------------------
}

jQuery.fn.showshader_shop_reload = function(divItem) {

                                                var element = $(divItem) //.attr('id')
                                          
                                             //   var fhoehe = ((Fensterhoehe()/2)-(formHeight[0]/2));
                                             //   var fweite = ((Fensterweite()/2)-(formWidth[0]/2));

                                                var fhoehe = ((Fensterhoehe()/2)-(600/2));
                                                var fweite = ((Fensterweite()/2)-(704/2));

                                                $('#'+divItem).block({
                                                    message: '<div style="height:100px:width:100px;"><img src="fileadmin/templates/img/ajax-loader.gif" /></div>',
                                                    css: {
                                                        border: '0px solid #a00',
                                                        background: 'transparent'
                                                    },
                                                    overlayCSS:  {
                                                        backgroundColor:'#fff',
                                                        opacity:        '0.5'
                                                    }
                                                });

  //--------------------------------------------------------------------------
}

jQuery.fn.showshader_shop_terms = function(divItem) {

                                                var element = $(divItem) //.attr('id')

                                             //   var fhoehe = ((Fensterhoehe()/2)-(formHeight[0]/2));
                                             //   var fweite = ((Fensterweite()/2)-(formWidth[0]/2));

                                                var fhoehe = ((Fensterhoehe()/2)-(200/2));
                                                var fweite = ((Fensterweite()/2)-(304/2));

                                                $('#'+divItem).block({
                                                    message: $('#shopshader_noTerms'), css: {  cursor: 'pointer'}
                                                });

                                                //$.blockUI({ message: $('#'+divItem), css: {  cursor: 'pointer'}});
    //--------------------------------------------------------------------------
}

jQuery.fn.showshader_shop_putincart = function(divItem) {
                                             
                                                var fhoehe = ((Fensterhoehe()/2)-(200/2));
                                                var fweite = ((Fensterweite()/2)-(304/2));

                                                $.blockUI.defaults = {
                                                // styles for the message when blocking; if you wish to disable
                                                // these and use an external stylesheet then do this in your code:
                                                // $.blockUI.defaults.css = {};
                                                css: {
                                                padding:        0,
                                                margin:         0,
                                                height:         '200px',
                                                width:          '304px',
                                                top:            fhoehe,
                                                left:           fweite,
                                                textAlign:      'center',
                                                color:          '#000',
                                                border:         '0px solid #aaa',
                                                backgroundColor:'#fff',
                                                cursor:         'default'
                                                },

                                                // styles for the overlay
                                                overlayCSS:  {
                                                backgroundColor:'#000',
                                                opacity:        '0.5'
                                                },

                                                // z-index for the blocking overlay
                                                baseZ: 1000,

                                                // set these to true to have the message automatically centered
                                                centerX: true, // <-- only effects element blocking (page block controlled via css above)
                                                centerY: true,

                                                // allow body element to be stetched in ie6; this makes blocking look better
                                                // on "short" pages.  disable if you wish to prevent changes to the body height
                                                allowBodyStretch: true,

                                                // be default blockUI will supress tab navigation from leaving blocking content;
                                                constrainTabKey: true,

                                                // fadeOut time in millis; set to 0 to disable fadeout on unblock
                                                fadeOut:  400,

                                                // suppresses the use of overlay styles on FF/Linux (due to significant performance issues with opacity)
                                                applyPlatformOpacityRules: true
                                                };


                                                $.blockUI({ message: $('#'+divItem), css: {  cursor: 'pointer'}});
    //--------------------------------------------------------------------------
}

jQuery.fn.showsem = function() {

                                                //Screen Berechnung mitte
                                                var eleTop =  ($(window).height() - this.height() ) / 2+$(window).scrollTop();
                                                var eleLeft = (( $(window).width() - this.width() ) / 2+($(window).scrollLeft()));
                                                if($.browser.msie){
                                                    eleLeft = (( $(window).width() - this.width() ) / 2+($(window).scrollLeft()));
                                                }
                                                var element = $(this);
                                                var eleHeight = this.height() + 'px';
                                                var eleWidth = this.width() + 'px';
                                                $.blockUI.defaults = {
                                                // styles for the message when blocking; if you wish to disable
                                                // these and use an external stylesheet then do this in your code:
                                                // $.blockUI.defaults.css = {};
                                                css: {
                                                padding:        0,
                                                margin:         0,
                                                height:         eleHeight,
                                                width:          eleWidth,
                                                top:            eleTop,
                                                left:           eleLeft,
                                                textAlign:      'center',
                                                color:          '#000',
                                                border:         '0px solid #aaa',
                                                backgroundColor:'',
                                                cursor:         'default',
                                                position:       'absolute'
                                                },

                                                // styles for the overlay
                                                overlayCSS:  {
                                                backgroundColor:'#000',
                                                opacity:        '0.5'
                                                },

                                                // z-index for the blocking overlay
                                                baseZ: 1000,

                                                // set these to true to have the message automatically centered
                                                centerX: true, // <-- only effects element blocking (page block controlled via css above)
                                                centerY: true,

                                                // allow body element to be stetched in ie6; this makes blocking look better
                                                // on "short" pages.  disable if you wish to prevent changes to the body height
                                                allowBodyStretch: true,

                                                // be default blockUI will supress tab navigation from leaving blocking content;
                                                constrainTabKey: true,

                                                // fadeOut time in millis; set to 0 to disable fadeout on unblock
                                                fadeOut:  400,

                                                // suppresses the use of overlay styles on FF/Linux (due to significant performance issues with opacity)
                                                applyPlatformOpacityRules: true
                                                };


                                                $.blockUI({ message: $(element), css: {  cursor: 'pointer'}});
    //--------------------------------------------------------------------------
}

jQuery.fn.showshader_register_main = function(divItem) {
                                                //Screen Berechnung mitte
                                                var formWidthPX = $('#'+divItem).css("width");
                                                var formHeightPX = $('#'+divItem).css("height");
                                                var formWidth = formWidthPX.split('p');
                                                var formHeight = formHeightPX.split('p');

                                                var element = $(divItem) //.attr('id')

                                               // var fhoehe = ((Fensterhoehe()/2)-(formHeight[0]/2));
                                               // var fweite = ((Fensterweite()/2)-(formWidth[0]/2));

                                                var fhoehe = ((Fensterhoehe()/2)-(520/2));
                                                var fweite = ((Fensterweite()/2)-(780/2));

                                                $.blockUI.defaults = {
                                                // styles for the message when blocking; if you wish to disable
                                                // these and use an external stylesheet then do this in your code:
                                                // $.blockUI.defaults.css = {};
                                                css: {
                                                padding:        0,
                                                margin:         0,
                                                height:         'auto',
                                                width:          'auto',
                                                top:            '100px',
                                                left:           fweite,
                                                textAlign:      'left',
                                                color:          '#000',
                                                border:         '0px solid #aaa',
                                                backgroundColor:'#fff',
                                                cursor:         'default',
                                                position:       'absolute'

                                                },

                                                // styles for the overlay
                                                overlayCSS:  {
                                                backgroundColor:'#000',
                                                opacity:        '0.5'
                                                },

                                                // z-index for the blocking overlay
                                                baseZ: 1000,

                                                // set these to true to have the message automatically centered
                                                centerX: true, // <-- only effects element blocking (page block controlled via css above)
                                                centerY: true,

                                                // allow body element to be stetched in ie6; this makes blocking look better
                                                // on "short" pages.  disable if you wish to prevent changes to the body height
                                                allowBodyStretch: true,

                                                // be default blockUI will supress tab navigation from leaving blocking content;
                                                constrainTabKey: true,

                                                // fadeOut time in millis; set to 0 to disable fadeout on unblock
                                                fadeOut:  400,

                                                // suppresses the use of overlay styles on FF/Linux (due to significant performance issues with opacity)
                                                applyPlatformOpacityRules: true
                                            };


                                                $.blockUI({ message: $('#'+divItem), css: {  cursor: 'pointer'}});
    //--------------------------------------------------------------------------
}
jQuery.fn.showshader_intro = function(divItem) {
                                                //Screen Berechnung mitte
                                                var formWidthPX = $('#'+divItem).css("width");
                                                var formHeightPX = $('#'+divItem).css("height");
                                                var formWidth = formWidthPX.split('p');
                                                var formHeight = formHeightPX.split('p');

                                                var element = $(divItem) //.attr('id')

                                               // var fhoehe = ((Fensterhoehe()/2)-(formHeight[0]/2));
                                               // var fweite = ((Fensterweite()/2)-(formWidth[0]/2));

                                                var fhoehe = ((Fensterhoehe()/2)-(548/2));
                                                var fweite = ((Fensterweite()/2)-(972/2));

                                                $.blockUI.defaults = {
                                                // styles for the message when blocking; if you wish to disable
                                                // these and use an external stylesheet then do this in your code:
                                                // $.blockUI.defaults.css = {};
                                                css: {
                                                padding:        0,
                                                margin:         0,
                                                height:         'auto',
                                                width:          'auto',
                                                top:            '100px',
                                                left:           fweite,
                                                textAlign:      'center',
                                                color:          '#000',
                                                border:         '0px solid #aaa',
                                                backgroundColor:'#fff',
                                                cursor:         'default',
                                                position:       'absolute'

                                                },

                                                // styles for the overlay
                                                overlayCSS:  {
                                                backgroundColor:'#000',
                                                opacity:        '0.5'
                                                },

                                                // z-index for the blocking overlay
                                                baseZ: 1000,

                                                // set these to true to have the message automatically centered
                                                centerX: true, // <-- only effects element blocking (page block controlled via css above)
                                                centerY: true,

                                                // allow body element to be stetched in ie6; this makes blocking look better
                                                // on "short" pages.  disable if you wish to prevent changes to the body height
                                                allowBodyStretch: true,

                                                // be default blockUI will supress tab navigation from leaving blocking content;
                                                constrainTabKey: true,

                                                // fadeOut time in millis; set to 0 to disable fadeout on unblock
                                                fadeOut:  400,

                                                // suppresses the use of overlay styles on FF/Linux (due to significant performance issues with opacity)
                                                applyPlatformOpacityRules: true
                                            };


                                                $.blockUI({ message: $('#'+divItem), css: {  cursor: 'pointer'}});
    //--------------------------------------------------------------------------
}
