// unihome/js/script.js

jQuery(function($) {

	$(window).load(function () {


		/*****************************************
			PIWIK Website-Analyse einbinden
		*/
	   
	

			var pkBaseURL = "http://analyse.uni-oldenburg.de/piwik/";

		//$.getScript(pkBaseURL + "piwik.js",function(){
			try {
				var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
				piwikTracker.setCookieDomain('*.uni-oldenburg.de'); // Same cookie as: example.com, www.example.com, subdomain.example.com, ...
				piwikTracker.setDomains(['*.uni-oldenburg.de','*.icbm.de','134.106.*','10.0.*']); // Download & Click tracking alias domains
				piwikTracker.setDocumentTitle(document.domain + "/" + document.title);
				piwikTracker.trackPageView();
				piwikTracker.enableLinkTracking();
				
				$('a[href="http://www.youtube.de/universityoldenburg/"]').click(function(){
					piwikTracker.trackGoal(11);
				});
				
				// QPakt
				$('a[href="http://www.qpakt.uni-oldenburg.de/"]').click(function(){
					piwikTracker.trackGoal(12);
				});
				
				// OLWIN
				$('a[href="http://www.pe-oe.uni-oldenburg.de/31067.html"]').click(function(){
					piwikTracker.trackGoal(13);
				});
				
				$('a[href="http://www.giz.uni-oldenburg.de/"]').click(function(){
					piwikTracker.trackGoal(4);
				});
				$('a[href="http://www.kinderuni-oldenburg.de/"]').click(function(){
					piwikTracker.trackGoal(5);
				});
				
				
				$('a[href="http://www.uni-oldenburg.de/uni/51107.html"]').click(function(){
					piwikTracker.trackGoal(6);
				});
				
				// Jobbörse
				$('a[href="http://www.careerservice.uni-oldenburg.de/39388.html"]').click(function(){
					piwikTracker.trackGoal(7);
				});
				
				// Stud.IP-Button
				$('a[href*="elearning.uni-oldenburg.de"]').click(function(){
					piwikTracker.trackGoal(9);
				});
				
				// Stud.IP-Loginformular
				$('#unilogin').submit(function(){
					piwikTracker.trackGoal(14);
				});
				$('a[href^="http://www.presse.uni-oldenburg.de/"]').click(function(){
					piwikTracker.trackGoal(10);
				});
					
				
			} catch( err ) {
			//	alert(err);
			}																	  
		//});
		




		// SlideShow-PlugIn laden
		$.getScript("http://www.uni-oldenburg.de/img/script/aino-galleria/src/galleria.js",function() {
			// Zusätzliche Bilder für die Slideshow in die Seite einsetzen
			var bild_pfad = 'http://www.uni-oldenburg.de/img/orga/unihome/bilder/';
			var bild_array = [
			'hoersaal-sommer.jpg',
			'careerservice.jpg',
			/*	'bibliothek_studentin.jpg', */
			'bibliothek_oben.jpg',
			'bibliothek_etage.jpg',
			/*	'sport_training.jpg', */
			'studierende_lernen.jpg',
			'terramare.jpg',
			'ehrentafeln.jpg',
			/*	'ehrentafeln2.jpg', */
			'mikroskop.jpg',
			'buecher.jpg',
			'studis_springen.jpg',
			'kletterwand.jpg',
			'messpfahl.jpg',
			'offshore.jpg',
			'kopfhoerer.jpg',
			'prof_mathe.jpg',
			'wattenmeer-pfahlmodell.jpg',
			/*	'pendel.jpg', */
			'sport_rangeln.jpg',
			'chemie.jpg'
			];
		
			bild_shuffle = function(o){ //v1.0
				for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
				return o;
			};
			var bi = bild_array.shift(); // 0tes Bild entfernen, da es bereits statisch in der Seite steht
			bild_array = bild_shuffle(bild_array);
		
		
			//if(Galleria)
			for(i=0;i<bild_array.length;i++) { 
				$("#unibilder").append('<a href="'+bild_pfad+bild_array[i]+'"><img src="'+bild_pfad+'klein/'+bild_array[i]+'" alt="" /></a>');
			}
	
	
			Galleria.loadTheme('http://www.uni-oldenburg.de/img/script/aino-galleria/src/themes/uniolhome/galleria.classic.js');
		
			// Slideshow starten
			$('#unibilder').galleria({
				autoplay: 5000,
				transition_speed: 1000,
				transition: 'fade'
			});
		
		
		});
	
	
	

	
	
	
	

		$('#unilogin_label, #username, #password').click(function(){
			$('#unilogin').addClass('hover');
		});
		$('#unilogin_reset').click(function(){
			$('#unilogin').removeClass('hover');
		});
	
		var error = false;
		error = getUrlVars()['error'];
		
		if(error) {
			error = error.replace('+',' ');
			alert(error);
		}
		
	
		function getUrlVars()
		{
			var vars = [], hash;
			var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
			for(var i = 0; i < hashes.length; i++)
			{
				hash = hashes[i].split('=');
				vars.push(hash[0]);
				vars[hash[0]] = hash[1];
			}
			return vars;
		}
	
	
	
	
	
	
	
	/*	
		var rahmenelement = $("buttons");
		var im = $("<script></script>")
		.attr("type","text/javascript")
		.attr("src","http://www.uni-oldenburg.de/img/script/intranetmeldungen.js");
	$("body").append(im);
*/
	}); // .load
}); // .ready

