﻿/* 2008-01-31 UI.js */
var UI={};
Object.extend=function(a, b){
  for (var property in b) a[property] = b[property];
  return a;
 };
UI.$=function(s) { return document.getElementById(s) };
UI.trim=function(s) {return s.replace(/(^\s*)|(\s*$)/g, "") };
UI.toogle=function(id) { UI.$(id).style.display=(UI.getStyle(UI.$(id),'display')=='none') ? 'block':'none' };
UI.getEl=function(e){var E=UI.getE(e);return E.target || E.srcElement}
UI.getE=function(e){return e || window.event}
UI.random=function(min, max){ return Math.floor(Math.random() * (max - min + 1) + min) };
UI.addEvent=function(object, type, listener) {	
	if(object.addEventListener) {if(type=='mousewheel')type='DOMMouseScroll'; object.addEventListener(type, listener, false)}
	else { object.attachEvent("on"+type, listener); }
};
UI.delEvent=function(object, type, listener){
	if (object.removeEventListener) {if(type=='mousewheel')type='DOMMouseScroll'; object.removeEventListener(type, listener, false)}
	else object.detachEvent('on'+type, listener);
};
UI.stopEvent=function(event) {
	var e=event || window.event;
	if(e.preventDefault) {e.preventDefault(); e.stopPropagation(); }
	else {e.returnValue = false; e.cancelBubble = true;}
};
UI.getEventWheel=function(e){
	var delta=0;
	if(e.wheelDelta) delta=e.wheelDelta/120;
	else if(e.detail) delta=-e.detail/3;
	return delta;
};
UI.getBrowser=function(){
	var ua=navigator.userAgent.toLowerCase();
	var opera=/opera/.test(ua)
	UI._browser={
		ie:!opera && /msie/.test(ua),
		ie_ver: parseFloat(((ua.split('; '))[1].split(' '))[1]),
		opera:opera,
		ff:/firefox/.test(ua),
		gecko:/gecko/.test(ua)		
	};
	return UI._browser;
};
UI.resizeIframe=function(iframe_id) {
	var h = (self.innerHeight) ? document.documentElement.offsetHeight : document.body.scrollHeight;
	try{parent.UI.$(iframe_id).style.height = h+"px";}catch(e){}
};
UI.rollOver=function(s) {
	var img=(typeof(s)=="string") ? img=UI.$(s):s;
	img.onmouseover=function() { UI.rollOver.over(img) }
	img.onmouseout=function() { UI.rollOver.out(img) }
}
UI.rollOver.over=function(img){ var src=img.src; img.src=src.replace("_off.","_on."); }
UI.rollOver.out=function(img){ var src=img.src; img.src=src.replace("_on.","_off."); };
UI.popUp=function(url,name,w,h,scroll,resize,status,center){
	if(!scroll) scroll=0;
	if(!resize) resize=0;
	if(!status) status=1;
	if(center){
		var x = (screen.width - w) / 2;
		var y = (screen.height - h) / 2;
		center = ",top="+y+",left="+x;
	}
	return window.open(url,name,"width="+w+",height="+h+",status="+status+",resizable="+resize+",scrollbars="+scroll+center);
};
UI.setCookie=function(name, value, expires, path, domain, secure){
	if(expires){//day 
		var d=new Date(); d.setDate(d.getDate()+expires);
		expires = d.toGMTString();
	}
	document.cookie = name + "=" + escape(value) +
	  ((expires) ? "; expires=" + expires : "") +
	  ((path) ? "; path=" + path : "") +
	  ((domain) ? "; domain=" + domain : "") +
	  ((secure) ? "; secure" : "");
};
UI.getCookie=function(name){
	name += "=";
	cookie = document.cookie + ";";
	start = cookie.indexOf(name);
	if (start != -1){
		end = cookie.indexOf(";",start);
		return unescape(cookie.substring(start + name.length, end));
	}
	return "";
};
UI.embedSWF=function(f,w,h,options){
	var param={	id:"UIswf_"+f,quality:'high',bgcolor:'#ffffff',allowScriptAccess:'always'}
	Object.extend(param, options);
	var id='id="'+param.id+'"';
	var name = 'name="'+param.id+'"';
	var p='',e='';	
	for(i in param) {
		if(i=='id')continue;
		p+='<param name="'+i+'" value="'+param[i]+'">\n';
		e+=i+'="'+param[i]+'" ';
	}
	var s='<object '+id+' width="'+w+'" height="'+h+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0">';
	s+='<param name="movie" value="'+f+'">'+ p;	
	s+='<embed '+name+' src="'+f+'" width="'+w+'" height="'+h+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" '+e+'/>';
	s+='</object>';
	document.write(s);
	return s;
};
UI.embedWMP=function(f,width,height,options){
	var param={	id:"UIwmp_"+f,autostart:'1',showstatusbar:'-1',transparentatstart:'1',displaybackcolor:'0',uimode:'full'}
	Object.extend(param, options);
    var w = (width)? width : 330;
    var h = (height)? height : 315;
	var id='id="'+param.id+'" name="'+param.id+'"';
	var p='',e='';
	for(i in param){
		if(i=='id')continue;
		p+='<param name="'+i+'" value="'+param[i]+'">\n';
		e+=i+'="'+param[i]+'" ';
	}
	var s='<object '+id+' width="'+w+'" height="'+h+'" classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject" style="filter:gray();">';
	s+='<param name="filename" value="'+f+'">'+ p;
	s+='<embed '+id+' src="'+f+'" width="'+w+'" height="'+h+'" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/windows/mediaplayer/" '+e+' />';
	s+='</object>';
	document.write(s);
};
UI.getStyle=function(el, style){
	var value = el.style[style];
	if(!value){
		if(document.defaultView && document.defaultView.getComputedStyle) {
			var css = document.defaultView.getComputedStyle(el, null);
			value = css ? css[style] : null;
		}else if (el.currentStyle) value = el.currentStyle[style];
	}
	return value == 'auto' ? null : value;
};
UI.getPosition=function(el)
{
	var left=0,top=0;
	while(el){
		left+=el.offsetLeft || 0;
		top+=el.offsetTop || 0;
		el=el.offsetParent;
	}
	return {'x': left, 'y': top}
};
UI.getScroll=function () {
	if(document.all && typeof document.body.scrollTop != "undefined"){
		var cont=document.compatMode!="CSS1Compat"?document.body:document.documentElement;
		return {left:cont.scrollLeft, top:cont.scrollTop, width:cont.clientWidth, height:cont.clientHeight}
	}else 
		return {left:window.pageXOffset, top:window.pageYOffset, width:window.innerWidth, height:window.innerHeight}
};
UI.submit=function(f) { 
	var form=UI.$(f)||document.forms[f];	
	if(form.onsubmit && !form.onsubmit()) return;
	form.submit();
};
UI.focus=function(n) { 
	var s=null;
	s = UI.$(n)||document.getElementsByName(n)[0];
	s.focus();
};
UI.$F=function(n) {
	var s=null;
	s = UI.$(n)||document.getElementsByName(n)[0];
	if(s.type=="checkbox"){
		var c=[];
		var r=document.getElementsByName(n);
		for(var i=0;i<r.length; i++) if(r[i].checked) c.push(r[i].value);
		return (c.length>0)?c:"";
	}else if(s.type=="radio"){
		var r=document.getElementsByName(n);
		for(var i=0;i<r.length; i++) if(r[i].checked) return r[i].value;
		return "";
	}
	return s.value;
};
UI.length=function(str,len,tail){
	if(!tail) tail="";
	var l=0, c=0, l2=0, u="", s="";
	if(len>0) l2=len;	
	for(var i=0;u=str.charCodeAt(i);i++){
		if (u>127) l+=2;
		else l++;
		if(l2) {
			s+=str.charAt(i); 
			if(l>=l2){
				if(l>l2) s=s.slice(0,-1);
				return s+tail;
			}
		}		
	}
	return l2 ? s:l;
};
UI.html2str=function(s,m){
	var s1=["&amp;","&#39;","&quot;","&lt;","&gt;"];
	var s2=["&","'","\"","<",">"];
	var s3=[];
	if(m) {s3=s1;s1=s2;s2=s3;}
	for(var i in s1) s=s.replace(new RegExp(s1[i],"g"), s2[i]);
	return s;
};
UI.setOpacity=function(el,value){
	el.style.filter="alpha(opacity="+value+")";
	el.style.opacity=(value/100);
	el.style.MozOpacity=(value/100);
	el.style.KhtmlOpacity=(value/100);
};
UI.indexOf=function(arr,s){
	for(var i=0;i<arr.length; i++) if(arr[i]==s) return i;
	return -1;
};
UI.resizeImage=function(img,w,h){
	var t = new Image();
	t.src=img.src;	
	if(t.width==0 || t.height==0) return;
	if(t.width>w || t.height >h){
		img.width=w;img.height=h;
		if((t.width/w) > (t.height/h) )	img.height=Math.round(t.height * (w / t.width));
		else img.width = Math.round(t.width *  (h / t.height));
	}else{
		img.width=t.width;
		img.height=t.height;
	}
	if(img.width==0 || img.height==0) setTimeout(function(){UI.resizeImage(img,w,h)},500);
};
UI.StringBuffer=function(){this.buffer=new Array()}
UI.StringBuffer.prototype={append:function(s){this.buffer.push(s)},toString:function(){return this.buffer.join("")}};
UI.parseQuery=function(){
	var r=[],t=[];
	var a=location.search.substr(1).split('&');
	for(i=0;i<a.length;i++){t=a[i].split("=");r[t[0]] = t[1];}
	return r;
};
UI.addComma=function(s){
	s+='';
	var re = new RegExp('(-?[0-9]+)([0-9]{3})'); 
	while(re.test(s)) s = s.replace(re, '$1,$2'); 
	return s;
}; 
/* 2008-01-31  UI.Ajax.js */
UI.Ajax = function(options) {
	this.options={
		method:'GET',
		param:'',
		onComplete:null,
		onError:null,
		asynchronous: true,
		contentType: 'application/x-www-form-urlencoded',
		encoding:'UTF-8'
	}
	Object.extend(this.options, options);
	if(this.options.url) this.send();
};
UI.Ajax.prototype={
	getReq:function(){
		var req=null;
		try { req = new XMLHttpRequest(); }
		catch(e){
			try { req = new ActiveXObject("Msxml2.XMLHTTP"); }
			catch(e){
				try { req = new ActiveXObject("Microsoft.XMLHTTP"); }
				catch(e) { }
			}
		}
		return req;
	},
	send:function(){
		this.req = this.getReq();	
		var op=this.options;
		var url=op.url;
		var param=op.param;
		var method=op.method.toUpperCase();
		if(method=='GET' && param) url=url+"?"+param;
		this.req.open(method, url, op.asynchronous);
		this.req.setRequestHeader('Content-Type', op.contentType+';charset='+op.encoding);
		var self = this;
		this.req.onreadystatechange = function() { self.onStateChange.call(self) }
		this.req.send(method=='POST'?param:null);
	},
	onStateChange: function() {
		if(this.req.readyState==4){
			if(this.req.status=="200") this.options.onComplete(this.req.responseText.replace(/<script(.|\s)*?\/script>/g,""));
			else{
				alert("数据读取错误！请稍后再试！");
			}				
		}
	}
};
/* 2008-01-31 UI.Tab.js */
UI.Tab=function(cid,count,options){
	this.options={
		snum:1,					
		event_type:'mouseover', //mouseover,click
		menu_type:'img',		//img,css
		class_over:'on',		//over   css
		onChange:null			
	}
	Object.extend(this.options, options);
	this.cid=cid;
	this.count=count;
	var menu;
	for(var i=1; i<=count; i++){
		menu=UI.$("menu_"+cid+"_"+i);
		menu.n=i;
		menu.css=menu.className;
		var self=this;
		menu['on'+this.options.event_type]=function(){ self.on(this.n) }
	}
	this.on(this.options.snum);
}
UI.Tab.prototype = {
	on : function(n){
		this.n=n;
		var type=this.options.menu_type;
		for(var k=1; k<=this.count; k++){
			UI.$("div_"+this.cid+"_"+k).style.display="none";
			if(type=='img')	UI.$("menu_"+this.cid+"_"+k).src=UI.$("menu_"+this.cid+"_"+k).src.replace("on.","off.");
			else UI.$("menu_"+this.cid+"_"+k).className=UI.$("menu_"+this.cid+"_"+k).css;	
		}
		UI.$("div_"+this.cid+"_"+n).style.display="block";
		if(type=='img')	UI.$("menu_"+this.cid+"_"+n).src=UI.$("menu_"+this.cid+"_"+n).src.replace("off.","on.");
		else UI.$("menu_"+this.cid+"_"+n).className= UI.$("menu_"+this.cid+"_"+n).css +' '+this.options.class_over;
		if(this.options.onChange) this.options.onChange.call(this);
	}
};

