$(document).ready(function(){
	correctPNG();
});

function img_auto_resize(p,w,h){
	var pw,ph;
	var c;
	pw = p.width;
	ph = p.height;
	if(w>0 && pw>w){ph=ph*(w/pw);pw=w;}
	if(h>0 && ph>h){pw=pw*(h/ph);ph=h;}
	p.width=pw;
	p.height=ph;
}

function mhHover(cls){
	event.srcElement.className = cls;
}

function checkNumber(par_val){
	if(par_val==""){
		return false;
	}else{
		for(i=0; i<par_val.length; i++){
			if (par_val.substring(i, i+1)!="."){
				if (par_val.substring(i, i+1)<"0" || par_val.substring(i, i+1)>"9"){
					return false;
				}
			}
		}
		return true;
	}
}

//使用 IE6.0 和 IE5.5 中的 PNG 格式的背景透明
// correctly handle PNG transparency in Win IE 5.5 & 6.0
function correctPNG(){
	var arVersion = navigator.appVersion.split("MSIE");
	var version = parseFloat(arVersion[1]);
	if ((version < 7.0) && (document.body.filters)){
		for(var j=0; j<document.images.length; j++){
			var img = document.images[j];
			var imgName = img.src.toUpperCase();
			if (imgName.substring(imgName.length-3, imgName.length) == "PNG"){
				var imgID = (img.id) ? "id='" + img.id + "' " : "";
				var imgClass = (img.className) ? "class='" + img.className + "' " : "";
				var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
				var imgStyle = "display:inline-block;" + img.style.cssText;
				if (img.align == "left") imgStyle = "float:left;" + imgStyle;
				if (img.align == "right") imgStyle = "float:right;" + imgStyle;
				if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
				var strNewHTML = "<span " + imgID + imgClass + imgTitle + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";
				img.outerHTML = strNewHTML;
				j = j-1;
			}
		}
	}
}

//刷新验证码
function reloadSecurityCode(obj){
	var strlink=$('#'+obj).attr('src');
	strlink+=strlink.indexOf('?')=='-1'?"?":"&";
	strlink+="thistime="+Math.random();
	$('#'+obj).attr("src",strlink);
}

//复制到剪贴板 并且提示
function CopyToClipBoard(content,tip){
	window.clipboardData.setData("Text",content);
	if(tip!='')alert(tip);
}

//跳转到友情链接
function openFriendLink(url){
	if(url!='-1'){
		window.open(url,"_blank");
	}
}
