// JavaScript Document
var bgr = new Array(
	new Array("99", "1024", "920", "http://i2.ytimg.com/bg/ISq8lfBLVWSjovAWWKmCiQ/101.jpg", "", "_blank", "", "104")
);

var bgrin = new Array(
	new Array("99", "1024", "920", "http://i2.ytimg.com/bg/ISq8lfBLVWSjovAWWKmCiQ/101.jpg", "", "_blank", "", "104")
);

var bgrin2 = new Array(
	new Array("99", "1024", "920", "http://i2.ytimg.com/bg/ISq8lfBLVWSjovAWWKmCiQ/101.jpg", "", "_blank", "", "104")
);

	var http = createRequestObject();
	function createRequestObject() {
		var xmlhttp;
		try { xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch(e) {
	    try { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
		catch(f) { xmlhttp=null; }
	  }
	  if(!xmlhttp&&typeof XMLHttpRequest!="undefined") {
		xmlhttp=new XMLHttpRequest();
	  }
		return  xmlhttp;
	}
	function wmpEmbed(_width, _height, _url)
	{
		_h='<OBJECT id="wmp" type=application/x-oleobject height="'+_height+'" width="'+_width+'" classid=CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6>'+
		'<PARAM NAME="URL" VALUE="'+_url+'">'+
		'<PARAM NAME="rate" VALUE="1">'+
		'<PARAM NAME="balance" VALUE="0">'+
		'<PARAM NAME="currentPosition" VALUE="0">'+
		'<PARAM NAME="defaultFrame" VALUE="">'+
		'<PARAM NAME="playCount" VALUE="1">'+
		'<PARAM NAME="loop" VALUE="true">'+
		'<PARAM NAME="autoStart" VALUE="-1">'+
		'<PARAM NAME="currentMarker" VALUE="0">'+
		'<PARAM NAME="invokeURLs" VALUE="0">'+
		'<PARAM NAME="baseURL" VALUE="">'+
		'<PARAM NAME="volume" VALUE="100">'+
		'<PARAM NAME="mute" VALUE="0">'+
		'<PARAM NAME="uiMode" VALUE="full">'+
		'<PARAM NAME="menu" VALUE="false">'+
		'<PARAM NAME="stretchToFit" VALUE="0">'+
		'<PARAM NAME="windowlessVideo" VALUE="0">'+
		'<PARAM NAME="enabled" VALUE="-1">'+
		'<PARAM NAME="enableContextMenu" VALUE="-1">'+
		'<PARAM NAME="fullScreen" VALUE="0">'+
		'<PARAM NAME="SAMIStyle" VALUE="">'+
		'<PARAM NAME="SAMILang" VALUE="">'+
		'<PARAM NAME="SAMIFilename" VALUE="">'+
		'<PARAM NAME="captioningID" VALUE="">'+
		'<PARAM NAME="enableErrorLoaddings" VALUE="0">'+
		'<PARAM NAME="_cx" VALUE="6747">'+
		'<PARAM NAME="_cy" VALUE="5239">'+
		'<EMBED type="application/x-mplayer2" '+
		'pluginspage="http://microsoft.com/windows/mediaplayer/en/download/"'+
		'id="wmp" name="wmp" displaysize="4" autosize="-1"'+
		'bgcolor="darkblue"  showtracker="-1"'+
		'showdisplay="0" showstatusbar="-1" menu="false" videoborder3d="-1" width="'+_width+'" height="'+_height+'"';
		if (_url!='')
			_h+='src="'+_url+'" ';
		_h+='autostart="true" designtimesp="5311" loop="true" volume="0">'+
		'</EMBED>'+
		'</OB'+'JECT>';
		return _h;
	}
	function play_Trailer(_url) {
		eval("wmp_TrailerHTML").innerHTML = wmpEmbed('393', '365', _url);
	}
	function eHide(_objName)
		{
			eval(_objName).style.visibility="hidden";
		}

	function eShow(_objName)
		{
			eval(_objName).style.visibility="";
		}	
	_urlLast='';
	function urlChange()
		{
			try
			{
				var _urlCurrent=window.location.href;
				if (_urlCurrent!=_urlLast)
				{
					_urlLast=_urlCurrent;
					return true;
				}
			}
			catch(e)
			{
			}
			return false;
		}
	function urlReset()
		{
			_urlLast='';
		}

	function urlEncode(_uniString)
		{
			try
			{
				var _st=_uniString;
				_st=_st.replace(/\n/g,'<BR>');
				_st=_st.replace(/&amp;/g,'%26');
				_st=_st.replace(/&/g,'%26');
				return _st;
			}
			catch(_e)
			{
				return '';
			}
		}

	_urlSplitChar=',';
	function urlRequest(_id)
		{
			try
			{
				var _urlCurrent=window.location.href;
				_urlCurrent=_urlCurrent.split('#');
				if (_urlCurrent[1])
				{
					_urlCurrent=_urlCurrent[1];
					if (_id)
					{
						_urlCurrent=_urlCurrent.split(_urlSplitChar);
						if (_urlCurrent[_id])
							return _urlCurrent[_id];
					}
					else
						return _urlCurrent;
				}
			}
			catch(_e)
			{
				return '';
			}
			return '';
		}
	function getVar(cnt) {
		var url;
		url=window.location.href;
		url=url+'#';
		url=url.split('#');
		url=url[1];
		url=url+',';
		url=url.split(',');
		url=url[cnt];
		if (!url)
			return '';
		return url;
	}
	function do_Login()
	{
		var Username= encodeURIComponent(document.f_Login.txt_UserName.value);
		var PassWord= encodeURIComponent(document.f_Login.txt_PassWord.value);
		if (Username=='') {
			eval("loginError").innerHTML = '{login_notUsername}';
			document.f_Login.txt_UserName.value = '';
			eval("loginError").style.display = 'block';
			return false;
		}
		if (PassWord =='') {
			eval("loginError").innerHTML = '{login_notPassword}';
			document.f_Login.txt_PassWord.value = '';
			eval("loginError").style.display = 'block';
			return false;
		}
		eval("loginHTML").style.display = 'none';
		eval("loadingLogin").style.display = 'block';
		try {
			http.open('POST',  'index.php');
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.onreadystatechange = response_Login;
			http.send('obj=doLogin&user='+Username+'&pass='+PassWord);
		}
		catch(e){}
		finally{}
		return false;
	}
	function response_Login() {
		try {
			if((http.readyState == 4)&&(http.status == 200)){
				document.body.scrollTop=0;
				response = http.responseText;
				if (response!='') {
					eval("loginHTML").style.display = 'block';
					eval("loadingLogin").style.display = 'none';
					eval("loginError").innerHTML = ''+response+'';
					eval("loginError").style.display = 'block';
				}
				else {
					 window.location="index.php?refresh=1";
				}
			}
	  	}
		catch(e){
			 do_Login();
		}
		finally{}
	}
	var cPage = 1;
	var cView = 1;
	function show_HTML(_url) {
		document.body.scrollTop=400;
		showLoadding('loadingHTML');
		try {
			http.open('POST',  'index.php');
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.onreadystatechange = response_show_HTML;
			http.send('obj='+_url+'&page='+cPage+'&view='+cView);
		}
		catch(e){}
		finally{}
		return false;
	}
	function response_show_HTML() {
		try {
			if((http.readyState == 4)&&(http.status == 200)){
				cancelLoadding('loadingHTML');
				document.body.scrollTop=500;
				response = http.responseText;
				if (response) eval("mainHTML").innerHTML = response;
				else {
					 show_HTML();
				}
			}
	  	}
		catch(e){
			 show_HTML();
		}
		finally{}
	}
	function loadPage() {
		var	cURL=urlRequest();
		if (!cURL)
			cURL='Home';
		show_HTML(cURL);
	}
	function urlCheck()
		{
			if (urlChange()) 
				setTimeout("loadPage()",100);
	}

		function do_Logout() {
			try {
				http.open('POST',  'action.php');
				http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				http.onreadystatechange = response_doLogout;
				http.send('act=Logout');
				}
				catch(e){}
				finally{}
				return false;
			return false;
		}
		function response_doLogout() {
			try {
				if((http.readyState == 4)&&(http.status == 200)){
					response = http.responseText;
					window.location="index.php?refresh=1";
				}
				  	}
					catch(e){
						alert('Sever error, please click F5 in KeyBoard');
					}
					finally{}
		}
		function do_UpdateInfo() {
			var txtFullname= encodeURIComponent(document.fr_Infomation.txtFullname.value);
			var txtSex= encodeURIComponent(document.fr_Infomation.txtSex.value);
			var txtDay= encodeURIComponent(document.fr_Infomation.txtDay.value);
			var txtMonth= encodeURIComponent(document.fr_Infomation.txtMonth.value);
			var txtYear= encodeURIComponent(document.fr_Infomation.txtYear.value);
			var txtPassword= encodeURIComponent(document.fr_Infomation.txtPassword.value);
			var txtRePassword= encodeURIComponent(document.fr_Infomation.txtRePassword.value);
			var txtEmail= encodeURIComponent(document.fr_Infomation.txtEmail.value);
			var txtAvatar= encodeURIComponent(document.fr_Infomation.txtAvatar.value);
			if (txtPassword != txtRePassword) 
			{
				alert("{title_signup15}");
				return false;
			}
			try {
				http.open('POST',  'action.php');
				http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				http.onreadystatechange = response_doUpdateInfo;
				http.send('act=UpdateInfo&fullname='+txtFullname+'&pass='+txtPassword+'&sex='+txtSex+'&day='+txtDay+'&month='+txtMonth+'&year='+txtYear+'&mail='+txtEmail+'&avatar='+txtAvatar);
				}
				catch(e){}
				finally{}
			return false;
		}
		function response_doUpdateInfo() {
			try {
				if((http.readyState == 4)&&(http.status == 200)){
					response = http.responseText;
					if (response) {
						document.getElementById("reg_Error").innerHTML = response;
						document.getElementById("reg_Error").style.display = "block";
					}
					else {
						alert('{title_signup21}');
					}
				}
				  	}
					catch(e){
						alert('Sever error, please click F5 in KeyBoard');
					}
					finally{}
		}
		function do_Signup()
		{
			var txtUsername= encodeURIComponent(document.fr_Signup.txtUsername.value);
			var txtFullname= encodeURIComponent(document.fr_Signup.txtFullname.value);
			var txtSex= encodeURIComponent(document.fr_Signup.txtSex.value);
			var txtDay= encodeURIComponent(document.fr_Signup.txtDay.value);
			var txtMonth= encodeURIComponent(document.fr_Signup.txtMonth.value);
			var txtYear= encodeURIComponent(document.fr_Signup.txtYear.value);
			var txtPassword= encodeURIComponent(document.fr_Signup.txtPassword.value);
			var txtRePassword= encodeURIComponent(document.fr_Signup.txtRePassword.value);
			var txtEmail= encodeURIComponent(document.fr_Signup.txtEmail.value);
			var txtConfirmEmail= encodeURIComponent(document.fr_Signup.txtConfirmEmail.value);
			if(	check_Str(txtUsername) == "" ||	check_Str(txtFullname) == "" ||	check_Str(txtPassword) == "" ||	check_Str(txtRePassword) == "" || check_Str(txtEmail) == "" || check_Str(txtConfirmEmail) == "" )
			{
				alert('{title_signup14}');
				return false;
			}
			if (txtPassword != txtRePassword) 
			{
				alert("{title_signup15}");
				return false;
			}
			if (txtEmail != txtConfirmEmail) 
			{
				alert("{title_signup16}");
				return false;
			}
			try {
				http.open('POST',  'action.php');
				http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				http.onreadystatechange = response_doSignup;
				http.send('act=Signup&user='+txtUsername+'&fullname='+txtFullname+'&pass='+txtPassword+'&sex='+txtSex+'&day='+txtDay+'&month='+txtMonth+'&year='+txtYear+'&mail='+txtEmail);
				}
				catch(e){}
				finally{}
				return false;
			}
		function response_doSignup() {
			try {
				if((http.readyState == 4)&&(http.status == 200)){
					response = http.responseText;
					if (response) {
						document.getElementById("reg_Error").innerHTML = response;
						document.getElementById("reg_Error").style.display = "block";
					}
					else {
						alert('{title_signup21}');
						window.location = '#Login';
					}
				}
				  	}
					catch(e){
						alert('Sever error, please click F5 in KeyBoard');
					}
					finally{}
		}

				function check_Search() {
					var txtSearch= document.f_Search.txt_Search.value;
					if (txtSearch.length<2 || txtSearch == 'Nh&#7853;p t&#7915; kh&#243;a t&#236;m ki&#7871;m ...') {
						alert("T&#7915; kh&#243;a ph&#7843;i c&#243; chi&#7873;u d&#224;i t&#7915; 2 k&#237; t&#7921; tr&#7903; l&#234;n!");
						document.f_Search.txt_Search.focus();
						document.f_Search.txt_Search.value = '';
						return false;
					}
					window.location = '#Search,'+txtSearch;
					return false;
				}

function getWinSize()
{        
    if( window.innerHeight )
    {
        d = (window.scrollMaxY > 0) ? 17 : 0;                
        pageWidth = window.innerWidth + window.scrollMaxX - d;
        pageHeight = window.innerHeight + window.scrollMaxY;
        
    }
    else if( document.body.scrollHeight > document.body.offsetHeight ) // all but Explorer Mac
    {
        pageWidth = document.body.scrollWidth;
        pageHeight = document.body.scrollHeight;        
    }
    else
    {
        pageWidth = document.body.offsetWidth + document.body.offsetLeft;
        pageHeight = document.body.offsetHeight + document.body.offsetTop;        
    }
    
    var winSize = new Array(pageWidth, pageHeight);    
    return winSize;        
}

function showDiv(obj)
{
    obj.style.display = 'block';
}

function hideDiv(obj)
{
    obj.style.display = 'none';
}

function showLoadding( dlg )
{
    winSize = getWinSize();
    //document.loadingHTMLFF.e.focus();
    //loadingHTML.focus();
    myLoadding = document.getElementById(dlg);
    myLoadding.style.display = 'block';
    myLoadding.style.visibility = 'hidden';
    h = myLoadding.clientHeight;
    w = myLoadding.clientWidth;
    /*
    */
    var myMask = document.getElementById('myMask');            
    myMask.style.width = winSize[0] + 'px';
    myMask.style.height = winSize[1]  + 'px';
    myMask.style.display = 'block';
    
    var hscroll = (document.all ? document.scrollLeft : window.pageXOffset);
    var vscroll = (document.all ? document.scrollTop : window.pageYOffset);        
    
    //alert(hscroll);
    left = (winSize[0] - w) / 2;
    //top = (window.innerHeight - h) / 2 + vscroll;
    myLoadding.style.left = left + 'px';
    //myLoadding.style.top = top + 'px';
    
    myLoadding.style.display = 'block';
    myLoadding.style.visibility = 'visible';
}

function cancelLoadding( dlg )
{
    hideDiv(document.getElementById('myMask'));        
    hideDiv(document.getElementById(dlg));        
	document.mainHTMLFF.e.focus();
	mainHTML.focus();
}