﻿
   String.prototype.Trim = function()
   {
     return this.replace(/^\s*|\s*$/g, '');
   }

   /**
   +----------------------------------------------------------
   * 验证邮件格式[validmail]
   * access public 
   +----------------------------------------------------------
   * return boolean
   +----------------------------------------------------------
   */ 
   function validmail(text)
   {
    var reg_email = /([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)/i;
    return reg_email.test(text);
   } 
   
   function setTab(name,cursel,n){
    for(i=1;i<=n;i++){
    var menu=document.getElementById(name+i);
    var con=document.getElementById("con_"+name+"_"+i);
    menu.className=i==cursel?"hover":"";
    con.style.display=i==cursel?"block":"none";
    }
   }

    //输出flash
    function write_flash(flashurl,width,height)
	{				
      //images/bcastr.swf?bcastr_xml_url=cycle_image.php
      var swf_width=width;
      var swf_height=height;
      // 0xffffff:文字颜色|1:文字位置|0x0066ff:文字背景颜色|60:文字背景透明度|0xffffff:按键文字颜色|0x0066ff:按键默认颜色|0x000033:按键当前颜色|8:自动播放时间(秒)|2:图片过渡效果|1:是否显示按钮|_blank:打开窗口
      var swf_config = "|2|||0xffffff|0x000000||4|3|1|_self"
      document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ swf_width +'" height="'+ swf_height +'">');
      document.write('<param name="movie" value="'+ flashurl +'"><param name="quality" value="high">');
      document.write('<param name="menu" value="false"><param name=wmode value="transparent">');
      document.write('<param name="FlashVars" value="bcastr_config='+swf_config+'">');
      document.write('<embed src="'+ flashurl +'" wmode="transparent" FlashVars="bcastr_config='+swf_config+'" menu="false" quality="high" width="'+ swf_width +'" height="'+ swf_height +'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); 
      document.write('</object>'); 
	}

    /**
    +----------------------------------------------------------
    * 输出视频[write_video]
    * access public 
    +----------------------------------------------------------
    * param  string    vodurl         图片地址
    * param  string    vodtext        图片名称
    * param  string    vodwidth       图片宽度
    * param  string    vodheight      图片高度
    +----------------------------------------------------------
    * return void
    +----------------------------------------------------------
    */ 
    function write_video(vodurl, vodtitle, vodlink, vodwidth, vodheight)
	{
	   if(!vodwidth){vodwidth = 690;}
	   if(!vodheight){vodheight = 320;}
	   if(vodurl)
	   {
	     flvflash = "images/vcastr.swf";
	     vodurl = weburl_get()+vodurl;
document.write('<object type="application/x-shockwave-flash" data="'+flvflash+'" width="'+ vodwidth +'" height="'+ vodheight +'" id="vcastr">');
document.write('<param name="movie" value="'+flvflash+'"/>');
document.write('<param name="allowFullScreen" value="true" />');
document.write('<param name="FlashVars" value="xml={vcastr}{channel}{item}{source}'+ vodurl +'{/source}{duration}{/duration}{title}'+ vodtitle +'{/title}{link}'+ vodlink +'{/link}{/item}{/channel}{config}{bufferTime}4</bufferTime>{contralPanelAlpha}0.75{/contralPanelAlpha}{controlPanelBgColor}0x000000{/controlPanelBgColor}{controlPanelBtnColor}0xffffff{/controlPanelBtnColor}{contralPanelBtnGlowColro}0xffff00{/contralPanelBtnGlowColro}{controlPanelMode}bottom{/controlPanelMode}{defautVolume}0.7{/defautVolume}{isAutoPlay}true{/isAutoPlay}{isLoadBegin}true{/isLoadBegin}{isShowAbout}true{/isShowAbout}{scaleMode}showAll{/scaleMode}{isRepeat}false{/isRepeat}{/config}{plugIns}{/plugIns}{/vcastr}"/>');
document.write('</object>');
	   }
	}

    function weburl_get()
	{
		var webhost = location.hostname;
		var webport = location.port;
		var pathname = location.pathname;
        var weburl = "http://"+webhost;
		if(webport)
		{
			weburl +=":"+webport;
		}
		return weburl+"/";
	}

	
//首页收藏
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);
}
}
}




