/**
 * Top City Application Framework JavaScript
 *
 * @package Application
 * @category JavaScript
 * @subpackage base functions
 * @author Rick
 * @version $0.3$
 * @copyright 2006-11-22 9:23:32
 */
//var trigger='faction',domain='.vbuddy.com';

function Search(o,url,defaultmsg)
{	
	if(defaultmsg != undefined)
	{
		o.default_value = defaultmsg;
	}
	o.org_value=o.value;
	o.style.color='black';
	if(o.org_value == o.default_value)
	{
		o.value='';
	}
	o.onfocus=function(){this.style.color='black';if(this.value==this.default_value)this.value='';}
	o.onblur=function(){if((this.org_value==this.default_value) && (this.value.trim()==''))this.style.color='gray';this.value=this.value.trim()||this.org_value;}
	if(url!=undefined)
	{
		
			o.onkeypress=function(e){e=e||window.event;if (e.keyCode==13 && this.value.trim()) window.location.href=url+'/q:'+encodeURI(this.value.trim());}
		
	}
}

/**
 * common function
 * we can change url parameter name using this function.
 * for example: search network tags  
 *
 * @author Louis
 */
function Search2(o,url,tag,defaultmsg)
{	
	if(defaultmsg != undefined)
	{
		o.default_value = defaultmsg;
	}
	o.org_value=o.value;
	o.style.color='black';
	if(o.org_value == o.default_value)
	{
		o.value='';
	}
	o.onfocus=function(){this.style.color='black';if(this.value==this.default_value)this.value='';}
	o.onblur=function(){if((this.org_value==this.default_value) && (this.value.trim()==''))this.style.color='gray';this.value=this.value.trim()||this.org_value;}
	//o.onkeypress=function(e){e=e||window.event;if (e.keyCode==13 && this.value.trim()) window.location.href='?'+trigger+'=Search'+(this.name?'.'+this.name:'')+'&q='+encodeURI(this.value.trim());}
	if(url!=undefined)
	{
		if(tag!=undefined)
		{
			if(tag.length > 0)
				o.onkeypress=function(e){e=e||window.event;if (e.keyCode==13 && this.value.trim()) window.location.href=url+'/'+tag+':'+encodeURI(this.value.trim());}
			else
				o.onkeypress=function(e){e=e||window.event;if (e.keyCode==13 && this.value.trim()) window.location.href=url+encodeURI(this.value.trim());}
		}
		else
		{
			o.onkeypress=function(e){e=e||window.event;if (e.keyCode==13 && this.value.trim()) window.location.href=url+'/q:'+encodeURI(this.value.trim());}
		}
		
	}
}


/**
 * some mouse's actions on text box or other 
 * 
 * for example: onclick,onfocus,onblur and so on  
 *
 * @author Louis
 */
function MouseAction(o,defaultmsg)
{
	if(defaultmsg != undefined)
	{
		o.default_value = defaultmsg;
	}
	o.org_value=o.value;
	o.style.color='black';
	if(o.org_value == o.default_value)
	{
		o.value='';
	}
	o.onfocus=function(){this.style.color='black';if(this.value==this.default_value)this.value='';}
	o.onblur=function(){if((this.org_value==this.default_value) && (this.value.trim()==''))this.style.color='gray';this.value=this.value.trim()||this.org_value;}
}

