if(typeof Prototype == 'undefined' ){
	document.write('<script src="/lib/js/lib/prototype.js"><\/script>'); 
}
function headerBar(){
	var url = '/home/headerBarAjax.php?'+new Date().getTime();
	var myAjax = new Ajax.Updater($("site_bar"), url,{
		method : "get",
		evalScripts: true
	});
}

function logoutAjax(url){
	new Ajax.Request( url,{
		method : "get",
		onComplete : function(re){
			location.reload();
		}
	});
}

function copyCode(){
	var testCode = this.location.href;
	if(copy2Clipboard(testCode) != false){
		alert("您好，本页网址复制成功，请粘贴到您的QQ/MSN上推荐给您的好友^-^！");
	}
}
copy2Clipboard=function(txt){
	if(window.clipboardData){
		window.clipboardData.clearData();
		window.clipboardData.setData("Text",txt);
	} else if(navigator.userAgent.indexOf("Opera")!=-1){
		window.location=txt;
	} else if(window.netscape){
		try{
			netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
		} catch(e){
			alert("您的firefox安全限制限制您进行剪贴板操作，请打开‘about:config’将‘signed.applets.codebase_principal_support’设置为true’之后重试，相对路径为firefox根目录/greprefs/all.js");
			return false;
		}
		var clip=Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
		if(!clip)return;
		var trans=Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
		if(!trans)return;
		trans.addDataFlavor('text/unicode');
		var str=new Object();
		var len=new Object();
		var str=Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
		var copytext=txt;str.data=copytext;
		trans.setTransferData("text/unicode",str,copytext.length*2);
		var clipid=Components.interfaces.nsIClipboard;
		if(!clip)return false;
		clip.setData(trans,null,clipid.kGlobalClipboard);
	}
}

function shareBookmark() {
	var title = document.title;
	var 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 goToshare(webid){
	var url = location.href;
	window.open("/home/share.php?webid="+webid+"&shareUrl="+encodeURIComponent(url));
}

function iFav(type){
	$('favopen').className = 'fav selected';
	$('favtag1').className = '';
	$('favtag2').className = '';
	$('favtag3').className = '';
	$('favtag5').className = '';
	$('favtag6').className = '';
	$("favtag"+type).className = "current";
	var url = '/home/favorites.php?type='+type+'&'+new Date().getTime();
	var myAjax = new Ajax.Updater($("favcontent"), url,{
		method : "get",
		evalScripts: true
	});
}
function favDel(favId,type){
	if(confirm('确认删除吗？')){
		var url = '/home/handle/favDelHandle.php?favId='+favId+'&type='+type+'&'+new Date().getTime();
		var myAjax = new Ajax.Request( url,{
			method : "get",
			onComplete : function(re){
				iFav(re.responseText);
			}
		});
	}
}
function closeFav(){
	$('favopen').className = 'fav';
}

function siteSearchTab(obj,o, num,goTo){ //Tab切换
	var children = document.getElementById(o).getElementsByTagName('li');	
	for(var i=0; i < children.length; i++){
		children[i].className = ''
	}
	
	document.getElementById("searchForm").action = goTo;
	document.getElementById("seType").value = num;
	obj.className += 'selected'
}

serverFlag = true;
function openOnlineServer(id,obj){
	init(obj);
	if(serverFlag){
		document.getElementById(id).className="open";
		menuOut();
		serverFlag = false;
	}else{
		document.getElementById(id).className="close";
		menuIn();
		serverFlag = true;
	}
}

shareFlag = true;
function openShare(id,obj){
	init(obj);
	if(shareFlag){
		document.getElementById(id).className="open";
		menuOut();
		shareFlag = false;
	}else{
		document.getElementById(id).className="close";
		menuIn();
		shareFlag = true;
	}
}