/* 2008-01-31 UI.Rolling.js */
UI.Rolling=function(cid,count,interval,n) {
	this.cid = cid;
	this.count = count;	
	this.n = (n)?n:"1";
	this.onchange = null;
	for(var k=1; k<=this.count; k++) UI.$(this.cid+"_"+k).style.display="none";
	UI.$(this.cid+"_"+this.n).style.display="block";
	this.div = UI.$(this.cid);// div
	this.div.onmouseover=function(){this.isover=true; }
	this.div.onmouseout=function() {this.isover=false;}
	this.btn_next = UI.$("btn_"+this.cid+"_next");
	this.btn_prev = UI.$("btn_"+this.cid+"_prev");
	var self=this;
	if(this.btn_next) this.btn_next.onclick=function(){self.next() }
	if(this.btn_prev) this.btn_prev.onclick=function(){self.prev() }
	if(interval>0) setInterval(function(){self.play()}, interval);
}
UI.Rolling.prototype = {
	play : function() {
		if(this.div.isover) return;
		this.next();
	},
	change :function(){
		if(this.onchange) this.onchange();
	},
	prev :function(){
		UI.$(this.cid+"_"+this.n).style.display="none";
		this.n=(this.n==1)?this.count:--this.n;
		UI.$(this.cid+"_"+this.n).style.display="block";
		this.change();
	},
	next :function(){
		UI.$(this.cid+"_"+this.n).style.display="none";
		this.n=(this.n==this.count)? 1:++this.n;
		UI.$(this.cid+"_"+this.n).style.display="block";
		this.change();
	},
	random : function() {
		var rn=Math.round((this.count-1)*Math.random());
		for(var i=0;i<rn;i++) this.next();
	}
};
/* 2008-01-31 UI.Calender.js */
UI.Calender = function(year,month){
	var d=new Date();
	if(year) d.setFullYear(year);
	if(month) d.setMonth(month-1);
	this.day=d;
	this.day_sweek=-1;
	this.ymd=this.getYMD(d);
	this.today=new Date();
	this.today_ymd=this.getYMD(this.today);
	this.selday=null;
	this.selday_ymd="";
	this.selbox=null;
	this.is_draw=0;
	this.is_show=0;
	this.show_el=null;
	this.pid = "UI_Calender"+String(Math.random()).substring(2,6);
};
UI.Calender.prototype={
	setBox:function(num,ymd,type){ //type 1:prev,2:next,0:now
		var box=UI.$(this.pid+"_"+num);
		box.ymd=ymd;			
		if(type==1) box.className="UICalender_box_prev";
		else if(type==2) box.className="UICalender_box_next";
		else {
			box.className="UICalender_box";			
			if(ymd==this.today_ymd) box.className="UICalender_box_today";
		}
		box.innerHTML=ymd.substring(6,8);
		var self=this;
		if(this.onClick) box.onclick=function(){ self.onClick(box) };
	},
	getYMD :function(date){
		var y=date.getFullYear();
		var m=date.getMonth()+1;
		if(m<10) m="0"+m;
		var d=date.getDate();
		if(d<10) d="0"+d;
		return y+""+m+""+d;
	},
	getLastDay :function(date){
		return new Date(date.getFullYear(),date.getMonth()+1,0).getDate();
	},
	getSweek:function(date){
		return new Date(date.getFullYear(),date.getMonth(),1).getDay();
	},
	goPrev:function(){
		this.draw(this.day.getFullYear(), this.day.getMonth()-1);
	},
	goNext:function(){
		this.draw(this.day.getFullYear(), this.day.getMonth()+1);
	},
	goToday:function(){
		this.draw(this.today.getFullYear(), this.today.getMonth());
	},
	show:function(el){
		this.show_el=el;
		var pos=UI.getPosition(el);
		var ifa=parent.document.getElementById('UICalenderIfa');
		if(!this.is_show){
			UI.addEvent(parent.document,"mousedown",function(){ ifa.style.display='none' })
			this.is_show=1;
		}
		if(this.selbox)	this.selbox.className="UICalender_box";	

		var str=el.value.replace(/[^0-9]/g,"");		
		if(str.length==8){//
			var selday=new Date(str.substring(0,4), str.substring(4,6)-1, str.substring(6,8));
			this.draw(selday.getFullYear(), selday.getMonth());
			
			var d=selday.getDate();
			var n1=Math.ceil((d+this.day_sweek)/7) - 1;
			var n2= d-(1+(7*n1)-this.day_sweek);
			this.selbox=UI.$(this.pid+"_"+n1+""+n2);
			this.selbox.className="UICalender_box_selday";
		}
		ifa.style.top=pos.y+el.offsetHeight+"px";
		ifa.style.left=pos.x+"px";
		ifa.style.display="block";
	},
	print:function(){
		var s=this.skin();
		document.write('<div id="'+this.pid+'">'+s+'</div>');
		var day=this.day;
		var selyear=UI.$(this.pid+"_selyear");
		var selmonth=UI.$(this.pid+"_selmonth");
		var btnprev=UI.$(this.pid+"_btnprev");
		var btnnext=UI.$(this.pid+"_btnnext");
		try{
			var self=this;
			UI.addEvent(selyear, "change", function(){
				self.draw(selyear.value, selmonth.value - 1);
			});
			UI.addEvent(selmonth, "change", function(){
				self.draw(selyear.value, selmonth.value - 1);
			});
			UI.addEvent(btnprev, "click", function(){self.goPrev()});
			UI.addEvent(btnnext, "click", function(){self.goNext()});
		}catch(e){}
		this.draw(day.getFullYear(), day.getMonth());
	},
	draw:function(year,month){
		var day=this.day;
		if(this.is_draw) if(year==day.getFullYear() && month==day.getMonth()) return;
		this.is_draw=1;
		day.setFullYear(year);
		day.setMonth(month);		
		this.day_sweek=this.getSweek(day);
		try{
			UI.$(this.pid+"_selyear").value=day.getFullYear();
			UI.$(this.pid+"_selmonth").value=day.getMonth()+1;
		}catch(e){}
		var d0=new Date(year,month,1);
		d0_lastday=this.getLastDay(d0);
		var d1=new Date(year,month-1,1);	 
		var d2=new Date(year,month+1,1);	 
		var d1_lastday=this.getLastDay(d1);
		var num=null;
		var d0_day=1,d2_day=1;
		for(var i=0; i<6; i++) {			
			for(var j=0; j<7; j++) {
				num=i+""+j;
				if(i==0 && j<this.day_sweek) { 
					d1.setDate( d1_lastday - (this.day_sweek-j) + 1 );
					this.setBox(num, this.getYMD(d1),1)					
				}else if(d0_day>d0_lastday){
					d2.setDate(d2_day++);
					this.setBox(num, this.getYMD(d2),2)
				}else {
					d0.setDate(d0_day++);
					this.setBox(num, this.getYMD(d0),0)
				}
			}
		}
	},
	skin:function(){}
};
 
