//添加到收藏夹
function addShaweiToFavorite(pagetitle){
	if (document.all){
		window.external.addFavorite(window.location.href,pagetitle);
	}else if (window.sidebar){
      		window.sidebar.addPanel(pagetitle, window.location.href, pagetitle);
    }else{
   		showMsg("您的浏览器不支持该动作，请按CTRL+D收藏！");
	}
}
//设为首页
function setHome(obj,url){
	try{
		obj.style.behavior='url(#default#homepage)';obj.setHomePage(url);
	}catch(e){
		if(window.netscape){
			try{
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");  
            }catch (e){ 
				alert("抱歉！您的浏览器不支持直接设为首页。请在浏览器地址栏输入“about:config”并回车然后将[signed.applets.codebase_principal_support]设置为“true”，点击“加入收藏”后忽略安全提示，即可设置成功。");  
            }
				var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
				prefs.setCharPref('browser.startup.homepage',url);
        }
    }
}

//显示定制消息框
function showMsg(text){
	var msg = '<div class="popBgF" id="pp"><div class="popBgS"><ul class="popUl"><li class="popli"><input name="" type="image" src="http://sto.shawei.tom.com/vod/images/vod_popup/vop_popup_close.gif" class="popClose" onclick="$(\'#popup_overlay\').remove();$(\'#pp\').remove()" /></li><li class="pop0619">'+text+'</li><li class="popli"><input name="" type="image" src="http://sto.shawei.tom.com/vod/images/vod_popup/vop_popup_but.gif" class="popBut"  onclick="$(\'#popup_overlay\').remove();$(\'#pp\').remove()" /></li></ul></div></div>';
	$("body").append('<div id="popup_overlay"></div>');
	$("#popup_overlay").css({
		position: 'absolute',
		zIndex: 99998,
		top: '0px',
		left: '0px',
		width: '100%',
		height: $(document).height(),
		background: '#333',
		opacity: '0.5'
	});
	$("body").append(msg);
	var h = document.body.scrollTop;
	if(h == 0){
		h = document.documentElement.scrollTop;	
	}
	$("#pp").css({
		position: 'absolute',
		zIndex: 99999,
		left:Math.floor(($(document).width() - $("#pp").width())/2)+'px',
		top: (document.documentElement.clientHeight/2+h-$("#pp").height()/2)+'px'
	});
}

function obj(objectId){
	if(document.getElementById && document.getElementById(objectId)) {
		// W3C DOM
		return document.getElementById(objectId);
	} else if (document.all && document.all(objectId)) {
		// MSIE 4 DOM
		return document.all(objectId);
	} else if (document.layers && document.layers[objectId]) {
		// NN 4 DOM.. note: this won"t find nested layers
		return document.layers[objectId];
	} else {
		return false;
	}
}