//charset=UTF-8
function iter(ns,fn){
	var l = ns.length;
	if(!l)return fn(ns);
	var r;
	for(var i=0;i<l;i+=1){if(r=fn(ns[i], i))break;}
	return r;
}
function each(ns, fn, args){
	var l = ns.length;
	args = args || [];
	if(!l)return fn.apply(ns, args);
	var r;
	for(var i=0;i<l;i+=1){if(r=fn.apply(ns[i], args))break;}
	return r;
}
function addClass(el, className){
	el.className = el.className.replace(new RegExp('\\b'+className+'\\b|$'),' '+className+' ');
}
function removeClass(el, className){
	el.className = el.className.replace(new RegExp('\\b'+className+'\\b'),' ');
}
var ui = {
		slide:{
			onmouseover:function(i){
				ui.alpha(this, 1);
				this.style.borderColor='#ff0';
				var a = this.parentNode.parentNode.getElementsByTagName('a')[0];
				if(a.last){ui.slide.onmouseout.call(a.last);}
				a.last = this;
				a.target = -i * a.scrollHeight;
				a.timeline = 0;
			},
			onmouseout:function(){
				ui.alpha(this, 0.5);
				this.style.borderColor='#fff';
			},
			onclick:function(i){
				var a = this.parentNode.parentNode.getElementsByTagName('a')[i];
				if(a.target=='_blank'){
					window.open(a.href);
				}else{
					location.href = a.href;
				}
			},
			run:function(a){
				var t = parseInt(a.style.marginTop)||0;
				a.timeline = a.timeline + 1;
				var i;
				if(a.timeline == 200){
					a.timeline = 0;
					var h = a.scrollHeight;
					i = -a.target / h + 1;
					var imgs = a.parentNode.getElementsByTagName('span')[0].getElementsByTagName('img');
					i == imgs.length && (i=0);
					var img = imgs[i];
					a.last && ui.slide.onmouseout.call(a.last);
					ui.slide.onmouseover.call(img, i);
				}
				var d = (a.target - t) * 0.1;
				var di = d > 0 ? Math.ceil(d) : Math.floor(d);
				var r = t + di;
				a.style.marginTop = r +'px';
				//window.status = 'a='+a.target + ' t='+ t+' d='+d + ' di='+di + ' r='+r + ' l=' + a.timeline+' i='+i;
			},
			load:function(id){
				addEvent(window, 'onload', function(){
					var el = $(id);
					var as = el.getElementsByTagName('a');
					var span = document.createElement('span');
					var imgs = [];
					for(var i=0;i<as.length;i++){
						var img = new Image();
						imgs[i] = img;
						img.src = as[i].getElementsByTagName('img')[0].src;
						var h = 20;
						var w = h * img.width / img.height;
						img.height = h;
						img.width = w;
						for(var k in ui.slide){
							if(k.substring(0, 2) == 'on'){
								addEvent(img, k, ui.slide[k], i);
							}
						}
						span.appendChild(img);
					}
					el.appendChild(span);
					var a = as[0];
					ui.slide.onmouseover.call(imgs[0], 0);
					a.timer = setInterval(function(){ui.slide.run(a);}, 10);
				});
			}
		}
	};
//Fix  FireFox
var ff = /Firefox/.test(window.navigator.userAgent);
if (ff) {
	HTMLElement.prototype.__defineGetter__("currentStyle", function () {
		return this.ownerDocument.defaultView.getComputedStyle(this, null);
	});
	window.attachEvent=HTMLElement.prototype.attachEvent=function(type, fn){
		type = type.substring(2);
		this.addEventListener(type, fn, false);
	};
}
if(ff){
	ui.alpha = function(el, opacity){
		el.style.MozOpacity=opacity;
	};
	ui.click = function(el){
		var evt = document.createEvent("MouseEvents");
		evt.initEvent("click", true, true);
		el.dispatchEvent(evt);
	};
}else{
	ui.alpha = function(el, opacity){
		el.filters.alpha.opacity=opacity*100;
	};
	ui.click = function(el){
		el.click();
	};
}


function addEvent(target, type, method) {
	var args = Array.prototype.slice.call(arguments, 3);
	target.attachEvent(type, function(){
		return method.apply(target, args);
	});
}

function showtab(n,i){
	var id = n+i+'_';
	iter(g('#'+id).parentNode.childNodes,function(a){
		if(a.id)
			if(a.id==id)
				a.style.display='block';
			else if(a.id.indexOf(n)==0)
				a.style.display='none';
	});
	var id1 = n+i;
	iter(g('#'+id1).parentNode.childNodes,function(a){
		if(a.id)
			if(a.id==id1){
				a.style.backgroundImage = a.currentStyle.backgroundImage.replace(/a\.gif/g, 'b.gif');
			}else if(a.id.indexOf(n)==0){
				a.style.backgroundImage = a.currentStyle.backgroundImage.replace(/b\.gif/g, 'a.gif');
			}
	});
}
String.prototype.trim = function(){
	return this.replace(/(^\s+)|(\s+$)/g,'');
};

