// 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 
//khanhtq - tin tuc
function news(val)
{
	var	query	=	"act=news&i="+val;
	var http 	=	khoitao_ajax();
	try
	{
		$$$('news_right').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)
				{
					$$$('news_right').innerHTML = http.responseText;
				}
				else
				{
					//alert('Co loi he thong. Vui long thu lai sau.');
				}
			}
		}
		http.send(query);
	}
	catch (e)
	{
	}
	return false;
}
jQuery(window).load(function(){ 
			
	var newsoption1 = {
		firstname: "mynews",
		secondname: "showhere",
		thirdname:"news_display",
		fourthname:"news_button",
		playingtitle:"Now Playing:",
		nexttitle:"Next News:",
		prevtitle:"Prev News:",
		newsspeed:'10000',
		effectis:'0',
		mouseover:true,
		newscountname:"test",
		disablenewscount:false
	}
	$.init_news(newsoption1);
	  $('#latest').cycle({
		fx:    'scrollUp',
		timeout: 3000, 
		delay: -1000 
	});
	          

	Cufon.replace('h1.title_main,.tgp_body .body_bottom .left .content_bottom .box_news .title_cat, .tgp_body .body_bottom .right .title_cat,.tgp_body .body_bottom .news_today h1.title', {fontFamily:'Tahoma',color: '-linear-gradient(#016193, #016193)'}); 
	Cufon.replace('.title_cat .tt,.tgp_body .body_top .left .lien_he .title_lien_he .tt ', {fontFamily:'Arial',color: '-linear-gradient(#FFC660, #FFC660)'});  

	

}); 
$(document).ready(function(){
		$('#photos').galleryView({
			filmstrip_size: 8,
			frame_width: 221,
			frame_height: 110,
			background_color: 'transparent',
			nav_theme: 'dark',
			border: 'none',
			show_captions:true,
			caption_text_color: 'black'
		});
	});
function change_module(i)
{
	right_module = i;
	$("#a1").removeClass("active");
	$("#a2").removeClass("active");
	if (right_module == 1)
	{
			$(".content_module_1").hide("slide", { direction: "up" }, 500, function(){
			$(".content_module_1").css("visibility","hidden");
			$(".content_module_1").css("height","0px");
			$(".content_module_1").css("display","none");
			$(".content_module_2").css("visibility","visible");
			$(".content_module_2").css("height","100px");
			if(($(".tgp_body .body_bottom .left").height())<=($(".tgp_body .body_bottom .right").height()))
			{
				$(".tgp_body .body_bottom .left").css("height","700px");
				$(".tgp_body .body_bottom .right").css("height","700px");
			}
			$(".content_module_2").show("slide", { direction: "up" }, 500);
		});
		$("#a1").addClass("active");
	}else{
			$(".content_module_2").hide("slide", { direction: "up" }, 500, function(){
			$(".content_module_2").css("visibility","hidden");
			$(".content_module_2").css("height","0px");
			$(".content_module_2").css("display","none");
			$(".content_module_1").css("visibility","visible");
			$(".content_module_1").css("height","60px");
			if(($(".tgp_body .body_bottom .left").height())<=($(".tgp_body .body_bottom .right").height()))
			{
				$(".tgp_body .body_bottom .left").css("height","650px");
				$(".tgp_body .body_bottom .right").css("height","650px");
			}
			$(".content_module_1").show("slide", { direction: "up" }, 500);
		});
		$("#a2").addClass("active");
	}
}

