﻿// AJAX INIT
function $$$(id) {
	return document.getElementById(id);
}
function khoitao_ajax()
{
	var x;
	try 
	{
		x	=	new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
    	try 
		{
			x	=	new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(f) { x	=	null; }
  	}
	if	((!x)&&(typeof XMLHttpRequest!="undefined"))
	{
		x=new XMLHttpRequest();
  	}
	return  x;
}
//cuongnt - kt member
function kt_member(frm)
{
	txt_username = frm.txt_username.value
	txt_password = frm.txt_password.value
	if(!txt_username)
	{
		alert("Vui lòng nhập tên đăng nhập!");
		frm.txt_username.focus();
		return false;
	}
	if(!txt_password)
	{
		alert("Vui lòng nhập mật khẩu!");
		frm.txt_password.focus();
		return false;
	}
	else

	{
		var	query	=	"act=kt_member&txt_username="+txt_username+"&txt_password="+txt_password;
		var http 	=	khoitao_ajax();
		try
		{
			$$$('kt_member').innerHTML = "<center style='margin-top:50px'><img src='/images/ajax-loader.gif' /></center>";
			http.open("POST", "/action.php");
			http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			http.setRequestHeader("Cache-control", "no-cache");		
			http.onreadystatechange = function()
			{
				if (http.readyState == 4)
				{
					if (http.status == 200)
					{
						if(http.responseText)
						{
							$$$('kt_member').innerHTML = http.responseText;
						}
						else
						{
							return false;
						}
					}
					else
					{
							return false;
					}
				}
			}
			http.send(query);
		}
		catch (e)
		{
		}
		return false;
	}
}
//cuongnt - sign out kt member
function kt_member_signout()
{
		var	query	=	"act=kt_member_signout";
		var http 	=	khoitao_ajax();
		try
		{
			$$$('kt_member').innerHTML = "<center style='margin-top:50px'><img src='/images/ajax-loader.gif' /></center>";
			http.open("POST", "/action.php");
			http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			http.setRequestHeader("Cache-control", "no-cache");		
			http.onreadystatechange = function()
			{
				if (http.readyState == 4)
				{
					if (http.status == 200)
					{
						$$$('kt_member').innerHTML = http.responseText;
						window.location.href = "/noi-bo/the-gioi-phang.html";
					}
					else
					{
							return false;
					}
				}
			}
			http.send(query);
		}
		catch (e)
		{
		}
		return false;
}
function	Forward(url)
{
	window.location.href = url;
}
function	_postback()
{
	return void(1);
}
/*So sanh height cua 2 the div tgp_body_content & tgp_right*/
function EqualHeight(elements) { 
    //Xác định chiều cao của cột cao nhất 
    tallest = 0; 
    elements.each(function() { 
        elementHeight = jQuery(this).height(); 
        if(elementHeight > tallest) { 
            tallest = elementHeight; 
        } 
    }); 
    //Chỉnh chiều cao cho tất cả các cột 
    //theo chiều cao của cột cao nhất 
    elements.height(tallest); 
} 
//Áp đặt chiều cao cho các cột khi trang 
$(function(){
Cufon.replace('.tgp_container .tgp_menu ul#nav li a.act,.tgp_container .tgp_body .tgp_left .tgp_introdution h1.title, .tgp_container .tgp_body .tgp_right .tgp_content h1.tieude span', { fontFamily: 'HP-Hai Au', hover: true });
Cufon.replace('.tgp_copyright .div_2 .slogan ul li', { fontFamily: 'HP-Hai Au'});
});



//đã được load hoàn tất. 
jQuery(window).load(function(){ 

    jQuery(window).resize(function(){ 
    });
	EqualHeight(jQuery(".tgp_container .tgp_body .tgp_left,.tgp_container .tgp_body .tgp_right,.tgp_container .tgp_body .tgp_content .content .left,.tgp_container .tgp_body .tgp_content .content .right")); 
		jQuery(window).resize(function(){ 
			EqualHeight(jQuery(".tgp_container .tgp_body .tgp_left,.tgp_container .tgp_body .tgp_right")); 
		});
});

$(document).ready(function()
{		
		
	$('.box_hot_news').vTicker({
		speed: 500,
		pause: 5000,
		animation: 'fade',
		mousePause: false,
		showItems: 3
	});

		$('#SanPham').show().galleryView({
		filmstrip_size: 4,
		frame_width: 90,
		frame_height: 90,
		background_color: 'transparent',
		nav_theme: 'dark',
		border: 'none',
		show_captions:false,
		caption_text_color: 'black',
		pointer_width : 2
		
	});

		//menu
        $('.tgp_menu ul').nmcDropDown({
	   submenu_selector: 'div,div.dich_vu,div.news',
	   show: {opacity: 'show', top: '-=18px'},
	   show_speed: 200,
	   hide: {opacity: 'hide', top: '+=18px'},
	   hide_speed: 400
	});

	$('#slides1').bxSlider({
	        wrapper_class: 'slides1_wrap',
			alignment: 'vertical',
	        margin: 0,
	        auto: true,
			prev_image: '',
			next_image: '',
			speed: 1000,
	        auto_controls: false
	    });
	
	$('.tooltip').tooltip();
	//menu
	$(".slider").jCarouselLite({
			btnNext: ".next",
			btnPrev: ".prev",
			speed: false, // Toc do chay hinh
			auto: false,// Thoi gian chay hinh
			visible: 1
		});
    
	
});	

