//获得控件版本号
function ptui_getActivXVer(){
	try{
		var obj = new ActiveXObject("TimwpDll.TimwpCheck");
		var ver = obj.GetVersion();
		return ver;
	}
	catch(e){
		return 0;
	} 
}
//判断QQ是否运行
function ptui_checkQQRunning(){
	try{
		var obj = new ActiveXObject("TimwpDll.TimwpCheck");              
		return obj.CheckQQRunning();
	}
	catch(e){
		return false;
	} 
}

function $O(i){return document.getElementById(i);};

function logout(){
	document.frames["loader_title"].location=g_urls_new_portal['domain']+"user_load.php?cmd=logout";
}

function write_menu()
{
	document.write('	<div id="season">')
	document.write('	<div id="header">')
	document.write('  	<h1><a href="http://vip.qq.com"><img src="http://imgcache.qq.com/vipportal_v2/img/logo_vip.gif" alt="QQ会员vip.qq.com" /></a></h1>')
	document.write('    <div class="menu_top">')
	document.write('      <div class="welcome" id="login_title">&nbsp;</div>')
	document.write('      <div class="menu_channel">')
	document.write('        <a href="javascript:go_new(\'qq\')" class="channel_qq">QQ特权频道</a><span> | </span>')
	document.write('        <a href="javascript:go_new(\'life\')" class="channel_life">生活特权频道</a><span> | </span>')
	document.write('        <a href="javascript:go_new(\'game\')" class="channel_game">游戏特权频道</a>')
	document.write('      </div>')
	document.write('    </div>')
	document.write('    <map id="menu">')
	document.write('       <div id="menu_full">')
	document.write('      	<a onmouseover="show_sub_level(0);" href="javascript:go_new(\'index\')" class="menu_index"><strong>首 页</strong></a><span> | </span>')
	document.write('        <a onmouseover="show_sub_level(1);" href="javascript:go_new(\'my_freedom_index\')" class="menu_level"><strong>成长体系</strong></a><span> | </span>')
	document.write('        <a onmouseover="show_sub_level(2);" href="javascript:go_new(\'freedom_set\')" class="menu_freedom"><strong>特权与功能</strong></a><span> | </span>')
	document.write('        <a onmouseover="show_sub_level(3);" href="javascript:go_new(\'act_index\')" class="menu_act"><strong>会员活动</strong></a><span> | </span>')
	document.write('        <a onmouseover="show_sub_level(4);" href="javascript:go_new(\'mall\')" class="menu_change"><strong>兑换专区</strong></a><span> | </span>')
	document.write('        <a onmouseover="show_sub_level(5);" href="javascript:go_new(\'bbs\')" class="menu_bbs"><strong>会员社区</strong></a><span> | </span>')
	document.write('        <a onmouseover="show_sub_level(6);" href="javascript:go_new(\'help\')" class="menu_help"><strong>帮 助</strong></a>')
	document.write('      </div>')
	document.write('      <div id="sub_level" class="menu_sub">')
	document.write('      </div>')
	document.write('<div class="menu_join">| 开通会员，享受特权生活！<a href="http://paycenter.qq.com/club/?pageshow=&CacheTime=1221557370" target="_blank" class="bt_user_join" title="开通会员">开通会员</a></div>');
	document.write('    </map>')
	document.write('    <h2 class="vip_people">我是会员，我享特权！</h2>')
	document.write('  </div>')
	document.write('</div>')
	document.domain="qq.com";
	reg_login();
}
var g_urls_new_portal = {
 domain:	     ("http://vip.qq.com/"),
 index :         ("index.html"),
 game :          ("game.html"),
 life :          ("life.html"),
 qq :            ("qq.html"),

 my_freedom_index:("my_freedom/level.html"),

 freedom_set:    ("freedom/freedom.html"),

 act_index:      ("freedom_act/act.html"),
 game_colum_act: ("freedom_act/game1.html"),
 life_colum_act: ("freedom_act/life1.html"),
 qq_colum_act:   ("freedom_act/qq1.html"),
 theme_colum_act:("freedom_act/theme1.html"),

 act_life       :("act_life.html"),

 mall:	         ("mall/mall.php"),
 bbs:            ("bbs.html"),
 help:           ("templates/portal/help.html")

};
var main_menu=[[],[],[],[["QQ特权频道活动",'javascript:go_new(\'qq_colum_act\')'],["生活特权频道活动",'javascript:go_new(\'life_colum_act\')'],["游戏特权频道活动",'javascript:go_new(\'game_colum_act\')'],["主题活动",'javascript:go_new(\'theme_colum_act\')']],[],[],[]];
function go_new(index)
{
	window.top.location=g_urls_new_portal['domain']+g_urls_new_portal[index];
}


