//处理HTML程序，让JavaScript可以在用户端运行
var setInnerHTML = function (iEl, htmlCode) {
	var el=document.getElementById(iEl);var ua = navigator.userAgent.toLowerCase();el.innerHTML="";
    if (ua.indexOf('msie') >= 0 && ua.indexOf('opera') < 0) {
        htmlCode = '<div style="display:none">for IE</div>' + htmlCode;
        htmlCode = htmlCode.replace(/<script([^>]*)>/gi,'<script$1 defer>');
        el.innerHTML = htmlCode;el.removeChild(el.firstChild);
    } else {
        var el_next = el.nextSibling;var el_parent = el.parentNode;
        el_parent.removeChild(el);el.innerHTML = htmlCode;
        if (el_next) {el_parent.insertBefore(el, el_next)
        } else {el_parent.appendChild(el);}
    }
}

//微软在线播放器
function getPlay(strId,setUrl,setWidth,setHeight){
	var strText="<object title=\"www.yxgz.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.yxgz.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+"  width=320 height=240 >";
		strText = strText+"</embed>";
		strText = strText+"</object>";
		
		setInnerHTML(strId,strText);
}
/* TAB选项卡 */
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";
		}
	} 
}

/* TAB选项卡 */
function sTabs(obj,tabObj,id,icount){
	for(i=0; i <icount; i++){
		if (i == 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";
		}
	} 
}


/* TAB选项卡 */
function nTabsTo(tabObj,count,no){
	for(i=0;i<count;i++){
		if (i == no){
			$("#"+tabObj+"_te_"+i).attr('src','../images/have/a.gif');
			$("#"+tabObj+"_co_"+i).slideDown("slow"); 
		}else{
			$("#"+tabObj+"_te_"+i).attr('src','../images/have/r.gif');
			$("#"+tabObj+"_co_"+i).css('display','none');
		}
	} 
}

//统计多选选中项目
function chk_CheckBox(param1,param2){
	var intCount = $(param1).val();
	var i;
	var iCount = 0;
	if(intCount==1){
		if(document.all(param2).checked==true){
			iCount = iCount+1;
		}
	}else{
		for(i=0;i<intCount;i++){
			if(document.all(param2)(i).checked==true){
				iCount = iCount+1;
			}
		}
	}
	return iCount;
}

//全选反选
var CheckAll = function(form,str){
	for (var i=0;i<form.elements.length;i++){
		var e = form.elements[i];
		if (e.type=="checkbox"){
			e.checked = str;
		}
	}
}
//加入收藏
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){}
}
//计算输入文字
function counttext(obj,str){
	icount = 1000;
	text = obj.value;
	if(text.length<icount){
		ic = text.length;
		$(str).val(icount-ic)
	}else{
		alert("您的输入不能大于"+icount);
		return false;
	}
}
