(function($){
	$.fn.extend({
		hinweisFenster: function() {
			
			var overlay = $("<div id='overlay'></div>");
			var hinweis = $("<div id='hinweis'><a href='#' class='closebutton'></a><div class='header'>Bitte denken Sie daran, ...</div><div class='content'><strong>den Antrag:</strong><ol> <li>vollständig auszufüllen</li> <li>zu unterschreiben</li> <li>und mit einer lesbaren Kopie vom Führerschein/Reisepass oder Personalausweis</li> </ol> <strong>an uns zu schicken:</strong> <div id='postfenster'> American Express Austria Bank GmbH<br /> Kärntner Str. 21-23<br /> 1010 Wien<br /> </div> <a href='assets/gold-fyf-final-0409.pdf' id='antragherunterladen' class='button'></a></div></div>");
			return this.each(function() {

				//Listen for clicks on objects passed to the plugin
				$(this).click(function(e) {
					
					if (typeof document.body.style.maxHeight === "undefined") { //if IE 6
						$("body","html").css({height: "100%", width: "100%"});
					}

					//Append the overlay to the document body
					$("body").append(overlay.click(function() { hinweisClose(); }))
					$('body').append(hinweis);
					$('#antragherunterladen').click(function() {
						hinweisClose();
					})
					$('#hinweis .closebutton').click(function() {
						hinweisClose();
						return false;
					})

					//Set the css and fade in our overlay
					overlay.css("opacity", 0.4);
					overlay.fadeIn(150);
					hinweis.fadeIn(150);

					//Prevent the anchor link from loading
					e.preventDefault();

					//Activate a listener 
					$(document).keydown(handleEscape);		
				});
			});

			//Our function for hiding the modalbox
			function hinweisClose() {

				$(document).unbind("keydown", handleEscape)
				overlay.remove();
				hinweis.remove();
			}

			//Our function that listens for escape key.
			function handleEscape(e) {

				if (e.keyCode == 27) {

					hinweisClose();
				}
			}
		}
	})
	})(jQuery);

	$(function() {
		$('a[rel*=hinweisFenster]').hinweisFenster();
	})