function CaptchaReload(){getx('CaptchaImg').src='/Captcha/'+Math.random().toString().substring(2);}
function makex(x,attr){var obj=document.createElement(x);if(attr)setx(obj,attr);return obj;}
function getx(id){return document.getElementById(id);}
function setx(x,attr){for (var name in attr)x.setAttribute(name,attr[name]);}
function addx(o,x){o.appendChild(x);return x;}
function disb(o){o.style.color='#eee';o.disabled=true;if(o.form)o.form.submit();}
function cleartimer(timer){if(timer)window.clearTimeout(timer);}
String.prototype.trim=function(){return this.replace(/(\s+$)|(^\s+)/g, '');}
String.prototype.strim=function(){return this.replace(/\s+/g, ' ').trim();}
String.prototype.ucfirst=function(){return this.length?this.substring(0,1).toUpperCase()+this.substring(1):this;}
function tagform(form,tag)
{	form.onsubmit=function(){if(tag.value==tag.org_value)tag.value='';form.submit();}
	tag.org_value= getJs(161);
	if (tag.value.trim()=='') {tag.style.color="gray";tag.value=tag.org_value;}
	tag.onfocus=function(){this.style.color='black';if(this.value==this.org_value)this.value='';}
	tag.onblur=function(){if(this.value.trim()){this.value=this.value.trim();}else{this.style.color='gray';this.value=this.org_value;}}
	tag.onkeyup=function(){if (this.value.trim()!= this.value.strim()){this.value=this.value.strim();}}
}
function DropDownSelect(oid, val)
{	var obj=document.getElementById(oid);
	for (i=0; i<obj.options.length; i++){if (obj.options[i].value==val){obj.selectedIndex=i;return true;}}
	return false;
}
function getDom(offset)
{	if (navigator.userAgent.indexOf('Opera')>=0) {var dom=document.body;}
	else {var dom=document.documentElement;}
	switch (offset)
	{case 'st':return parseInt(dom.scrollTop);
	case 'oh':return parseInt(dom.offsetHeight);
	case 'sw':return parseInt(dom.scrollWidth);
	case 'sh':return parseInt(dom.scrollHeight);
	case 'ch':return parseInt(dom.clientHeight);
	case 'cw':return parseInt(dom.clientWidth);}
	return dom;
}
var Version={
	init : function()
	{	var Agent = navigator.userAgent;
		this.ie=(Agent.indexOf('MSIE')>=0);
		this.ie7=(Agent.indexOf('MSIE 7')>=0);
		this.opera=(Agent.indexOf('Opera')>=0);
		this.ff=(Agent.indexOf('Firefox')>=0);
		this.safari = (Agent.indexOf('Safari')>=0);
		this.string = Agent;
	}
}
Version.init();
var css={
	_addedSheets : {},
	getsheets : function()
	{	var doc_sheets=document.styleSheets;
		if (doc_sheets.length)	this._sheets=doc_sheets[doc_sheets.length - 1];
	},
	add : function(_name,_class,force)
	{	if (!this._sheets)	this.getsheets();
		if (this._addedSheets.propertyIsEnumerable(_name)&&!force) return;
		if (this._sheets.addRule)
		{	var _curpos=this._sheets.rules.length;
			this._sheets.addRule(_name, _class, _curpos);
		}
		else if (this._sheets.insertRule)
		{	var _curpos=this._sheets.cssRules.length;
			this._sheets.insertRule(_name+' {'+_class+'}' ,_curpos);
		}
		this._addedSheets[_name]=_curpos;
	},
	remove : function(_name)
	{	if (this._addedSheets.propertyIsEnumerable(_name))
		{	if (!this._sheets)	this.getsheets();
			if (this._sheets.removeRule)this._sheets.removeRule(this._addedSheets[_name]);
			else if (this._sheets.deleteRule)this._sheets.deleteRule(this._addedSheets[_name]);
			for (var _index in this._addedSheets)
			{	if (this._addedSheets[_index] > this._addedSheets[_name]) this._addedSheets[_index]--;	}
			delete this._addedSheets[_name];
		}
	}
}

/**
 * Top City Application Framework JavaScript
 *
 * @package Tab Bar content
 * @category JavaScript
 * @subpackage Tabbar
 * @author Rick
 * @version $0.3$
 * @return void 2007-6-7 11:39:18
 */
