function SetHome(obj,url){
		if(!url){
			var url = window.location.href;
		}
        try{
                obj.style.behavior='url(#default#homepage)';obj.setHomePage(url);
        }
        catch(e){
                if(window.netscape) {
                        try {
                                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                        }
                        catch (e) {
                                alert(_lang.prompt1.copy);
                        }
                        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
                        prefs.setCharPref('browser.startup.homepage',url);
                 }
        }
}

function checkeURL(URL){
	var str=URL;
	var Expression=/http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/;
	var objExp=new RegExp(Expression);
	if(objExp.test(str)==true){
		return true;
	}else{
		return false;
	}
} 
function favtodesktop(){
	
	if(!Myself) {
			showDialog(_lang.prompt1.noprevelige_not_self,'notice');
			return;
		}
	showWindow('x_addapp','home.php?mod=spacecp&ac=x_share&op=app&link='+escape(document.getElementById('address').value)+'&handlekey=handle_addapp_'+uid+'&uid='+uid, 'get', 0);
}
function Showtablist(){
	var div=document.createElement('div');
	div.id='tablist_show';
	div.className='tablist_container';
	_window.windows['_W_sys_browser'].contentCase.appendChild(div);
	//div.onmouseout=function(){_window.windows['_W_sys_browser'].contentCase.removeChild(document.getElementById('tablist_show'))}
	var tabs=new Array();
	var objs=document.getElementById('tabs_container').getElementsByTagName('div');
		for (var i=0;i<objs.length;i++){
			if(objs[i].className=='tabs_td' || objs[i].className=='tabs_td_active'){
					tabs.push(objs[i]);
			}
		}
	var html='';
	for(var i=0;i<tabs.length;i++){
	
		html+='<div class="tablist_li" onclick="FocusTab('+tabs[i].id.replace('tab_','')+')">'+document.getElementById('name_'+tabs[i].id.replace('tab_','')).innerHTML+'</div>';
	}
	div.innerHTML=html;
	jQuery(document).bind('mousedown.temp1',function(e){
				//var obj = event.srcElement ? event.srcElement : event.target;
				e=e?e:window.event;
				var obj = e.srcElement ? e.srcElement :e.target;
			
				var tid=jQuery(obj).parent().attr('id');
			//alert(tid);
			if(tid!='tablist_show'){
				
				jQuery('#tablist_show').remove();
				jQuery(document).unbind('.temp1');
				
			}
		});
	
}
function ChangeSequence(direction){
	var tab=_tab.tabs[_window.currentTab];
	if((tab.Csequence<=1 && direction=='back') || (tab.Csequence>=tab.sequence.length && direction=='next')) return;
	else{
		if(direction=='back') tab.Csequence-=1;
		else tab.Csequence+=1;
	}
	document.getElementById('address').value=tab.sequence[tab.Csequence-1];
	document.getElementById('ifm_browser_'+_window.currentTab).src=tab.sequence[tab.Csequence-1];
	if(tab.Csequence==1) document.getElementById('name_'+_window.currentTab).innerHTML=tab.name;
	else document.getElementById('name_'+_window.currentTab).innerHTML=tab.sequence[tab.Csequence-1].replace('http://','');
	if(tab.Csequence<=1 ) document.getElementById('seq_back__W_sys_browser').className='BACK1';
	else document.getElementById('seq_back__W_sys_browser').className='BACK2';
	if(tab.Csequence>=tab.sequence.length ) document.getElementById('seq_next__W_sys_browser').className='NEXT1';
	else document.getElementById('seq_next__W_sys_browser').className='NEXT2'
	

}
function geturlname(url){
	
}
function viewTab(url){
		url = url.substr(0,7).toLowerCase()=="http://"?url:"http://"+url;
		if(checkeURL(url)){
			document.getElementById('address').value=url;
			document.getElementById('ifm_browser_'+_window.currentTab).src=url;
			_tab.tabs[_window.currentTab].url=url;
			if(url!=_tab.tabs[_window.currentTab].sequence[_tab.tabs[_window.currentTab].Csequence-1]){
				document.getElementById('name_'+_window.currentTab).innerHTML=url.replace('http://','');
				_tab.tabs[_window.currentTab].sequence.splice(_tab.tabs[_window.currentTab].Csequence,_tab.tabs[_window.currentTab].sequence.length-_tab.tabs[_window.currentTab].Csequence)
				_tab.tabs[_window.currentTab].Csequence=_tab.tabs[_window.currentTab].sequence.push(url);
				if(_tab.tabs[_window.currentTab].Csequence>1) document.getElementById('seq_back__W_sys_browser').className='BACK2';
				document.getElementById('seq_next__W_sys_browser').className='NEXT1';
			}
		}else{
			alert(_lang.urlinvalid);
		}
}
function FocusTab(tabid){
		if(!document.getElementById('tab_'+tabid)) return;
		var win=_window.windows['_W_sys_browser'];
		jQuery(win.contentCase).find('iframe').hide();
		document.getElementById('ifm_browser_'+tabid).style.display='block';
		document.getElementById('address').value=_tab.tabs[tabid].url;
		jQuery('#tabs_container').find('.tabs_td_active').removeClass('tabs_td_active').addClass('tabs_td');
		document.getElementById('tab_'+tabid).className='tabs_td_active';
		
		_window.currentTab=tabid;
		var tab=_tab.tabs[_window.currentTab];
		if(tab.Csequence<=1 ) document.getElementById('seq_back__W_sys_browser').className='BACK1';
		else document.getElementById('seq_back__W_sys_browser').className='BACK2';
		if(tab.Csequence>=tab.sequence.length ) document.getElementById('seq_next__W_sys_browser').className='NEXT1';
		else document.getElementById('seq_next__W_sys_browser').className='NEXT2';
}
function CloseTab(tabid){
		var win=_window.windows['_W_sys_browser'];
		win.contentCase.removeChild(document.getElementById('ifm_browser_'+tabid));
		document.getElementById('tabs_container').removeChild(document.getElementById('tab_'+tabid));
		delete _tab.tabs[tabid];
		var sum=0;
		for(var id in _tab.tabs){ sum++}
		if(sum<1){
			OpenBrowser('sys_browser','about:blank',_lang.index);
		}else{
			if(_window.currentTab==tabid){
				for(var id in _tab.tabs){
					_window.currentTab=id;
				}
				FocusTab(_window.currentTab);
			}
			
			_window.resetTabs();
		}
		return false;
		
}