function get(url, fn){
	var r;
	try{
        r = new XMLHttpRequest();
    }catch(ff){
        try{
            r = new ActiveXObject("Msxml2.XMLHTTP");
        }catch(ie5){
            try{r = new ActiveXObject("Microsoft.XMLHTTP");}
            catch(failed){
            	alert('XMLHTTP ERROR');
            	return null;
            }
        }
    }
	var b = (fn !== undefined);
    r.open("GET", url, b);
    r.send(null);
    if(b){
   		 r.onreadystatechange=function(){
	    	if(r.readyState ===4 && r.status===200){
		    	var result = r.responseText.trim();
		    	r=null;
		    	fn(result);
	    	}
    	};
    }else{
	    var result = null;
	    if(r.status==200){
	    	result = r.responseText.trim();
	    }
	    r = null;
	    return result;
    }
}
function ifr(f){
	this.f = f;
	var a = f.action;
	var id='ifr_'+a;
	this.iframe = $(id);
	if(!this.iframe){
		try{
			this.iframe = document.createElement('<iframe name="'+id+'"></iframe>');
		}catch(e){
			this.iframe = document.createElement('iframe');
		}
		this.iframe.name=id;
		this.iframe.id=id;
		this.iframe.style.display='none';
		document.body.appendChild(this.iframe);
	}
	f.target=id;
	return this;
}
ifr.prototype= {
		valid:
			function(i, regex, f){
	if(this.e !== undefined){
		return;
	}

	if(i === undefined){
		return;
	}
	var v;
	if(i.value === undefined){
		var a=0;
		for(;a<i.length;a++){
			if(i[a].checked || i[a].selected){
				return;
			}
		}
		this.result(i[0], false, f);
		return;
	}else{
		v = i.value;
	}
	if(v===undefined){
		//return;
	}else{
		v=v.trim();
		i.value=v;
	}
	var r;
	if(regex === undefined){
		r = !!v;
	}else{
		if(typeof regex === 'boolean'){
			r = regex;
		}else if(typeof regex === 'string'){
			regex = new RegExp(regex,'g');
		}
		if(regex instanceof RegExp){
			r = regex.test(v);
		}
	}
	this.result(i, r, f);
},
remotevalid:function(elem, url, fn){
	if(this.e !== undefined){
		return;
	}
	if(elem === undefined ){
		return;
	}
	var valid = get(url + elem.value) !== '1';
	this.result(elem, valid, fn);
},
result: function(elem, valid, f){
	if(elem === undefined){
		return;
	}
	if(!valid){
		this.e = elem;
		if(f !== undefined){
			f.apply(elem);
		}else{
			elem.focus();
		}
	}
},
submit:function(){
	if(!this.e){
		this.f.submit();
	}
},
radio:function(name){
	var ns = this.f[name];
	var l = ns.length;
	for(var i=0;i<l;i++){
		if(ns[i].checked){
			return ns[i].value;
		}
	}
}
};
function overtr(table){
	var tbody = table.firstChild;
	var trs = tbody.childNodes;
	for(var i=0;i<trs.length;i+=1){
		var tr=trs[i];
		if(i%2==0){
			tr.bgColor='#fffff';
			tr.onmouseover=function(){
				this.bgColor='#ff8822';
			};
			tr.onmouseout=function(){
				this.bgColor='#ffffff';
			};
		}else{
			tr.bgColor='#eeeeee';
			tr.onmouseover=function(){
				this.bgColor='#ff8822';
			};
			tr.onmouseout=function(){
				this.bgColor='#eeeeee';
			};
		}
	}
}
function $(id,parentElement){
return (parentElement||document).getElementById(id);
}
function nextNodeName(node, nodeName){
	while(node = node.nextSibling){
		if(node && node.nodeName == nodeName){
			return node;
		}
	}
}
function prevNode(node, nodeName){
	while(node = node.previousSibling){
		if(node && node.nodeName == nodeName){
			return node;
		}
	}
}
function g(i,j){
	if(!j){j=document;}
	var f=i.charAt(0);
	if(f=='#'){
		return document.getElementById(i.substring(1));
	}else if(f=='.'){
		return getElementsByClassName(i.substring(1),j);
	}else if(f=='$'){
		return j.getElementsByName(i.substring(1));
	}else{
		return j.getElementsByTagName(i);
	}
}
function getElementsByClassName(className,parentElement){
	var s = parentElement.getElementsByTagName("*");
	var result=[];
	className=" "+className+" ";
	for(var i=0;j=s[i];i+=1){
		if((" "+j.className+" ").indexOf(className)!=-1){
			result.push(j);
		}
	}
	return result;
}

