/*showFlash*/
function forumFlash(iUrl,iId,iWidth,iHeight,iWmode)
{
	var flash = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+ iWidth +'" height="' + iHeight +'" id = "'+iId+'"/>';
	flash = flash + '<param name="movie" value="'+ iUrl +'" />';
	flash = flash + '<param name="quality" value="high" />';
	flash = flash + '<param name="menu" value="false" />';
	if (iWmode == 1) {
	   flash = flash + '<param name="wmode" value="transparent" />';      
	}
	flash = flash + '<embed src="' + iUrl + '" width="'+ iWidth +'" height="'+ iHeight +'" menu="false" quality="high" name="'+iId+'"';
	if (iWmode == 1) {
	   flash = flash + 'wmode="transparent" ';      
	}
	flash = flash + ' pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" mwode="transparent"></embed>';
	flash = flash + '</object>';
	
	document.writeln(flash); 
	//alert(flash);
}
/*popwin*/
function openwin(w,h){
	document.getElementById("winbox").style.display = "block";
	document.getElementById("winbox").style.marginLeft = -w/2 + "px";
	document.getElementById("winbox").style.marginTop = -h/2 + "px";
	document.getElementById("winbox_bg").style.width = w + "px";
	document.getElementById("winbox_bg").style.height = h + "px";
	document.getElementById("winbox_main").style.width = w - 20 + "px";
	document.getElementById("winbox_main").style.height = h - 20 + "px";	
	document.getElementById("winbox").style.top = document.documentElement.scrollTop + 400 + "px";
}
function openwin2(w,h){
	document.getElementById("winbox2").style.display = "block";
	document.getElementById("winbox2").style.marginLeft = -w/2 + "px";
	document.getElementById("winbox2").style.marginTop = -h/2 + "px";
	document.getElementById("winbox_bg2").style.width = w + "px";
	document.getElementById("winbox_bg2").style.height = h + "px";
	document.getElementById("winbox_main2").style.width = w - 20 + "px";
	document.getElementById("winbox_main2").style.height = h - 20 + "px";	
	document.getElementById("winbox2").style.top = document.documentElement.scrollTop + 400 + "px";
}
function finalTop(w,h){
	document.getElementById("winbox").style.display = "block";
	document.getElementById("winbox").style.marginLeft = -w/2 + "px";
	document.getElementById("winbox").style.marginTop = -h/2 + "px";
	document.getElementById("winbox_bg").style.width = w + "px";
	document.getElementById("winbox_bg").style.height = h + "px";
	document.getElementById("winbox_main").style.width = w - 20 + "px";
	document.getElementById("winbox_main").style.height = h - 20 + "px";
	//alert(document.documentElement.scrollHeight);
	document.getElementById("winbox").style.top = document.documentElement.scrollHeight - 500 + "px";
}
function closewin(){
document.getElementById("winbox").style.display = "none";
}
function closewin2(){
document.getElementById("winbox2").style.display = "none";
}
function showforums(){
openwin(640,550)
}
function showforums2(){
openwin2(640,580)
}
/*type_write*/
var count=0;

var xcount2 = 1;
var xcount3 = 0;
var type2,tip2;
var xflag = false;
var stop_time = 5; //设定多长时间后改变提示信息
var jump_time = 10; //设定多长时间后跳转
var jump_url = "general_forum.php";
function doTip(){
	xcount2++;
	if( xcount2 >= stop_time &&  xcount2 <= jump_time ){
		document.getElementById(tip2).innerHTML = "Now you are able to select either \"General\" or \"Game Pub\" and start your travel. If you haven't selected a pub in " + (jump_time-stop_time-xcount3) + " second, our waitress will lead you to the closest area - \"General Pub\".";
		xcount3++;
		xflag = true;
	}
	if( xcount2 > jump_time ){
		xcount2 = 0;
		clearTimeout(type2);
		window.location = jump_url;
	}
	type2 = setTimeout("doTip()",1000);
}

function type_write(div,content,newFlag){
	  if(count<=content.length){
	   document.getElementById(div).innerHTML=content.substring(0,count);
	   count++;
	   type = setTimeout("type_write(\""+div+"\",\""+content+"\"," + newFlag + ")",30);
	  }else{
		  if( newFlag == 1 ){
			  if( type2 != undefined ){
			  	clearTimeout(type2);
		   	  }
		  	  tip2 = div;
		   	  doTip();
		  }
	   clearTimeout(type); 
	  }
	  document.body.onclick = function(){ 
	  		if( !xflag ){
				if( newFlag == 1 ){
					if( type2 != undefined ){
	     				clearTimeout(type2);
	   				}
					tip2 = div;
	   				doTip();
				}
		   		clearTimeout(type);
		    	document.getElementById(div).innerHTML=content;
			}
	  }
	  
}

function g_close_pop()
{
  g_pop.close();
}
function changetext(objElement) { 
var oTextCount = document.getElementById("txtCount"); 
iCount = objElement.value.length; 
oTextCount.value =  iCount; 
} 

function gopreview(){
	if(document.getElementById("body").value!=document.getElementById("memo").value){
		document.getElementById("body").value=document.getElementById("memo").value;
		var popupWin = window.open('', 'preview_page', 'scrollbars=yes,width=600,height=400');
		document.preview.submit()
	}
}

