//简化document.getElementById
function $(id){return document.getElementById(id);}

//flash播放器调用
function Flash(url,width,height,transparent)
{
	var wmode
	if(transparent){wmode="transparent"}else{wmode="opaque"};
	document.write('<object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ width +'" height="'+ height +'">');
	document.write('<param name="movie" value="'+ url +'" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="menu" value="false" />');
	document.write('<param name="wmode" value="'+ wmode +'" />');
	document.write('<embed ID="FlashID" src="'+ url +'" wmode="'+wmode+'" menu="false" quality="high" width="'+ width +'" height="'+ height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}

//flv播放器调用
function Flv(url,width,height)
{
	var flv_player="/images/flv_player.swf";
	document.write('<object id="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"  width="'+ width +'" height="'+ height +'">');
	document.write('<param name="movie" value="'+ flv_player +'" />');
	document.write('<param name="allowfullscreen" value="true" />');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="menu" value="false" />');
	document.write('<param name="flashvars" value="file='+ url +'" />');
	document.write('<embed ID="focus_flash" src="'+ flv_player +'" wmode="opaque" FlashVars="file='+ url +'" menu="false" quality="high" width="'+ width +'" height="'+ height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"/>');
	document.write('</object>');
}

//获取今天的日期和星期
function DateandWeekday(){
	todayDate = new Date();
	date = todayDate.getDate();
	month= todayDate.getMonth() +1;
	year= todayDate.getYear();
	if(navigator.appName == "Netscape")
	{
		document.write(1900+year);
		document.write("年");
		document.write(month);
		document.write("月");
		document.write(date);
		document.write("日");
	}
	if(navigator.appVersion.indexOf("MSIE")!= -1)
	{
		document.write(year);
		document.write("年");
		document.write(month);
		document.write("月");
		document.write(date);
		document.write("日");
	}
	document.write("&nbsp;");
	if (todayDate.getDay() == 0) document.write("星期日");
	if (todayDate.getDay() == 1) document.write("星期一");
	if (todayDate.getDay() == 2) document.write("星期二");
	if (todayDate.getDay() == 3) document.write("星期三");
	if (todayDate.getDay() == 4) document.write("星期四");
	if (todayDate.getDay() == 5) document.write("星期五");
	if (todayDate.getDay() == 6) document.write("星期六");
}

//加入收藏
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 Display(ID,n_b)
{
	if (n_b=="none")
	{
		$(ID).style.display="none";
	}else{
	    $(ID).style.display="block";
	}
}

//弹出窗口，自动居中
function OpenWindow(file,w,h,s)
{
    window.open(file,'','resizable=no,width='+w+',height='+h+',scrollbars='+s+',left='+(screen.availWidth-w)/2+',top='+(screen.availHeight-h)/2);
}

//开关
function Switch(id)
{
	if($(id).style.display=="none")
	{
		$(id).style.display="block"
	}else{
		$(id).style.display="none"
	}
}

//去除字符串左右两边空格
function Trim(s){return s.replace(/(^\s*)|(\s*$)/g,"");} 
//验证搜索
function CheckSearch(theForm)
{
	if(Trim(theForm.keywords.value)=="")
	{
		alert("请输入关键字！再进行搜索！");
		theForm.keywords.focus();
		return(false);
	}
	if(Trim(theForm.keywords.value)=="请输入关键字"){
		alert("请输入关键字！再进行搜索！");
		theForm.keywords.focus();
		return(false);
	}
}

function check()
	{
		if (document.form1.name.value=="")
		{
			alert("请输入名字！");
		}
		else if (document.form1.title.value=="")
		{
			alert("请输入主题！");
		}
		else if (document.form1.content.value=="")
		{
			alert("请输入内容！");
		}
		else
		{
			return true;
		}
		return false;
	}
	