var TabBar={
	Active : '', Setting:{'Height':25,'Width':90},
	TabHolder : new Array,
	SetStyle : function(_imgpath,_tabcolor,_tabactivecolor,_tabpadding)
	{	this._imgpath=_imgpath;
		this._tabcolor=_tabcolor;
		this._tabactivecolor=_tabactivecolor;
		this._tabpadding=_tabpadding;
	},
	Create : function(id,_color,_padleft)
	{	this._holder=getx(id);
		if (this._holder==undefined) return;
		this._holder.innerHTML='';
		this._bordercolor=(_color!=undefined && _color!=false) ? '#ccc':'black';
		this._padleft=this._step=!isNaN(_padleft) ? _padleft:5;
		with (this._holder.style)
		{	position='relative';
			height=this.Setting.Height+'px';
			borderBottom='1px solid '+this._bordercolor;
		}
	},
	_setstep : function(_step)
	{	this._step += _step;
	},
	_sidebar : function(_name,_active)
	{	if (_active && this.Active==_name)	sideimg='a_left.gif';
		else	sideimg='p_left.gif';
		var _sideimg=makex('div');
		_sideimg.className='_tabbar';
		with (_sideimg.style)
		{	width='3px';
			height='41px';
			left='0px';
			position='absolute';
			background='url('+this._imgpath+sideimg+')';
		}
		return _sideimg;
	},
	_tabname : function(_name,_active)
	{	var tabname=makex('div');
		tabname.innerHTML=_name;
		tabname.style.padding='4px 17px 1px 17px';
		tabname.style.margin='0px 3px';
		tabname.style.textAlign='center';
		if (_active && this.Active==_name)
		{	tabname.style.background='url('+this._imgpath+'a_middle.gif) top repeat-x';
			tabname.style.fontWeight='bold';
		}
		else
		{	tabname.style.background='url('+this._imgpath+'p_middle.gif) top repeat-x';
			var _imgpath=this._imgpath;
			tabname.onmouseover=function(){this.style.background='url('+_imgpath+'h_middle.gif) top repeat-x';}
			tabname.onmouseout=function(){this.style.background='url('+_imgpath+'p_middle.gif) top repeat-x';}
		}
		return tabname;
	},
	_tabrightname : function(_name,_active)
	{	var tabname=makex('div');
		tabname.innerHTML=_name;
		tabname.style.padding='4px 17px 1px 17px';
		tabname.style.margin='0px 3px';
		tabname.style.textAlign='center';
		tabname.style.fontWeight='bold';
		tabname.style.color='#36c';
		if (_active && this.Active==_name)
		{	
			tabname.style.background='url('+this._imgpath+'a_middle.gif) top repeat-x';
		}
		else
		{	tabname.style.background='url('+this._imgpath+'p_middle.gif) top repeat-x';
			var _imgpath=this._imgpath;
			tabname.onmouseover=function(){this.style.background='url('+_imgpath+'h_middle.gif) top repeat-x';}
			tabname.onmouseout=function(){this.style.background='url('+_imgpath+'p_middle.gif) top repeat-x';}
		}
		return tabname;
	},
	_reset : function()
	{	this._step=this._padleft;
		for (var tab in this.TabHolder)
		{	if (tab==this.Active)
			{	this.TabHolder[tab].style.left=this._step+this._tabpadding-3+'px';
				this._setstep(this.TabHolder[tab].offsetWidth+this._tabpadding-6);
			}
			else
			{	this.TabHolder[tab].style.left=(this._step+this._tabpadding).toString()+'px';
				this._setstep(this.TabHolder[tab].offsetWidth+this._tabpadding);
			}
		}
	},
	addTab : function(_name,_link,_active)
	{	if (this._holder==undefined)   return;
		var tabholder=makex('div');
		this.TabHolder[_name]=tabholder;
		if (_active && this.Active=='') this.Active=_name;
		with (tabholder.style)
		{	overflow='hidden';
			position='absolute';
			cursor='pointer';
			if (_active && this.Active==_name)
			{	zIndex=100;
				height=this.Setting.Height+1+'px';
				background='url('+this._imgpath+'a_right.gif) '+this._tabactivecolor+' top right no-repeat';
				left=(this._step+this._tabpadding-3).toString()+'px';
				this._setstep(-6);
			}
			else
			{	height=this.Setting.Height-3+'px';
				marginTop='3px';
				background='url('+this._imgpath+'p_right.gif) '+this._tabcolor+' top right no-repeat';
				left=(this._step+this._tabpadding).toString()+'px';
			}
		}
		if (_link!=undefined && _link!=false)
		{	tabholder.onclick=function()
			{	window.location.href=_link;	}
		}
		addx(this._holder,tabholder);
		addx(tabholder,this._sidebar(_name,_active));
		var new_tab = this._tabname(_name,_active);
		addx(tabholder,new_tab);
		if (new_tab.offsetWidth<(this.Setting.Width-10)) {new_tab.style.width=(this.Setting.Width-40).toString()+'px';}
		this._setstep(tabholder.offsetWidth+this._tabpadding);
	},
	addRightTab : function(_name,_link,_active)
	{	
		if (this._holder==undefined)   return;
		var tabholder=makex('div');
		this.TabHolder[_name]=tabholder;
		if (_active && this.Active=='') this.Active=_name;
		with (tabholder.style)
		{	overflow='hidden';
			position='absolute';
			cursor='pointer';
			if (_active && this.Active==_name)
			{	zIndex=100;
				height=this.Setting.Height+1+'px';
				background='url('+this._imgpath+'a_right.gif) '+this._tabactivecolor+' top right no-repeat';
				//left=(this._step+this._tabpadding-3).toString()+'px';
				//this._setstep(-6);
			}
			else
			{	height=this.Setting.Height-3+'px';
				marginTop='3px';
				background='url('+this._imgpath+'p_right.gif) '+this._tabcolor+' top right no-repeat';
				//left=(this._step+this._tabpadding).toString()+'px';
			}
		}
		if (_link!=undefined && _link!=false)
		{	tabholder.onclick=function()
			{	window.location.href=_link;	}
		}
		addx(this._holder,tabholder);
		addx(tabholder,this._sidebar(_name,_active));
		var new_tab = this._tabrightname(_name,_active);
		addx(tabholder,new_tab);
		if (new_tab.offsetWidth<(this.Setting.Width-10)) {new_tab.style.width=(this.Setting.Width-40).toString()+'px';}
		tabholder.style.left = this._holder.offsetWidth - tabholder.offsetWidth + 'px';
		//this._setstep(tabholder.offsetWidth+this._tabpadding);
	},
	editTab : function (_tab,_newName)
	{	if (this.TabHolder[_tab]!=undefined)
		{	this.TabHolder[_tab].getElementsByTagName('div')[1].innerHTML=_newName;
			this._reset();
		}
	}
}
TabBar.SetStyle('/images/tabbar/','#f4f3ee','#FBFAFC',1);