UI.setClip=function(s,m){
	try{
		var swf=(navigator.appName.indexOf("Microsoft")!=-1)?window['UIclipSwf']:document['UIclipSwf'];
		swf.setClip(s);alert(m);
	}catch(e){
		alert("在您的浏览器不支持");
	}
}
UI.setClip.url='http://photo-media.daum-img.net/js/media3/rssClip.swf'; //请使用本服务上传到服务器
UI.setClip.print=function(){
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="1" height="1" id="UIclipSwf"><param name="allowScriptAccess" value="always" /><param name="movie" value="'+UI.setClip.url+'" /><embed src="'+UI.setClip.url+'" width="1" height="1" name="UIclipSwf" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /><\/object>');
}
/* 2008-01-31 UI.Drag.js */
UI.Drag=function(drag, options){
	var el=UI.$(drag);
	el.options={
		handle:'',
		container:'',
		move_mode:'',	//1:horizontal 2,vertical
		limit_top:-1,
		limit_bottom:-1,
		limit_left:-1,
		limit_right:-1,
		onStart:null,
		onStop:null,
		onDrag:null
	}
	Object.extend(el, el.options);
	Object.extend(el, options);
	el.isdrag=true;
	el.width=0;el.height=0;
	el.area_width=0;el.area_height=0;
	UI.Drag.setXY(el);
	if(el.handle){
		el.handle=UI.$(el.handle);
		el.isdrag=false;
		el.handle.isdrag=true;
		el.handle.target=el;
	}
	if(el.container){
		UI.$(el.container).style.position="relative";
		el.width=parseInt(UI.getStyle(el,"width")) || el.offsetWidth;
		el.height=parseInt(UI.getStyle(el,"height")) || el.offsetHeight;
		el.area_width=parseInt(UI.getStyle(UI.$(el.container),"width")) || UI.$(el.container).offsetWidth;
		el.area_height=parseInt(UI.getStyle(UI.$(el.container),"height")) || UI.$(el.container).offsetHeight;	
	}
	this.obj=el;
};
UI.Drag.setXY=function(el){
	var pos=UI.getPosition(el);
	el.x=parseInt(UI.getStyle(el,"left"));
	el.y=parseInt(UI.getStyle(el,"top"));
	if(isNaN(el.x)) el.x=pos.x;
	if(isNaN(el.y)) el.y=pos.y;
};
UI.Drag.start=function(event){
	var e=event || window.event; var el=e.target || e.srcElement;	
	if(el.sliderKnob) el=UI.$(el.sliderKnob);//UI.Slider
	if(!el.isdrag) return;
	if(el.target) el=el.target;
	_uiDrag.obj=el;
	UI.Drag.setXY(el);
	_uiDrag.gx = e.clientX;
	_uiDrag.gy = e.clientY;
	if(el.onStart) el.onStart.call(el);
	if(el.onStop) _uiDrag.onStop=el.onStop;
	if(el.onDrag) _uiDrag.onDrag=el.onDrag;
};
UI.Drag.move=function(event){	
	var drag=_uiDrag.obj;
	if(!drag) return;
	var e=event || window.event; var el=e.target || e.srcElement;
	var top =drag.y + e.clientY - _uiDrag.gy;
	var left=drag.x + e.clientX - _uiDrag.gx;
	if(drag.area_width && drag.area_height){
		if(top<=0) top=0;
		else if(top >= drag.area_height-drag.height) top=drag.area_height-drag.height; 
		if(left<=0) left=0;
		else if(left >= drag.area_width-drag.width) left=drag.area_width-drag.width; 
	}
	if(drag.limit_top>-1 && top<drag.limit_top) top=drag.limit_top;
	if(drag.limit_bottom>-1 && top>drag.limit_bottom) top=drag.limit_bottom;
	if(drag.limit_left>-1 && left<drag.limit_left) left=drag.limit_left;
	if(drag.limit_right>-1 && left>drag.limit_right) left=drag.limit_right;	
	if(!drag.move_mode || drag.move_mode==2) drag.style.top = top+"px";
	if(!drag.move_mode || drag.move_mode==1) drag.style.left = left+"px";	
	if(_uiDrag.onDrag) _uiDrag.onDrag.call(drag);
};
UI.Drag.end=function(event){
	if(_uiDrag.onStop) _uiDrag.onStop.call(_uiDrag.obj);
	_uiDrag.obj=null;	
	_uiDrag.onStop=null;
	_uiDrag.onDrag=null;
};

