/*-----------------------------------------
 
 copyright 2009 by mmc
 
 Version: 1.0
 
 Author: Georg Paul
 
 Author URI: http://www.mmc-agentur.at
 
 -------------------------------------------*/



$(document).ready(function(){
	
	
	// init Innerfade-Plugin
	if ($('#header_teaser ul li').length > 1) {
		
		$('#header_teaser ul').innerfade(
		{
			animationtype: 'fade',
			speed: 1000,
			timeout: 5000,
			type: 'sequence'
		});
		
	}

	appendProgressBar();
	
//	$('#main_nav').children().each(function() {
//		$(this).bind('mouseenter', function() {
//			var childUL = $(this).children('ul');
//			childUL.css('width',parseInt($(this).width())+76+'px');
//		});
//	});
	
	
	$('#local #user,#local #pass').mmcFormDefaults();
	
	

});



function appendProgressBar(){
	if ($('body').hasClass('layout_1')) {
		$('#header_teaser').append('<div id="progress_bar"><span></span></div>');
		var progressPixelWidth = 23;
		var teaserCount = $('#header_teaser ul li').length;

	
		var progressBarWidth = (progressPixelWidth * teaserCount) + 'px';
		$('#progress_bar').css('width', progressBarWidth);
	}
}

function refreshProgressBar(activeTeaser){
	
	var teaserCount = $('#header_teaser ul li').length;
	
	var teaserPosition = $(activeTeaser).prevAll('li').length;
	if (teaserPosition == 0) teaserPosition =  teaserCount;
	
	var bgPositionOffset = -21 * teaserPosition;
	$('#progress_bar span').css('background-position', '0 ' + bgPositionOffset + 'px')
	
	
}
function fadeOutCallback(){
	//$('.header_teaser_content p').hide();
	
}


(function($) {
	$.fn.mmcFormDefaults = function() {
		this.each(function() {
			$(this).val($(this).attr('title'));
			
			$(this).bind('focus', function() {
				if ($(this).val() == $(this).attr('title')) {
					$(this).val('');
				}	
			});
			
			$(this).bind('blur', function() {
				if ($(this).val() == '') {
					$(this).val($(this).attr('title'));
				}
			});
		});
		
		return this;
	};
	})(jQuery);
