var Starter={
	funs:[],add:function (fun){
		if(!this.funs){
			this.funss=[];
			
		}
		this.funs.push(fun);
		
	},start:function (){
		if(!this.funs||this.funs.length<=0){
			return ;
			
		}
		$A(this.funs).each(function (f){
			(f)();
			
		});
		
	}
};

var LoadBar={
	show:function (text,type){
		
		clearTimeout(this.timeout);
		//text=text||(((typeofApp!='undefined')&&App.Lang&&App.Lang.loading)?App.Lang.loading:'loading...');		
		this.build(text);		
		if(type=='ok'){
			
			Element.addClassName(this.element,'okBar');			
			
		}
		
		
		
		else {
			Element.removeClassName(this.element,'okBar');
			
		}
		Element.show(this.element);
		this.element.style.right='0px';
		this.element.style.top=document.documentElement.scrollTop+30+'px';
		this.showStatusBar(text);
		
	},hide:function (delay){
		if(LoadBar.element){
			LoadBar.timeout=setTimeout(function (){
				if(LoadBar.element){
					Element.hide(LoadBar.element);
					
				}
				LoadBar.hideStatusBar();
				
			},((delay&&!isNaN(delay))?delay:0));
			
		}
	},destroy:function (){
		if(this.element){
			Element.remove(this.element);
			this.element=null;
			
		}
	},build:function (text){
		if(this.element){
			this.element.firstChild.firstChild.alt=text;
			this.element.firstChild.childNodes[1].nodeValue=text;
			return ;
			
		}
		
		this.element=document.createElement('div');		
		Element.addClassName(this.element,'loadBar');		
		this.element.style.zIndex=1000;		
		this.element.style.position='absolute';		
		Element.hide(this.element);		
		var innerDiv=document.createElement('div');		
		var img=/*((typeofApp!='undefined')&&App.Actions&&App.Actions.imgPath)?App.Actions.imgPath+'loading.gif':*/'/common/images/loading.gif';		
		innerDiv.innerHTML='<img src="'+img+'" alt="text" />'+text;		
		this.element.appendChild(innerDiv);		
		document.body.appendChild(this.element);
		
	},
	showStatusBar:function (text){
		
		setTimeout(function (){
			
			window.status=text;
			
		},10);		
		
	},
	hideStatusBar:function (){
		
		setTimeout(function (){
			window.status='';
			
		},10);		
		
	},
	loadPage:function (){
		
		this.show('请稍候，正在下载...');		
		
	}
	
};
Starter.add(LoadBar.hide);
if($('_loadingText')){
	
	Element.hide($('_loadingText'));	
	LoadBar.loadPage();	
	
}

function loadTopBar() {
LoadBar.show('读取中...');
var url='/ajax/space/getHead!default.jspa';
var pars='';
var myAjax=new Ajax.Request(url,{method:'post',parameters:pars,onComplete:doneTopBar});
} 

function doneTopBar(req){
	$('siteNav').innerHTML = req.responseText;
	JQ(".topSlideup").click(function(){
		JQ("#siteNav").slideUp();
	}) 
}

function addFav(aUrl,aTitle){
	window.external.AddFavorite(aUrl,aTitle);
}

function logout(){
	var aurl = document.URL; 
	if(document.getElementById('_logoutURL')){
		aurl = document.getElementById('_logoutURL').innerText;
	}
	window.location.href = "http://login.lava.cn/logout.jspa?url=" + escape(aurl);
}

function login(){
	window.location.href = "http://login.lava.cn/login!default.jspa?&successURL=" + escape(document.URL);
}


function register(){
	window.location.href = "http://register.lava.cn/userRegister!default.jspa?fromURL=" + escape(document.URL);
}

function copyUrl(aUrl) 
{
	window.clipboardData.setData('text',aUrl)
	alert('网址复制成功啦!');			
}

function copyContent(txt,info) 
{
	window.clipboardData.setData('text',txt)
	alert(info);			
}

function clearTxt(elementID){
	document.getElementById(elementID).value = "";
}

function SetString(str,len)
{
 var strlen = 0;
 var s = "";
for(var i = 0;i < str.length;i++)
{
     if(str.charCodeAt(i) > 128)
         strlen += 2;
      else
        strlen++;
      s += str.charAt(i);
      if(strlen >= len)
        return s + "...";
}
return s;
}
