// 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);
}
function	poll(i)
{
	if(i == 1)
	{
		$('.date_bc').css({'display':'block'});
		$('.btn_binh_chon').css({'display':'block'});
	}
	else
	{
		$('.date_bc').css({'display':'none'});
		$('.btn_binh_chon').css({'display':'block'});
	}
}

function vote(frm)
{
	txt_id = frm.txt_id.value;
	txt_ten = frm.txt_ten.value;
	txt_ngay = frm.txt_ngay.value;
	txt_binh_chon = frm.txt_binh_chon.value;

	var	query	=	"act=vote&txt_id="+txt_id+"&txt_ten="+txt_ten+"&txt_ngay="+txt_ngay+"&txt_binh_chon="+txt_binh_chon;
	var http 	=	khoitao_ajax();
	try
	{
		$$$('loading').innerHTML = "<center><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)
				{
					$$$('loading').innerHTML = http.responseText;
				}
				else
				{
					alert('Co loi he thong. Vui long thu lai sau.');
				}
			}
		}
		http.send(query);
	}
	catch (e)
	{
	}
	return false;
}

/*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); 
}
jQuery(window).load(function(){ 
    EqualHeight(jQuery(".tgp_container .tgp_body .content .tin_tuc_xem, .tgp_container .tgp_body .content .news_order")); 
    jQuery(window).resize(function(){ 
        EqualHeight(jQuery(".tgp_container .tgp_body .content .tin_tuc_xem, .tgp_container .tgp_body .content .news_order")); 
    }); 
});
//Áp đặt chiều cao cho các cột khi trang 
//đã được load hoàn tất.
$(document).ready(function()
{
	$(function(){
		//Cufon.replace('.tgp_container .tgp_body .content h1', {fontFamily:'HP-Hai Au',color: '-linear-gradient(#00558c, #00558c)'});  
		Cufon.replace('.tgp_container .tgp_banner .tgp_menu ul li a,.tgp_container .tgp_banner .sub a', {fontFamily:'HP-Avo', hover: {color: '-linear-gradient(#fff, #fff)', textShadow:'1px 1px 1px #000'},outline :'none'});
		Cufon.replace('.tgp_container .tgp_banner .tgp_menu ul li a', {fontFamily:'HP-Avo',color: '-linear-gradient(#c1edff, #c1edff)', textShadow:'1px 1px 1px #000'});
		Cufon.replace('.tgp_container .tgp_banner .tgp_menu ul li', {fontFamily:'HP-Avo', hover: {background:'/images/hover.png'},outline :'none'});
		Cufon.replace(' .tgp_container .tgp_banner .tgp_lien_he span', {fontFamily:'HP-Avo',color: '-linear-gradient(#c1edff, #c1edff)'});
		Cufon.replace('.tgp_container .tgp_banner .tgp_menu ul li a.active', {fontFamily:'HP-Avo',color: '-linear-gradient(#fff, #fff)'});
		Cufon.replace('.tgp_container .tgp_news .box1 h1 span', {fontFamily:'HP-Avo',color: '-linear-gradient(#fff, #fff)'});
		Cufon.replace('.tgp_container .tgp_body .tgp_right h1',{fontFamily:'HP-Avo',color: '-linear-gradient(#fff, #fff)'});
		Cufon.replace('.tgp_container .tgp_body .tgp_left h1',{fontFamily:'HP-Avo',color: '-linear-gradient(#fff, #fff)'});
		Cufon.replace('.tgp_container .tgp_body h1,.tgp_container .tgp_banner .sub',{fontFamily:'HP-Avo',color: '-linear-gradient(#fff, #fff)'});
		Cufon.replace('.tgp_container .tgp_body .tgp_logo .logo_right .box1 h3','.tgp_container .tgp_body .tgp_logo .logo_left h3',{fontFamily:'HP-Avo',color: '-linear-gradient(#fff, #fff)'});
		Cufon.replace('.tgp_container .tgp_body .tgp_logo .logo_left h3',{fontFamily:'HP-Avo',color: '-linear-gradient(#fff, #fff)'});
		Cufon.replace('.image_default, .tgp_container .tgp_body .tgp_logo .logo_left .content a span',{fontFamily:'HP-Bahamas L',color: '-linear-gradient(#000000, #000000)'});
		Cufon.replace('.tgp_container .tgp_slide #SanPham ul li a span',{fontFamily:'HP-Bahamas L',color: '-linear-gradient(#000000, #000000)'});
	});
});


//cuongnt
$(document).ready(function() {
	// Slide news
	  $('.tgp_container .tgp_body .tgp_anh .right').cycle({fx: 'fade', timeout: 3000, speed: 9000});
	  $('.tgp_container .tgp_body .tgp_anh .left ul li a').hover(function(){
		  $('.tgp_container .tgp_body .tgp_anh .right').cycle('pause');
			  $(this).siblings('img').fadeIn();
		 },
		function() {
		  $('.tgp_container .tgp_body .tgp_anh .right').cycle('resume');
				$(this).siblings('img').fadeOut();
		  }); 
	$("#select-wrapper").jqTransform();
	
	$('#example1 .docxongloanthi1').kwicks({
		max: 604
	});
	$('#example1 .docxongloanthi5').kwicks({
		max: 604
	});
	$('#example1 .docxongloanthi9').kwicks({
		max: 604
	});

	$('#SanPham').show().galleryView({
		filmstrip_size: 7,
		//panel_width: 700,
		//panel_height: 140,
		frame_width: 128,
		frame_height: 90,
		background_color: 'transparent',
		nav_theme: 'dark',
		border: 'none',
		show_captions:false,
		caption_text_color: 'black',
		pointer_width : 2
		
	});
	$('.tooltip').tooltip();
	
	//xử lý logo
//		  $('.tgp_container .tgp_body .tgp_logo .logo_right .box2 .content #example1 .kwicks li').hover(function(){
//		  $(this).css({'left':'0'});
//		 },
//		function() {
//			$(this).css({'left':'left'});
//		  }); 
	//xu ly active
	var curr_act = $("#get_act").val();
	if(curr_act == "home")
	{
		$('.tgp_container .tgp_banner .tgp_menu ul li a.active').addClass('active');
	}
	
});