function da(q) {
	q.nextSibling.style.display= (q.nextSibling.style.display =="none")?"":"none";
}
function $(id){
return document.getElementById(id);
}

function req(url){
	var f = document.getElementById('requestiframe');
	if(!f){
		f = document.createElement('iframe');
		f.id='requestiframe';
		f.style.display='none';
		document.body.appendChild(f);
	}
	f.src=url;
}
function radiovalue(name){
	return getradio(name);
}
function getradio(name, node){
var items = g("INPUT", node||document);
for(var i=0;i<items.length;i++){
var it = items[i];
if(it.name==name && it.checked){
return it.value;
}
}
}

function setradio(name, value){
if(!value){return;}
var els = document.getElementsByTagName("INPUT");
for(var i=0;i<els.length;i++){
	var el = els[i];
	if(el.name==name && el.value == value){
		el.checked=true;
	}
}
}
function setselect(name, value){
var els = document.getElementsByTagName("SELECT");
for(var i=0;i<els.length;i++){
	var el = els[i];
	if(el.name==name){
		el.value=value;
	}
}
}
function order(action, column){
var text = document.getElementById(action+'.order');
var value=text.value;
var desc = column+' desc';
if(value == column){
value=desc;
}else if(value == desc){
value='';
}else{
value=column;
}
text.value=value;
text.form.submit();
}

function selecta(all){
	var	is = document.getElementsByTagName('input');
	var checked = all.checked;
	for(var i=0; i<is.length; i++){
		if(is[i].name == all.name && is[i].type == 'checkbox'){
			is[i].checked = checked;
		}
	}
}
function el(id){
if(document.getElementById){
return document.getElementById(id);
}else{
return window[id];
}
}
function winopen(url, height, width){

if(!height){
height=500;
}
if(!width){
width=600;
}
var params='height='+height+', width='+width+',top=0, left=0,  toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no';
window.open(url,'',params);
}

function winopen2(url,height,width){ 
	l = width;
	t = height;
	var win = window.open(url,'','scrollbars=yes,width='+l+',height='+t+',top='+(screen.availHeight/3-t/2)+',left='+(screen.availWidth/2-l/2));  
	win.focus();
}

/* begin ie input onfocus style */
function focustyle(type, tag, id) {
if (window.attachEvent) {
window.attachEvent("onload", function() {
var els=(id==null)?document.getElementsByTagName(tag):document.getElementById(id).getElementsByTagName(tag);
type(els);
});
}
}
elfocus=function(els) {
for(var i=0; i<els.length; i++){
els[i].onfocus=function() {
this.className+=" focus";
};
els[i].onblur=function() {
this.className=this.className.replace(new RegExp(" focus\\b"), "");
};
}
};
//focustyle(elfocus, "input");
//focustyle(elfocus, "textarea");
/* end ie input onfocus style */

