		
		// Preload Login Background
		//imgLoader = new Image();
		//imgLoader.src = "template/img/login/background_login.png";
		
		// Main Background Count
		var bgiCount = 6;
		
		// Main init
		$(document).ready(function() {
			pl_h = new Planatvet_Tabs();
			pl_l = new Plantavet_Login();
		});
		
		var pl_h;
		var pl_l;
		
		var Planatvet_Tabs = new Class({
			initialize: function() {
				this.tabHolder = $('#home_teaser').children('.col_1').children('ul');
				this.contentHolder = $('#home_teaser').children('.col_2').children('ul');
				this.tabs = Array(
					this.tabHolder.children('li.phytopharmaka'),
					this.tabHolder.children('li.potenzierte_arzneimittel'),
					this.tabHolder.children('li.nutrazeutika'),
					this.tabHolder.children('li.pflegemittel')
				);
				this.contents = Array(
					this.contentHolder.children('li.start'),
					this.contentHolder.children('li.phytopharmaka'),
					this.contentHolder.children('li.potenzierte_arzneimittel'),
					this.contentHolder.children('li.nutrazeutika'),
					this.contentHolder.children('li.pflegemittel')
				);
				this.containerClasses = Array(
					"start",
					"phytopharmaka",
					"potenzierte_arzneimittel",
					"nutrazeutika",
					"pflegemittel"
				);
				this.activeTab = 0;
			},
			showTab: function(i) {
				if(i !== this.activeTab) {
					this.activeTab = i;
					this.hideTabs();
					this.tabs[i-1].addClass('active');
					this.contents[i].parent().parent().css('background-position','right '+i*(-231)+'px');
					this.contents[i].fadeIn(500);
					this.hideTabs();
				}
			},
			hideTabs: function() {
				var i = 0;
				while(i<5) {
					if(i !== this.activeTab) {
						if(i!=0) {
							this.tabs[i-1].removeClass('active');
						}
						this.contents[i].stopAll().hide();
					}
					i++;
				}
			}
		});
		
		var Plantavet_Login = new Class({
			initialize: function() {
				var _ref = this;
				$('#login_toggle').children('a').click(
					function() {
						_ref.toggleLoginWindow();
					}
				);
				/*$('#login').children('.col_4').children('.button_big.weiter').click(
					function() {
						_ref.checkLogin();
					}
				);*/
			},
			checkLogin: function() {
				//
			},
			toggleLoginWindow: function() {
				window.scrollTo(0, 0);
				$('#login').toggle();
				$('#login_toggle').toggleClass('active');
			},
			showLoginWindow: function() {
				window.scrollTo(0, 0);
				$('#login').show();
				$('#login_toggle').addClass('active');
				$('#username').focus();
			},
			hideLoginWindow: function() {
				$('#login').hide();
				$('#login_toggle').removeClass('active');
			},
			login: function() {
				
			}
		});
		
		function checkLogin() {
			var username = $('#username').val();
			var password = $('#password').val();
			if(username != "" && password != "") {
				$('#login_form').submit();
			}
			else {
				alert('Bitte geben Sie einen Benutzernamen und Passwort ein!');
				if(username == "" && password == "") $('#username').focus();
				else if(username == "" && password != "") $('#username').focus();
				else $('#password').focus();
			}
		}
		
		function getRandom( min, max ) {
			if( min > max ) 	return( -1 );
			if( min == max ) 	return( min );
			var r = parseInt( Math.random() * ( max+1 ) );
			return( r + min <= max ? r + min : r );
		}
