// 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;
}
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 .main .tgp .colum_left .gioi_thieu .hoatdong_thungo_docthem .hoat_dong a.hoat_dong_content, .tgp_container .main .tgp .colum_left .gioi_thieu .hoatdong_thungo_docthem .thu_ngo a.thu_ngo_content', { fontFamily: 'r',hover: {color: '-linear-gradient(#090909, #090909)'} });
Cufon.replace('.tgp_container .main .tgp .colum_left .gioi_thieu .title_gioi_thieu, .tgp_container .main .tgp .colum_left .tin_tuc .title_tin_tuc,.tgp_container .main .tgp .colum_right .ho_tro .title_ho_tro, .tgp_container .main .tgp .colum_right .sub_menu .title_sub', { fontFamily: 'HGEOSLAB'});
Cufon.replace('.bg_banner .tgp_banner .menu_search .menu ul.menu_top li.sub_menu_top a.link_menu_top', { fontFamily: 'r', hover: {color: '-linear-gradient(#0084ff, #0084ff)'} });
Cufon.replace('.tgp_container .main .tgp .colum_left .sanpham_thugian .san_pham ul li a', { fontFamily: 'r',hover: {color: '-linear-gradient(#0084ff, #0084ff)'} });
});
//đã được load hoàn tất. 
jQuery(window).load(function(){ 
 
    EqualHeight(jQuery(".tgp_container .main .tgp .colum_left .sanpham_thugian .san_pham, .tgp_container .main .tgp .colum_left .sanpham_thugian .thu_gian"));
    //Tự động điều chỉnh lại chiều cao sau khi 
    //resize browser. Nếu không quan tâm đến việc 
    //resize browser, bạn có thể gỡ bỏ hàm này 
    jQuery(window).resize(function(){ 
    EqualHeight(jQuery(".tgp_container .main .tgp .colum_left .sanpham_thugian .san_pham, .tgp_container .main .tgp .colum_left .sanpham_thugian .thu_gian"));
    });
	
	//if (document.getElementById("global_act").value == "home")
//	{
//	$(".tgp_wrapper_bottom").css({'background':'url(/images/wrapper_bottom_2.gif) repeat-x left 490px'});
//	$(".tgp_container .tgp_body .tgp_right .tgp_content").css({'background':'none'});
//	}
});

function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        vertical: true,
		auto: 4,
        wrap: 'last',
        initCallback: mycarousel_initCallback
    });
});

$(document).ready(function()
{	
	//if (document.getElementById("global_act").value == "tin_tuc")
//	{
//		window.scrollTo(0,200);
//	}
	
	$(".tgp_container .main .tgp .colum_left .gioi_thieu .content_gioi_thieu .box_sp").hover(function(){
        $(this).find('p:first').css({visibility: "visible",display: "none"}).show(400); 
        },function(){ 
        $(this).find('p:first').css({visibility: "hidden"}); 
        }); 
	
	$(".form_lien_he input.btn").hover(function() { 
	  $(this).css({background: "#3FA700"});
	}, function() {
	  $(this).css({background: "#00A651"});
	});
	
	
	$("#slideshow").slideshow({
		pauseSeconds	:	3,
		fadeSpeed		:	2,
		width			:	580,
		height			:	310,
		cssClass		:	'slideshow'
	});
	
	$(".sub_pic").jCarouselLite({
	auto: true,
	speed: 300, // Toc do chay hinh
	auto: 5000,// Thoi gian chay hinh
	visible: 3
	});
	$(".box_tin1").jCarouselLite({
	auto: true,
	speed: 300, // Toc do chay hinh
	auto: 3000,// Thoi gian chay hinh
	visible: 1
	});
	
	$(".box_tin2").jCarouselLite({
	auto: true,
	speed: 300, // Toc do chay hinh
	auto: 6000,// Thoi gian chay hinh
	visible: 1
	});

	$('.box_hot_news').vTicker({
		speed: 500,
		pause: 5000,
		animation: 'fade',
		mousePause: false,
		showItems: 2
	});
		
	$("#select-wrapper").jqTransform();
});