function _tab(url,name)
{
	this.id=_tab.zIndex++;
	this.sequence=new Array();
	this.url=url;
	this.name=name;
	this.Csequence=0;
	_tab.tabs[this.id]=this;
};
_tab.tabs={};
_tab.zIndex=0;

function CreateTabs(url ,name)
{

	var win=_window.windows['_W_sys_browser'];
	if(url!='about:blank')	url = url.substr(0,7).toLowerCase()=="http://"?url:"http://"+url;
	var obj=new _tab(url,name);
	_window.currentTab=obj.id;
	obj.Csequence=obj.sequence.push(url);
	document.getElementById('seq_next__W_sys_browser').className='NEXT1';
	document.getElementById('seq_back__W_sys_browser').className='BACK1';
	jQuery(win.contentCase).find('iframe').hide();
	/*for(var id in _tab.tabs){
		if(document.getElementById('ifm_browser_'+id)) document.getElementById('ifm_browser_'+id).style.display='none';
	}*/
	jQuery('#tabs_container').find('.tabs_td_active').removeClass('tabs_td_active').addClass('tabs_td');
	//var xframe = document.cre('<iframe name="ifm_browser_' + _window.currentTab + '" id="ifm_browser_' + _window.currentTab + '" src="'+url+'" frameBorder="0" marginHeight="0" marginWidth="0" class="browserIframe"></iframe>');
	if (BROWSER.ie) {
			xframe = document.createElement('<iframe name="ifm_browser_' + _window.currentTab + '" id="ifm_browser_' + _window.currentTab + '" src="'+url+'" frameBorder="0" marginHeight="0" marginWidth="0" class="browserIframe"></iframe>');
		} else {
			xframe = document.createElement('iframe');
			xframe.name = 'ifm_browser_' + _window.currentTab;
			xframe.id = 'ifm_browser_' + _window.currentTab;
			xframe.className='browserIframe';
			xframe.frameBorder=0;
			xframe.marginHeight=0;
			xframe.marginWidth=0;
			xframe.src=url;
		}
	win.contentCase.appendChild(xframe);
	
	document.getElementById('address').value=url;
	
	var div=document.createElement('div');
	div.id="tab_"+ _window.currentTab;
	div.className="tabs_td_active";
	div.style.cssText="position:absolute; overflow:hidden;width:110px;height:23px;";
	document.getElementById('tabs_container').appendChild(div);
	
	div.innerHTML='<div class="zuo"></div><div id="tab_con_'+_window.currentTab+'" class="bg" onmouseover=\"showClose('+_window.currentTab+',\'over\');\" onmouseout="showClose('+_window.currentTab+',\'out\');" onclick="FocusTab('+_window.currentTab+');"><span class="name_text" id="name_'+_window.currentTab+'">'+name+'</span><div id="close_'+_window.currentTab+'"  onclick="CloseTab('+_window.currentTab+');return false;" class="tabs_close" title="'+_lang.Close+'" ></div></div><div class="you"></div>';
	_window.resetTabs();
	
	
}
function showClose(tabid,evt){

		if(evt=='over'){
			document.getElementById('close_'+tabid).style.display='block'; 
		}else{
			document.getElementById('close_'+tabid).style.display='none'; 
		}

	
}