var _uiDrag={};
UI.addEvent(document, "mousedown", UI.Drag.start );
UI.addEvent(document, "mousemove", UI.Drag.move );
UI.addEvent(document, "mouseup", UI.Drag.end );
/* 2008-01-31 UI.Move.js */
UI.Move=function(id) {
	this.id=id;
	this.div=UI.$(id);
	this.x= parseInt(UI.getStyle(this.div,'left'))||0;
	this.y= parseInt(UI.getStyle(this.div,'top'))||0;
};
UI.Move.prototype={
	slide : function(pos) {
		this.pos = pos;
		this.pos_n = 0;
		this.speed=0.3;
		this.inteval = 20;
		this.setPos();
		this.playing =true;
		var self=this;
		this.tid=setInterval(function(){self.play()}, this.inteval);
	},
	play : function() {
		this.x += (this.x2-this.x)*this.speed;		
		this.y += (this.y2-this.y)*this.speed;
		this.set(this.x,this.y);
		if(Math.round(this.x)==this.x2 && Math.round(this.y)==this.y2){
			this.x=Math.round(this.x);
			this.y=Math.round(this.y);
			this.set(this.x,this.y);
			if(this.pos_n>=this.pos.length)	{this.playing=false; clearInterval(this.tid)}
			else this.setPos();
		}
	},
	setPos:function(){
		var arr=this.pos[this.pos_n].split(",");
		this.x2 = arr[0];
		this.y2 = arr[1];
		this.pos_n++;
	},
	set:function(x,y){
		this.div.style.left = x+"px";
		this.div.style.top = y+"px";
	}
};
/* 2008-01-31 UI.Slider.js */
UI.Slider=function(area,knob,options) {
	this.options={
		onSlide:null,
		onChange:null,
		max_value:100,
		move_value:5,
		value:0,
		wheel_area:'',	//运动检测领域的鼠标滚轮
		mode:1			//1:horizontal 2,vertical
	}
	Object.extend(this.options, options);
	this.value=this.options.value;
	this.max_value=this.options.max_value;
	this.area=UI.$(area);
	this.knob=UI.$(knob);
	this.area.width=parseInt(UI.getStyle(this.area,"width"));
	this.area.height=parseInt(UI.getStyle(this.area,"height"));
	this.knob.width=parseInt(UI.getStyle(this.knob,"width"));
	this.knob.height=parseInt(UI.getStyle(this.knob,"height"));
	this.track_length = (this.options.mode==1) ? this.area.width-this.knob.width:this.area.height-this.knob.height;
	var self=this;
	this.drag=new UI.Drag(knob, {
		container:area,
		move_mode:this.mode,
		onDrag:function(){self.slide()},
		onStop:function(){self.change()}
	});	
	this.area.sliderKnob=knob;
	UI.addEvent(this.area, "mousedown", function(event){ self.moveKnobClientXY.call(self,event) });
	UI.addEvent(this.area, 'mousewheel',function(event){ self.wheelScroll.call(self,event) });
	if(this.options.wheel_area)	UI.addEvent(UI.$(this.options.wheel_area), 'mousewheel',function(event){ self.wheelScroll.call(self,event) });
	if(this.value>0){
		if(this.options.mode==1) this.knob.style.left=this.val2pos()+"px";
		else this.knob.style.top=this.val2pos()+"px";
	}
};
UI.Slider.prototype={
	pos2val:function() {
		var val=Math.floor( parseInt(this.getKnobPos()) * this.max_value / this.track_length);
		if(val<0) val=0;
		else if(val>this.max_value) val=this.max_value;
		this.value=val;
		return val;
	},
	val2pos:function(value) {
		if(!value) value=this.value;
		var pos=Math.floor( value * this.track_length / this.max_value);
		return pos;
	},
	getKnobPos:function(){
		return (this.options.mode==1) ? this.knob.style.left:this.knob.style.top;
	},
	setKnobPos:function(pos){
		if(this.options.mode==1) this.knob.style.left=pos+'px';
		else this.knob.style.top=pos+'px';
	},
	moveKnobClientXY:function(event){
		var e=event || window.event; var el=e.target || e.srcElement;
		var pos=0;
		var scroll = UI.getScroll();
		if(this.options.mode==1) {
			pos=e.clientX-UI.getPosition(this.area).x+scroll.left-(this.knob.width/2);
			if(pos<0) pos=0;
			else if(pos>this.area.width-this.knob.width) pos=this.area.width-this.knob.width;
			this.setKnobPos(pos);
		}else{
			pos=e.clientY-UI.getPosition(this.area).y+scroll.top-(this.knob.height/2);
			if(pos<0) pos=0;
			else if(pos>this.area.height-this.knob.height) pos=this.area.height-this.knob.height;
			this.setKnobPos(pos);
		}
		this.change();
	},
	moveKnob:function(type,event){
		if(type=='up' && this.value<this.max_value){//value up
			this.value+=this.options.move_value;
			if(this.value>this.max_value) this.value=this.max_value; 
			this.setKnobPos(this.val2pos());
			this.change();
			if(event)UI.stopEvent(event);
		}else if(type=='down' && this.value>0){ //value down
			this.value-=this.options.move_value;
			if(this.value<0) this.value=0; 
			this.setKnobPos(this.val2pos());
			this.change();
			if(event)UI.stopEvent(event);
		}	
	},
	wheelScroll:function(event){
		var delta=UI.getEventWheel(event);
		var type = (delta<0)? 'up':'down';
		this.moveKnob(type,event);
	},
	down:function(el){
		var self=this;
		self.moveKnob('down');
		UI.s_interval=setInterval( function(){self.moveKnob('down')}, 100);
		if(!el.isMouseup){
			UI.addEvent(el, "mouseup",  function(){clearInterval(UI.s_interval)});
			UI.addEvent(el, "mouseout", function(){clearInterval(UI.s_interval)});
			el.isMouseup=true;
		}
	},
	up:function(el){
		var self=this;
		self.moveKnob('up');
		UI.s_interval=setInterval( function(){self.moveKnob('up')}, 100);
		if(!el.isMouseup){
			UI.addEvent(el, "mouseup",  function(){clearInterval(UI.s_interval)});
			UI.addEvent(el, "mouseout", function(){clearInterval(UI.s_interval)});
			el.isMouseup=true;
		}
	},
	slide:function(){
		this.pos2val();
		if(this.options.onSlide) this.options.onSlide.call(this);
	},
	change:function(){
		this.pos2val();
		if(this.options.onChange) this.options.onChange.call(this);
	}
};

