// Copyright 2007 JP7

function png_check(){
	var tagsArray=new Array('BODY','DIV','IMG','TABLE','TR','TD','INPUT')
	for(var i=0;i<tagsArray.length;i++){
		var tags=document.getElementsByTagName(tagsArray[i])
		for(var j=0;j<tags.length;j++){
			png_fix(tags[j])
		}
	}
}

function png_filter(obj,s,m){
	var f='DXImageTransform.Microsoft.AlphaImageLoader'
	if(obj.filters[f]){
		obj.filters[f].enabled=(s)?true:false
		if(s){
			with(obj.filters[f]){
				src=s
				sizingMethod=m
			}
		}
	}else if(s)obj.style.filter='progid:'+f+'(src="'+s+'",sizingMethod="'+m+'")'
	obj.currentPNG=s
}

function png_fix(obj){
	// Check Browser
	if (!is.ie||is.v>=7)return
	// Check Current PNG
	var bgImg=obj.currentStyle.backgroundImage
	if(bgImg.indexOf(obj.currentPNG)!=-1)return
	// DO
	var blankImg='/_default/img/px.gif'
	if(bgImg&&bgImg!='none'){
		if(bgImg.match(/^url[("']+(.*\.png)[)"']+$/i)){
			var s=RegExp.$1;
			if(obj.currentStyle.width=='auto'&&obj.currentStyle.height=='auto')obj.style.width=obj.offsetWidth+'px'
			obj.style.backgroundPosition='10000px 10000px'
			png_filter(obj,s,'crop');
			//png_filter(obj,s,'scale');
			// IE link fix.
			for(var n=0;n<obj.childNodes.length;n++){
				if(obj.childNodes[n].style)obj.childNodes[n].style.position='relative'
			}
  	}else png_filter(obj);
	}else if(obj.tagName=='IMG'){
		if((/\.png$/i).test(obj.src)){
			if(obj.currentStyle.width=='auto')obj.style.width=obj.offsetWidth+'px'
			if(obj.currentStyle.height=='auto')obj.style.height=obj.offsetHeight+'px'
			png_filter(obj,obj.src,'scale');
			obj.src=blankImg;
		}else if(obj.src.indexOf(blankImg)<0)png_filter(obj);
	}
}