function ssubmit(obj){
	if((obj.action.indexOf('baidu.com')!=-1 || obj.action.indexOf('gougou.com')!=-1 || obj.action.indexOf('taobao.com')!=-1))	{ 
		if(ieVersion > 0 && ieVersion <=8 ){
				document.charset='GBK';
				obj.submit();
				document.charset='UTF-8';
			}else{
				obj.acceptCharset='GBK';
				obj.submit();
			}
	}else{
		obj.acceptCharset='UTF-8';
		obj.submit();
	}
	
	
	
}
var oldlogos=document.getElementById("logos").innerHTML;
document.getElementById("logos").innerHTML='';
var pdiv=null;
function OpenId(id) {
	if(pdiv) document.body.removeChild(pdiv);
	else	pdiv=document.createElement("div");
	pdiv.style.position="absolute";
	pdiv.style.zIndex=9998;
	pdiv.style.visibility="hidden";
	pdiv.innerHTML=oldlogos;
	var b=document.getElementById("qc"),c=jQuery(b).offset();
	pdiv.style.top=c['top']+b.offsetHeight+10+"px";
	pdiv.style.left=c['left']+"px";
	pdiv.style.cursor="default";
	pdiv.style.width=b.offsetWidth-5+81+"px";
	pdiv.onmouseout=function(){pdiv.style.display='none';};
	pdiv.onmouseover=function(){pdiv.style.display='';};
	document.body.appendChild(pdiv);
	pdiv.style.visibility="visible";
	pdiv.style.display='';
}
function Csite(id) {
	var obj=document.getElementById('aca1');
	var Form=document.getElementById('w');
	var va=document.getElementById('query');
	
	
	switch(id){
		
		case 'google':
			obj.style.background="url('x/images/search/google.gif')";
			Form.action='http://google.com/search?';
			va.name='q';
			Form.acceptCharset='UTF-8';
			fireDOMContentLoaded();
			//aa.setSearchServer("http://www.google.com/search?"); 
			break;
		case 'ggtupian':
			obj.style.background="url('x/images/search/ggtupian.gif')";
			Form.action='http://images.google.com/images?';
			va.name='q';
			Form.acceptCharset='UTF-8';
			fireDOMContentLoaded();
			//aa.setSearchServer("http://images.google.com/images?"); 
			break;
		case 'ggshipin':
			obj.style.background="url('x/images/search/ggshipin.gif')";
			Form.action='http://www.google.com.hk/search?tab=iv&tbo=u&tbs=vid:1&';
			va.name='q';
			Form.acceptCharset='UTF-8';
			fireDOMContentLoaded();
			//aa.setSearchServer("http://video.google.com/videosearch?"); 
			break;
		case 'ggmp3':
			obj.style.background="url('x/images/search/ggmp3.gif')";
			Form.action='http://www.google.cn/music/search?';
			va.name='q';
			Form.acceptCharset='UTF-8';
			//document.getElementById("query").value=encodeURI(document.getElementById("query").value);
			fireDOMContentLoaded();
			//aa.setSearchServer("http://www.google.com/music/search?"); 
			break;
		case 'ggditu':
			obj.style.background="url('x/images/search/ggditu.gif')";
			Form.action='http://maps.google.com/maps?';
			va.name='q';
			Form.acceptCharset='UTF-8';
			fireDOMContentLoaded();
		//	aa.setSearchServer("http://maps.google.com/maps?"); 
			break;
		
		case 'baidu':
			obj.style.background="url('x/images/search/baidu.gif')";
			Form.action='http://www.baidu.com/s?';
			va.name='wd';
			Form.acceptCharset='GBK';
			fireDOMContentLoaded();
		//	aa.setSearchServer("http://www.baidu.com/s?"); 
			break;
		case 'baiduimg':
			obj.style.background="url('x/images/search/baiduimg.gif')";
			Form.action='http://image.baidu.com/i?';
			va.name='word';
			Form.acceptCharset='GBK';
			document.getElementById('ct').value='201326592';
			fireDOMContentLoaded();
			//aa.setSearchServer("http://image.baidu.com/i?"); 
			break;
		case 'baidushipin':
			obj.style.background="url('x/images/search/baidushipin.gif')";
			Form.action='http://video.baidu.com/v?';
			va.name='word';
			Form.acceptCharset='GBK';
			fireDOMContentLoaded();
			//aa.setSearchServer("http://video.baidu.com/v?"); 
			break;
		case 'baidump3':
			obj.style.background="url('x/images/search/baidump3.gif')";
			Form.action='http://mp3.baidu.com/m?';
			Form.acceptCharset='GBK';
			//shtml.innerHTML="<input id=query name=word autocomplete='off' ><input name=ct value=134217728 type=hidden>";
			va.name='word';//shtml.innerHTML="<input id=query name=word autocomplete='off' ><input name=ct value=201326592 type=hidden>";
			document.getElementById('ct').value='134217728';
			fireDOMContentLoaded();
			//aa.setSearchServer("http://mp3.baidu.com/m?"); 
			break;
		case 'baiduzhidao':
			obj.style.background="url('x/images/search/baiduzhidao.gif')";
			Form.action='http://zhidao.baidu.com/q?';
			va.name='word';
			Form.acceptCharset='GBK';
			document.getElementById('ct').value='17';
			document.getElementById('tn').value='ikaslist';
			fireDOMContentLoaded();
		//	aa.setSearchServer("http://zhidao.baidu.com/q?"); 
			break;
		case 'taobao':
			obj.style.background="url('x/images/search/taobao.gif')";
			Form.action='http://search.taobao.com/search?';
			va.name='q';
			Form.acceptCharset='GBK';
			fireDOMContentLoaded();
		//	aa.setSearchServer("http://search.taobao.com/search?"); 
			break;
		case '115':
			obj.style.background="url('x/images/search/115.gif')";
			Form.action='http://115.com/s?';
			va.name='q';
			Form.acceptCharset='GBK';
			fireDOMContentLoaded();
			//aa.setSearchServer("http://115.com/s?"); 
			break;
		case 'gougou':
			obj.style.background="url('x/images/search/gougou.gif')";
			Form.action='http://www.gougou.com/search?';
			va.name='search';
			Form.acceptCharset='GBK';
			fireDOMContentLoaded();
			//aa.setSearchServer("http://www.gougou.com/search?"); 
			
			break;
	}
	if(pdiv)	{document.body.removeChild(pdiv);pdiv=null;}
}
function fireDOMContentLoaded() {
  //  initSuggest();
	//document.getElementById('query').value='';
  //setTimeout(function(){document.getElementById('query').focus();}, 500);
}
function clear() {
    //initSuggest();
	document.getElementById('query').value='';
  	document.getElementById('query').focus();
}


 

