// 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 
//đã được load hoàn tất.
$(document).ready(function()
{
	$(function(){
		

	});
	
	//hover menu
	$("#nav li").hover(function(){
		$(this).find('a:first').addClass('hove');
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).show(200); 
	},function(){
		$(this).find('a:first').removeClass('hove');
		$(this).find('ul:first').css({visibility: "hidden"}); 
	});
	
	
	
	//hover pano sp
	$('.tgp_hinh_noi_dung_sp .btn_time').hover(function(){
		$(this).css({background:'#4e4b07'});
		$(this).find('.text').css({display:'block'});
	},function(){
		$(this).css({background:'none'});
		$(this).find('.text').css({display:'none'});
	});
	
	$('.tgp_hinh_noi_dung_sp .btn_who').hover(function(){
		$(this).css({background:'#4e4b07'});
		$(this).find('.text').css({display:'block'});
	},function(){
		$(this).css({background:'none'});
		$(this).find('.text').css({display:'none'});
	});
	
	$('.tgp_hinh_noi_dung_sp .btn_img').hover(function(){
		$(this).css({background:'#4e4b07'});
		$(this).find('.text').css({display:'block'});
	},function(){
		$(this).css({background:'none'});
		$(this).find('.text').css({display:'none'});
	});
	
	//hover btn_gui frmGuiCauHoi
	$('.frmGuiCauHoi .btn').hover(function(){
		$(this).css({background:'url(/images/btn_gui_hover.jpg)'});
	},function(){
		$(this).css({background:'url(/images/btn_gui.jpg)'});
	});
	
	
	
	//select tinh thanh
	$("#select_tt").hover(function(){
		$(this).find('.select_content').css({display: "block"}).show(200); 
	},function(){		
		$(this).find('.select_content').css({display: "none"});
	});
	
	$("#select_nam").hover(function(){
		$(this).find('.select_content').css({display: "block"}).show(200); 
	},function(){		
		$(this).find('.select_content').css({display: "none"});
	});
	
	$(".frm_select_to").click(function(){
		if ($(this).find('.list_to').css('display') == "none") {
			$(this).find('.list_to').slideDown('fast');
		} else {
			$(this).find('.list_to').slideUp('fast');
		}
	});
	
	$(".frm_select_to").hover(function(){	
	},function(){
		$(this).find('.list_to').slideUp('fast');
	});
	
	$(".option1").click(function(){
		var text = $(this).text();
		$('#to').val(text);
		$('#frm_select_to_title').text(text);
		
	 });
	
	$(".option2").click(function(){
		$("#country").val($(this).text());
		$('#frm_select_country_title').text($(this).text());
		
	 });
	
	$("#link_lket").click(function(){
		if ($(this).find('.list_link').css('display') == "none") {
			$(this).find('.list_link').css({display: "block"}).show(200); 
		} else {
			$(this).find('.list_link').css({display: "none"});
		}
	});
		
	$('.frmLienHe .btn').hover(function(){
		$(this).css({background:'url(/images/btn_gui_hover.jpg)'});
	},function(){
		$(this).css({background:'url(/images/btn_gui.jpg)'});
	});
	
	
	
	//show/hide noi dung tu van tieu dung
	$('.tgp_tu_van_content').click(function(){
		if ($(this).find('.content').css('display') == 'none') 
		{
			$('.tgp_tu_van_content').find('.content').css({'display':'none'});
			$('.tgp_tu_van_content').find('img:first').attr({'src':'/images/arrow_right.jpg'});			
			$(this).find('.content').slideDown(500);
			$('html, body').animate({
				scrollTop: $(this).offset().top
			},500);
			$(this).find('img:first').attr({'src':'/images/arrow_down.jpg'});
		}
		else 
		{
			$(this).find('.content').slideUp(300);
			$(this).find('img:first').attr({'src':'/images/arrow_right.jpg'});
		}
	});
	
	//hover images hinh anh
	$('.tgp_container .tgp_content .tgp_content_center .tgp_noi_dung_ha .img').hover(function(){
		$(this).find('img:first').css({padding:'0',border:'solid 1px #fc8701'});
	},function(){
		$(this).find('img:first').css({padding:'1px 1px 1px 1px',border:'none'});
	});
	
	//hover arrow hinh anh
	$('.tgp_nav_row_arrow .arrow_prev').hover(function(){
		$(this).css({background:'url(/images/btn_prev_ha_hover.jpg)'});
	},function(){
		$(this).css({background:'url(/images/btn_prev_ha.jpg)'});
	});
	
	$('.tgp_nav_row_arrow .arrow_next').hover(function(){
		$(this).css({background:'url(/images/btn_next_ha_hover.jpg)'});
	},function(){
		$(this).css({background:'url(/images/btn_next_ha.jpg)'});
	});		
	
	
	$('.jsddm .first a').hover(function(){
		Cufon.replace(this, {fontFamily:'HP-Cassia',color: '-linear-gradient(#9D001C, #9D001C)'});
	},function(){
		Cufon.replace(this, {fontFamily:'HP-Cassia',color: '-linear-gradient(#460813, #460813)'});
	});
	
	$('.jsddm>li').hover(function(){
		if (!$(this).hasClass('active'))
			$(this).find("a:first").addClass('active');
	},function() {
		if ($(this).hasClass('active1'))
			$(this).removeClass('active1');
		else 
			$(this).find("a:first").removeClass('active');
	});
	
	//hover sub menu
	$('#nav li ul.sub_menu li a').hover(function(){
		Cufon.replace($(this), {fontFamily:'HP-TranVanDang',color: '-linear-gradient(#ffb400, #ffb400)'});
	},function(){
		Cufon.replace($(this), {fontFamily:'HP-TranVanDang',color: '-linear-gradient(#f6dba1, #f6dba1)'});
	});
});
