//闪动的文字 
var colorchanged = document.getElementsByName('colorchanged');
function changecolor(){	
	for(var i=0;i<colorchanged.length;i++){
		colorchanged[i].style.color="red";
	}
	
}

function changecolor1(){
	for(var i=0;i<colorchanged.length;i++){
		colorchanged[i].style.color="green";
	}
}
setInterval(changecolor,500);
setInterval(changecolor1,500);
//---------------------------------------------------------------------
//来回变换的图片
var picchanged1 = document.getElementsByName('picchanged1');
var picchanged2 = document.getElementsByName('picchanged2');

function show1(){
	for(var i=0;i<picchanged1.length;i++){
		if(picchanged1[i]!=null){
			picchanged1[i].style.display='none';
		}
	}
	for(var i=0;i<picchanged2.length;i++){
		if(picchanged2[i]!=null){
			picchanged2[i].style.display='inline';
		}
	}	
}
function show2(){
	for(var i=0;i<picchanged1.length;i++){
		if(picchanged1[i]!=null){
			picchanged1[i].style.display='inline';
		}
	}
	for(var i=0;i<picchanged2.length;i++){
		if(picchanged2[i]!=null){
			picchanged2[i].style.display='none';
		}
	}
}
setInterval(show1,5000);
setInterval(show2,5000);
//---------------------------------------------------------------------


//去除空格
function toWord(str){
	var strCntext;
	var string_arr = str.split(" ");
	strCntext = "";
    for(i= 0; i < string_arr.length ; i++){
		strCntext += string_arr[i];
		if (i!=(string_arr.length-1)){
			strCntext +="&nbsp;";
		}
    }
	return strCntext;
}

function toBreakWord(str,intLen){
	var strLen;
	var strCntext;
	strLen = geth(str);
	if (strLen > intLen){
		strCntext = str.substring(0, intLen);
	}else{
		strCntext = str;
	}
	return strCntext;
}

function geth(o){ 
	str = o;
	var tmp = 0;
	for(var i=0;i<str.length;i++){
		tmp += 2 
	}
	return tmp; 
}


//---------------------------------------------------------------------
//首页“媒体联播”处的滑动门
function switchtab(id){
	if(id=="hanzy"){
		for(var i=1;i<3;i++){
			document.getElementById("hanzy"+i).style.display = 'block';
			document.getElementById('hanbs'+i).style.display = 'none';
			document.getElementById('hanws'+i).style.display = 'none';
		}
	}

	if(id=="hanbs"){
		for(var i=1;i<3;i++){
			document.getElementById("hanbs"+i).style.display = 'block';
			document.getElementById('hanws'+i).style.display = 'none';
			document.getElementById('hanzy'+i).style.display = 'none';
		}	
	}

	if(id=="hanws"){
		for(var i=1;i<3;i++){
			document.getElementById("hanws"+i).style.display = 'block';
			document.getElementById('hanbs'+i).style.display = 'none';
			document.getElementById('hanzy'+i).style.display = 'none';
		}
	}
}

//---------------------------------------------------------------------
//滑动门
function scrollDoor(){
}
scrollDoor.prototype = {
	sd : function(menus,divs,openClass,closeClass){
		var _this = this;
		if(menus.length != divs.length)
		{
			alert("菜单层数量和内容层数量不一样!");
			return false;
		}				
		for(var i = 0 ; i < menus.length ; i++)
		{	
			_this.$(menus[i]).value = i;				
			_this.$(menus[i]).onmouseover = function(){
					
				for(var j = 0 ; j < menus.length ; j++)
				{						
					_this.$(menus[j]).className = closeClass;
					_this.$(divs[j]).style.display = "none";
				}
				_this.$(menus[this.value]).className = openClass;	
				_this.$(divs[this.value]).style.display = "block";				
			}
		}
		},
	$ : function(oid){
		if(typeof(oid) == "string")
		return document.getElementById(oid);
		return oid;
	}
}
function huadongmen(){
	var SDmodel = new scrollDoor();
	SDmodel.sd(["m01","m02","m03","m04","m05","m06","m07","m08","m09","m10","m11"],["c01","c02","c03","c04","c05","c06","c07","c08","c09","c10","c11"]);
	
}