//DD Tab Menu
var ddtabmenu={
	disabletablinks: false, ////Disable hyperlinks in 1st level tabs with sub contents (true or false)?
	currentpageurl: window.location.href.replace("http://"+window.location.hostname, "").replace(/^\//, ""), //get current page url (minus hostname, ie: http://www.dynamicdrive.com/)

definemenu:function(tabid, dselected){
	this[tabid+"-menuitems"]=null;
	ddtabmenu.init(tabid, dselected);
},

showsubmenu:function(tabid, targetitem){
	var menuitems=this[tabid+"-menuitems"]
 for (i=0; i<menuitems.length; i++){
		menuitems[i].className=""
		if (typeof menuitems[i].hasSubContent!="undefined")
			document.getElementById(menuitems[i].getAttribute("rel")).style.display="none"
	}
	targetitem.className="current"
	if (typeof targetitem.hasSubContent!="undefined")
		document.getElementById(targetitem.getAttribute("rel")).style.display="block"
},

isSelected:function(menuurl){
	var menuurl=menuurl.replace("http://"+menuurl.hostname, "").replace(/^\//, "")
	return (ddtabmenu.currentpageurl==menuurl)
},

init:function(tabid, dselected){
	var menuitems=document.getElementById(tabid).getElementsByTagName("a")
	this[tabid+"-menuitems"]=menuitems
	for (var x=0; x<menuitems.length; x++){
		if (menuitems[x].getAttribute("rel")){
			this[tabid+"-menuitems"][x].hasSubContent=true
			if (ddtabmenu.disabletablinks)
				menuitems[x].onclick=function(){return false}
		}
		else //for items without a submenu, add onMouseout effect
			menuitems[x].onmouseout=function(){this.className=""}
		menuitems[x].onmouseover=function(){ddtabmenu.showsubmenu(tabid, this)}
		if (dselected=="auto" && typeof setalready=="undefined" && this.isSelected(menuitems[x].href)){
			ddtabmenu.showsubmenu(tabid, menuitems[x])
			var setalready=true
		}
		else if (parseInt(dselected)==x)
			ddtabmenu.showsubmenu(tabid, menuitems[x])
	}
}
}

//用于首页头条文字切换
function show_intro(pre,pree,n,select_n,css) {
for (i = 1; i <= n; i++) {
var intro = document.getElementById(pre + i);
var cha = document.getElementById(pree + i);
intro.style.display = "none";
cha.className=css + "1";
if (i == select_n) {
intro.style.display = "block";
cha.className=css;
}
}
}
var tn = 1;
var tims_running = 0;
function change_headline(n){
show_intro('focus_text','focus_but',4,n,'on');
tn = n;
}
function mouse_on(n){
tims_running = 0;
change_headline(n);
}
function mouse_out(){
tims_running = 1;
}
function run()
{
if(tims_running == 1){
change_headline(tn);
tn++;
}
if(tn>=5)
{
tn = 1;
}
}
function startrun()
{
tims_running = 1;
tims = window.setInterval("run()",3000);
}
//用于头部导航鼠标移上去的高亮效果

function menuIcon(id){  
	var allElements = document.getElementById(id).getElementsByTagName("li");    
	for (var i=0; i < allElements.length; i++){   
		allElements[i].onmouseover = mouseGoesOver;   
		allElements[i].onmouseout = mouseGoesOut;   
	}   
} 
var curr='';  
function mouseGoesOver(){   
	curr = this.className;
	if(curr==''||curr=='undefined'){}
	else{this.className = this.className+" "+this.className+"On";}
}   
function mouseGoesOut(){
	
	if(curr==''||curr=='undefined'){}
	else{this.className = curr;}
}

/*
function menuIcon(id){
	if (document.getElementById(id)){
	var sfEls = document.getElementById(id).getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++){
		sfEls[i].onmouseover=function(){
			this.className+=(this.className.length>0? " ": "") + this.className+"On";
		}
		sfEls[i].onmouseout=function(){
			var curr = this.className;
			alert(curr);
			this.className=this.className.replace(new RegExp("^"+curr+"On\\b"),"");
		}
	}
}
}
*/
//用于头部导航行情中心下拉菜单和某些广告
function MM_findObj(n, d) { //v4.01
var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_showHideLayers() { //v6.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
obj.visibility=v; }
}
//用于内容随机切换
function tabContent(id,eName){
var id= document.getElementById(id);
var p = id.getElementsByTagName(eName);
for(i=0;i<p.length;i++){
hi_now = new Date();
if(i ==hi_now.getSeconds() % p.length){
p[i].className+=(p[i].className.length>0? " ": "") + "hidden";
}
else{
p[i].className=p[i].className.replace(new RegExp("( ?|^)hidden\\b"),"");
}
}
}
//用于内容向上滚动,有停顿
/**startmarquee(一次滚动高度,速度,停留时间,元素ID);**/
function startmarquee(lh,speed,delay,obj){
var t;
var p=false;
var o=document.getElementById(obj);
o.innerHTML+=o.innerHTML;
o.onmouseover=function(){p=true}
o.onmouseout=function(){p=false}
o.scrollTop = 0;
function start(){
t=setInterval(scrolling,speed);
if(!p) o.scrollTop += 1;
}
function scrolling(){
if(o.scrollTop%lh!=0){
o.scrollTop += 1;
if(o.scrollTop>=o.scrollHeight/2) o.scrollTop = 0;
}else{
clearInterval(t);
setTimeout(start,delay);
}
}
setTimeout(start,delay);
}
//用于图片无间隙向上滚动
var pcScroll=
{
"speed":30,
"init":function(mid,mid1,mid2)
{
this.moveid=document.getElementById(mid);
this.moveid1=document.getElementById(mid1);
this.moveid2=document.getElementById(mid2);
this.moveid2.innerHTML=this.moveid1.innerHTML;
},
"marquee":function (){ 
if(pcScroll.moveid2.offsetTop-pcScroll.moveid.scrollTop<=0)//当滚动至demo1与demo2交界时 
pcScroll.moveid.scrollTop-=pcScroll.moveid1.offsetHeight  //demo跳到最顶端 
else{ 
pcScroll.moveid.scrollTop++ 
} 
},
"startmove":function()
{
var MyMar=setInterval(pcScroll.marquee,30)
this.moveid.onmouseover=function() {clearInterval(MyMar)}
this.moveid.onmouseout=function() {MyMar=setInterval(pcScroll.marquee,30)}
}	
};
