$(document).ready(function(){

	$('input.fehler, select.fehler').focus(function(){
		$(this).removeClass('fehler');
	})
	
	$.datepicker.setDefaults({duration: 'fast'});

	$.ajaxSetup({cache: false});

	
	$('.helpsuggest').each(function()
	{
		if($(this).val() == '')
		{
			$(this).val(this.title);
		}
	});
	
	$('.helpsuggest').focus(function()
	{
		if($(this).val() == this.title)
		{
			$(this).val('');
		}
	})

	$('.helpsuggest').blur(function()
	{
		if($(this).val() == '')
		{
			$(this).val(this.title);
		}
	})
	
	$('.togglebox').live('click', function()
	{
		/*
			BugFix für IE8
			toggle() funktioniert nicht auf Tabellen in jQuery 1.3.2
			sonst:
			$(this).closest('tr').children('td.toggle').toggle();
		*/
		$(this).closest('tr').children('td.toggle').each(function(){
			
			if($(this).css('display') == 'none')
			{
				$(this).show();
			}
			else
			{
				$(this).hide();
			}
			
		});
	});
	
	if ($.browser.msie)
	{	
		
	    $("select.iefix").mousedown(function(){
	    	
	    	$(this).css({
	    		'min-width':'212px',
				'width':'auto',
				'position':'absolute'
	    	});
	    	/*
	    	if($(this).width() < 220)
	    	{
				$(this).width(220);
	    	}
	    	*/
	    });
	    
	    $("select.iefix").change(function(){
	    	$(this).css({
				'width':'220px',
				'position':'relative'
	    	});
	    });
	    
	    $("select.iefix").blur(function(){
	    	$(this).css({
				'width':'220px',
				'position':'relative'
	    	});
	    });
	    	    
	}
});

var Helper = {};

Helper.matchId = function(text) {
	return parseInt(text.match(/\d+$/)[0]);
};

var LibValidate = {};

LibValidate.allowInt = function () {
	while(!($(this).val().match(/^\d+$/)) && ($(this).val() != ""))
	{
		$(this).val($(this).val().substr(0, $(this).val().length -1));
	}
};

LibValidate.allowDouble = function () {
	while(!($(this).val().match(/^\d+([\.|,]{0,1}\d*){0,1}$/)) && ($(this).val() != ""))
	{
		$(this).val($(this).val().substr(0, $(this).val().length -1));
	}
};

LibValidate.allowNegativeDouble = function () {
	while(!($(this).val().match(/^-?\d*([\.|,]{0,1}\d*){0,1}$/)) && ($(this).val() != ""))
	{
		$(this).val($(this).val().substr(0, $(this).val().length -1));
	}
};