function reg_login()
{
	
    iframe_str='<iframe width="0px" height="0px" scrolling="no" border="0px" frameborder="no" id="loader_title" name="loader_title" src="'+g_urls_new_portal['domain']+'user_load.php"></iframe>';
	document.write(iframe_str);
	div_str='<div style="position:absolute;z-index:100;left:50%;top:220px;width:380px;height:310px;visibility:hidden;" id="login_div"><iframe name="login_frame" id="login_frame" frameborder="no" scrolling="no" width="100%" height="100%" src=""></iframe></div>';
	document.write(div_str);

}
function set_title(str){
	$O("login_title").innerHTML=str;

}
function re_fl(){
	document.frames["loader_title"].location=g_urls_new_portal['domain']+"user_load.php";
	if($O("login_loader")){
		$hide("user_info");
		document.frames["login_loader"].location.reload();
	}
}
//各个页面输出版权提示
function show_sub_level(index)
{
	var a_l=main_menu[index].length;
	var str="";
	if(a_l>0){
		for(var loop=0;loop<a_l;loop++){
			if((a_l-1)!=loop)
			str+="<a href="+main_menu[index][loop][1]+">"+main_menu[index][loop][0]+"</a><span> | </span>";
			else
			str+="<a href="+main_menu[index][loop][1]+">"+main_menu[index][loop][0]+"</a>";
		}
	}
	$O("sub_level").innerHTML=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 logout_newportal(){
    try{
        var f = document.forms['LogoutForm'];
        f.action = "/login.php?urlback=" + escape(window.location.href);
        f.submit();
        return true;
    }catch(e){}
}
function ptlogin2_onResize(width, height){	
	login_wnd = $O("login_div");
	if (login_wnd)
{
		show_at_center(login_wnd, width, height)
		login_wnd.style.width = width + "px";
		login_wnd.style.height = height + "px";		
		login_wnd.style.visibility = "visible"
	}
}
function ptlogin2_onClose(){
	login_wnd = $O("login_div");	
	login_wnd.style.display="none"
}

function openLogin(urlparam){	
	login_wnd = $O("login_div");
	login_wnd.style.visibility = "hidden"
	if (login_wnd != null){
		login_wnd.style.display = "block"	//设为block， 否则页面不会真正载入
		if (ptui_getActivXVer() < 3.9 || !ptui_checkQQRunning() ) {
			url="http://ui.ptlogin2.qq.com/cgi-bin/login?link_target=blank&target=self&appid=8000201&f_url=loginerroralert&s_url=";
			url += escape(g_urls_new_portal['domain']+"user_load.html");
		}
		else{
			url="http://ui.ptlogin2.qq.com/cgi-bin/login?appid=8000201&qlogin_jumpname=clubvip&f_url=loginerroralert&qlogin_auto_login="
			if(urlparam==1)
			url +="1";
			else
			url +="0";
			url +="&s_url="+escape(g_urls_new_portal['domain']+"redirect.html");
			tweb_set_cookie("vipportalautologin",location.href,0,'/');
		}
		$O("login_frame").src = url;
	}
}
function tweb_set_cookie(){
    var argv = tweb_set_cookie.arguments;
    var argc = argv.length;
    if ( argc < 2 ) {
        return false;
    }
    var name  = argv[0];
    var value = argv[1];
    if ( argv[2] ) { var expires = argv[2]; }
    if ( argv[3] ) { var path    = argv[3]; }
    if ( argv[4] ) { var domain  = argv[4]; }
    if ( argv[5] ) { var secure  = argv[5]; }
    var today   = new Date();
    var expdate = new Date( today.getTime() + ( expires * 60 * 60 * 1000 ) );

    document.cookie = name + "=" + escape( value )
    + ( expires ? ";expires=" + expdate.toGMTString() : "" )
    + ( path    ? ";path=" + path : "" )
    + ( domain  ? ";domain=" + domain : "" )
    + ( secure  ? ";secure" : "" );
    return true;
}
function show_at_center(div_control, div_width, div_height){
	try{
		div_control.style.top = (window.innerHeight / 2 + pageYOffset)-div_height/2+"px";
		div_control.style.left= (window.innerWidth  / 2 + pageXOffset)-div_width/2+"px";
	} 
	catch(e) { 
		div_control.style.top = (document.documentElement.offsetHeight / 2 + document.body.scrollTop )-div_height/2+"px";
		div_control.style.left= (document.documentElement.offsetWidth  /2 + document.body.scrollLeft)- div_width/2+"px";
	}
}

function write_copyright(){
   document.write("<div class='menu'><a href='http://www.tencent.com/' target='_blank'>关于腾讯</a> | <a href='http://www.tencent.com/index_e.shtml' target='_blank'>About Tencent</a> | <a href='http://www.qq.com/contract.shtml' target='_blank'>服务条款</a> | <a href='http://www.tencentmind.com/' target='_blank'>广告服务</a> | <a href='http://hr.tencent.com/' target='_blank'>腾讯招聘</a> | <a href='http://service.qq.com/' target='_blank'>客服中心</a> | <a href='http://www.qq.com/map/' target='_blank'>网站导航</a></div>"+
"<span class='num'>Copyright &copy; 1998 - 2008 Tencent. All Rights Reserved</span><br />"+
"<span>腾讯公司</span> <a href='http://www.tencent.com/zh-cn/le/copyrightstatement.shtml' target='_blank' class='clink'>版权所有</a>");
};

//高亮某一导航栏元素
function light_on(id)
{
	/*
    for ( var key in menu_top ) document.getElementById(menu_top[key]).className="menu_off";
    var tmp=document.getElementById(id);
    if(typeof(tmp)=="undefined"||tmp=="undefined")return;
    tmp.className="menu_on";
	*/
}
function show_banner()
{
    var url = location.href.replace(/\?.*/g, "");
    var domain = 'http://vip.qq.com/';//域名测试与发布的时候注意修改,域名+页面组成URL用来标识唯一的页面,以决定哪个menu加粗显示.
    var url_set= new Array(domain+"main_act.php",domain+"qqnum_act.php",domain+"game_privilege.php",domain+"play_privilege.php",domain+"taste_privilege.php",domain+"shopping_privilege.php");
    var target_set= new Array("id_act_banner1","id_act_banner2","id_act_banner3","id_act_banner4","id_act_banner5","id_act_banner6");
    var target='';
    for( var i in url_set) {
        if (url==url_set[i]) {
            target=target_set[i];
            break;
        }
     }
    if (target!='') document.getElementById(target).style.display = "";
}


// JavaScript Document
// allanhuang 2008-4-17
var init_menu_id='';//下拉菜单
var init_menu_nav='';//导航条元素
var menu_top = new Array('menu_index','menu_level','menu_freedom','menu_act','menu_qbean','menu_bbs','menu_help');//全部导航条元素

//参数:
//id主页面子菜单,也就是init_menu_id
//nav主页面中对应的导航条元素也就是init_menu_nav
//c_id鼠标指向的页面子菜单
//c_nav鼠标指向的页面中对应的导航条元素
function mouse_on(id,nav,c_id,c_nav)
{
	/*
    _hide_menu(id);
    if (c_id!='none'&&c_id!='') _show_menu(c_id,c_nav);
    light_on(c_nav);
	*/
	switch(nav){
		case 'menu_level':{
			show_sub_level(1);
		}
		break;
		case 'menu_act':{
			show_sub_level(3);
		}
		break;
	}
}
function mouse_out(id,nav,c_id,c_nav)
{
    if (c_id!='none'&&c_id!='') _hide_menu(c_id);
    _show_menu(id,nav);
    light_on(nav);
}
function _show_menu(id,nav)
{
    if ( typeof(id) == "undefined" || typeof(nav) == "undefined" || id == "" || nav == "" || id == "none") return false;
    try {
        var menu = document.getElementById( id );
        if(typeof(menu)=="undefined") return 0;
        menu.style.display = "";
        var timeout = null;
        if(id!=init_menu_id) {
            menu.onmouseover = function(){
                menu.style.display = "";
                document.getElementById(nav).className = "nav_on";
                _hide_menu(init_menu_id);
                light_on(nav);
            }
            menu.onmouseout = function(){
                if (init_menu_nav==''){
                    _hide_menu('level_list');
                    _hide_menu('privact_list');
                }
                light_on(init_menu_nav);
                document.getElementById(nav).className = "";
                menu.style.display = "none";
                _show_menu(init_menu_id,init_menu_nav);
            }
         }// end if
    }catch ( x ){}
}
//init_menu_id="level_list";init_menu_nav="menu_level";


function _hide_menu(id) {
	/*
    if ( typeof(id) == "undefined" || id=="" || id=="none") return false;
    var menu = document.getElementById( id );
    if ( typeof(menu) == "undefined" ) return false;
   
	
	menu.style.display = "none";
	*/
}