/**
 *
 * SVN Infos:
 * Revision				: $Revision: 122 $
 * Date					: $Date: 2011-05-24 20:53:22 +0200 (Tue, 24 May 2011) $
 * Author				: $Author: te $
 * 
 * Copyright			: (C) MTA International.net 2011 | by Zedan and Chrono
 * 
 */
$(document).ready(function() {
	/*
	 * login and logout password encryption.
	 */
	// find username and password
	var inputUsername = $('#UserUsername');
	var inputPassword = $('#UserPassword');
	
	// register focus and change functions for username
	inputUsername.focus(function(){
		$(this).removeClass('defaultValue');
	});
	
	// register focus and change function for password
	inputPassword.focus(function(){
		$(this).removeClass('defaultValue');
	});
	
	// reset stuff on empty value
	$('#login').focusout(function() {
		if(!inputUsername.val()) {
			inputUsername.addClass('defaultValue');
		}
		
		if(!inputPassword.val()) {
			inputPassword.addClass('defaultValue');
		}
	});
	
	// if the browser automatically fills in the values
	if(inputUsername.val()) {
		inputUsername.removeClass('defaultValue');
	}
	if(inputPassword.val()) {
		inputPassword.removeClass('defaultValue');
	}
	
	
	/*
	 * fadeout flash messages on click
	 */
	$('.flash-error, .flash-success, .flash-notice').click(function(){
		$(this).fadeOut();  
		return false;  
	});
	
	/*
	 * datepicker enabled
	 */
	$('.datepicker').datepicker({
		monthNames: ['Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'],
		dateFormat: 'dd.mm.yy'
	});
	
	/*
	 * ajax experience
	 */
	$('.ajax-experience a.ajax-link').click(function() {
		var button = $(this);
		$.ajax({
			url: button.attr('href'),
			success: function(data) {
				button.parent().html(data);
				$('.ajax-experience form').ajaxForm(function() { 
					alert("Thank you for your comment!"); 
				});
			}
		});
		return false;
	});
	
	$('#dialog').dialog({
		autoOpen: false,
		width: 400,
		modal: true,
		buttons: {
			"OK": function() { alert('df') },
			"NOK": function() { alert('hi') }
		}
	});
	
	$('#dialog_link').click(function(e) {
		e.preventDefault();
		$('#dialog').dialog('open');
	});
	
	$('.edit').editable('http://www.example.com/save.php', {
         indicator : 'Saving...',
         tooltip   : 'Click to edit...'
     });
     $('.edit_area').editable('http://www.example.com/save.php', { 
         type      : 'textarea',
         cancel    : 'Cancel',
         submit    : 'OK',
         indicator : '<img src="img/indicator.gif">',
         tooltip   : 'Click to edit...'
     });

});


