// Bayerische Hochschulen Funktionen



$(document).ready(function(){

//$("#content").css ({opacity:0.9});

$("#finderHref a").hide();



   $('.email').each(function() {

   var $email = $(this);

	     var address = $email.text()

	         .replace(/\s*\[at\]\s*/, '@')

	         .replace(/\s*\[dot\]\s*/g, '.');

	      $email.html('<a href="mailto:' + address + '">'

	         + address +'</a>');

	   });

  

    

function formatText(index, panel) {

		  return index + "";

	    }



if($("#selectbox_1").length) {

	

	

	 $(function(){ $("#selectbox_1").uniform(); });

	 $(function(){ $("#selectbox_2").uniform(); });

	 $(function(){ $("#selectbox_3").uniform(); });

	 $(function(){ $("#selectbox_4").uniform(); });

	

	 $("#selectbox_1").change(function(){

   
      $('#uniform-selectbox_2 span').html("&mdash; Studienkategorie w&auml;hlen &mdash;");
  
  		$('#uniform-selectbox_3 span').html("&mdash; Studiengang w&auml;hlen &mdash;");
  
  		$('#uniform-selectbox_4 span').html("&mdash; Hochschule w&auml;hlen &mdash;");
  
  		var id_hauptkategorie=$(this).children('option:selected').val();
  
  		$("#finderHref a").hide();
  
  	 	$("#selectbox_2").load("/?type=5000",{value: id_hauptkategorie, select: 1	});
  
  		$("#selectbox_3").load("/?type=5000",{value: 0, select: 2	});
  
  		$("#selectbox_4").load("/?type=5000",{value: 0, select: 3	});

		

		

	});

	  

	  $("#selectbox_2").change(function(){

  		$.uniform.update();
  
  		$("#finderHref a").hide();
  
      var id_hauptkategorie=$(this).children('option:selected').val();
  
      $("#selectbox_3").load("/?type=5000",{value: id_hauptkategorie, select: 2	});
  
  		$("#selectbox_4").load("/?type=5000",{value: 0, select: 3	});
 
  
  		$('#uniform-selectbox_3 span').html("&mdash; Studiengang w&auml;hlen &mdash;");
  
  		$('#uniform-selectbox_4 span').html("&mdash; Hochschule w&auml;hlen &mdash;");
  

      });

	  

	  $("#selectbox_3").change(function(){

    		$.uniform.update();
    
    		$("#finderHref a").hide();
    
    		$('#uniform-selectbox_4 span').html("&mdash; Hochschule w&auml;hlen &mdash;");
    
        var id_hauptkategorie=$(this).children('option:selected').val();

       	$("#selectbox_4").load("/?type=5000",{value: id_hauptkategorie, select: 3	});

      });

	  

	   

	  $("#selectbox_4").change(function(){

		$.uniform.update();

		var finderHref = ($(this).children('option:selected').val());

       $("#finderHref a").hide();

		$('a#'+finderHref).show();

      });



};







	 

$(function () {

        

		if($('.argumentSlider').length) {

            $('.argumentSlider').argumentSlider({

                easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin

                autoPlay: false,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.

                delay: 3000,                    // How long between slide transitions in AutoPlay mode

                startStopped: false,            // If autoPlay is on, this can force it to start stopped

                animationTime: 600,             // How long the slide transition takes

                hashTags: true,                 // Should links change the hashtag in the URL?

                buildNavigation: true,          // If true, builds and list of anchor links to link to each slide

        		pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover

        		startText: "Go",             // Start text

		        stopText: "Stop",               // Stop text

		        navigationFormatter: formatText       // Details at the top of the file on this use (advanced use)

            });

            

            $("#slide-jump").click(function(){

                $('.argumentSlider').argumentSlider(6);

            });

         }  

        });	

		

			



});



$(function(){

		   

if($('.tipKurse').length || $('.mapit').length) {

	$('.tipKurse').bt({

      delay: 300,	

      trigger: 'click',

      closeWhenOthersOpen: true,  

	  padding: 10,

	  width: 280,

	  spikeLength: 8,

	  spikeGirth: 10,

	  positions: ['top'],

	  overlap: 10, 

	  cornerRadius:  3,

	  fill: 'rgba(255, 255, 255, .95)',

	  strokeWidth: 1,

	  strokeStyle: '#d4d4d4',

	  cssStyles: {color: '#333', fontWeight: 'normal'},

	  textzIndex:       9999,                 

   	  boxzIndex:        9998

	});

	

	$('.mapit').bt({

      	  

	  padding: 10,

	  width: 140,

	  spikeLength: 8,

	  spikeGirth: 10,

	  positions: ['bottom'],

	  overlap: -5, 

	  cornerRadius:  3,

	  fill: 'rgba(255, 255, 255, .95)',

	  strokeWidth: 1,

	  strokeStyle: '#d4d4d4',

	  cssStyles: {color: '#333', fontWeight: 'normal'},

	  textzIndex:       9999,                 

   	  boxzIndex:        9998

	});

}



if($('.infotip').length) {

	$('.infotip').bt({

      delay: 1,		  

	  padding: 10,

	  width: 230,

	  spikeLength: 8,

	  spikeGirth: 10,

	  positions: ['bottom'],

	  overlap: 0, 

	  cornerRadius:  3,

	  fill: 'rgba(255, 255, 255, .95)',

	  strokeWidth: 1,

	  strokeStyle: '#d4d4d4',

	  cssStyles: {color: '#333', fontWeight: 'normal'},

	  textzIndex:       9999,                 

   	  boxzIndex:        9998

	});

}

});	





(function ($) {

    $.fn.selectChain = function (options) {

        var defaults = {

            key: "id",

            value: "label"

        };

        

        var settings = $.extend({}, defaults, options);

        

        if (!(settings.target instanceof $)) settings.target = $(settings.target);

        

        return this.each(function () {

            var $$ = $(this);

            

            $$.change(function () {

                var data = null;

                if (typeof settings.data == 'string') {

                    data = settings.data + '&' + this.name + '=' + $$.val();

                } else if (typeof settings.data == 'object') {

                    data = settings.data;

                    data[this.name] = $$.val();

                }

                

                settings.target.empty();

                

                $.ajax({

                    url: settings.url,

                    data: data,

                    type: (settings.type || 'get'),

                    dataType: 'json',

                    success: function (j) {

                        var options = [], i = 0, o = null;

                        

                        for (i = 0; i < j.length; i++) {

                            // required to get around IE bug (http://support.microsoft.com/?scid=kb%3Ben-us%3B276228)

                            o = document.createElement("OPTION");

                            o.value = typeof j[i] == 'object' ? j[i][settings.key] : j[i];

                            o.text = typeof j[i] == 'object' ? j[i][settings.value] : j[i];

                            settings.target.get(0).options[i] = o;

                        }



			// hand control back to browser for a moment

			setTimeout(function () {

			    settings.target

                                .find('option:first')

                                .attr('selected', 'selected')

                                .parent('select')

                                .trigger('change');

			}, 0);

                    },

                    error: function (xhr, desc, er) {

                        // add whatever debug you want here.

			alert("an error occurred");

                    }

                });

            });

        });

    };

})(jQuery);


