var Input_monitor={
	onBlur:function(e2){
		var e=$(e2);
		if(e.value==''){
			e.value=e.title;
			e.addClassName('input_init');
		}
	},
	onFocus:function(e2){
		var e=$(e2);
		if(e.hasClassName('input_init')&&e.value==e.title){
			e.value='';
			e.removeClassName('input_init');
		}
	},
	onClick:function(e2){
		var e=$(e2);		
		if(e.value==''||e.value==e.title || e.value.replace(/[ ]/g,"") == ""){
			window.alert(res["input_key"]);
			return false;
		}
		var str=e.value;
		var SPECIAL_STR="`~!@%^&*;'\"?><[]{}<>※……％$￥＃#◎×^÷'‘’『』【】'＋～！》《。:=+“”‘";
		for(i=0;i<str.length;i++)
			if(SPECIAL_STR.indexOf(str.charAt(i))!=-1){
				window.alert(res["search_no_special_char"]);
				return false;
			}
		if(e.value.length >= 255){
			window.alert(res["search_toolong"]);
			return false;
		}
		return true;
	}
}
var TagEvent={
	defaultCurrentClassName:'current',
	add:function(e,event,currentClassName){ // currentClassName || 'current'
		Event.observe(e,event||'click',TagEvent.onEvent);
	},
	onEvent:function(event){
		var e=Event.element(event);
		while(e.tagName.toLowerCase()!='li'&&e.tagName.toLowerCase()!='body'){
			e=e.up();
		}
		if(e.tagName.toLowerCase()=='body'){
			return;
		}
		for( var first=e.up().down();first;first=first.next()){
			first.removeClassName(TagEvent.defaultCurrentClassName);
		}
		e.addClassName(TagEvent.defaultCurrentClassName);
	}
}

var temp=null;
function changebg(obj,color){
	if(temp!==null){
		temp.style.backgroundColor="";
	}
	obj.style.backgroundColor=color;
	temp=obj;
}

var WinHelper={
	resetFrameHeight:function(e){
	var subWeb = document.frames ? document.frames[e.id].document : e.contentDocument;
    if(e != null && subWeb != null)
    { 
            e.style.height="0px";//初始化一下,否则会保留大页面高度
            e.style.height = subWeb.documentElement.scrollHeight+"px"; 
            e.style.width = subWeb.documentElement.scrollWidth+"px"; 
            subWeb.body.style.overflowX="auto";
            subWeb.body.style.overflowY="auto";

}
	},
	getH:function(){
		return document.documentElement.scrollHeight;
	}
	
};

var VerticalMenu={
	init:function(rootid,path){
		var getSpace=function(k){
			var v=[];
			for( var i=0;i<k;i++){
				v.push('&nbsp;');
			}
			return v.join('');
		};
		var insertSpanPrefix=function(p,level){ // 插前缀
			p.innerHTML='<span class="prefix">'+getSpace(3*level-3)+'</span>'+p.innerHTML;
		};
		var f=function(e,level){
			// insertSpanPrefix(e,level);
			e.down('a').innerHTML=getSpace(3*level-3)+e.down('a').innerHTML;
			if(e.down('ul')){
				e.down('a').removeClassName('open');
				// e.down('span.suffix').innerHTML = '+';

				e.down('ul').hide();
				for( var e1=e.down('ul').down('li');e1;e1=e1.next()){
					f(e1,level+1);
				}
			}
		};
		for( var c=$(rootid).down('ul').down('li');c;c=c.next('li')){
			f(c,1);
		}
		$(rootid).down('ul').show();
	},
	// 打开一个，就必须把其它的关闭
	now:null,
	onclick:function(event){
		var e=Event.element(event);
		if(!e.down('ul')&&e.up().tagName.toLowerCase()=='li'){
			e=e.up();
		}
		if(e.down('ul')){
			if(e.down('a').hasClassName('open')){
				e.down('a').removeClassName('open');
				e.down('span.suffix').innerHTML="\<img src=\""+ctx+"/images/rightarrow.jpg\" width=\"20px;\" height=\"20px;\"\/\>";
				e.down('ul').hide();
			}else{
				e.down('a').addClassName('open');
				e.down('span.suffix').innerHTML="\<img src=\""+ctx+"/images/downarrow.jpg\" width=\"20px;\" height=\"20px;\"\/\>";
				e.down('ul').show();
				VerticalMenu.hideBrother(e);
			}

		}else if(e.down('a')){

			if(VerticalMenu.now!=null){
				VerticalMenu.now.removeClassName('current');
			}
			VerticalMenu.now=e;
			e.addClassName('current');
		}

	},
	hideBrother:function(eSelf){
		var e=eSelf.up().down();
		while(e){
			if(e!=eSelf&&e.down('ul')){
				e.down('a').removeClassName('open');
				e.down('span.suffix').innerHTML=="\<img src=\""+ctx+"/images/rightarrow.jpg\" width=\"20px;\" height=\"20px;\"\/\>";
				e.down('ul').hide();
			}
			e=e.next();
		}
	}
}