function LM_Display2(id,index,loop){
  var R_Id="r_"+id;
  var C_Id="c_"+id;
  for (var i=1; i<=loop; i++){	
    if (index == i) {
      thisMenu = document.getElementById(R_Id + index);
      thisTit = document.getElementById(C_Id + index);
      if(thisMenu.style.display=="block"){
        thisMenu.style.display = "none";
        thisTit.className = (thisTit.className).replace("c_M2_b", "");
      }else{
        thisMenu.style.display = "block";
        thisTit.className += " c_M2_b";
      }
    }else{
      otherMenu = document.getElementById(R_Id + i);
	  otherTit = document.getElementById(C_Id + i);
      otherMenu.style.display = "none";
      otherTit.className = (otherTit.className).replace("c_M2_b", "");
    }
  }
}
function DisplayMenu(id,index,loop) {
var thisMenu;
for (var i=1; i<=loop; i++)				
	if (index == i) {
		thisMenu = document.getElementById(id + index);
		thisMenu.style.display = "block";
	}else{
		otherMenu = document.getElementById(id + i);
		otherMenu.style.display = "none";
	}
}
function ReverseDisplayMenu(id,index,loop) {
var thisMenu;
for (var i=1; i<=loop; i++)				
	if (index == i) {
		thisMenu = document.getElementById(id + index);
		thisMenu.style.display = "none";
	}else{
		otherMenu = document.getElementById(id + i);
		otherMenu.style.display = "block";
	}
}
function ViewG(id,index,loop) {
	DisplayMenu(id,index,loop);
	UI.$('S_layer1').style.display='none';
}
function LM_Display(id,index,loop){
	var M_Id="c_"+id;
	ReverseDisplayMenu(M_Id,index,loop);
	var R_Id="r_"+id;
	DisplayMenu(R_Id,index,loop);
}
//Paging
function paging(cid){
    if(UI.$(cid)){
        var img = UI.$(cid).getElementsByTagName("img");
        for(i=0; i<img.length; i++)  UI.rollOver(img[i]);
    }
}
//RSS DIV
function openRssDiv(event){
    var el= UI.getEl(event);
    var div_sub = UI.$("rss");
    if(div_sub.style.display=='block') {div_sub.style.display='none'; return; }
    else{div_sub.style.display='block';}
    var pos=UI.getPosition(el);
    div_sub.style.top = 0;
    div_sub.style.right = 0;
    div_sub.style.display='block';
    UI.$("rss_close").onclick = function(){div_sub.style.display='none'; return false;}
    UI.stopEvent(event);
}

