var oEMailRegexp  = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;

$(document).ready(function() {
	// check for ie6 and apply transparent png patch
	if (document.all && !window.opera && !window.XMLHttpRequest && $.browser.msie) {
		DD_belatedPNG.fix('#content_container, #footer');
	}
	
	var sUserAgent = navigator.userAgent;
	var bIsIE      = sUserAgent.indexOf('MSIE') > -1;
	var fIE        = bIsIE ? parseFloat(sUserAgent.substring(sUserAgent.indexOf('MSIE') + 5, sUserAgent.indexOf(';', sUserAgent.indexOf('MSIE'))), 10) : -1;
	
//	alert(navigator.userAgent);
	if (bIsIE) {
//		if (fIE < 8) {
			$('.weiterButton').css('paddingTop', (parseInt($('.weiterButton').css('paddingTop'), 10) + 1) + 'px');
			$('input[type="text"]').each(function() { 
				$(this).width($(this).width() - 2); 
				$(this).css({
					'marginTop'    : '-1px',
					'marginBottom' : '-1px'
				});
			});
			$('textarea').each(function() { 
				$(this).width($(this).width()   - 1); 
				$(this).height($(this).height() - 2); 
				$(this).css({
					'marginTop'    : '-1px',
					'marginBottom' : '-1px'
				});
			});
//		}
	}
	else if (window.opera) {
		$('.weiterButton').css({
			'paddingTop' : (parseInt($('.weiterButton').css('paddingTop'), 10) + 12) + 'px'
		});
		$('.zurueckButton').css({
			'paddingTop' : (parseInt($('.zurueckButton').css('paddingTop'), 10) + 4) + 'px'
		});
		$('input[type="text"]').each(function() { 
			$(this).width($(this).width() - 2); 
		});
		$('textarea').each(function() { 
			$(this).width($(this).width()   - 2); 
			$(this).height($(this).height() - 2); 
		});
	}
	else if (navigator.userAgent.indexOf('Firefox') > -1) {
		$('select').height($('select').height() + 3);
		$('input[type="text"]').each(function() {
			$(this).height($(this).height() - 1); 
		});
		$('textarea').each(function() { 
			$(this).height($(this).height() - 7); 
		});
	}
	else if (navigator.userAgent.indexOf('Chrome') > -1) {
		$('input[type="text"]').each(function() {
			$(this).height($(this).height() - 2); 
			$(this).css({
				'marginTop'    : (parseInt($(this).css('marginTop'   ), 10) + 2) + 'px',
				'marginBottom' : (parseInt($(this).css('marginBottom'), 10) + 2) + 'px'
			});
		});
		$('textarea').each(function() { 
			$(this).width($(this).width() - 2); 
			$(this).height($(this).height() - 1); 
		});
	}
	else if (navigator.userAgent.indexOf('Safari') > -1) {
		$('input[type="text"]').each(function() {
			$(this).height($(this).height() - 2); 
			$(this).css({
				'marginTop'    : (parseInt($(this).css('marginTop'   ), 10) + 2) + 'px',
				'marginBottom' : (parseInt($(this).css('marginBottom'), 10) + 2) + 'px'
			});
		});
		$('textarea').each(function() { 
			$(this).width($(this).width()   + 2); 
			$(this).height($(this).height() + 3); 
		});
	}
	
	$(":input:not(button)").keypress(function(e) {  
         if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {  
             $('button.weiterButton').click();  
             return false;  
         } else {  
             return true;  
         }  
     }); 
});

function preselectDropdown(name, value) {
	$("#"+name+" option[value="+value+"]").attr("selected",true);
}