jQuery.noConflict();

var openForm = '';

jQuery(document).ready(function(){
						   
  //waechselt hintergrundgrafik bei auswahl suche
  jQuery("#go1").click(function () { 
    jQuery('#go2').removeClass("selected");
    jQuery('#go1').addClass("selected");
    jQuery(this).find('input').attr('checked', 'checked');
    jQuery("#form5").animate({
      top: "-120px"
    }, 500);
    jQuery("#second").animate({
      top: "40px"
    }, 500);
    jQuery('#li4').removeClass("selected");
    jQuery('#li4 input').removeAttr("checked");
    jQuery('#li5').removeClass("selected");
    jQuery('#li5 input').removeAttr("checked");
    jQuery('#li6').removeClass("selected");
    jQuery('#li6 input').removeAttr("checked");
    jQuery('#li3').addClass("selected");
    jQuery('#li3 input').attr({ 
      checked: "checked"
    });	
    jQuery("#form5").hide();
    jQuery('#form2').hide("fast");
    jQuery('#form3').hide("fast");
    jQuery('#form4').hide("fast");
    jQuery('.partner_text').hide();
    jQuery('.locations_text').show('normal');
    
    jQuery('#form1').show("slow", function() {
      jQuery('#form1').find('input[name=aFulltext]').focus();
    });	
  });	
  
  jQuery("#go2").click(function () { 
    jQuery('#go1').removeClass("selected");
    jQuery('#go2').addClass("selected");
    jQuery(this).find('input').attr('checked', 'checked');
    jQuery('#form1').hide("fast");
    jQuery('#form2').hide("fast");
    jQuery('#form3').hide("fast");
    jQuery('#form4').hide("fast");
    jQuery('#form5').show("slow");
    jQuery("#second").animate({
      top: "-60px"
    }, 500);
    jQuery('.locations_text').hide();
    jQuery('.partner_text').show('normal');	
    
    jQuery("#form5").animate({
      top: "40px"
    }, 500, function() {
      jQuery('#form5').find('input[name=aFulltext]').focus();
    });
  });
	
  // Formulare einblenden
  jQuery('#second li').click(function() {
    var id = jQuery(this).attr('id');
		
    if (openForm != id) {
      // Klassen zuweisen
      jQuery('#second li').removeClass('selected');
      jQuery(this).addClass('selected');
			
      // Radioboxen auswählen
      jQuery('#second li input').removeAttr('checked');
      jQuery(this).find('input').attr('checked', 'checked');
			
      // Formular auswählen
      var formNumber = id.substr(2) * 1 - 2;
      jQuery('.formcontainer').hide('fast');
      jQuery('#form' + formNumber).show('slow', function() {
        jQuery('#form' + formNumber).find('input[name=aFulltext]').focus();
      });
			
      openForm = id;
    }
  });
	
  // tooltip in formularen
  jQuery('a.title').cluetip({
    splitTitle: '|'
  });
  
  jQuery('a.help').cluetip({
    width: '155px', 
    local: true, 
    hideLocal: true, 
    showTitle: false
  });
  
  jQuery('input[name=aFulltext]').focus(function(event) {
    event.stopPropagation();
  });
  
  jQuery('input[name=aFulltext]').keyup(function(event) {
    if(event.keyCode == 13) {
      jQuery(this).parents('form').submit();
    }
  });
});
