$(document).ready(tpl_size_background);
$(window).load(tpl_size_background);
$(window).bind('resize',tpl_size_background);
$(document).bind('resize',tpl_size_background);
function tpl_size_background()
{
	var doc = parseInt( $(document).height( ) );
	var win = parseInt( $(window).height( ) );
	var height = ( win > doc ) ? win : doc;
	$('div.tpl_background').height( height );
	if( $.browser.msie && parseInt( $.browser.version ) == 6 )
	{
		var doc = parseInt( $(document).width( ) );
		var win = parseInt( $(window).width( ) );
		var width = ( win > doc ) ? win : doc;
		var correction = ( width - 1000 > 0 ) ? (width - 1000) / 2 : 0;
		$('div.tpl_banner').css({left:'-'+(510-correction)+'px',width:(width+510)+'px'});
		$('div.tpl_banner').bind('click',function(){alert(width);});
	}
}

var replacePNG = function(){
	var thiswidth = $(this).width();
	var thisheight = $(this).height();	
	if( !$(this).is(':visible') )
	{
		if( $(this).attr('height') )
		{
			thisheight = parseInt( $(this).attr('height') );
		}
		else if( $(this).css('height') )
		{
			thisheight = parseInt( $(this).css('height') );
		}
		if( $(this).attr('width') )
		{
			thiswidth = parseInt( $(this).attr('width') );
		}
		else if( $(this).css('width') )
		{
			thiswidth = parseInt( $(this).css('width') );
		}
		if( !( thisheight > 0 && thiswidth > 0 ) )
		{
			return;
		}
	}
    var fixedPNG = $('<span></span>').css({display: 'inline-block',width: thiswidth,height: thisheight,filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+$(this).attr('src')+"',sizingMethod='scale');"});
    $(this).replaceWith( fixedPNG );
}

$(document).ready(function(){
	if( $.browser.msie && parseInt( $.browser.version ) == 6 )
	{
		$('img[src$="\.png"]').each(function(){
			$(this).bind('load',replacePNG);
			if( this.complete ){
				$(this).trigger("load");
			}
		});
    }
}); 
