


var tvid =8;
var user_init = '  <a href="SetHome(this)">设为首页</a><em>|</em><a href="AddFavorite(\'动感101\')">添加收藏</a></div><div class="center"><a target="_blank" href="/home/do.php?ac=1c230a00e4009320c27d09e937f76b46">登录</a><em>|</em><a  target="_blank" href="/home/do.php?ac=145052e2e88cf878cfa9dd76207870d4">注册</a>';

var  parr = new Array('p1','p2','p3','p4','p5','p6','p8');

  function showUserMsg()
  {
	  	$.ajax({
	      type: "post",
	      url: "/home/getstatus.php",
	      dataType:"text/html",
	      data: "",
	      beforeSend: function(XMLHttpRequest){
	         $("#userloading").html('正在加载...');
	      },
	      success: function(data){
	    	
	    		eval("var data_json="+data);
	    		
	    		if( data_json && data_json.uid )
	    		{
	    			 username = data_json.username;
	    			 uid = data_json.uid;
	    			str = '欢迎您<a target="_blank" href="/home/space.php?'+uid+'"><b>'+username+'</b></a>!&nbsp;'
	    			+'<a target="_blank" href="/home/space.php?'+uid+'">空间</a>&nbsp;&nbsp;'+'<a href="javascript:void()" onclick="user_loginout()">退出</a>';
	    			$("#userloading").html(str);
	    		}else
	    		{
	    			$("#userloading").html(user_init);
	    		}
	      }
	  	});
  }
  
  
  function user_loginout()
  {
	  
	 	$.ajax({
		      type: "post",
		      url: "/home/logout.php",
		      dataType:"text/html",
		      data: "",
		      beforeSend: function(XMLHttpRequest){
		         $("#userloading").html('正在退出...');
		      },
		      success: function(data){
		    	  showUserMsg();
		      }
		  	});
  }
  


  
  
  function SetHome(obj){
	vrl = window.location.host;
	  for( var i = 0 ; i < parr.length; i++ )
	  {
		   var host = window.location.href ;
		   if( host.indexOf( "/"+parr[i]) >0 )
		   {
			   if( host.indexOf( "/p8") >0 )
			   {
				  vrl = "http://"+window.location.host;
				  break;
			   }else
			   {
			   vrl = "http://"+window.location.host +"/"+parr[i];
			   break;
			   }
		   }
	  }
	  
	  
          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 AddFavorite(title) {
	  url = location.href;
	  
	  if (window.sidebar) { 
	  window.sidebar.addPanel(title, url,""); 
	  } else if( document.all ) {
	  window.external.AddFavorite( url, title);
	  } else if( window.opera && window.print ) {
	  return true;
	  }
	  
	  }
function check_home()
{
	var url = location.href;

	if(  "http://www.eastradio.com/index.phtml"==url ||  url.indexOf('/p8')!=-1)
	{
		if(this.parent.header_frame.document.getElementById('back_home')){
			
		this.parent.header_frame.document.getElementById('back_home').innerHTML='';	
		}
	}
	else
	{
		if(this.parent.header_frame.document.getElementById('back_home')){
			
		this.parent.header_frame.document.getElementById('back_home').innerHTML='<a href="http://www.eastradio.com" target="_top"><span><img src="images/erc.png" /></span><bdo>返回主站</bdo></a>';	
		}			
	}
}




