Element.implement({
	show: function() {
		this.setStyle('display', 'block');
	},
	
	hide: function() {
		this.setStyle('display', 'none');
	},
	
	toggle: function() {
		if(this.getStyle('display') == 'none') {
			this.show();
		} else {
			this.hide();
		}
	}
});


var infos = {
	'de-DE': {
		Season : {
			alias:"Geben Sie eine Kurzbeschreibung der Saison ein. Als Beispiel dient '2010/11'",
			longalias:"Geben Sie eine lange Beschreibung der Saison ein, als Beispiel: 'Bezirksoberliga Season 2010/11'"
		},
		Club: {
			alias:"Geben Sie einen Namen des Vereins an. Dies ist der Name der haupts&auml;chlich im System erscheint.",
			shortalias:"Geben Sie einen kurzen Namen des Vereins an. Wenn Sie das Automatische bef&uuml;llen durch das BFV plugin haben wollen, geben Sie hier den Namen des Vereins an, wie er in den BFV Tabellen eingetragen ist. Zus&auml;tzliche Zeichen wie II m&uuml;&szlig;en weggela&szlig;en werden. Beispiel: 'TSV Regen II' bei BFV mu&szlig; hier als 'TSV Regen' angegeben werden.",
			file:"W&auml;hlen Sie ein Vereinslogo aus."
		},
		Comment: {
			title:"Der Titel des Beitrags"
		},
		Page: {
			title:"Geben Sie den Titel der Seite an. Dieser sollte kurz (maximal Zwei W&ouml;rter betragen)."
		},
		Betpool: {
			league_id: "W&auml;hlen Sie die Liga aus f&uuml;r die Sie ein Tippspiel einrichten wollen.",
			betmatches:"Geben Sie die Anzahl der Spiele an die gleichzeitig im Voraus getippt werden k&ouml;nnen.",
			active: "Setzen sie ein H&auml;ckchen falls die angemeldeten User noch tippen k&ouml;nnen."
		},
		Person: {
			firstname: "Geben Sie den Vornamen ein",
			lastname: "Geben Sie den Nachnamen ein"
		},
		Attachment: {
			alternative:"Geben Sie eine Beschreibung der Datei an. Halten Sie die l&auml;nge der Beschreibung so kurz und pr&auml;gnant wie m&ouml;glich.",
			file:"W&auml;hlen Sie die anzuh&auml;ngende Datei aus. Die Datei kann von folgenden Typen sein: jpeg, png, tiff, gif and pdf",
			'delete': "Setzen Sie ein H&auml;ckchen und senden Sie das Formular ab, wenn Sie diese Datei l&ouml;schen m&ouml;chten."
		},
		Event: {
			title:"Geben Sie einen kurzen und pr&auml;gnanten Titel der Veranstaltung an."
		},
		Album: {
			title:"Geben Sie einen kurzen und pr&auml;gnanten Titel des Fotoalbums an."
		},
		Photo: {
			file: "W&auml;hlen Sie das hochzuladende Foto.",
			alternative:"Geben Sie eine Beschreibung der Datei an. Halten Sie die l&auml;nge der Beschreibung so kurz und pr&auml;gnant wie m&ouml;glich.",
			'delete': "Setzen Sie ein H&auml;ckchen und senden Sie das Formular ab, wenn Sie dieses Bild l&ouml;schen m&ouml;chten."
		},
		ClubsPerson: {
			'person_id':"W&auml;hlen Sie die Person aus die eine Funktion im Verein hat. Zuerst hinzugef&uuml;gte Personen werden auch als erste aufgelistet.",
			'season_id':"W&auml;hlen Sie die Saison in welcher diese Person die Funktion &uuml;bernimmt.",
			'type':"Geben Sie die Funktion ein welche die Person einnimmt. Dies kann zum Beispiel '1. Vorstand', 'Ka&szlig;ier' oder 'Webmaster' sein. Zuerst hinzugef&uuml;gte Personen werden auch zuerst aufgelistet.",
			'info':"Dieses Feld ist nicht verpflichtent. Jedoch ist es empfehlenswer wenige Informationen &uuml;ber die Person oder das Amt abzugeben. Zum Beispiel Kontaktdaten."
		},
		Team: {
			'alias':"Geben Sie den Namen der Mannschaft an. Zum Beispiel: 'Die Erste', 'A-Jugend'",
			'matchpreview':"Falls hier ein H&auml;ckchen gesetzt ist, wird das n&auml;chste Spiel der Mannschaft auf der Startseite angezeigt. Nachdem Sie dieses H&auml;ckchen gesetzt haben vergewi&szlig;ern Sie sich ob das Resultat auf der Startseite auch gut au&szlig;ieht.",
			'club_id':"W&auml;hlen Sie den Verein der zu dieser Mannschaft geh&ouml;rt."
		},
		TeamsPerson: {
			person_id:"W&auml;hlen Sie die Person die eine Rolle im Team &uuml;bernimmt.",
			type:"W&auml;hlen Sie die Rolle im Team.",
			subtype:"W&auml;hlen Sie eine Subrolle dieser Person. Bis jetzt sind diese auf Positionen von Spielern begrenzt.",
			info:"Bis jetzt noch nicht benutzt. Bitte la&szlig;en Sie dieses Feld frei."
		},
		League: {
			alias:"Geben Sie einen Namen der Liga an. z.B.: 'Bezirksoberliga Niederbayern'",
			shortalias:"Geben Sie einen k&uuml;rzeren Namen der Liga ein. Diese Abk&uuml;rzung wird zum Beispiel im Menu benutzt.",
			tableonstartpage:"Wenn ein H&auml;ckchen gesetzt ist dann wird die Tabelle der Liga auf der Startseite angezeigt.",
			bfvid:"Geben Sie die BFV id von dieser Liga an. Das mu&szlig; nur dann gemacht werden, wenn Sie die Liga automatisch bef&uuml;llen la&szlig;en wollen bzw Ergebni&szlig;e automatisch eintragen la&szlig;en wollen. <b>Wie finden Sie die BFV id heraus:</b> Gehen Sie aud die BFV Seite der gew&uuml;nschten Liga. Beachten Sie nun die Addre&szlig;leiste der Seite. Dort finden Sie einen Teil der ungef&auml;hr so au&szlig;ieht: <i>&szlig;e=1&<b>liga_id=3337</b>&filter</i>. In diesem Fall ist die BFV id 3337.",
			bfvseason:"Dieses Feld mu&szlig; nur gesetz werden wenn das Automatische bef&uuml;llen &uuml;ber das BFV archiv gew&uuml;nscht wird. Geben Sie Saison wie folgt an: Ist die Saison &uuml;ber die Jahre 2009/2010 gelegt, geben Sie <b>2009</b> an.",
			archive:"Selektieren Sie diese Box falls der Automatische Bef&uuml;ller die Werte aus dem BFV Archiv holen soll. Stellen Sie sicher, da&szlig; sie die BFV id und die BFV Saison korrekt gesetzt haben.",
			matchday_id:"W&auml;hlen Sie den aktuellen Spieltag."
		},
		Matchday: {
			num:"Geben Sie die Nummer des Spieltags an, unabh&auml;ngig davon ob dieser in der R&uuml;ckrunde oder Hinrunde Platziert ist.",
			'name':"Geben Sie den Namen des Spieltags an: z.B. '1. Spieltag'",
			'round':"Geben Sie den Namen der Runde an in dem Sich dieser Spieltag befindet. z.B. 'Hinrunde' or 'R&uuml;ckrunde'"
		},
		Match: {
			home_club:"W&auml;hlen Sie den Heimverein aus. Falls ihr gew&uuml;nschter Verein nicht vorhanden ist, f&uuml;gen Sie diesen Verein zu dieser Liga hinzu.",
			guest_club:"W&auml;hlen Sie den Gastverein aus. Falls ihr gew&uuml;nschter Verein nicht vorhanden ist, f&uuml;gen Sie diesen Verein zu dieser Liga hinzu.",
			home_goal:"Geben Sie die Tore des Heimvereins ein.",
			guest_goal:"Geben Sie die Tore des Gastvereins ein.",
			location:"Geben Sie den Ort der Begegnung an"
		},
		Survey: {
			question:"Geben Sie die Frage dieser Umfrage ein. Nachdem Sie Umfrage erstellt haben k&ouml;nnen Sie Antworten hinzuf&uuml;gen.",
			active:"Mu&szlig; gesetzt werden solange User die M&ouml;glichkeit haben sollen abzustimmen."
		},
		Answer: {
			answer:"Geben Sie die Antwort ein die dieser Umfrage hinzugef&uuml;gt werden soll."
		}
	},
	'en-US': {
		Season : {
			alias:"Fill in a short description like '2010/11'",
			longalias:"Add a long description for the season. E.g. fill in 'Bezirksoberliga Season 2010/11'"
		},
		Club: {
			alias:"Fill in an alias for the club. This is actually the most displayed alias",
			shortalias:"Fill in a short alias for the club. If you youse BFV for automagick league fill, please fill in here the name like it is shown on BFV whereas additional chars like 'II' have to be omitted",
			file:"Select a logo for this club."
		},
		Comment: {
			title:"The title of this comment."
		},
		Page: {
			title:"Type in a title for the page."
		},
		Betpool: {
			league_id: "Select a league for which you want create a betting pool.",
			betmatches:"Add some integer that describes the amount of matches that can be tipped parallel",
			active: "Check this box if you want that users should be able to tip in this betting pool"
		},
		Person: {
			'name': "The name of the person. Please fill in the first and last name"
		},
		Attachment: {
			alternative:"Type in a textual description of the file. Hold this information as short as po&szlig;ible.",
			file:"Select a file that you want attach. The file can be one out of the following types: jpeg, png, tiff, gif and pdf",
			'delete': "Check this, and submit the form, if you want that this photo should be deleted."
		},
		Event: {
			title:"Insert a short descriptive title of the event"
		},
		Album: {
			title:"Type in the title of this photo album"
		},
		Photo: {
			file: "Select the photo that you want to upload",
			alternative:"Type in a textual description of the photo. Hold this information as short as po&szlig;ible.",
			'delete': "Check this, and submit the form, if you want that this photo should be deleted."
		},
		ClubsPerson: {
			'person_id':"Select the person that has an official role in the club. People added first are listed at first.",
			'season_id':"Select the season in which the person holds this role.",
			'type':"Enter some role which this person should have. This can be e.g. Senior Exececutive Officer or Webmaster. People added first are listed at first.",
			'info':"This field is not mandatory but it is recommended to fill in some information about the role. For example add the addre&szlig; of the selected person"
		},
		Team: {
			'alias':"Add an alias for the team. E.g. '1. Senior Team' or 'JuniorTeam A'",
			'matchpreview':"If this box is checked the next match of this team is shown on the home page of the system. After checking this box please have a look at the home page.",
			'club_id':"Select the club in which this team is positioned."
		},
		TeamsPerson: {
			person_id:"Select the person that should play a role in the team",
			type:"Select the role of the person",
			subtype:"Select a sub role of the person. This is till now restricted to positions where players can play.",
			info:"Currently not used. Left this blank"
		},
		League: {
			alias:"Type in an alias for this season. E.g. 'Bezirksoberliga Niederbayern'",
			shortalias:"Type in an abbreviation for league. This abbreviation is used e.g. in the menu and at any places where space is bare",
			tableonstartpage:"If this box is checked the table of this league is shown on the home page of the system.",
			bfvid:"Insert the BFV id of the league. This has only be done if you use the automagick wizard to fill the league or update results. <b>How to find out the BFV id:</b> Go to the BFV page of the desired league. Look at the url of the page. There you find a part that is something like that: <i>&szlig;e=1&<b>liga_id=3337</b>&filter</i>. In this case the BFV id would be 3337.",
			bfvseason:"This field is only needed if you use the archive version of the wizard. E.g. if you want to automagickally create leagues insert the corresponding season in here. For a season spanning the years 2009/2010 insert <b>2009</b>.",
			archive:"Check this field if the automagick wizard should fill in values from the BFV archive. Be sure that the BFV id and BFV season is set corretly",
			matchday_id:"Select the current matchday"
		},
		Matchday: {
			num:"Enter the number of the matchday irrespective to the round in which this matchday resides in.",
			'name':"Enter the name of the matchday e.g. '1. Matchday'",
			round:"Enter the name of the round. E.g. 'First half' or 'Second half'"
		},
		Match: {
			home_club:"Select the club that is the home team. If you are mi&szlig;ing a club, please add the corresponding club to the league.",
			guest_club:"Select the club that is the guest team. If you are mi&szlig;ing a club, please add the corresponding club to the league.",
			home_goal:"Insert the amount of goals that the home team scored",
			guest_goal:"Insert the amount of goals that the guest team scored",
			location:"Add the location where the match takes place"
		},
		Survey: {
			question:"Enter the question for this survey. After you submitted the form you can add answers to the survey.",
			active:"Whether users can vote or not."
		},
		Answer: {
			answer:"Enter the answer that should be added to the survey"
		}
	}
};