/**
 * Top City Application Framework JavaScript
 *
 * @package Tips and Confirm
 * @category JavaScript
 * @subpackage Other
 * @author Rick
 * @version $0.3$
 * @return void 2007-6-7 11:39:18
 */
var FloatBox = {
	_config : {'Title':getJs(162),'Question':getJs(163),'Button':getJs(164),'Button2':getJs(129),'Callback':false,'Argu':null},
	_makeBorder : function(x)
	{	if (!this._instance) return;
		if (navigator.userAgent.indexOf('MSIE')>=0) css.add('table#PopWindow th','filter:alpha(opacity=60);');
		var _table=addx(this._instance,makex('table',{'id':'PopWindow'}));
		var _tbody=addx(_table,makex('tbody'));
		var _tr = addx(_tbody,makex('tr'));
		addx(addx(_tr,makex('td')),x);
		var _th = addx(_tr,makex('th',{'id':'PopTR'}));
		var _img= addx(_th,makex('img'));
		_img.src="/images/tabbar/shadow-tr.gif";
		var _tr = addx(_tbody,makex('tr'));
		var _th = addx(_tr,makex('th',{'id':'PopBL'}));
		addx(_th,makex('div',{'id':'PopB'}));
		addx(_tr,makex('th',{'id':'PopBR'}));
		var _w=this._instance.offsetWidth,_h=this._instance.offsetHeight;
		this._instance.style.width=_w+'px';this._instance.style.height=_h+'px';
		this._instance.style.left=(getDom('cw')-_w)/2 + 'px';
		this._instance.style.top=getDom('st')+Math.floor((getDom('ch')-_h)*2/5) + 'px';
		this._instance.style.visibility='visible';
		this._cover.style.visibility='visible';
	},
	_makeBorder2 : function(x,position_top)
	{	if (!this._instance) return;
		if (navigator.userAgent.indexOf('MSIE')>=0) css.add('table#PopWindow th','filter:alpha(opacity=60);');
		var _table=addx(this._instance,makex('table',{'id':'PopWindow'}));
		var _tbody=addx(_table,makex('tbody'));
		var _tr = addx(_tbody,makex('tr'));
		addx(addx(_tr,makex('td')),x);
		/*
		//Comment these codes, the float window will not has the shadow
		var _th = addx(_tr,makex('th',{'id':'PopTR'}));
		var _img= addx(_th,makex('img'));
		_img.src="/images/tabbar/shadow-tr.gif";
		var _tr = addx(_tbody,makex('tr'));
		var _th = addx(_tr,makex('th',{'id':'PopBL'}));
		addx(_th,makex('div',{'id':'PopB'}));
		addx(_tr,makex('th',{'id':'PopBR'}));
		*/
		var _w=this._instance.offsetWidth,_h=this._instance.offsetHeight;
		this._instance.style.width=_w+'px';this._instance.style.height=_h+'px';
		this._instance.style.left=(getDom('cw')-_w)/2 + 'px';
		//this._instance.style.top= 10 + 'px';
		if(position_top != undefined)
			this._instance.style.top= position_top + 'px';
		else
			this._instance.style.top=getDom('st')+Math.floor((getDom('ch')-_h)*2/5) + 'px';
		this._instance.style.visibility='visible';
		this._cover.style.visibility='visible';
	},
	draw : function(o,noshadow)
	{	if (!this._holder)this._holder=document.body;
		if (this._instance) {this._holder.removeChild(this._instance);this._instance=null;}
		var select=document.getElementsByTagName('select'),div=makex('div');
		with (div.style)
		{	position='absolute';visibility='hidden';
			zIndex=2900;top='0px';left='0px';
			width=getDom('sw')+'px';
			height=Math.max(getDom('sh'),getDom('ch'))+'px';
			if (Version.ie&&!Version.ie7){background='none';filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod="scale", src="/images/tabbar/back.png")';}
			else{background='url(/images/tabbar/back.png)';}
		}
		document.body.appendChild(div);
		if (Version.ie&&!Version.ie7&&select.length)
		{	var ifm = addx(div,makex('iframe',{'id':'PopBack'}));
			with(ifm.style){width='100%';height='100%';top='0px';left='0px';filter="Alpha(Opacity=0)";}
		}
		this._cover=div;
		this.windowresize=window.onresize;
		this.bodykeydown=document.body.onkeydown;
		document.body.onkeydown=function(e){e=e||window.event;if (e.keyCode==9){e.cancelBubble=true;e.returnValue=false;if(div.currentStyle){e.keyCode=0;}return false;}}
		window.onresize=function(){div.style.height=Math.max(getDom('sh'),getDom('ch'))+'px';div.style.width=getDom('sw')+'px';}
		this._instance = makex('div');with (this._instance.style)
		{position='absolute';zIndex='2901';top='0px';visibility='hidden';}
		addx(this._holder,this._instance);
		if(noshadow == 'false')
		{
			this._makeBorder2(o);
		}
		else
		{
			this._makeBorder(o);
		}
		
	},
	storeDraw : function(o,noshadow,position_top)
	{	if (!this._holder)this._holder=document.body;
		if (this._instance) {this._holder.removeChild(this._instance);this._instance=null;}
		var select=document.getElementsByTagName('select'),div=makex('div');
		with (div.style)
		{	position='absolute';visibility='hidden';
			zIndex=2900;top='0px';left='0px';
			width=getDom('sw')+'px';
			height=Math.max(getDom('sh'),getDom('ch'))+'px';
			if (Version.ie&&!Version.ie7){background='none';filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod="scale", src="/images/tabbar/back.png")';}
			else{background='url(/images/tabbar/back.png)';}
		}
		document.body.appendChild(div);
		if (Version.ie&&!Version.ie7&&select.length)
		{	var ifm = addx(div,makex('iframe',{'id':'PopBack'}));
			with(ifm.style){width='100%';height='100%';top='0px';left='0px';filter="Alpha(Opacity=0)";}
		}
		this._cover=div;
		this.windowresize=window.onresize;
		this.bodykeydown=document.body.onkeydown;
		document.body.onkeydown=function(e){e=e||window.event;if (e.keyCode==9){e.cancelBubble=true;e.returnValue=false;if(div.currentStyle){e.keyCode=0;}return false;}}
		window.onresize=function(){div.style.height=Math.max(getDom('sh'),getDom('ch'))+'px';div.style.width=getDom('sw')+'px';}
		this._instance = makex('div');with (this._instance.style)
		{position='absolute';zIndex='2901';top='0px';visibility='hidden';}
		addx(this._holder,this._instance);
		if(noshadow == 'false')
		{
			if(position_top != undefined)
				this._makeBorder2(o,position_top);
			else
				this._makeBorder2(o);
		}
		else
		{
			this._makeBorder(o);
		}
		
	},
	init : function(_config)
	{	this.config=_config||this._config;
		this.config.Title=_config.Title||this._config.Title;
		this.config.Question=_config.Question||this._config.Question;
		this.config.Button=_config.Button||this._config.Button;
		this.config.Button2=_config.Button2||this._config.Button2;
		this.config.Callback=_config.Callback||this._config.Callback;
		this.config.Argu=_config.Argu||this._config.Argu;
	},
	alert : function(_config)
	{	if (this._instance) return;
		this.init(_config);
		var _box=makex('div',{'id':'ConfirmBox'});
		var _h=addx(_box,makex('h5'));_h.innerHTML=this.config.Title;
		var _p=addx(_box,makex('p'));_p.innerHTML=this.config.Question;
		var _center=addx(_box,makex('center'));
		_center.innerHTML='<input type="button" onclick="FloatBox.cancel();" value="'+getJs(164)+'" />';
		this.draw(_box);
	},
	confirm : function(_config)
	{	if (this._instance) return;
		this.init(_config);
		var _box=makex('div',{'id':'ConfirmBox'});
		var _h=addx(_box,makex('h5'));_h.innerHTML=this.config.Title;
		var _p=addx(_box,makex('p'));_p.innerHTML=this.config.Question;
		var _center=addx(_box,makex('center'));
		_center.innerHTML='<input type="button" onclick="FloatBox.ok();" value="'+(this.config.Button||getJs(164))+'"/><input type="button" onclick="FloatBox.cancel();" value="'+getJs(129)+'" />';
		this.draw(_box);
	},
	confirm2 : function(_config)
	{	if (this._instance) return;
		this.init(_config);
		var _box=makex('div',{'id':'ConfirmBox'});
		var _h=addx(_box,makex('h5'));_h.innerHTML=this.config.Title;
		var _p=addx(_box,makex('p'));_p.innerHTML=this.config.Question;
		var _center=addx(_box,makex('center'));
		_center.innerHTML='<input type="button" onclick="FloatBox.ok();" value="'+(this.config.Button||getJs(164))+'"/><input type="button" onclick="FloatBox.cancel();" value="'+(this.config.Button2||getJs(129))+'" />';
		this.draw(_box);
	},
	confirm3 : function(_config)
	{	if (this._instance) return;
		this.init(_config);
		var _box=makex('div',{'id':'ConfirmBox'});
		var _h=addx(_box,makex('h5'));_h.innerHTML=this.config.Title;
		var _p=addx(_box,makex('p'));_p.innerHTML=this.config.Question;
		var _center=addx(_box,makex('center'));
		_center.innerHTML='<table><tr><td><input type="button" onclick="FloatBox.ok();" value="'+(this.config.Button||getJs(164))+'"/></td><td>|&nbsp;&nbsp;<a href="javascript:void(0)" onclick="FloatBox.cancel();" style="font-weight:bolder">'+(this.config.Button2||getJs(129))+'</td></tr></table>';
		this.draw(_box);
	},
	ok : function()
	{	this.cancel();
		if (this.config.Callback)
		{	this.config.Callback(this.config.Argu||null);	}
	},
	cancel : function()
	{	if (this._instance) {this._holder.removeChild(this._instance);this._instance=null;}
		document.body.removeChild(this._cover);
		window.onresize=this.windowresize;
		document.body.onkeydown=this.bodykeydown;
	}
}
var Tips = {
	_time:1000,
	Run : function(_text,_time)
	{	if (this.tip)
		{	cleartimer(this._timer);
			this._timer=0;
			this.tip.parentNode.removeChild(this.tip);
			this.tip=null;
		}
		var _tip=makex('div');
		var dom = getDom();
		this.tip=_tip;
		with (_tip.style)
		{	width = '180px';
			padding = '2px';
			position = 'absolute';
			textIndent = '22px';
			margin='8px';
			zIndex = '100';
			lineHeight = '20px';
			top = dom.scrollTop.toString()+'px';
			left = (dom.offsetWidth+dom.scrollLeft - ((navigator.userAgent.indexOf('MSIE')>=0)?218:200)).toString() + 'px';
			background = 'url(/images/site/running.gif) #FFE835 2px 2px no-repeat;';
		}
		addx(document.body,_tip);
		window.onscroll = window.onresize = function()
		{	_tip.style.top = dom.scrollTop.toString()+'px';
			_tip.style.left = (dom.offsetWidth+dom.scrollLeft - ((navigator.userAgent.indexOf('MSIE')>=0)?218:200)).toString() + 'px';
		}
		_tip.innerHTML=_text;
		this._timer= window.setTimeout(function(){cleartimer(_tip.timer);Tips.tip=null;_tip.parentNode.removeChild(_tip);},_time||this._time);
	}
}
function Confirm(config){FloatBox.confirm(config||false);}
function Confirm2(config){FloatBox.confirm2(config||false);}
function Confirm3(config){FloatBox.confirm3(config||false);}
function Alert(config){FloatBox.alert(config||false);}
function addComment(id,a){gotoHash(a||'#Comment');getx(id||'CommentArea').focus();}
function Comment(q,o){q.Callback=gotoUrl;q.Argu=o.href;Confirm(q);}
var pDelete={'Title':getJs(166),'Question':getJs(167),'Button':getJs(168)};
var bDelete={'Title':getJs(169),'Question':getJs(170),'Button':getJs(168)};
var cDelete={'Title':getJs(171),'Question':getJs(172),'Button':getJs(168)};
var cCancel={'Title':getJs(173),'Question':getJs(174),'Button':getJs(175)};
var cReject={'Title':getJs(176),'Question':getJs(177),'Button':getJs(178)};