function check(obj)
{
	if(obj.user.value == ''){
		alert('Please input username.');
		return false;
	}else if(obj.pass.value == ''){
		alert('Please input password.');
		return false;
	}else{
		return true;
	}
}


    /*flash auto menu*/

	  
function floater(){
	var floaterObj = document.getElementById("floater");
	if(floaterObj){
		floaterObj.style.top=document.documentElement.scrollTop +"px";
	}
}
function scall(){
	floater();
}
window.onscroll=scall;
window.onresize=scall;
window.onload=scall;


function changeLetter(num){
	$(".scenter > div > div").css("display","none");
	$("#letter"+num).css("display","block");
	$(".sleft > p > a").removeClass('on');
	$(".sleft > p > a:eq("+num+")").addClass('on');
	}
function subLetter(obj,num){
	$(".sright >  div").css("display","none");
	$("#sub"+num).css("display","");
	$(".scenter > div >div > p > a").removeClass('on');
	$(obj).addClass('on');
	}
function setImg(dir){
	ubbTag( "memo","[img]",dir );
	//theGetFocus.init( "memo","[img]"+dir+"[/img]" );
	//theGetFocus.setTxtToFocusPosition();
	/*document.getElementById('memo').value += "[img]"+dir+"[/img]";*/
}

/* thick box */
function tooltip(){
	var id = 'tt';
	var top = 3;
	var left = 3;
	var maxw = 300;
	var speed = 10;
	var timer = 20;
	var endalpha = 95;
	var alpha = 0;
	var tt,t,c,b,h;
	var ie = document.all ? true : false;
	this.x = false;
	var o = this;
	o.x_x = false;
	
	return{
		show:function(v,w){
			if(this.x){
				if(tt == null){
					tt = document.createElement('div');
					tt.setAttribute('id',id);
					t = document.createElement('div');
					t.setAttribute('id',id + 'top');
					c = document.createElement('div');
					c.setAttribute('id',id + 'cont');
					b = document.createElement('div');
					b.setAttribute('id',id + 'bot');
					tt.appendChild(t);
					tt.appendChild(c);
					tt.appendChild(b);
					document.body.appendChild(tt);
					tt.style.opacity = 0;
					tt.style.filter = 'alpha(opacity=0)';
					
					o.x_x = true;
					
					document.onmousemove = this.pos;
				}
				tt.style.display = 'block';
				c.innerHTML = v;
				tt.style.width = w ? w + 'px' : 'auto';
				if(!w && ie){
					t.style.display = 'none';
					b.style.display = 'none';
					tt.style.width = tt.offsetWidth;
					t.style.display = 'block';
					b.style.display = 'block';
				}
				if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
				h = parseInt(tt.offsetHeight) + top;
				clearInterval(tt.timer);
				tt.timer = setInterval(function(){tooltip.fade(1)},timer);
			
			}
		},
		pos:function(e){
			if( o.x_x ){
				var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
				var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;			
				tt.style.top = (u - h) + 'px';
				tt.style.left = (l + left) + 'px';
			}
		},
		fade:function(d){
			if( o.x_x ){
				var a = alpha;
				if((a != endalpha && d == 1) || (a != 0 && d == -1)){
					var i = speed;
					if(endalpha - a < speed && d == 1){
						i = endalpha - a;
					}else if(alpha < speed && d == -1){
						i = a;
					}
					alpha = a + (i * d);
					tt.style.opacity = alpha * .01;
					tt.style.filter = 'alpha(opacity=' + alpha + ')';
				}else{
					clearInterval(tt.timer);
					if(d == -1){tt.style.display = 'none'}
				}
			}
		},
		hide:function(){
			if( o.x_x ){
				clearInterval(tt.timer);
				tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
			}
		}
	};
}

//投票结果查看
function vote_openwin(w,h){
	document.getElementById("vote_winbox").style.display = "block";
	document.getElementById("vote_winbox").style.marginLeft = -w/2 + "px";
	document.getElementById("vote_winbox").style.marginTop = -h/2 + "px";
	document.getElementById("vote_winbox_bg").style.width = w + "px";
	document.getElementById("vote_winbox_bg").style.height = h + "px";
	document.getElementById("vote_winbox_main").style.width = w - 20 + "px";
	document.getElementById("vote_winbox_main").style.height = h - 20 + "px";	
	document.getElementById("vote_winbox").style.top = document.documentElement.scrollTop + 400 + "px";
}
function vote_finalTop(w,h){
	document.getElementById("vote_winbox").style.display = "block";
	document.getElementById("vote_winbox").style.marginLeft = -w/2 + "px";
	document.getElementById("vote_winbox").style.marginTop = -h/2 + "px";
	document.getElementById("vote_winbox_bg").style.width = w + "px";
	document.getElementById("vote_winbox_bg").style.height = h + "px";
	document.getElementById("vote_winbox_main").style.width = w - 20 + "px";
	document.getElementById("vote_winbox_main").style.height = h - 20 + "px";
	//alert(document.documentElement.scrollHeight);
	document.getElementById("vote_winbox").style.top = document.documentElement.scrollHeight - 500 + "px";
}
function vote_closewin(){
	document.getElementById("vote_winbox").style.display = "none";
}
function vote_show(){
	vote_openwin(640,350)
}