String.prototype.trim = function(){return this.replace(/(^[ |　]*)|([ |　]*$)/g, "");}
function $(s){return document.getElementById(s);}
function $name(s){return document.getElementByName(s);}
function $$(s){return document.frames?document.frames[s]:$(s).contentWindow;}
function $f(s){return document.forms?document.forms[s]:$(s).contentWindow;}
function $c(s){return document.createElement(s);}
function $n(name){return document.getElementsByTagName(name || "*");}
function dw(s){document.write(s);}
function hide(s){$(s).style.display=$(s).style.display=="none"?"":"none";}
function isNull(_sVal){return (_sVal == "" || _sVal == null || _sVal == "undefined");}
function removeNode(s){if(exist(s)){$(s).innerHTML = '';$(s).removeNode?$(s).removeNode():$(s).parentNode.removeChild($(s));}}
function newopen(_sUrl){window.open(_sUrl, "_blank");}
function wopen(_sUrl){location.href=_sUrl;}
function MM_openBrWindow(theURL,winName,wd,wh,wl,wt) {
	var Twd=800;
	var Twh=600;
	var Twl=0;
	var Twt=0;
	if(!wd){wd=Twd;}
	if(!wh){wh=Twh;}
	if(!wl){ww=Twl;}
	if(!wt){ww=Twt;}
  window.open(theURL,winName,'toolbar=no,location=no,menubar=no,scrollbars=yes,resizable=yes,width='+wd+',height='+wh+',left='+wl+',top='+wt+'');
}
function setAddHome() { 
	title = "Webpage Title"; 
	url = "Webpage URL";  
 	if (window.sidebar){ // Mozilla Firefox Bookmark		
 		window.sidebar.addPanel(window.document.title, window.document.location.href,"");	
 	}else if( window.external ){ // IE Favorite
 		window.external.AddFavorite(window.document.location.href,window.document.title);
	}else{alert('Browser does not support the ...');}
}
function setHome(homeurl){document.body.style.behavior='url(#default#homepage)';document.body.setHomePage(homeurl); return false;}
window.oDel=function(obj){if($(obj)!=null){$(obj).parentNode.removeChild($(obj))}}
function hideList(_sId,_sStr,_iBegin,_iEnd,_sShow){for(var i = _iBegin; i <= _iEnd; i++)if(exist(_sId + i)){$(_sId + i).style.display = _sStr;_sStr == 'none' ? $(_sShow + i).className = 'down' : $(_sShow + i).className = 'up'}}
function IsWinDel(Surl,Stxt)
{
	if(!Stxt){var Stxt="Are you sure you want to delete ?";}
	if (confirm(Stxt)){location.href=Surl;}else{location.href="javascript:void(0);";}
}
function fucCheckNUM(num_str){
	var patn = /^\d+(\.\d+)?$/;
	if(!patn.test(num_str.value))
	{
		num_str.value="";
		return false;
	}
	return true;
}
function fucCheckfloat(num_str){
	var patn = /^[0-9.]{1,100}$/;
	if(!patn.test(num_str.value))
	{
		num_str.value="";
		return false;
	}
	return true;
}
function formatPic(obj,w,t){
var _text = $(obj);
var _imgs = _text.getElementsByTagName("IMG");
var _tabs = _text.getElementsByTagName("TABLE");
	for (i=0;i<_imgs.length;i++){
		if (_imgs[i].scrollWidth > w){
			_imgs[i].width = w;
			_imgs[i].onclick= showThisPic;
			_imgs[i].style.cursor="pointer";
			_imgs[i].alt="Click to enlarge";
		}
	}
	if(t == 2)
	{
		for (i=0;i<_tabs.length;i++){
			if (_tabs[i].width > w){
				_tabs[i].style.width = w+"px";
			}
		}
	}
}
function showThisPic(){window.open(this.src);}
function openWindow(_sUrl, _sWidth, _sHeight, _sTitle, _sScroll){
	var oEdit = new dialog();
	oEdit.init();
	oEdit.set('title', _sTitle ? _sTitle : "System tips" );
	oEdit.set('width', _sWidth);
	oEdit.set('height', _sHeight);
	oEdit.open(_sUrl, _sScroll ? 'no' : 'yes');
	}
function LoadFlash(s_url,s_wmode,s_width,s_Height,s_name,s_id){
	document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"+s_width+"' height='"+s_Height+"' id='"+s_id+"'>");
	document.write("<param name='movie' value='"+s_url+"'>");
	document.write("<param name='quality' value='high'>");
	document.write("<param name=\"menu\" value=\"false\">");
	document.write("<PARAM name=wmode value='"+s_wmode+"'>");	
	document.write("<embed src='"+s_url+"' wmode='"+s_wmode+"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+s_width+"' height='"+s_Height+"' name='"+s_name+"' swLiveConnect='true'></embed>");
	document.write("</object>");
}

function DrawImage(ImgD,w,h){
	var image=new Image();
	image.src=ImgD.src;
	if(image.width>0 && image.height>0){
		flag=true;
		if(image.width/image.height>= w/h){
			if(image.width>w){
				ImgD.width=w;
				ImgD.height=(image.height*w)/image.width;
			}
			else{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
		}
		else{
			if(image.height>h){
				ImgD.height=h;
				ImgD.width=(image.width*h)/image.height;
			}else{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
		}
	}
}
function imgzoom(o) {
	if(event.ctrlKey) {
		var zoom = parseInt(o.style.zoom, 10) || 100;
		zoom -= event.wheelDelta / 12;
		if(zoom > 0) {
			o.style.zoom = zoom + '%';
		}
		return false;
	} else {
		return true;
	}
}
function getcookie(name) {
	var cookie_start = document.cookie.indexOf(name);
	var cookie_end = document.cookie.indexOf(";", cookie_start);
	return cookie_start == -1 ? '' : unescape(document.cookie.substring(cookie_start + name.length + 1, (cookie_end > cookie_start ? cookie_end : document.cookie.length)));
}