/**
 * Top City Application Framework JavaScript
 *
 * @package
 * @category JavaScript
 * @subpackage
 * @author Tony
 * @version $0.3$
 * @return void 2007-02-21 23:10:18
 */
function gotoUrl(url){window.location.href=url;}
function gotoHash(hash){window.location.hash=hash;}
function goBack(){history.back(-1);}

/**
 * Create a cookie 
 * 
 * @Para string name : cookie's name
 * @Para mix value : cookie's value, it can be array/string/number and so on
 * @Para int days : cookie's expires, the unit is 'day'.
 */
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/;domain="+domain;
}

/**
 * Read the cookie and return the value of cookie 'name'
 * if the cookie is not exist, return null
 * 
 * @Para string name : cookie's name
 * @Return mix : the return value can be array, int, string and so on.
 */
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

/**
 * Delete the cookie
 */
function eraseCookie(name) {
	createCookie(name,"",-1);
}

/**
 * Modify above function for friendly urls
 *
 * @package
 * @category JavaScript
 * @subpackage
 * @author louis
 * @return string 2007-09-05
 */
function setNQS(qr,s,n)
{	if(qr=='' || s=='')	return qr;
	qs= '/'+qr+'/';
	if(s!='' && n=='')
	{	if(qs.indexOf('/'+s+':')>=0)
		{	qs1=qs.substring(0,qs.indexOf('/'+s+':'));
			ts=qs.substring(qs.indexOf('/'+s+':'));
			qs2=ts.substring(ts.indexOf('/'));
			return ts.substring(1,ts.length-1);
		}
		else
		{	return qr;	}
	}
	if(s!='' && n!='')
	{	if(qs.indexOf('/'+s+':'+n+'/')>=0)
		{	return qr;	}
		else
		{	if(qs.indexOf('/'+s+':')>=0)
			{	qs1=qs.substring(0,qs.indexOf('/'+s+':'));
				ts=qs.substring(qs.indexOf('/'+s+':')+1);
				qs2=ts.substring(ts.indexOf('/'));
				ts=qs1+'/'+s+':'+n+qs2;
				return ts.substring(1,ts.length-1);
			}
			else
			{	ts=qs+s+':'+n+'/';
				return ts.substring(1,ts.length-1);
			}
		}
	}
}


