/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

// EZPZ Hint v1.1.1; Copyright (c) 2009 Mike Enriquez, http://theezpzway.com; Released under the MIT License
// adaption for textareas by Volkmar Kantor
// --> grab the input's title attribute
(function($){
	$.fn.ezpz_hint = function(options){
		var defaults = {
			hintClass: 'ezpz-hint',
			hintName: 'ezpz_hint_dummy_input'
		};
		var settings = $.extend(defaults, options);

		return this.each(function(){
			var hint;
			var dummy_input;
            var b_textarea = false;

			// grab the input's title attribute
			text = $(this).attr('title');

			// create a dummy input and place it before the input
            if(! $(this).is('textarea')) {
                hint = $('<input type="text" name="temp" value="" />');
            } else {
                hint = $('<textarea name="temp" value="" />');
                b_textarea = true;
            }
			hint.insertBefore($(this));


			// set the dummy input's attributes
			hint.attr('class', $(this).attr('class'));
			hint.attr('size', $(this).attr('size'));
			hint.attr('name', settings.hintName);
			hint.attr('autocomplete', 'off');
			hint.attr('tabIndex', $(this).attr('tabIndex'));
			hint.addClass(settings.hintClass);
            if(!b_textarea) {
                hint.val(text);
            } else {
                hint.text(text);
                hint.attr('cols',$(this).attr('cols'));
                hint.attr('rows',$(this).attr('rows'));
            }


			// hide the input
			$(this).hide();

			// don't allow autocomplete (sorry, no remember password)
			$(this).attr('autocomplete', 'off');

			// bind focus event on the dummy input to swap with the real input
			hint.focus(function(){
				dummy_input = $(this);
				$(this).next().show();
				$(this).next().focus();
				$(this).next().unbind('blur').blur(function(){
					if ($(this).val() == '') {
						$(this).hide();
						dummy_input.show();
					}
				});
				$(this).hide();
			});

			// swap if there is a default value
			if ($(this).val() != ''){
				hint.focus();
			};

			// remove the dummy inputs so that they don't get submitted
			$('form').submit(function(){
				$('.' + settings.hintName).remove();
			});
		});

	};
})(jQuery);


/****************************************/


jQuery(document).ready(function() {

	//use the inputs title-parameter to overlabel the search-form
	var ezpz_options = {hintClass:'overlabel'};
	var input_css_options = {'width':'140px','border':'none'};
	var formular = jQuery('#searchform');
	formular.find('#searchterm')
		.attr(
			'title', 
			formular.find('label').hide().html()
		)
		.ezpz_hint(ezpz_options)
		.css(input_css_options);
	formular.find('.overlabel').css(input_css_options);
	//*/

	//--> slideshow
	jQuery('#slideshow')
        .cycle({
			fx:		'fade',
			speed:	800,
			timeout:7000,
			pause:	1,
    		pager: '#slideshowNav .content',
			cleartypeNoBg: true
		});
	
	//copy and relocate the header-navigation
	jQuery('#Seitenende .meta').clone().appendTo(jQuery('#header'));
});
