//标签切换
function nTabs(tabObj,obj){
	var tabList = document.getElementById(tabObj).getElementsByTagName("li");
	for(i=0; i <tabList.length; i++){
		if (tabList[i].id == obj.id){
			document.getElementById(tabObj+"_te_"+i).className = "sli"; 
    		document.getElementById(tabObj+"_co_"+i).style.display = "block";
		}else{
			document.getElementById(tabObj+"_te_"+i).className = ""; 
			document.getElementById(tabObj+"_co_"+i).style.display = "none";
		}
	} 
}
//加入收藏
function AddFavorite(sURL,sTitle){
	try{
		window.external.addFavorite(sURL, sTitle);
	}catch (e){
		try
	{
		window.sidebar.addPanel(sTitle, sURL, "");
	}catch (e){
		alert("加入收藏失败，请使用Ctrl+D进行添加");
		}
	}
}
//设为首页
function SetHome(obj,vrl){
	try{
		obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
	}catch(e){
		if(window.netscape){
			try{
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
			}catch (e){
				alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。");
			}
			var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
			prefs.setCharPref('browser.startup.homepage',vrl);
		}
	}
}
//复制
function copyText(id){
	try{
		var targetText = document.getElementById(id);
		targetText.focus();
		targetText.select();
		var clipeText = targetText.createTextRange();
		clipeText.execCommand("Copy");
		alert("复制成功！");
	}catch(e){}
}


//FLASH播放
function getFlash(setWidth,setHeight,setUrl){
	if(parseInt(setHeight)<1){
		setHeight = "100%";	
	}
	if(parseInt(setWidth)<1){
		setWidth = "100%";	
	}
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width='+setWidth+' height='+setHeight+'>')
	document.write('<param name="movie" value='+setUrl+'>')
	document.write('<param name="quality" value="high">')
	document.write('<param name="wmode" value="transparent" /> ')
	document.write('<embed src='+setUrl+' quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width='+setWidth+' height='+setHeight+' wmode="transparent"></embed></object>')
}

//FLASH播放器返回代码
function getFlashHtml(setWidth,setHeight,setUrl){
	if(parseInt(setHeight)<1){
		setHeight = "100%";	
	}
	if(parseInt(setWidth)<1){
		setWidth = "100%";	
	}
	
	strText = "";
	
	strText = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width='+setWidth+' height='+setHeight+'>';
	
	strText += '<param name="movie" value='+setUrl+'>';
	strText += '<param name="quality" value="high">';
	strText += '<param name="wmode" value="transparent" /> ';
	strText += '<embed src='+setUrl+' quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width='+setWidth+' height='+setHeight+' wmode="transparent"></embed></object>';
	return strText;
}

//FLV视频播放
function getFlv(w,h,t,f,autoplay){
	var PUBLIC = "http://dcgz2011.gywb.cn/Public";
	var swf_width=w //445
	var swf_height=h //301
	var texts=t //'男左女右'
	var files=f//'http://www.yxgz.cn/Files/adminFiles/jzt/ok2_3.flv'
	
	//var files='1.flv|2.flv'
	var strText = "";
	
	strText = strText+'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"';
	strText = strText+'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ swf_width +'" height="'+swf_height +'">';
	strText = strText+'<param name="movie" value="'+PUBLIC+'/flash/vcastr22/vcastr22.swf"><param name="quality" value="high">';
	strText = strText+'<param name="menu" value="true"><param name="allowFullScreen" value="true" />';
	strText = strText+'<param name="FlashVars" value="vcastr_file='+files+'&vcastr_title='+texts+'&IsAutoPlay='+autoplay+'&IsContinue='+autoplay+'">';
	strText = strText+'<embed src="'+PUBLIC+'/flash/vcastr22/vcastr22.swf" allowFullScreen="true" FlashVars="vcastr_file='+files+'&vcastr_title='+texts+'&IsAutoPlay='+autoplay+'&IsContinue='+autoplay+'"';
	strText = strText+' menu="true" quality="high" width="'+ swf_width +'" height="'+ swf_height +'" type="application/x-shockwave-flash"';
	strText = strText+' pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
	
	return strText;
}

//微软在线播放器
function getPlay(setUrl,setWidth,setHeight){
	var strText="<object title=\"www.gywb.cn\" align=\"middle\" classid=\"CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95\" class=\"object\" id=\"MediaPlayer\" width="+setWidth+" height="+setHeight+">";
		strText = strText+"<param name=\"AUTOSTART\" value=\"true\"/>";
		strText = strText+"<param name=\"ShowStatusBar\" value=\"-1\"/>";
		strText = strText+"<param name=\"Filename\" value="+setUrl+">";
		strText = strText+"<param name=\"DisplaySize\" value=\"0\"> ";
		strText = strText+"<param name=\"ShowCaptioning\" value=\"0\">";
		strText = strText+"<param name=\"ShowControls\" value=\"0\">";
		strText = strText+"<param name=\"ShowAudioControls\" value=\"0\">";
		strText = strText+"<param name=\"ShowGotoBar\" value=\"0\">";
		strText = strText+"<embed title=\"贵阳新闻网：www.gywb.cn\" type=\"application/x-oleobject\" codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701\" flename=\"mp\" src="+setUrl+">";
		strText = strText+"</embed>";
		strText = strText+"</object>";
		return strText;
}


//根据传入地址，自动选择播放器代码
function playAuto(url,playid){
	val = url.indexOf(".swf");
	if(val > 0){
		$(playid).html(getFlashHtml(610,460,url));
		return false;
	}
	
	val = -1;
	val = url.indexOf(".flv");
	if(val > 0){
		$(playid).html(getFlv(610,460,"在线直播",url,1));
		return false;
	}
	
	//默认采用微软播放器
	$(playid).html(getPlay(url,610,460));
}


//根据传入地址，自动选择播放器代码
function topicPlayAuto(url,playid){
	val = url.indexOf(".swf");
	if(val > 0){
		$(playid).html(getFlashHtml(286,249,url));
		return false;
	}
	
	val = -1;
	val = url.indexOf(".flv");
	if(val > 0){
		$(playid).html(getFlv(286,249,"专题视频",url,0));
		return false;
	}
	
	//默认采用微软播放器
	$(playid).html(getPlay(url,286,249));
}

//指定范围随机数
var rand = {};
rand.get = function (begin,end){
	return Math.floor(Math.random()*(end-begin))+begin;
}


//高度对齐设置
function autoDivHeight(lname, rname, lx, rx){
	var l = $(lname), r = $(rname);
	var lheight = l.height();
	var rheight = r.height();
	
	var layoutHeight = Math.max(lheight, rheight);
	l.css("height",layoutHeight + lx+"px"); 
	r.css("height",layoutHeight + rx+"px"); 
}

//搜索
function so_key(){
	key = $('#sokey').val();
	if(key.length > 1){
		document.form1.submit();
	}else{
		alert('请填写搜索关键字！');
		$('#sokey').focus();
	}
}

//JS日期调用
function index_time(){
	var dateday = new Array();
	dateday[0] = "星期日";
	dateday[1] = "星期一";
	dateday[2] = "星期二";
	dateday[3] = "星期三";
	dateday[4] = "星期四";
	dateday[5] = "星期五";
	dateday[6] = "星期六";
	
	var myDate = new Date();
	n = myDate.getFullYear();
	y = myDate.getMonth() + 1;
	r = myDate.getDate();
	x = myDate.getDay();
	
	return n+"年"+y+"月"+r+"日&nbsp;"+dateday[x];
}
date = index_time();
