﻿
//-----------------------------------------------------------------------------
//  rollover image
//-----------------------------------------------------------------------------

function imgChange(obj, imgSrc) {
  obj.src = imgSrc;
}

//-----------------------------------------------------------------------------
// onfocus
//-----------------------------------------------------------------------------


function allblur() {
			for (i = 0; i < document.links.length; i++)
				  document.links[i].onfocus = document.links[i].blur;
	 }

function bluring(){ 
	if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus();
} 
//document.onfocusin=bluring;


// blur//
function autoblur()
 {
	if(event.srcElement.tagName == "A")
	{
		 document.body.focus();
	}
}
//document.onfocusin = autoblur;

//#### javascript left/right (coder:son) ####
function Left(str, n){
if (n <= 0)
    return "";
else if (n > String(str).length)
    return str;
else
    return String(str).substring(0,n);
}


function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}
//#### javascript left/right (coder:son) ####

//only english and numeric
function check_stringornumber(tmp)
{
	for (i = 0; i < tmp.value.length; i++) {
		if (tmp.value.charAt(i) >= '0' && tmp.value.charAt(i) <= '9')
			continue;
		else if (tmp.value.charAt(i) >= 'a' && tmp.value.charAt(i) <= 'z')
			continue;
		else if (tmp.value.charAt(i) >= 'A' && tmp.value.charAt(i) <= 'Z')
			continue;
		else {
			alert("inserting only english and numeric!");
			tmp.focus();
			tmp.select();
			return false;
		}
	}
	return true;
}

//User info rayer open
function openUserDiv(userid)
{
	viewMemInfoFrm.userid.value = userid;
	m_x=(document.layers)?k.pageX:document.body.scrollLeft+event.clientX 
	m_y=(document.layers)?k.pageY:document.body.scrollTop+event.clientY 

	var m_x = Number(m_x)-2;
	var m_y = Number(m_y)-2;

	viewMemInfo.style.left = m_x;
	viewMemInfo.style.top = m_y;
	viewMemInfo.style.visibility = "";
}

//friend register function
function regFriend(userid)
{
	if(confirm("Bạn đã đăng ký  bạn chơi.đó thành bạn?")==true)
	{
		friendIfra.location.href = 	"/forum/common/register_friend.html?userid="+userid;
	}
}

//userid click open rayer/proc
function openInfo(str)
{
	if(str == "1")
	{
	//user info
	window.open('/forum/common/view_member.html?userid='+viewMemInfoFrm.userid.value, 'viewinfo', 'width=550 height=290');
	}
	else if(str == "2")
	{
	//real short message
	window.open('/forum/common/send_memo.html?userid='+viewMemInfoFrm.userid.value, 'viewinfo', 'width=400 height=270');
	}
	else if(str == "3")
	{
	//1:1 chatting
	window.open('/forum/common/request_1to1.html?userid='+viewMemInfoFrm.userid.value, 'viewinfo', 'width=360 height=280');
	}
	else if(str == "4")
	{
	//register friend
	regFriend(viewMemInfoFrm.userid.value);
	}
	
	viewMemInfo.style.visibility = "hidden";
}


function GFcActiveXWrite(s) {
    document.write (s);
}
//bug 
//function bug(){
//url = "/event/20061113_pop_01.html" ;
//window.open(url,'','toolbar=no,menubar=no,location=no,directions=no, scrollbars=no,status=no,width=400,height=500');
//}
 
function go_go(u,t,c)
{
window.open(u,t);
if(c == "Y")
{
	window.self.close();
}		
}	

function refill(mo) 
{ 
var width = 350;
var height = 520;
var vtop  = (screen.height - height) / 2;
var vleft = (screen.width - width) / 2;
var opt ="toolbar=0, status=0, scrollbars=no, location=0, menubar=0, width=350, height=520";
window.open("/game/common/success_refill.html?game_no="+mo,"popup",opt);

}

