// JavaScript Document
var loadd = 1;
function load_news(type)
{
	
	$('#loadding_page').html('<img src="'+ROOT_BASE+'images/loading8.gif" border="0" />');
	if(loadd == 1){
		loadd = 2;
	$.ajax({
		type:'POST',
		url: ROOT_BASE+'ajax.php',
		data: 'action=load_news&&type='+encodeURIComponent(type),							
		success:function(html){
			$("#ul_load_news").html(html);
			$('#loadding_page').html('');
			loadd = 1;
		}
	});
	}	
}
function change_langs(lang)
{
	$.ajax({
		type:'POST',
		url: ROOT_BASE+'ajax.php',
		data: 'action=change_langs&lang='+encodeURIComponent(lang),							
		success:function(html){
			document.location.href = document.location.href;
		}
	});
}

// JavaScript Document
function load_cb_city(lang_code,divID)
{
	$.ajax({
		type:'POST',
		url: ROOT_BASE+'ajax.php',
		data: 'action=loadCity&lang_code='+encodeURIComponent(lang_code),							
		success:function(html){
			$('#'+divID).html(html);
		}
	});
}
/*function change_langs(lang)
{
	$.ajax({
		type:'POST',
		url: ROOT_BASE+'ajax.php',
		data: 'action=change_langs&lang='+encodeURIComponent(lang),							
		success:function(html){
			document.location.href = document.location.href;
		}
	});
}*/

function nextPageVideo(tab,value,name_div)
{
	$.ajax({
		type:'POST',
		url: ROOT_BASE+'ajax.php',
		data: 'action=nextPageVideo&tab='+encodeURIComponent(tab)+'&p='+encodeURIComponent(value),							
		success:function(html){
			alert(html);
			//$("#"+name_div).html(html);
		}
	});
}
function set_view_video(video)
{
	$.ajax({
		type:'POST',
		url: ROOT_BASE+'ajax.php',
		data: 'action=video&video='+encodeURIComponent(video),							
		success:function(html){
			//$("#"+name_div).html(html);
		}
	});
}
function check_captcha()
{
	var theForm=document.frm_napthe;
	$('#error_napthe').html('<img src="'+ROOT_BASE+'images/loading8.gif" border="0"   height="15"/>');
	$(this).unbind('click',check_captcha);
	var error = '';
	if(theForm.code.value=='')
	{
		$('#error_napthe').html('<b>Lỗi:</b><br/>• &nbsp; Nhập mã số thẻ!');
		theForm.code.focus();
		$(this).click(check_captcha);
		return false;
	}
	if(theForm.captcha.value=='')
	{
		$('#error_napthe').html('<b>Lỗi:</b><br/>• &nbsp; Nhập mã an toàn!');
		theForm.captcha.value = '';
		$("#send_napthe").click(check_captcha);
		theForm.captcha.focus();
		return false;
	}
	$.ajax({
		type:'POST',
		url: ROOT_BASE+'ajax.php',
		data: 'action=check_captcha&captcha='+theForm.captcha.value,							
		success:function(html){
			if(html == 'true')
				document.frm_napthe.submit();
			else{
				$('#error_napthe').html('<b>Lỗi:</b><br/>• &nbsp; Mã an toàn không khớp!');
				document.getElementById('img_captcha').src=ROOT_BASE+'captcha.php?'+Math.random();
				theForm.captcha.focus();
				$("#send_napthe").click(check_captcha);
				return false;	
			}
		}
	});	
}

function check_chuyenkey()
{
	var theForm=document.frm_chuyenkey;
	$('#error_napthe').html('<img src="'+ROOT_BASE+'images/loading8.gif" border="0"   height="15"/>');
	$(this).unbind('click',check_captcha);
	var error = '';
	if(theForm.user_input.value.length<6 || theForm.user_input.value.length>24)
	{
		$('#error_napthe').html('<b>Lỗi:</b><br/>• &nbsp; Tên đăng nhập của người nhận key (6-24 ký tự)!');
		theForm.user_input.focus();
		$(this).click(check_chuyenkey);
		return false;
	}
	if(theForm.key_change.value=='' || parseInt(theForm.key_change.value)<1)
	{
		$('#error_napthe').html('<b>Lỗi:</b><br/>• &nbsp; Nhập số key muốn chuyễn (Lớn hơn 1 key)!');
		theForm.key_change.focus();
		$(this).click(check_chuyenkey);
		return false;
	}
	if(theForm.password_check.value.length<7 || theForm.password_check.value.length>13)
	{
		$('#error_napthe').html('<b>Lỗi:</b><br/>• &nbsp; Mật khẩu (7-13 ký tự)!');
		theForm.password_check.value = '';
		theForm.password_check.focus();
		$(this).click(check_chuyenkey);
		return false;
	}
	
	if(theForm.captcha.value=='')
	{
		$('#error_napthe').html('<b>Lỗi:</b><br/>• &nbsp; Nhập mã an toàn!');
		theForm.captcha.value = '';
		$("#send_napthe").click(check_chuyenkey);
		theForm.captcha.focus();
		return false;
	}
	$.ajax({
		type:'POST',
		url: ROOT_BASE+'ajax.php',
		data: 'action=check_captcha&captcha='+theForm.captcha.value,							
		success:function(html){
			if(html == 'true')
				document.frm_chuyenkey.submit();
			else{
				$('#error_napthe').html('<b>Lỗi:</b><br/>• &nbsp; Mã an toàn không khớp!');
				document.getElementById('img_captcha').src=ROOT_BASE+'captcha.php?'+Math.random();
				theForm.captcha.focus();
				$("#send_napthe").click(check_captcha);
				return false;	
			}
		}
	});	
}
function send_captcha(captcha){
	
}
