$(function() {
	//$('#container').wrapAll('<table class="ui-c"><tr class="ui-c"><td class="ui-c"></td></tr></table>');
	$('body').addClass('ui-js-active');
	

	if( jQuery.browser.msie ) {
		
		for( var i = 0 ; i<document.styleSheets.length ; i++ ) {
			scanStyleSheet(document.styleSheets[i]);
		}
		if( jQuery.browser.version == '6.0' ) {
			$("img[src$='.png']").each(function() {
				var img = new Image();
				var div = $("<span></span>").css({
					"display":"inline-block"
					});
				
				div.get(0).style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+$(this).attr("src")+ "',sizingMethod='scale')";
				
				img.onload = function() {
					div.css({
						width : img.width,
						height : img.height
					});
				};
				
				img.src = $(this).attr("src");
				$(this).hide();
				$(this).after(div);
			});
		}
		
	}
});


function scanStyleSheet( sheet, base ) {
	if( base == null ) base = '';
	
	var path = sheet.href.split('/');
	path.pop();
	path = path.join('/');
	
	
	if( base != ''  ) {
		if( path != '' ) {
			path = base+'/'+path;
		} else {
			path = base;
		}
	}
	
	for( var j = 0 ; j<sheet.imports.length ; j++ ) {
		scanStyleSheet(sheet.imports[j],path);
	}
	for( var j = 0 ; j<sheet.rules.length ; j++ ) {
		if( jQuery.browser.version == '6.0' ) {
			var bgImg = new String(sheet.rules[j].style.backgroundImage);
			if(bgImg.indexOf(".png")!=-1) {
				var iebg = bgImg.split('url(')[1].split(')')[0];
				sheet.rules[j].style.backgroundImage = 'none';
				sheet.rules[j].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+path+"/" + iebg + "',sizingMethod='scale')";
			}
		}
		if( sheet.rules[j].style.opacity != null ) {
			//sheet.rules[j].style.filter = "alpha(opacity = "+(sheet.rules[j].style.opacity*100)+")";
		}
	}
}