var AjaxLinks = {
	scan: function() {
		$$("a[rel|=ajax]").each(function(link) {
			link.removeEvents('click');
			link.addEvent('click', function(event) {
				info = link.get('rel').split("-");
				if(info.length > 1) {
					new Request.HTML({'update':info[1], 'onSucce&szlig;':AjaxLinks.scan}).get(link.href);
				}
				return false;
			});
		});
	}
};

window.addEvent('domready', function() {
	$$("input, select, textarea").each(function(el) {
		name = el.get('name');
		if(name != null && name.test(/\[.*\]/)) {
			arr = name.match(/\[([^\]]*)\]/g);
			
			var path = infos['de-DE'];
			arr.each(function(m) {
				if(path != null) {
					key = m.replace("[","").replace("]","");
					if(path[key] != null) path = path[key];
                }
            });
            
            if(path != null && $type(path) == "string") {
            	el.store('tip:title', 'Tip');
				el.store('tip:text', path);
				new Tips(el);
            }
		}
	});
	
	
	/*
	 * Home slideshow
	 */
	/*
	var navs = $('slideshow').getElements('.slidename');

	// create a basic slideshow
	navSlideShow = new SlideShow('slideshow', {
		onShow: function(data){
			// update navigation elements' class depending upon the current slide
			navs[data.previous.index].removeClass('current');
			navs[data.next.index].addClass('current');
		}
	});

	navs.each(function(item, index){
		// click a nav item ...
		item.addEvent('click', function(event){
			event.stop();
			// pushLeft or pushRight, depending upon where
			// the slideshow already is, and where it's going
			var transition = (navSlideShow.index < index) ? 'pushLeft' : 'pushRight';
			// call show method, index of the navigation element matches the slide index
			// on-the-fly transition option
			navSlideShow.show(index, {transition: transition});
		});
	});

	// tips, for pretty
	new Tips(navs, {
		fixed: true,
		text: '',
		offset: {
			x: -100,
			y: 20
		}
	});
	*/
	
	var homeSlideshow = $("slideshow");
	if(homeSlideshow != null) {
		ss = new SlideShow(homeSlideshow);
		ss.play();
		
		$("slideshow").getElements("div").each(function(slide, i) {
			el = slide.getElement('.slidename');
			if(el != null) {
				link = new Element("a", {'text': el.get('text')});
				link.addEvent('click', function() {
					ss.show(i);
				});
				$("slideshownav").adopt(link);
			}
		});
	}
	
	AjaxLinks.scan();
});