/**
 * Open a new window for url
 *
 * @author louis
 * @return false
 */
function openNewWindow(url)
{
	window.open(url,'winname','scrollbars=yes,menubar=no,width=620,height=520,resizable=yes,toolbar=no,location=no,status=no,screenX=200,screenY=100,left=200,top=100');
	return false;
}

var globalTip = {
	options : 
	{
		'hidden'		: true,
		'defValue'		: '',
		'defColor'		: 'gray',
		'actColor'		: 'black',
		'message'		: '',				//message will be shown
		'boxContentId'	: 'tipContent',		//messages' container
		'boxFloatId' 	: 'inputTip',		//messages' container's container.
		'boxWidth' 		: 0,				//width of tip box
		'topDiff'		: -30,
		'leftDiff'		: 8
	},
	checkOption : function(ops)
	{
		var config = this.options;
		for(prop in ops)
		{
			for(p in config)
			{
				if(p == prop)
					config[p] = ops[prop];
			}
		}
		this.options = config;
	},
	drawTable:function(x)
	{
	  	var _table = makex('table');
	  	var _tbody = addx(_table,makex("tbody"));
	  	var _tr = addx(_tbody,makex("tr"));
	  	addx(_tr,makex("td",{"id":"LTcorner"}));
	  	var _topB = addx(_tr,makex("td"));
	  	_topB.className = "TDB";
	  	addx(_tr,makex("td",{"id":"RTcorner"}));
	  	var _tr = addx(_tbody,makex("tr"));
	  	var _leftB = addx(_tr,makex("td"))
	  	_leftB.className = "LRB";
	  	var TdCore = addx(_tr,makex("td",{"id":"core"}));
	  	var _RightB = addx(_tr,makex("td"));
	  	_RightB.className = "LRB";
	  	var _tr = addx(_tbody,makex("tr"));
	  	addx(_tr,makex("td",{"id":"LDcorner"}));
	  	var _downB = addx(_tr,makex("td"));
	  	_downB.className = "TDB";
	  	addx(_tr,makex("td",{"id":"RDcorner"}));
	  	addx(x,_table);
	  	var _div = addx(TdCore,makex("div",{"id":this.options.boxContentId}));
	  	_table._Core = _div;
	  	return _table;
  	},
	rightTip : function(o,ops)
	{
		this.checkOption(ops);
		var config = this.options;
		
	    if((config.hidden) && (this.Holder))
	    {
	    	this.Holder.parentNode.removeChild(this.Holder);
	    	this.Holder = null;
	    }
	
		if(config.defValue.trim().length > 0)
	  	{
	  		o.dVal = config.defaultValue;
	  		if(o.value == o.dVal)
	  		{
	  			o.value = '';
	  			o.style.color = config.actColor;
	  		}
	  	}
	  	
	  	if(!this.Holder)
	  	{ 		
	  	
		  	o.style.position="relative";
		  	if(config.message.trim().length <= 0) return;
		  	var floatTip = makex("div",{"id":config.boxFloatId});
		  	this.Holder = floatTip;
		  	var re = /^[0-9]+$/;
		  	if((re.test(config.boxWidth)) && (config.boxWidth > 0) )
		  		floatTip.style.width = config.boxWidth + 'px';
		  	var outTable = this.drawTable(floatTip);
		  	outTable._Core.innerHTML = config.message;
		  	floatTip.style.left = o.offsetLeft + o.offsetWidth + config.leftDiff + 'px'; 
		  	floatTip.style.top  = o.offsetTop  + config.topDiff + 'px';
		  	addx(o.parentNode,floatTip);
	  	}
	  	
	  	o.onblur = function() { 
	  		if(globalTip.Holder)
	  		{
	  			globalTip.Holder.parentNode.removeChild(globalTip.Holder);
	  			globalTip.Holder = null;;
	  		}	  			
	  		if((this.value.trim() == '') && (this.dVal))
	  		{
	  			this.style.color = globalTip.defColor;
	  			this.value = this.dVal;
	  		}
	  	};
	}
}

