var $j = jQuery.noConflict();

$j(document).ready(function(){
	
/* ###################################################################################### */
/* GENERAL                                                                                */
/* ###################################################################################### */ 


/* STUDIENANGEBOT NAVI                                                                    */ 
/* -------------------------------------------------------------------------------------- */
   

    /* STUDIENANGEBOT INDIVIDUELL                                                    */ 
    
    $j('.organiForm input').click(function(){
        $j(".studienangebotreihe .bb").removeClass("high"); 
        $j(".studienangebotreihe .vz").removeClass("high"); 
        var classes = $j(".organiForm input:checked").val();
        $j('.'+classes).addClass("high");                            
    });    
    $j('.stgForm input[name="stgFormInputBak"]').click(function(){
        $j(".studienangebotreihe .bak").toggle();                            
    });
    $j('.stgForm input[name="stgFormInputMaster"]').click(function(){
        $j(".studienangebotreihe .master").toggle();                            
    });
    $j('.stgForm input[name="stgFormInputLehr"]').click(function(){
       $j(".studienangebotreihe .lehr").toggle();                            
    });
    $j('.stgForm input[name="stgFormInputDipl"]').click(function(){
        $j(".studienangebotreihe .dipl").toggle();                            
    });
    $j('.stgForm input[name="stgFormInputMatura"]').click(function(){
       $j(".studienangebotreihe .matura").toggle();                            
    });
	
	$j('.englischChoise input[name="stgFormInputEnglish"]').click(function(){
        /*
		$j('.stgForm input').removeAttr("checked");
		//$j('.stgForm input[name="stgFormInputMaster"],.stgForm input[name="stgFormInputBak"]').attr('checked', 'checked');
		$j(".studienangebotreihe .header").hide();
		$j(".studienangebotreihe .master, .studienangebotreihe .bak").show();		
		$j(".studienangebotreihe ul ul li:not(.en)").hide();
		*/ 	
		$j(".studienangebotreihe ul ul li.en").toggleClass("stgOdd");
    });
	
    

    /* STUDIENANGEBOT CLOSE / OPEN                                                       */ 
   /* $j('.closestudienangebot a').click(function(){
        $j("#header").toggleClass("headerbck");
        $j('#studienangebot').slideToggle();
    });
	
	$j('a[href$=studienangebot/], a[href$=programmes/], #menu a[href$=courses/], a[href$=index.php?id=17], a[href$=index.php?id=17&L=1], a[href$=index.php?id=17&L=0], a[href$=degree-programs/], #slideFH a').removeAttr("href").css('cursor','pointer').click(function(){
        $j("#header").toggleClass("headerbck");
        $j('#studienangebot').slideToggle();
    });
	*/
	
	$j("#hgb, #linz").equalHeights();
	$j("#wels, #steyr").equalHeights();
	$j("#wels h1, #steyr h1").equalHeights();
	$j("#hgb ul li:odd a, #linz ul li:odd a, #steyr ul li:odd a, #wels ul li:odd a").addClass("stgOdd");
    
/* HEADER NAVI    (Campus / Services)                                                     */ 
/* -------------------------------------------------------------------------------------- */

    $j('.arrow-down').each(function () {
        // options
        var hideDelay = 75;
        var hideDelayTimer = null;
        var beingShown = false;
        var shown = false;
        var trigger = $j('.trigger', this);
        var popup = $j('.above', this);
    
        $j([trigger.get(0), popup.get(0)]).mouseover(function () {
          if (hideDelayTimer) clearTimeout(hideDelayTimer);
    
          if (beingShown || shown) {
            return;
          } else {
            beingShown = true;
    
            var off = $j(this).parent().offset();
            if ( $j.browser.version !='6.0' ) { $j(trigger).parent().addClass('hoverStat');}
            //$j(trigger).parent().addClass('hoverStat');
            popup.css({
              top: off.top+38,
              left: off.left-1
              //width: $j(this).width()+9  
            }).show();
          }
        }).mouseout(function () {
          if (hideDelayTimer) clearTimeout(hideDelayTimer);
              hideDelayTimer = setTimeout(function () {
            hideDelayTimer = null;
            //popup.slideUp('fast', function(){ if ( $j.browser.version !='6.0' ) { 		$j(trigger).parent().removeClass('hoverStat')}});
			popup.hide();
			$j(trigger).parent().removeClass('hoverStat');
            beingShown = false;
          }, hideDelay);
        });
      });

/* ###################################################################################### */
/* STARTSITE                                                                              */
/* ###################################################################################### */ 
	
	/* ACTIVATE TABS */ 
	$j('#startSiteOverview ul:first').tabs({ 
		show: function(ui) {
			$j('#startSiteOverview ul li').removeClass('noBorder');
			$j('.ui-tabs-selected').next().addClass('noBorder');
		}
		
	}); // Alles auf einen Blick  // FAD { fx: { opacity: 'toggle' } }
	$j('.startSiteNews ul:first').tabs();	
	
	
    
/* ###################################################################################### */
/* STUDIENGAG                                                                             */
/* ###################################################################################### */ 
	
	/* STG HEADER */ 
	/*$j('.stgcluster').cycle({
			fx:     'fade', 
            speed:   550, 
            timeout: 7000, 
            cleartype:     1,
            pause:   1 
    	});
     */
	/* STUDIENGANG FACTS */ 
	$j('.facts table tr:first td').addClass('firstline');
	$j('.facts table tr td:first-child').addClass('label');

 
/* ###################################################################################### */
/* VESE Personen                                                                          */
/* ###################################################################################### */ 

    $j(".person").quickpaginate({ perpage: 15, showcounter: true, pager : $j(".listCounter") });
 
    $j(".funktion").each(function () { 
          $j(this).prevAll("div.d_tel").before(this); 
    });
    $j(".vornamen").each(function () { 
          $j(this).prevAll("span.name").before(this); 
    });
    $j(".besch_art").each(function () { 
          $j(this).prevAll("div.d_tel").before(this); 
    });
    
    $j(".titel_nachgestellt").each(function () { 
          $j(this).nextAll("span.name").after(this); 
    });
    
    $j(".person div.jahrgang").remove(); 


 
/* ###################################################################################### */
/* Konferenz Menu                                                                         */
/* ###################################################################################### */   


    $j('#menu a[href$=konferenzen/]').removeAttr("href").css('cursor','pointer').addClass('trigger').after('<ul id="chooseKonferenz" class="above"><li><a href="NFC2010/">NFC2010</a></li><li><a href="ifip-cms-2010/">IFIP CMS 2010</a></li><li><a href="ct-tagung-2010/">CT-Tagung 2010</a></li><li><a href="iv-kongress/">IV Kongress 2010</a></li><li><a href="lindi2009/">Lindi2009<span>International Symposium</span></a></li><li><a href="cross-cultural-dialogue-linz-09-november-2nd-to-4th/">Cross-Cultural Dialogue Linz 09</a></li></ul>').parent().addClass('konferenz');

    $j('#menu a[href$=conferences/]').removeAttr("href").css('cursor','pointer').addClass('trigger').after('<ul id="chooseKonferenz" class="above"><li><a href="NFC2010/">NFC2010</a></li><li><a href="ifip-cms-2010/">IFIP CMS 2010</a></li><li><a href="lindi2009/">Lindi2009<span>International Symposium</span></a></li><li><a href="cross-cultural-dialogue-linz-09-november-2nd-to-4th/">Cross-Cultural Dialogue Linz 09</a></li></ul>').parent().addClass('konferenz');


/*    $j('#menu a[href$=konferenzen/]').removeAttr("href").css('cursor','pointer').addClass('trigger').after('<ul id="chooseKonferenz" class="above"><li><a href="lindi2009/">Lindi2009<span>International Symposium</span></a></li><li><a href="cross-cultural-dialogue-linz-09-november-2nd-to-4th/">Cross-Cultural Dialogue Linz 09</a></li><li><a href="iv-kongress/">IV Kongress 2010</a></li><li><a href="ct-tagung-2010/">CT-Tagung 2010</a></li></ul>').parent().addClass('konferenz'); */
    
/*    $j('#menu a[href$=conferences/]').removeAttr("href").css('cursor','pointer').addClass('trigger').after('<ul id="chooseKonferenz" class="above"><li><a href="lindi2009/">Lindi2009<span>International Symposium</span></a></li><li><a href="cross-cultural-dialogue-linz-09-november-2nd-to-4th/">Cross-Cultural Dialogue Linz 09</a></li></ul>').parent().addClass('konferenz'); */

    
    $j('#menu li.konferenz').each(function () {
        // options
        var hideDelay = 75;
        var hideDelayTimer = null;
        var beingShown = false;
        var shown = false;
        var trigger = $j('.trigger', this);
        var popup = $j('.above', this);
    
        $j([trigger.get(0), popup.get(0)]).mouseover(function () {
          if (hideDelayTimer) clearTimeout(hideDelayTimer);
    
          if (beingShown || shown) {
            return;
          } else {
            beingShown = true;
    
            var off = $j(this).parent().offset();
            popup.css({
              top: off.top+36,
              left: off.left
              //width: $j(this).width()+9  
            }).show();
          }
        }).mouseout(function () {
          if (hideDelayTimer) clearTimeout(hideDelayTimer);
              hideDelayTimer = setTimeout(function () {
            hideDelayTimer = null;
            popup.hide();
            beingShown = false;
          }, hideDelay);
        });
      });
      

/* ###################################################################################### */
/* Random Partner Logos                                                                   */
/* ###################################################################################### */

   var zahl = Math.round(Math.random() * 5);
   $j('#partner'+zahl).parent().parent().hide();
	
/* ###################################################################################### */
/* Projekte Pagination                                                                    */
/* ###################################################################################### */

   $j('#year').change(function () {
      $j("#listContent td").hide();
      var aktYear = $j("#year option:selected").val();
      $j('tr.'+aktYear+' td').show();
      //$j("#listContent tr").quickpaginate({ perpage: 4, showcounter: true, pager : $j(".project-browseResults") });
      
    })
    .change();

/* ###################################################################################### */
/* Widok CV                                                                               */
/* ###################################################################################### */

   $j('.cvAreaContent td::first-child').addClass('cvDate');
   $j('.cvAreaContent td::last-child').addClass('cvContentDate');

/* ###################################################################################### */
/* Unternehmensstruktur                                                                   */
/* ###################################################################################### */   

    var mapOverlay = $j('#mapOverlay');
	mapOverlay.hide();
	$j('#unternehmensstruktur area').hover(
      function () {
        mapOverlay.html('<h1>' + $j(this).attr('alt') + '</h1>').show();
      }, 
      function () {
        mapOverlay.hide().html('');
      }
    );

/* ###################################################################################### */
/* ENDE                                                                                   */
/* ###################################################################################### */ 
 });