/* begin calendar */
function fix(value,digital){
	return (parseInt(value) + 10000).toString().substring(5-digital,5);
}
function date(d,s){
	d=d||new Date();
	s=s||'-';
	return d.getFullYear()+s+fix(d.getMonth()+1,2)+s+fix(d.getDate(),2);
}
function xoffset(el){
	
	this.t = el.offsetTop;
	this.l = el.offsetLeft;
	while(el=el.offsetParent){
		this.t += el.offsetTop;
		this.l += el.offsetLeft;
	}
	return this;
}
function dialog(html){
	var d = document.createElement('div');
	d.className='dialog';
	d.innerHTML = '<div></div><a href="javascript:;" onclick="this.parentNode.style.display=\'none\'" class="close">Close</a>';
	document.body.appendChild(d);
	var div = d.firstChild;
	div.innerHTML=html;
	return div;
}
function setwin(el){
	var width=el.offsetWidth;
	var height=el.offsetHeight;
	var client= document.documentElement.clientHeight?document.documentElement:document.body;
	var top2=client.scrollTop||0;
   	var left2=client.scrollLeft||0;
   	var height2=client.clientHeight||0;
	var width2=client.clientWidth||0;
	el.style.position = "absolute";

	var top = (height2-height)/2+top2;
	el.style.top =top<0?0:top;
	var left = (width2-width)/2+left2;
	el.style.left = left<0?0:left;
}
function dialog2(url,height,width){
	var d = document.getElementById('dia');
	var doc;
	if(d){
		document.body.removeChild(d);
		d = null;
	}
	d = document.createElement('iframe');
	d.id='dia';
	document.body.appendChild(d);
	doc=d.contentWindow.document;
	var html=get(url);
	doc.open("about:blank");   
       doc.write('<html><body><div id="dialog1"><a id="dialoga" onclick="window.frameElement.style.display=\'none\';">X</a></div><div id="dialog2">');
       doc.write(html);
       doc.write('</div></body></html>');   
       doc.close();
       //css
	var d1=doc.getElementById('dialog1');
	var d2=doc.getElementById('dialog2');
	var da=doc.getElementById('dialoga');
	doc.body.style.overflow="hidden";
	doc.body.style.margin="0px";
	doc.body.style.border="1px solid #f60";
	doc.body.style.backgroundColor="#eee";
	d1.style.backgroundColor="#f60";
	d1.style.height="15px";
	d1.style.display='block';
	da.href="javascript:;";
	da.style.paddingRight="5px";
	da.style.textDecoration="none";
	da.style.styleFloat="right";
	d2.style.padding="4px";
	d2.style.clear="both";
	d.style.width =width+"px";
	d.style.height =height+"px";
	setwin(d);
}
function dialog3(url,height,width){
  window.showModalDialog(url,window, "status:no;dialogHeight:"+height+"px;dialogWidth:"+width+"px;" );
}
function openhtml(url,height,width){
	var d = document.getElementById('dia');
	var doc;
	if(d){
		document.body.removeChild(d);
		d = null;
	}
	d = document.createElement('iframe');
	d.id='dia';
	document.body.appendChild(d);
	//doc=d.contentWindow.document;
	//var html=get(url);
	//doc.open();   
   // doc.write('<html><body>');
  //  doc.write(html);
   // doc.write('</body></html>');   
    //doc.close();
	d.src = url;
       //css
	doc.body.style.overflow="hidden";
	doc.body.style.margin="0px";
	doc.body.style.border="0px";
	d.style.width =width+"px";
	d.style.height =height+"px";
	setwin(d);
}
function follow(a, b){
	var os = xoffset(a);
	b.style.top = os.t + a.offsetHeight;
	b.style.left = os.l;
}
function time(el){
	var d = el.div;
	if(d){
		d.parentNode.style.display='block';
	}else{
		var time = /\btime\b/.test(el.className);
		var dd = [];
		var arr = (time?/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2}):(\d{2})$/:/^(\d{4})\-(\d{2})\-(\d{2})$/).exec(el.value);
		if(arr === null){
			var date = new Date();
			dd = [date.getFullYear(),date.getMonth()+1,date.getDate(), 
					date.getHours(), 
					date.getMinutes()];
		}else{
			arr.splice(0,1);
			dd = arr;
			for(var i=0;i<arr.length;i++){arr[i]=parseInt(arr[i]);}
		}
		
		var s = '<div class="year"><b>Year</b>'+gena(dd[0]-6,dd[0]+5, dd[0])+'</div>' +
		'<div class="month"><b>Month</b>'+gena(1,12, dd[1], 1, 12)+'</div>' +
		'<div class="dates"><b>Date</b>'+gena(1,31, dd[2], 1, 32)+'</div>';
		if(time){s += '<div class="hour"><b>Hour</b>'+gena(0, 23, dd[3], 1, 24)+'</div>' +
			'<div class="minute"><b>Minute</b>'+gena(0,59, dd[4], 1, 30)+'</div>';
			//'<div class="second"><b>Second</b>'+gena(0,59, dd[5], 15)+'</div>'
		}
		d = dialog(s);
		d.style.width=600;
		el.div = d;
		follow(el, d.parentNode);
		d.set=function(){
			var ns = this.getElementsByTagName('div');
			var l = ns.length;
			for(var i=0;i<l;i++){
				dd[i] = ns[i].value;
			}
			var tw=function(v){return v<10?'0'+v:v;};
			var s = dd[0]+'-'+tw(dd[1])+'-'+tw(dd[2]);
			if(time){
				s += ' '+tw(dd[3])+':'+tw(dd[4])+':00';
			}
			el.value=s;
			this.parentNode.style.display='none';
		};
		var ds = d.getElementsByTagName('div');
		var fns = {
				'year' : function(a) {
					afocus(a);
					acenter(a);
				},
				'month' : function(a) {
					afocus(a);
					acenter(a, 12);
				},
				'dates' : function(a) {
					afocus(a);
					acenter(a, 32);
					if(time===false){
						a.parentNode.parentNode.set();
					}
				},
				'hour' : function(a) {
					afocus(a);
					acenter(a, 24);
				},
				'minute' : function(a) {
					afocus(a);
					acenter(a, 60);
					a.parentNode.parentNode.set();
				},
				'second' : function(a) {
					afocus(a);
					acenter(a, 60);
				}
			};
		for(var i=0;i<ds.length;i++){
				ds[i].set=fns[ds[i].className];
				ds[i].value = dd[i];
			}
		}
	}
	function afocus(a) {
		var div = a.parentNode;
		it(div.childNodes, function() {
			if (this.className) {
				this.className = '';
			}
		});
		a.className = 'focus';
		div.value = a.innerHTML;
	}
	function acenter(a, circle) {
		var div = a.parentNode;
		var ns = div.childNodes;
		var l = ns.length;
		var c = l >> 1;
		var i=0;
		for(;i<l;i++){
			if(a==ns[i]){
				break;
			}
		}
		var step = l - 1;
		l = i-c;
		var val = function(s, step){
			var v = parseInt(s) + step;
			if(circle)v = (v+circle) % circle;
			return v;
		};
		if(l>0){
			l--;
			for(var j=0;j<l;j++){
				ns[1].innerHTML = val(ns[1].innerHTML, step);
				div.appendChild(ns[1]);
			}
		}else{
			l=-l;
			l++;
			for(var j=0;j<l;j++){
				ns[step].innerHTML = val(ns[step].innerHTML,-step);
				div.insertBefore(ns[step], ns[1]);
			}
		}
	}
	function it(ns, fn) {
		var l = ns.length;
		for ( var i = 0; i < l; i++) {
			fn.apply(ns[i]);
		}
	}
	function gena(fr, to, ct, step, circle) {
		var s = '';
		step = step || 1;
		var l = circle || to - fr + 1;
		var mod = to - fr + 1;
		var start = fr;
		if(circle){
			fr = ct - (circle>>1) - start;
			to = fr + circle - 1;
		}
		var width = 540 * step / l - 4;
		
		var prefix = '<a href="javascript:;" style="width:' + width + 'px" onclick="this.parentNode.set(this)" ';
		for (; fr <= to; fr+=step) {
			var tt = circle?(fr+mod)%mod+start:fr;
			var cl = ct == tt ? ' class="focus"' : '';
			s += prefix + cl + '>' + tt + '</a>';
		}
		return s;
	}
	//var calendar = time;
	/*end calendar*/