var TecIndex={
	init:function(rootid,index, intvalue){
		var getSpace=function(k){
			var v=[];
			for( var i=0;i<k;i++){
				v.push('&nbsp;');
			}
			return v.join('');
		};
		var f=function(e,level){
			// insertSpanPrefix(e,level);
			e.down('a').innerHTML=getSpace(3*level-3)+e.down('a').innerHTML;
			if(e.down('ul')){
				e.down('a').removeClassName('open');
				e.down('ul').hide();
				for( var e1=e.down('ul').down('li');e1;e1=e1.next()){
					f(e1,level+1);
				}
			}
		};
		for( var c=$(rootid).down('ul').down('li');c;c=c.next('li')){
			f(c,1);
		}
		$(rootid).down('ul').show();
		var li = $('id' + index + '_' + intvalue);
		if (li){
			TecIndex.initValue(rootid, index, li);
			return;
		}
		if (true){
			if( $(rootid).down('li') ){
				var li = $(rootid).down('li');
				while (li.down('li')){li = li.down('li');}
				TecIndex.es[index-1] = li;
				li.down('a').addClassName('current');
			}
		}
		return;

	},
	initValue:function(rootid, index, li){
		TecIndex.es[index-1]=li;
		li.down('a').addClassName('current');
		for (var ul = li.up('ul');ul; ul=ul.up('ul')){
			ul.show();
		}
	},
	es:[null,null],
	hander:function(index,e1,e2){
	},
	getElementLi:function(event){
		var e=Event.element(event);
		if(!e.down('ul')&&e.up().tagName.toLowerCase()=='li'){
			e=e.up();
		}
		return e;
	},
	onclick:function(event,index){
		var e=TecIndex.getElementLi(event);
		if(e.tagName.toLowerCase()!='li'){
			return;
		}
		if(e.down('ul')){
			if( e.down('a').hasClassName('open') ){
				e.down('a').removeClassName('open');
				e.down('span.suffix').innerHTML="\<img src=\""+ctx+"/images/rightarrow.jpg\" width=\"20px;\" height=\"20px;\"\/\>";
				e.down('ul').hide();
			}else{
				e.down('a').addClassName('open');
				e.down('ul').show();
				if( e.down('span.suffix') ){
					e.down('span.suffix').innerHTML="\<img src=\""+ctx+"/images/downarrow.jpg\" width=\"20px;\" height=\"20px;\"\/\>";
				}
			}
		}
		TecIndex.hideBrother(e);
		var old=TecIndex.es[index-1];
		TecIndex.es[index-1]=e;
		if( !TecIndex.es[index-1].down('ul') ){
			TecIndex.hander(index,TecIndex.es[0],TecIndex.es[1]);
		}

		if(old!=null){
			old.down('a').removeClassName('current');
			old.down('a').removeClassName('current');
		}
		e.down('a').addClassName('current');

	},
	hideBrother:function(eSelf){
		var e=eSelf.up().down();
		while(e){
			if(e!=eSelf&&e.down('ul')){
				e.down('a').removeClassName('open');
				e.down('ul').hide();
				if( e.down('span.suffix') ){
					e.down('span.suffix').innerHTML="\<img src=\""+ctx+"/images/rightarrow.jpg\" width=\"20px;\" height=\"20px;\"\/\>";
				}
			}
			e=e.next();
		}
	},
	otherAction:function(e,old){

		var isParent=function(p,c){
			for( var e=c;e;e=e.up('li')){
				if(e==p){
					return true;
				}
			}
			return false;
		};
		// 如果新的是孩子
	if(li.up('li')==old){
		// 老的兄弟，全关上
	if(old!=null){
		for( var e=old.up().down('li');e;e=e.next()){
			if(e!=old){
				e.hide();
			}
		}
	}
	// 如果新的是父亲
}else if(isParent(li,old)){
	// 老的儿子，全关掉
	for( var e=old.down('li');e;e=e.next()){
		e.hide();
	}
	// 依次关闭，直到到达父亲
	for( var e=old;e&&e!=li;e=e.up('li')){
		e.hide();
	}
}
// 当前的儿子，全打开
	for( var e=li.down('li');e;e=e.next()){
		e.show();
	}
}
};

function scrollDoor(){
}
scrollDoor.prototype={
	sd:function(menus,openClass,closeClass,iframe,target){
		for( var i=0;i<menus.length;i++){
			$(menus[i]).value=i;
			$(menus[i]).onclick=function(){

				for( var j=0;j<menus.length;j++){
					$(menus[j]).className=closeClass;
				}
				$(menus[this.value]).className=openClass;
				window.location=target[this.value];
			}
		}
	}
}
function formatDisplayContent(content,i){
	if(content=="")
		return "";
	content=content.sub("&gt;",">",i);
	content=content.sub("&apos;","'",i);
	content=content.sub("&quot;","\"",i);
	content=content.sub("&nbsp;"," ",i);// 替换空格
	content=content.sub("&lt;","<",i);
	content=content.sub("&#xD7;","×",i);
	content=content.sub("&#xA4;","¤",i);
	content=content.sub("&#xB7;","·",i);
	content=content.sub("&#xB1;","±",i);
	content=content.sub("&#xB5;","µ",i); 
	content=content.sub("&#xBE;","¾",i);
	content=content.sub("&#xB0;","°",i);
	content=content.sub("&#xBA;","º",i);
	content=content.sub("&#xB9;","¹",i);
	content=content.sub("&#xB2;","²",i);
	content=content.sub("&#xB3;","³",i);
	content=content.sub("&#xBD;","½",i);
	content=content.sub("&#xBC;","¼",i);
	return content.sub("&amp;","&",i);
}
