jQuery(document).ready(function($){var products_id=$('#pid').val();var freitext_max=new Array();$('.charCounter').each(function(){freitext_max[$(this).attr('id')]=$(this).html();});function fadeContainer(freitext_id,func){if(freitext_id.indexOf(',')==-1){id=$('#'+freitext_id).attr('name');id=id.substr(4);if(func=='fadeIn'){$('#container-'+id).fadeIn();}else{var counter=freitext_max['charCounter['+freitext_id+']'];$('#container-'+id).hide();$('#'+freitext_id).val('');$('#charCounter\\['+freitext_id+'\\]').html(counter);}}else{ids=freitext_id.split(',');for(i=0;i<ids.length;i++){id=$('#'+ids[i]).attr('name');id=id.substr(4);if(func=='fadeIn'){$('#container-'+id).fadeIn();}else{var counter=freitext_max['charCounter['+ids[i]+']'];$('#container-'+id).hide();$('#'+ids[i]).val('');$('#charCounter\\['+ids[i]+'\\]').html(counter);}}}}
if($('#ftm').val()==true){$.scrollTo('#productoptions',1000,{offset:-200});$.getJSON('inc/xtc_get_freitext.php?pid='+products_id,function(freitext_array){$.each(freitext_array,function(i,freitext){var ftm_input=$('[name="txt_'+freitext.options_values_id+'"]');if(ftm_input.val()==''||ftm_input.val()=='___'){ftm_input.val('');ftm_input.addClass('redborder');if(ftm_input.is('input')){ftm_input.next().after(' <span class="redtext">Bitte f&uuml;llen Sie dieses Feld aus.</span>');}else{ftm_input.after(' <span class="redtext">Bitte f&uuml;llen Sie dieses Feld aus.</span>');}}
ftm_input.focus(function(){$(this).removeClass('redborder');$(this).parent().find('span.redtext').hide();});});});}
$.getJSON('inc/xtc_get_freitext.php?action=optional&pid='+products_id,function(optional_freitext_array){$.getJSON('inc/xtc_get_freitext.php?action=switch&pid='+products_id,function(switch_freitext_array){if(switch_freitext_array!=null){$.each(switch_freitext_array,function(i,switch_freitext){if($('select[name="id['+switch_freitext.attribute_id+']"]').val()==switch_freitext.attribute_option){fadeContainer(switch_freitext.show_freitext,'fadeIn');fadeContainer(switch_freitext.hide_freitext,'hide');}else{fadeContainer(switch_freitext.show_freitext,'hide');fadeContainer(switch_freitext.hide_freitext,'fadeIn');}});}
if(optional_freitext_array!=null){$.each(optional_freitext_array,function(i,optional_freitext){if($('select[name="id['+optional_freitext.attribute_id+']"]').val()==optional_freitext.attribute_option){fadeContainer(optional_freitext.hide_freitext,'hide');}});}
$('select.event').each(function(){var attribute_id=$(this).attr('name');attribute_id=attribute_id.substr(3,attribute_id.length-4);var option_id=$(this).val();$(this).change(function(){option_id=$(this).val();if(optional_freitext_array!=null){$.each(optional_freitext_array,function(i,optional_freitext){if(optional_freitext.attribute_id==attribute_id){freitext_id=optional_freitext;if(optional_freitext.attribute_option==option_id){fadeContainer(freitext_id.hide_freitext,'fadeOut');return false;}else{fadeContainer(freitext_id.hide_freitext,'fadeIn');}}});}
if(switch_freitext_array!=null){$.each(switch_freitext_array,function(i,switch_freitext){if($('select[name="id['+switch_freitext.attribute_id+']"]').val()==switch_freitext.attribute_option){fadeContainer(switch_freitext.show_freitext,'fadeIn');fadeContainer(switch_freitext.hide_freitext,'hide');}else{fadeContainer(switch_freitext.show_freitext,'hide');fadeContainer(switch_freitext.hide_freitext,'fadeIn');}});}});});$('input[name^="txt_"], textarea[name^="txt_"]').each(function(){var counter=$('#charCounter\\['+$(this).attr('id')+'\\]');var maxLength=counter.text();counter.html(maxLength-$(this).val().length);$(this).keyup(function(){$(this).removeClass('redborder');if($(this).val().length>maxLength){$(this).addClass('redborder');$(this).val($(this).val().substring(0,maxLength));}
counter.html(maxLength-$(this).val().length).stop(true,true).fadeTo('fast',0.5,function(){$(this).fadeTo('fast',1);});});});});});});