UI.DynamicScript=function(url,enc){
	this.url=url||'';
	this.enc=enc||'';
	this.head=document.getElementsByTagName("head").item(0);
	if(this.url) this.call(this.url);
};
UI.DynamicScript.prototype={
	noCacheParam:function(){
		var b=(this.url.indexOf('?')==-1) ? '?':'&';
		return b+'nOcAchE='+(new Date()).getTime();
	},
	call:function(url){
		try{this.head.removeChild(this.script)}catch(e){};
		this.url=url;
		this.script = document.createElement("script");
		this.script.setAttribute("type", "text/javascript");   
		this.script.setAttribute("src", this.url+this.noCacheParam());
		if(this.enc) this.script.setAttribute("charset", this.enc);
		this.head.appendChild(this.script);
	}
};
//*** by ezsharp Start ***
getNodeValue = function(node) { //sectionTop_pastHeadline & issueSubTop
  nodeList = node.childNodes;
  for(var j=0; j<nodeList.length; j++){
    if(nodeList.item(j).nodeName != "#text"){
      return nodeList.item(j).nodeValue;
    }
  }
};
loadXML = function(method,url,is_async){ //sectionTop_pastHeadline & issueSubTop
  if(window.XMLHttpRequest) _req = new XMLHttpRequest();
  else _req = new ActiveXObject("Microsoft.XMLHTTP");
  _req.open(method,url,is_async);
  _req.onreadystatechange=newsProcessReqChange;
  _req.send(null);
};
newsProcessReqChange = function (){ //sectionTop_pastHeadline & issueSubTop
  if (_req.readyState == 4){
    if (_req.status == 200){
      drawXML(_req.responseXML);
    }
  }
};
UI.ImgCssTab=function(cid,count,options){ //image & css 
	this.options={
		snum:1,					
		event_type:'mouseover', 
		menu_type:'img',		//img,css
		class_over:'on',		
		onChange:null			
	}
	Object.extend(this.options, options);
	this.cid=cid;
	this.count=count;
	var menu;
	for(var i=1; i<=count; i++){
		menu=UI.$("menu_"+cid+"_"+i);
		menu.n=i;
		menu.css=menu.className;
		var self=this;
		menu['on'+this.options.event_type]=function(){ self.on(this.n) }
	}
	this.on(this.options.snum);
};
UI.ImgCssTab.prototype = {
	on : function(n){
	  this.n=n;
	  var type=this.options.menu_type;
	  for(var k=1; k<=this.count; k++){
		UI.$("div_"+this.cid+"_"+k).style.display="none";
		UI.$("menu_"+this.cid+"_"+k).src=UI.$("menu_"+this.cid+"_"+k).src.replace("on.","off.");
		if(UI.$("a_"+this.cid+"_"+k)) UI.$("a_"+this.cid+"_"+k).className=UI.$("a_"+this.cid+"_"+k).css;
	  }
	  UI.$("div_"+this.cid+"_"+n).style.display="block";
	  UI.$("menu_"+this.cid+"_"+n).src=UI.$("menu_"+this.cid+"_"+n).src.replace("off.","on.");
	  if(UI.$("a_"+this.cid+"_"+n)) UI.$("a_"+this.cid+"_"+n).className= UI.$("a_"+this.cid+"_"+n).css +' '+this.options.class_over;
	  if(this.options.onChange) this.options.onChange.call(this);
	  preidx = this.n-1;
	  if(preidx>0) UI.$("a_"+this.cid+"_"+preidx).className = "noBG";
	}
};
UI.$outerText=function(n) {
var s=null;
s = UI.$(n)||document.getElementsByName(n)[0];
return s.childNodes[0].nodeValue;
};
//*** by ezsharp End ***
function setPngImg(obj) {
obj.width=obj.height="1";
obj.className=obj.className.replace(/\bpng\b/i,'');
obj.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"
obj.src=''; 
return '';}