//fireDOMContentLoaded();
//if(document.addEventListener)document.addEventListener("DOMContentLoaded",fireDOMContentLoaded,false);
//else var timer=setInterval(function(){try{document.body.doScroll("left");fireDOMContentLoaded();window.clearInterval(timer)}catch(a){}});

var aa; 
function initSuggest(){
	AutoComplete.prototype.showContent=function(){
		var b=document.getElementById("qc"),c=SP.cumOffset(b);
		this.sdiv.className="sw";
		this.sdiv.style.top=c[1]+b.offsetHeight+"px";
		this.sdiv.style.left=c[0]+"px";
		this.sdiv.style.cursor="default";
		this.sdiv.style.width=b.offsetWidth-2+"px";
		SElement.show(this.sdiv);
		this.vis=true;this.curNodeIdx=-1;
	};
	aa=new AutoComplete("query","aa",true);
	aa.setSugServer("http://www.youdao.com/ac/");
	//aa.setLogServer("http://www.youdao.com/");
	aa.setSearchServer("http://www.286.com.cn/s?"); 
	//aa.setKeyFrom("web.index");
	var a=document.getElementById("aca");
	SEvent.observe(a,"click",aa.pressPoint.sbAEListener(aa));
	SEvent.observe(a,"mouseover",aa.onmouseover2.sbAEListener(aa));
	SEvent.observe(a,"mouseout",aa.onmouseout2.sbAEListener(aa));
} 


