// JScript 文件

function trim(txt){
    //txt = /[ 　]*/g.replace(txt,'');
    return txt;
}
function $(obj){
  var reObj;
  if (/^[0-9]$/g.test(obj) == true){
    reObj = document.all[obj];
  }else{
    reObj = document.all(obj);
  }
  return reObj;
}
function GetParent(obj,pid){
    var curObj = obj;
    while (curObj.tagName != "HTML"){
		if(typeof(curObj) != 'object'){
			return null;
		}else{
			if (curObj.tagName == "HTML"){return null;}
			if (curObj.name == pid || curObj.id == pid){return curObj;}
			curObj = curObj.parentNode;
		}
    }
    return null;
}
function GetParentByTagName(obj,pid){
    var curObj = obj.parentNode;
    if(typeof(curObj)!='object'|| typeof(curObj)==null){return null;}
    while (curObj.tagName != "HTML" ){        
		if(typeof(curObj) != 'object'){
			return null;
		}else{
			if (curObj.tagName == "HTML"){return null;}
			if (curObj.tagName == pid){return curObj;}
			curObj = curObj.parentNode;
		}
    }
    return null;
}
var DivTable = new Array();
function IniDivTable(obj){    
    var tab_title;
    var tab_list = new Array();
    var uls = obj.getElementsByTagName("UL");
    var tab_list_index = 0
    if(DivTable.toString().indexOf(obj.sourceIndex+',') < 0){        
        for(var uls_index=0;uls_index<uls.length;uls_index++){            
            if(uls[uls_index].className=='tab_title'){
                tab_title = uls[uls_index];
            }else{
                if(uls[uls_index].className=='tab_list'){
                    uls[uls_index].onmouseover = obj_onmouseover;
                    uls[uls_index].onmouseout = obj_onmouseout;
                    uls[uls_index].style.width = tab_title.style.width;
                    uls[uls_index].style.height = tab_title.style.height;
                    tab_list[tab_list_index] = uls[uls_index];
                    tab_list_index++;                    
                }
            }
            
        }       
       DivTable[DivTable.length] = obj.sourceIndex;
    }
}
var Move_oldClassName;
function obj_onmouseover(){
    Move_oldClassName = this.style.background;
    this.style.background = '#E1E1E1';
}
function obj_onmouseout(){
    this.style.background = Move_oldClassName;
}
function Wopen(url,wtitle,wWH){
    var result = window.showModalDialog(url,wtitle,wWH);
    return result;
}
function sltthis(def){                
    var obj = event.srcElement;
    return addslt(def,obj);
}
function addslt(def,obj){
    var tmpIds = ',' + def;    
    if(obj.tagName == 'INPUT' ){
        tmpIds = tmpIds.replace(','+obj.value,"");
        if (obj.checked){tmpIds += ','+ obj.value;}
        tmpIds = tmpIds.replace(",,","");        
    }    
    return tmpIds;
}
function QQ(q){
	document.write("<a href=\"javascript:;\" onclick=\"window.open('http://wpa.qq.com/msgrd?V=1&Uin="+q+"&Site=www.szzfpc.cn&Menu=yes','QQ','');\"><img border=\"0\" SRC=http://wpa.qq.com/pa?p=1:"+q+":4 alt=\""+q+"\"></a>");
	//<a target=blank href=http://wpa.qq.com/msgrd?V=1&Uin=850261713&Site=www.szzfpc.cn&Menu=yes><img border="0" SRC=http://wpa.qq.com/pa?p=1:850261713:4 alt="给寂寞的海洋发信息" align="absmiddle" /></a> 
}