function setcookie(name,value,date){
	var today = new Date();
	var expireDay = new Date();
	var msPerMonth = 24*60*60*1000*date;
	expireDay.setTime( today.getTime() + msPerMonth );
	document.cookie = name+'='+value+';expires=' + expireDay.toGMTString();
}

function getcookie(key){
	var search = key + "=";
	begin = document.cookie.indexOf(search);
	if (begin != -1) {
	  begin += search.length;
	  end = document.cookie.indexOf(";",begin);
	  if (end == -1) end = document.cookie.length;
	  return document.cookie.substring(begin,end);
	}
}

function menu(){
	var as = document.getElementById('a').getElementsByTagName('a');
	for(var i=0;i<as.length;i++){
		if(as[i].href == location.href){
			as[i].style.fontWeight='bold';
			break;
		}
	}
}
function menu2(menucss){
	var as = document.getElementById('a').getElementsByTagName('a');
	for(var i=0;i<as.length;i++){
		if(as[i].href == location.href){
			as[i].className=as[i].className+" "+menucss;
			break;
		}
	}
}
var IE=(navigator.userAgent.toLowerCase().indexOf('msie') != -1);
if(IE)document.execCommand('BackgroundImageCache', false, true);


function disp(ef){
	var ns = ef.parentNode.childNodes;
	for(var i=0;i<ns.length;i+=1){
		var f=ns[i];
		if(!f.id){
			continue;
		}
		if(f==ef){
			f.style.backgroundPositionY='bottom';
			document.getElementById(f.id+'_').style.display='block';
			f.style.color="#fff";
			f.style.fontSize="13";
		}else{
			f.style.backgroundPositionY='0';
			f.style.color="#666";
			document.getElementById(f.id+'_').style.display='none';
		}
	}
}


