// JavaScript Document
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;
			}
		}
	}
}


$(document).ready(function(){
	correctPNG();
	FlashMenu();
	$(window).resize(function(){FlashMenu();});
	
	function FlashMenu(){
		var WindowWidth=$(window).width();
		var WindowHeight=$(window).height();
		var DocumentWidth=$('.mainbar').width();
		var DocumentHeight=$('.mainbar').height();
		if(WindowWidth>DocumentWidth){
			var FlashWidth=$("#flash_factory").width();
			var FlashHeight=$("#flash_factory").height();
			var left=parseInt(WindowWidth/2);
				left=left + parseInt(DocumentWidth/2);
				left=left - parseInt(FlashWidth);
				left=left+"px";
			var top=WindowHeight-FlashHeight;
				top=parseInt(top/2);
				top=top+"px";
			$("#flash_factory").floatdiv({left:left,top:top});
		}else{
			$("#flash_factory").floatdiv("rightmiddle");
		}
	}
});
//window.attachEvent("onresize", correctPNG);