/// 删除非汉字字符
function DelNotHanZi(value){
	return value.replace(/[^\u4e00-\u9fa5]+/g,'');
}
/// 选择日期时间
function selectdate(){	
	var result = window.showModalDialog('/inc/wannianli.asp','select','scrollbar=no;dialogWidth=610px;dialogHeight=480px');
	if (typeof result != 'undefined')
	{
		result = result.split('$$$')
		if(arguments.length > 0){selectdate_arguments(arguments[0],result[0]);}
		if(arguments.length > 1){selectdate_arguments(arguments[1],result[1]);}
		if(arguments.length > 2){selectdate_arguments(arguments[2],result[2]);}
		if(arguments.length > 3){selectdate_arguments(arguments[3],result[3]);}
		return result[0];
	}
	return result;
}
function selectdate_arguments(obj,val){
	if (typeof obj != 'object'){obj=$(obj);}
	if (typeof obj == 'object'){
		if (obj != null){
			if (typeof obj.value != 'undefined'){obj.value=val;}
			//if (typeof obj.innerText != 'undefined'){obj.innerText=val;}
			//if (typeof obj.innerHTML != 'undefined'){obj.innerHTML=val;}
		}
	}
}
/// 自动宿放限制图片大小
function LimitSize(){
	var himgShow = document.getElementById( "himgShow");
	var zoom = 100;
	var obj = $("himgShowPic");
	obj.style.zoom=zoom+'%';
	while(himgShow.scrollWidth > 805 ){
		obj.style.zoom=zoom+'%';
		zoom -= 0.1;
	}
	while(himgShow.scrollHeight > 339 ){
		obj.style.zoom=zoom+'%';
		zoom -= 0.1;
	}
	isReset = false;
}
/// 自动宿放限制图片大小
function ImageSizeLimit(obj,pWidth,pHeight){
	var zoom = 100;
	obj.style.zoom=zoom+'%';
	var iWidth = obj.width;
	var iHeight = obj.height;
	if(pWidth > 0){                
		while(iWidth > pWidth ){
			iWidth = (obj.width / 100) * zoom;
			iHeight = (obj.height / 100) * zoom;
			obj.style.zoom=zoom+'%';
			zoom --;
			if(zoom < 1){obj.style.zoom='1%';return false;}
		}
	}
	if(pHeight > 0){                
		while(iHeight > pHeight ){
			iHeight = (obj.height / 100) * zoom;
			obj.style.zoom=zoom+'%';
			zoom --;
			if(zoom < 1){obj.style.zoom='1%';return false;}
		}
	}

}

// 图片不存在 默认图片
	var img_onerror_index=0;
	function img_onerror(){
		var obj = event.srcElement;
		if (obj.tagName=='IMG' && img_onerror_index != obj.sourceIndex)
		{			
			img_onerror_index =obj.sourceIndex;
			obj.src = '/Images/nopic.gif';
		}
	}

/// open window by full screeen   全屏最大化打开窗口 
function LaunchFull(url, name, features){
	var str = "left=0,screenX=0,top=0,screenY=0,";
	if (window.screen) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;
		str += ",height=" + ah;
		str += ",innerHeight=" + ah;
		str += ",width=" + aw;
		str += ",innerWidth=" + aw;
		str += ",scrollbars=yes";
		str += ",toolbar=no,menubar=no,resizable=no,location=no, status=no";
	} else {
		str += ",resizable"; // so the user can resize the window manually
	} 
	return window.open(url, name, str + features);
}
// zoom pic on roll mouse middle button 
function Img_OnMouseWheel_Zoom(o){                
	var zoom=parseInt(o.style.zoom, 10)||100;
	zoom+=event.wheelDelta/50;
	if (zoom>0) o.style.zoom=zoom+'%';
	return false;
}

// 进度条  Progress bar 
function Progress(obj,iAll,iIndex)
{
	var objIndex = obj.sourceIndex;
	var ProgressDiv = 'ProgressDiv_'; //+ objIndex;
	var ProgressSpan = 'ProgressSpan_'; //+ objIndex;
	var iRate = 0;

	if($(ProgressDiv)==null){
		obj.innerHTML += '<div id=\'' + ProgressDiv + '\' class=\'Progress\' style=\'border:1px solid #000;\' ><div id=' + ProgressSpan + '>%</div></div>';
		ProgressDiv = $(ProgressDiv);
		ProgressSpan = $(ProgressSpan);				
		ProgressSpan.style.width='1%';
		ProgressDiv.style.width = '100%';		
		ProgressSpan.innerText = iRate + '%';
	}else{
		iRate = (iIndex / iAll) *100;
		iRate = iRate.toString().split('.')[0] * 1;
		ProgressDiv = obj.all(ProgressDiv);
		ProgressSpan = obj.all(ProgressSpan);
		if(typeof(ProgressDiv)=='object' && typeof(ProgressSpan)=='object' && iRate < 101){
			var ProgressDiv_W = ProgressDiv.style.width;
			iRate = iRate + '%'
			ProgressSpan.style.width = iRate 
			ProgressSpan.innerText = iRate ;
		}				
	}
}
/// 替换字符串
function etReplace(obj,OldWord,NewWord)
{	
	var objs = obj.all;
	var isNext = false;
	for (var i = 0;i < objs.length ; i++)
	{
		if (typeof(objs[i].innerHTML)!='undefind')
		{
			if (objs[i].innerHTML != '' && objs[i].innerHTML == objs[i].innerText)
			{
				var tmpValue =objs[i].innerHTML.replace(OldWord,NewWord);
				objs[i].innerHTML = tmpValue;
				isNext = true;
			}
			if (isNext == true){isNext=false;i++;}
		}
	}
}