function picover(pic, arr, i){
	
	var a = g('#event');
	a.eventTime= true;
	a.href=arr[i];
	a.style.backgroundImage="url(/images/"+pic+i+".jpg)";
	var ns = g('b',a.parentNode);
	var l = ns.length;
	for(var x=0;x<l;x++){
		if(x==i){
			ns[x].style.backgroundColor='#fff';
			ns[x].style.color='#333';
		}else{
			ns[x].style.backgroundColor='#333';
			ns[x].style.color='#fff';
		}
	}
}
var picchange_i=0;
function picchange(pic,arr){
	
	var a=g('#event');
	var s =a.href;
	for(;picchange_i<arr.length;picchange_i++){
		if(s.indexOf(arr[picchange_i])>=0)break;
	}
	picchange_i++;
	if(picchange_i>=arr.length)picchange_i=0;
	a.href=arr[picchange_i];
	a.style.backgroundImage="url(/images/"+pic+picchange_i+".jpg)";
	
	var ns = g('b',a.parentNode);
	var l = ns.length;
	for(var x=0;x<l;x++){
		if(x==picchange_i){
			ns[x].style.backgroundColor='#fff';
			ns[x].style.color='#333';
		}else{
			ns[x].style.backgroundColor='#333';
			ns[x].style.color='#fff';
		}
	}
}

function checkmsn() {
 try {
        new ActiveXObject("MSNMessenger.P4QuickLaunch");
        return true;
  }catch (e) {
	  alert("您没安装MSN，请您先安装MSN！");
		 return false;
  }
}

function showtips(el, tp){
	if(!el.value){
		el.defaultValue = tp||el.title;
		el.value = el.defaultValue;
		addClass(el, 'tips');
		addEvent(el, 'onfocus', function(){
			if(this.value == this.defaultValue){
				this.value='';
				removeClass(this, 'tips');
			}
		});
	}
	/*
	addEvent(el, 'onblur', function(){
		if(this.value == ''){
			this.value = this.defaultValue;
			addClass(this, 'tips');
		}
	});
	*/
}

var timer;
function hide(id){
	timer = setInterval('hide0("'+id+'")',10);
}
function hide0(id){
	var el=g(id);
	var h = parseInt(el.style.height);
	if(h>25){
		el.style.height=h-25;
	}else{
		el.style.display='none';
		clearInterval(timer);
	}
}
function page(i,b){
	var p = $('page');
	b = b?parseInt(p.value)||1:0;
	p.value = b+(i||-1);
	p.form.submit();
}

function initpage(page,total,size){
	var s = '';
	if(!page)page=1;
	if(total>size){
		if(page > 1){
			s += '<img src="/images/page/first.gif" onclick="page(1)"/>';
			s += '<img src="/images/page/prev.gif" onclick="page(0,1)"/>';
		}
		var totalpage = Math.ceil(total/size);
		s += page + '/' + totalpage;
		if(page< totalpage){
			s += '<img src="/images/page/next.gif" onclick="page(1,1)"/>';
			s += '<img src="/images/page/last.gif" onclick="page('+totalpage+')"/>';
		}
	}
	document.write(s);;
}


