//Fix error when position:fixed is specified on internet explorer.
$(document).ready(function(){
	window.ie6StyleFix = function(){
		$.each($('*'), function(key, obj){
			//Change all fixed elements. Fixed property doesn't exist jet. Only if fixedPosition hasn't been manually introduced in the object.
			if ('fixed' == $(obj).css('position') && true != $(obj).attr('fixedPosition')){
				$(obj).css('position','absolute');
				var t = parseInt($(obj).css('top'));
				$(window).scroll(function(){
					//Desplazar el elemento igual que el scrolling
					var newTop = t + $(window).scrollTop();
					//Establecer la posición con respecto al tope
					$(obj).css('top', newTop + 'px');
				});
			};
			//Css doesn't let the user apply properties using input[type=checkbox] syntax
			if ('radio' == $(obj).attr('type') || 'checkbox' == $(obj).attr('type')){
				//These widths and heights cannot be changes, only the space that they occupy
				$(obj).css('width','13px');
				$(obj).css('height','13px');
			};
			//input[type=button] doesn't work
			if ('button' == $(obj).attr('type')){
				if ('' == $(obj).css('font-size')){
					$(obj).css('font-size', $(obj).css('font-size'));
				};
				if ('' == $(obj).css('width')){
					$(obj).css('width',$(obj).css('width'));
				};
			};
			//min-width property doesn't exist in IE6
			var minWidth = parseInt($(obj).css('min-width'));
			if (minWidth && minWidth > parseInt($(obj).width())){
				$(obj).css('width', minWidth + 'px');
			};
			//min-height property doesn't exist in IE6
			var minHeight = parseInt($(obj).css('min-height'));
			if (minHeight && minHeight > parseInt($(obj).height())){
				$(obj).css('height', minHeight + 'px');
			};
			//max-width property doesn't exist in IE6
			var maxWidth = parseInt($(obj).css('max-width'));
			if (maxWidth && maxWidth < parseInt($(obj).width())){
				$(obj).css('width', maxWidth + 'px');
			};
			//max-height property doesn't exist in IE6
			var maxHeight = parseInt($(obj).css('max-height'));
			if (maxHeight && maxHeight < parseInt($(obj).height())){
				$(obj).css('height', maxHeight + 'px');
			};
		});
	};
	fixedPosition = function(obj, minTop, minNewTop){
		//Averiguar el tope
		var vScrollTop = document.documentElement.scrollTop; // body for Safari
		var currentTop = minTop - vScrollTop;
		//Se compara el scrolling actual con la posición mínima respecto al tope para usar position:fixed
		if (currentTop < minNewTop){
			var newTop = vScrollTop + minNewTop;
		}else{
			var newTop = minTop;
		};
		//Establecer la posición con respecto al tope
		if (parseInt(obj.style.top) != newTop){
			obj.style.top = newTop + 'px';
		};
	};
	ie6StyleFix();
});