/* Et菜单 */
	/*
		调用：

		var Menu = new Et_Menu();
		Menu.id='etMenu'
		Menu.iSTop = 13;
		var MID = Menu.MainMenu('<a href=\'#\'>文件</a>');
		Menu.SubMenu(MID,'<a href=\'#\'>新建</a><br/>');
		var strMenu=Menu.Show(); //生成菜单

		备注：
		Css
		  object.id .MainMenu{主菜单}
		  object.id a{color:#000;padding:2px;}
		  object.id a:link{font-size:12px;}
		  object.id a:hover{font-size:13px;}
		  object.id .subMenu{background-color:#e3e3e3;padding:5px;top:50px;}
		  object.id .subMenu span{margin:2px;}
	*/
	function Et_Menu(){                        
		this.id = '';
		this.eMenu = new Array;
		this.iSTop = 13;
		this.MainMenu = Et_MN_MainMenu;
		this.SubMenu = Et_MN_SubMenu;
		this.Show = Et_MN_Show;
	}
	function Et_MN_Show(){
	   var reValue='<div id=\"' + this.id + '\" >\n';
		for(var i=0;i<this.eMenu.length;i++){
			var MM = 'M' + i;
			reValue += '	<span id=\'MM' + i + '\' class=\'MainMenu\' onMouseOver=\"MM_showHideLayers(\'_'+MM+'\',\'\',\'show\','+this.iSTop+')" onMouseOut=\"MM_showHideLayers(\'_'+MM+'\',\'\',\'hide\','+this.iSTop+')\">' + this.eMenu[i] + '</span>\n'
			if(typeof this.eMenu[MM] != 'undefined'){reValue += Et_MN_list(this.eMenu,MM,'',this.iSTop);}
		}
		reValue += '</div>';
		return reValue;
	}
	function Et_MN_list(eMenu,mm,pid,itop){
		var reValue = '';
		var id = pid + '_' + mm;
		if (typeof eMenu[mm] != 'undefined')
		{
			reValue += '	<div id=\'' + id + '\' onMouseOver=\"MM_showHideLayers(\''+ id +'\',\'\',\'show\','+itop+')" onMouseOut=\"MM_showHideLayers(\''+ id +'\',\'\',\'hide\','+itop+')\" style=\"visibility:hidden;position:absolute;\">\n'
			for (var i=0;i< eMenu[mm].length; i++)
			{
				reValue += '		<span id=\'' + id + i + '\'>' + eMenu[mm][i] + '</span>\n'
				var SM = 'M'+i;
				if(typeof eMenu[mm][SM] != 'undefined'){
					reValue += Et_MN_list(eMenu,SM,id);
				}
			}
			reValue += '	</div>\n'
		}
		return reValue
	}
	function Et_MN_MainMenu(name){var reValue=this.eMenu.length;this.eMenu[reValue] = name;return reValue;}
	function Et_MN_SubMenu(pid,name){
		var reValue='';
		var MM = 'M';
		if(typeof this.eMenu[pid] != 'undefined'){
			MM += pid;							
			if (typeof this.eMenu[MM] == 'undefined'){this.eMenu[MM]=new Array}
			reValue = this.eMenu[MM].length;
			this.eMenu[MM][reValue] = name;							
		}
		return reValue;
	}
	function MM_showHideLayers() { //v9.0
		var i,p,v,obj,iSTop,args=MM_showHideLayers.arguments;
		if (document.getElementById && ((obj=document.getElementById(args[0]))!=null)) {
			v=args[0+2];
			if (obj.style){ 
				if(v=='show'){v='visible';}
				if(v=='hide'){v='hidden';}
			}
			var ent = event.srcElement;
			iSTop = arguments[3];
			if(ent != null && obj.style.pixelTop<1){
				if(typeof iSTop =='undefined'){iSTop=ent.offsetHeight;}
				var tmpobj = ent;
				// 获得元素的左偏移量
				var left = tmpobj.offsetLeft;
				// 获得元素的顶端偏移量
				var top = tmpobj.offsetTop;
				// 循环获得元素的父级控件，累加左和顶端偏移量
				while (tmpobj = tmpobj.offsetParent) {
					left += tmpobj.offsetLeft;
					top += tmpobj.offsetTop;
				}
				top += iSTop;
				obj.style.pixelTop=top;obj.style.pixelLeft=left+4;
			}
			obj.style.visibility=v;
		}
	}
	
/* Et菜单 End */