function data(el,vl){
	var h = el.innerHTML;
	var m = "'"+h.replace(/'/g,"\'").replace(/<!--/g,"'+ ").replace(/-->/g,"+'").replace(/\r|\n/g,"\\r")+"'";
	with(vl){
		m=eval(m);
	}
	el.innerHTML=m;
}
function tabledata(el, vl){
	var row_num=el.rows.length;
     var cell_num=el.rows[0].cells.length;
     for(var i=row_num-1;i>=0;i--)
     {
          for(j=cell_num-1;j>=0;j--)
          {
               data(el.rows[i].cells[j],vl);
          }
     }
}
function selectdata(el, vl, fn){
	var l =vl.length;
	var os=el.options;
	for (var i=0; i < l; i++) {
         var op = document.createElement("option");
         op.value = vl[i].id;
         op.text = fn(vl[i]);
  		 os.add(op);
      }
}

function formdata(form,val){
var ns = form.elements;
var only=false;
var l = ns.length;
for(var i=0;i<l;i++){
	var n = ns[i];
	var name = n.name;
	var value= val[name];
	if(!value)continue;
	var type = n.nodeName + (n.type||'');
	switch(type){
	case 'INPUTtext':
	case 'INPUThidden':
	case 'SELECT':
		n.value = value;
		break;
	case 'INPUTradio':
		only = true;
	case 'INPUTcheckbox':
		checked(name,value,only,form);
		only=false;
		break;
	}
}
}

function formurl(f){
	var els = f.elements;
	var s = f.action+'?r='+Math.random();
	for(var j=0;j<els.length;j++){
		var el = els[j];
		if(!el.name){continue;}
		if(el.type === 'radio' || el.type === 'checkbox'){
			if(!el.checked){
			continue;
			}
		}
		s += '&' + el.name + '=' + encodeURIComponent(el.value);
	}
	return s;
}
function formget(form){
	var url=formurl(form);
	dialog(get(url));
	return false;

}
function checked(name,value,only,form){
iter(form[name],function(a){if(a.value==value){a.checked=true;return only;}});
}
function inityearselect(id,from,to){
	var os = $(id);
	if(!os){return;}
	os = os.options;
	
	var yy = new Date().getFullYear();
	from  = (from || -5) + yy;
	to  = (to||-50) + yy;
	var i = to-from>0?1:-1;
	for(;from!=to;from+=i){
		var o = document.createElement('option');
		o.value = from;
		o.text = from+'年';
		os.add(o);
	}
}
function formdate(form, name, value){
if(!value)return;
var yy = value.substring(0,4);
var mm = value.substring(5,7);
var dd = value.substring(8,10);
form[name+'yy'].value=yy;
form[name+'mm'].value=mm;
form[name+'dd'].value=dd;
}
function disableinput(name){
	iter(form[name],function(a){if(result.users[name])a.disabled=true;});
}
function changeage(el){
	var yy = new Date().getFullYear();
	$('marrydiv').style.display=(yy - el.value)>20?'':'none';
	
}
function toggle(a, b){
	var es = a.childNodes;
	for ( var i = 0; i < es.length; i++) {
		if(es[i].className){
			es[i].onclick = function(){
				togglea.apply(this, [a, b]);
			};
		}
	}
}
function togglea(a, b){
	var es1  = a.childNodes;
	var j=0;
	for(var i=0;i<es1.length; i++){
		if(es1[i].className){
			var left = parseInt(es1[i].currentStyle.width) * j;
			j++;
			if(!es1[i].style.backgroundPosition){
				continue;
			}
			if(es1[i]===this){
				es1[i].style.backgroundPosition = '-'+left+'px bottom';
			}else{
				es1[i].style.backgroundPosition = '-'+left+'px top';
			}
		}
	}
	var es2 = b.childNodes;
	var reg = new RegExp(this.className+'$');
	for(var i=0; i<es2.length; i++){
		if(es2[i].className){
			es2[i].style.display=(reg.test(es2[i].className))?'':'none';
		}
	}
}
// add a focus

addEvent(window,'onload', function(){
	var as = document.getElementsByTagName('a');
	var PATH  = location.pathname;
	for(var i=0;i<as.length;i++){
		var path = pathname(as[i].href);
		if(PATH === path){
			as[i].className += ' focus';
		}
	}
	//togglehref(as);
});
function pathname(href){
	var start = href.indexOf('/', 12);
	var end = href.indexOf('?', start);
	if(end === -1){end = href.length;}
	href = href.substring(start, end);
	return href;
}


function pop(el){
	var a = next(el,'.dialog');
	if(a === undefined ){
		a = next(el.parentNode, '.dialog');
	}
	var x = xoffset(el);
	a.style.position='absolute';
	a.style.top = x.t - 20;
	a.style.left = x.l + el.clientWidth;
	a.style.display='block';
	if(!el.onblur){
		el.onblur=function(){
			a.style.display='none';
		};
	}
}
function next(el, sl){
	var flag = sl.indexOf('.') + 1;
	if ( flag > 2 ) flag = 2;
	var f = [
function(){return this.tagName;},function(){return '.'+this.className;},function(){return this.tagName + '.' + this.className;}
		      	][flag];
	while ( el ) {
			var r =  f.apply(el);
		if ( r === sl ) {
			return el;
		}
		el = el.nextSibling;
	}
}

function togglehref(as){
	var href = location.href;
	var start = href.lastIndexOf('#');
	if(start ===-1){
		return;
	}
	var name = href.substring(start+1);
	if(as !== undefined )as = document.getElementsByTagName('A');
	for(var i=0;i<as.length;i++){
		var a = as[i];
		if(a.name === name){
			a.click();
			return;
		}
	}
	}
function changetime(){
	var d = new Date().getTime()-serverInterval;
	d = new Date(d);
	var s = d.getFullYear()+'-'+fix(d.getMonth()+1,2)+'-'+fix(d.getDate(),2) + ' ' + fix(d.getHours(),2)+':' + fix(d.getMinutes(),2)+':' + fix(d.getSeconds(),2);
	var t = $('timespan');
	if(t==undefined){
		t = document.createElement('<span id="timespan" style="position:fixed;left:240px; top:12px;">0000-00-00 00:00:00</span>');
		document.body.appendChild(t);
	}
	t.innerHTML =s;
}

function startcountdown(el, minutes){
	if(minutes){
		var time = new Date().getTime() + minutes * 60 * 1000;
		el.time = time;
		if(el.timer){
			clearInterval(el.timer);
		}
		el.timer = setInterval('startcountdown($("'+el.id+'"))', 1000);
		el.blur(); 
	}
	var seconds = el.time - new Date().getTime();
	if(seconds <= 0){
		clearInterval(el.timer);
		alert('Time\'s up.');
		return;
	}
	seconds = Math.floor(seconds/1000);
	minutes = Math.floor(seconds/60);
	seconds = seconds % 60;
	if(seconds<10)seconds = '0'+seconds;
	el.innerHTML = 'Restart - ' + minutes +':'+seconds;
}

function mouseover(n, i){
	n.onmouseover=function(){this.className += ' mouseover';};
	n.onmouseout=function(){this.className = this.className.replace(/\bmouseover\b/, '');};
	if(i % 2 == 0){
		n.className += ' rowodd';
	}
}
function newaction(el,url){
	var f = el.form;
	f.action = url;
	var r = new ifr(f);
	r.submit();
	return false;
}
function checkreg(el, reg, msg){
	var val = el.value;
	if(!val || !reg.test(val)){
		alert(msg);
		el.focus();
		return false;
	}
	return true;
}

function checknull(el,msg){
	if(!el.value){
		alert(msg);
		el.focus();
		return false;
	}
	return true;
}
function contentvalue(content){
var ifr=content.nextSibling.nextSibling;
var c=ifr.contentWindow.document.getElementById('editer').innerHTML;
	if(c.length>40000){
		alert('Content is too long!');
		return true;
	}
	content.value=c.replace(/<script.*<\/script>/ig,'');
	return false;
}

function showmenu(a){
	var h1 = a.parentNode;
	var div = h1.nextSibling;
	var nav = div.parentNode;
	var aa = nav.a;
	if(aa){
		aa.parentNode.nextSibling.style.display='none';
		aa.className='';
	}
	div.style.display='block';
	a.className='hover';
	if(!div.style.left){
		var left = h1.offsetLeft;
		var parentWidth = nav.clientWidth;
		var width = div.clientWidth;
		if(left + width > parentWidth){
			left = parentWidth - width;
		}
		left = left + 'px';
		div.style.left= left;
	}
	nav.a = a;
}
function setmenu(){
	var n =document.getElementById('navigation');
	if(!n){return;}
	var a=n.getElementsByTagName('h2');
	var l = a.length;
	for(var i=0;i<l;i++){
		var aa = a[i].getElementsByTagName('a')[0];
		if(aa.href==location.href){
			aa.style.color='#ff7f14';
			showmenu(aa.parentNode.parentNode.previousSibling.firstChild);
		}
	}
}
function player(id){
	var player=document.createElement("object");
	player.id=id+"obj";
	var d=document.getElementById(id);
	d.parentNode.insertBefore(player,d);
	player.classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6";
	player.settings.autoStart="false";
	player.width=d.style.width||250;
	player.height=62;
	d.style.display='none';
	var files=d.innerText;
	if(files==""){
		player.style.display='none';
	}else{
		var uu=files.split(',');
		for(var i in uu){
			if(uu[i]=="") uu.splice(i,1);
		}
		var i=0;
		player.URL=uu[0];
		if(uu.length>1){
			window.setInterval(function(){
				var curr=player.controls.currentPosition;
				var len=player.currentMedia.duration;
				if(player.playState==3 && curr+1>len){
					if(i!=(uu.length-1)){
						i=i+1;
						player.URL=uu[i];
						player.controls.play();
					}else{
						i=0;
						player.URL=uu[i];
					}
				}
			},1000);
		}
	}
}
addEvent(window,'onload',setmenu);
function slider(){
	var top = parseInt(document.documentElement.scrollTop);
	top -= 120;
	if(top < 0){ top = 0; }
	else{ top += 20; }
	var sider = document.getElementById("sider");
	var oldtop = parseInt(sider.style.top)||0;
	var newtop = oldtop+Math.floor((top - oldtop)*0.1);
	sider.style.top = newtop+"px";
}

ui.picture = {
	onmouseover:function(){
		this.timeline = 0;
	},
	run:function(el){
		var as = children(el);
		var a = as[0];
		var t = parseInt(a.style.marginLeft)||0;
		el.timeline++;
		if(el.timeline == 200) {
			el.appendChild(a);
			el.timeline = 0;
			a.style.marginLeft = '0px';
		}else{
			var d = (el.target - t) * 0.1;
			var di = Math.floor(d);
			var r = t + di;
			a.style.marginLeft = r +'px';
		}
	},
	load:function(id){
		addEvent(window, 'onload', function(){
			var el = $(id);
			addEvent(el,'onmouseover',ui.picture.onmouseover);
			el.target = -(children(el)[0].scrollWidth);
			el.timeline = 0;
			el.timer = setInterval(function(){ui.picture.run(el);}, 10);
		});
	}
};
	
function children(el){
	var c = el.firstChild;
	while(c){
		if(c.nodeType==1){
			break;
		}
		c = c.nextSibling;		
	}
	return el.getElementsByTagName(c.tagName);
}