/**
 * close the message that someone users was kicked out from the network  
 *
 * @author Louis
 */
function closeKickedOutMsg(o,network_id)
{
	o.src = '/images/icon/x-over.gif';
	o.onclick = function(){
		var para = {'network_id':network_id};
		$.ajax({
			beforeSend:function(){
				o.src = '/images/site/running.gif';
			},
			success:function(data){
				var json=eval('(' + data + ')');
				if(json.flag == 'successful')
				{
					o.parentNode.parentNode.removeChild(o.parentNode);
				}
			},
			type:'POST',
			data: para,
			url : '/network/closekickedoutmsg'
		});
	}
	o.onmouseout = function(){
		this.src = '/images/icon/x.gif';
	}
}

/**
 * set the language that is used by system. 
 *
 * @author Louis
 */
function init_set_language_cookie(val, tourl)
{
	createCookie('vbuddy_lang',val,10000);
	if(!tourl)
	{
		tourl = window.location.toString();
	}
	gotoUrl(tourl);
}

/**
 * get the message. 
 *
 * @author Louis
 */
function getJs(num,o)
{
	var p = 'js_messages.js_'+num;
	var jsMsg = (eval(p)||'error');
	if(typeof(o) == 'object')
	{
		for(var pa in o)
		{
			var reg = new RegExp('<@'+pa+'@>',"gi");
			jsMsg = jsMsg.replace(reg,o[pa]);
		}
	}
	return jsMsg;

}