var RW={
	Issue:function(){
		IssueStr = new UI.StringBuffer();	
		try{
			IssueStr.append("<dl class=\"dl\">");
			IssueStr.append("<dd class=\"fl\"><a href=\""+RIssue.newurl+"\"><img src=\""+RIssue.img+"\" width=\"75\" height=\"52\" alt=\""+RIssue.title+"\" class=\"R_img\" \/><\/a><br \/><\/dd>");
			var icon=(RIssue.icontype=="issue")?"b":"b2";
			IssueStr.append("<dt class=\"dt\"><a href=\""+RIssue.newurl+"\" class=\""+icon+"\">"+RIssue.title+"<\/a><br \/><\/dt>");
			IssueStr.append("<dd class=\"txt\"><a href=\""+RIssue.newurl+"\">"+RIssue.newtitle+"<\/a><br \/><\/dd>");
			IssueStr.append("<\/dl><p class=\"clr\">");	
		}catch(e){}
	},
	PNew:function(Sector,Target){
		try{
			var newStr = new UI.StringBuffer();	
			var rMenu=eval(Sector);	
			if(Target.indexOf('1')>0)
				newStr.append("<a href=\"#\" onclick=\"return false;\"><img src=\"/Images/media3/common/i_rss1.gif\" width=\"11\" height=\"11\" alt=\"RSS\" class=\"rss\" /></a>");
			if(Target.indexOf('2')>0)
				newStr.append("<a href=\"#\" onclick=\"return false;\"><img src=\"/Images/media3/common/i_rss1.gif\" width=\"11\" height=\"11\" alt=\"RSS\" class=\"rss\" /></a>");
			if(Target.indexOf('3')>0)
				newStr.append("<a href=\"#\" onclick=\"return false;\"><img src=\"/Images/media3/common/i_rss1.gif\" width=\"11\" height=\"11\" alt=\"RSS\" class=\"rss\" /></a>");
			newStr.append("<ul class=\"li\">");
			
			for(var i=1;i<=rMenu.length-1;i++){
				if(rMenu[i].bold=="Y"){
				newStr.append("<li><a href=\""+rMenu[i].url+"\" class=\"b\">"+rMenu[i].title+"<\/a><\/li>");
				}else{
				newStr.append("<li><a href=\""+rMenu[i].url+"\">"+rMenu[i].title+"<\/a><\/li>");
				}
			}
			newStr.append("<\/ul>");
			newStr.append("<div class=\"P\"><a href=\""+rMenu[0]+"\">更多..<\/a><\/div>");
			var tmpStr=newStr.toString()+IssueStr.toString();
			UI.$(Target).innerHTML=tmpStr;
			//alert(IssueStr.toString())
		}catch(e){}
	},
	Sec:function(Sector,Target){
		try{		
			var secStr = new UI.StringBuffer();	
			var rSec=eval(Sector);
				secStr.append("<dl class=\"R_dl\">");
				secStr.append("<dd class=\"fl\"><a href=\""+rSec[0].url+"\" class=\"b\"><img src=\""+rSec[0].img+"\" width=\"75\" height=\"52\" alt=\""+rSec[0].title+"\" class=\"R_img\" \/><\/a><br \/><\/dd>");
				secStr.append("<dt class=\"dt\"><a href=\""+rSec[0].url+"\" class=\"b\">"+rSec[0].title+"<\/a><br \/><\/dt>");
				secStr.append("<\/dl><p class=\"clr\">");
				secStr.append("<ul class=\"R_li\">");
			for(var i=1;i<=rSec.length-1;i++){
				if(rSec[i].bold=="Y"){
				secStr.append("<li><a href=\""+rSec[i].url+"\"  class=\"b\">"+rSec[i].title+"<\/a><\/li>");
				}else{
				secStr.append("<li><a href=\""+rSec[i].url+"\">"+rSec[i].title+"<\/a><\/li>");
				}
			}
				secStr.append("<\/ul>");
				secStr.append("<img src=\"/Images/media3/wing/tit_tvpot.gif\" alt=\"企业\" class=\"RSTab_tv\" width=\"224\" height=\"11\">");
				secStr.append("<ul class=\"R_li\">");
			//TV
			for(var i=0;i<=SecTvpot.length-1;i++){
				if(SecTvpot[i].bold=="Y"){
				secStr.append("<li><a href=\""+SecTvpot[i].url+"\" class=\"b\" target=\"_blank\">"+SecTvpot[i].title+"<\/a><\/li>");
				}else{
				secStr.append("<li><a href=\""+SecTvpot[i].url+"\" target=\"_blank\">"+SecTvpot[i].title+"<\/a><\/li>");
				}
			}
				secStr.append("<\/ul>");
				var tmpStr=secStr.toString();
				UI.$(Target).innerHTML=tmpStr;
		}catch(e){alert("s")}
	}
};
var Lhm={
    Topnew:function(Sector,Target){
		try{
			var newStr = new UI.StringBuffer();	
			var rMenu=eval(Sector);	
			
			newStr.append("<ul>");
			for(var i=1;i<=rMenu.length-1;i++){
				if(rMenu[i].bold=="Y"){
				newStr.append("<li><a href=\""+rMenu[i].url+"\" class=\"b\">"+rMenu[i].title+"<\/a><\/li>");
				}else{
				newStr.append("<li><a href=\""+rMenu[i].url+"\">"+rMenu[i].title+"<\/a><\/li>");
				}
			}
			newStr.append("<\/ul>");
			var tmpStr=newStr.toString();
			UI.$(Target).innerHTML=tmpStr;
		}catch(e){}
	},
	Topnewimg:function(Sector,Target){
		try{
			var newStr = new UI.StringBuffer();	
			var rMenu=eval(Sector);	
			
			newStr.append("<ul>");
			for(var i=1;i<=rMenu.length-1;i++){
				if(rMenu[i].cs=="Y"){
				newStr.append("<li class=\"gap\"><p class=\"ph\"><a href=\""+rMenu[i].url+"\"><img src=\""+rMenu[i].img+"\" width=\"130\" height=\"91\" alt=\"\" /><\/a><\/p>");
				}else{
				newStr.append("<li><p class=\"ph\"><a href=\""+rMenu[i].url+"\"><img src=\""+rMenu[i].img+"\" width=\"130\" height=\"91\" alt=\"\" /><\/a><\/p>");
				}
				newStr.append("<p class=\"txt\"><a href=\""+rMenu[i].url+"\">"+rMenu[i].title+"<\/a><\/p><\/li>");
			}
			newStr.append("<\/ul>");
			var tmpStr=newStr.toString();
			UI.$(Target).innerHTML=tmpStr;
		}catch(e){}
	}
};
//左侧菜单 ON/OFF
var LM_subject=['LM_subject','society','politics','economic','foreign','culture','entertain','digital','editorial']
NaviSet=function(){
	var NowUrl = window.location.href;
	this.Qualify(NowUrl);
	this.Get();
	if(this.UrlArray[0]=="tvnews" && this.UrlArray.length>3)//if is in TV news
		this.UrlArray.length=this.UrlArray.length-1;
	this.Set();
};
NaviSet.prototype = {
	Qualify:function(Url){},
	Get:function(){
		var UrlArray = this.NowUrl.split('\/');
		if(UrlArray[(UrlArray.length-1)].indexOf(".")>-1||UrlArray[(UrlArray.length-1)].indexOf("?")>-1||UrlArray[(UrlArray.length-1)]=="")
			UrlArray.length=UrlArray.length-1;
		this.UrlArray=UrlArray			
	},	
	Set:function(){
		var Urldepth = this.UrlArray;
		var LocationText = "";
		var LMpath = "LM_" ;
		for(var i=0;i<Urldepth.length;i++){
			LMpath = LMpath + Urldepth[i]+ "_";
			try{LocationText+=(i==(Urldepth.length-1))?"<a href=\""+UI.$(LMpath).href+"\" class=\"b\">"+UI.$(LMpath).childNodes[0].nodeValue+"</a>":"<a href=\""+UI.$(LMpath).href+"\">"+UI.$(LMpath).childNodes[0].nodeValue+"</a> &gt; ";}catch(e){}
		}
		if(UI.$(LMpath))	
			UI.$(LMpath).className="b";
	}
}

UI.setCookie('today','',-1,'/','base.cndmy.com');
UI.setCookie('today','',-1,'/');

function topNews()
{

UI.toogle('TopNewsP');
}

function topNewswrite(data){
UI.$("TopNewsP").innerHTML=data;
}