// 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);
}
jQuery(window).load(function(){ 
	/*So sanh height cua 2 the div tgp_body_content & tgp_right*/
	function EqualHeight(elements) { 
		tallest = 0; 
		elements.each(function() { 
			elementHeight = jQuery(this).height(); 
			if(elementHeight > tallest) { 
				tallest = elementHeight; 
			} 
		}); 
		elements.height(tallest); 
	} 
    EqualHeight(jQuery(".tgp_left_menu, .tgp_content, .tgp_right_menu")); 
    jQuery(window).resize(function(){ 
        EqualHeight(jQuery(".tgp_left_menu, .tgp_content, .tgp_right_menu")); 
    });
	Cufon.replace('h2');
}); 

$(document).ready(function() { 
	$('ul.sf-menu').superfish(); 
});
//khanhtq
function comment(frm)
{
	id = frm.id.value
	txt_ten = frm.txt_ten.value
	txt_email = frm.txt_email.value
	if(!txt_email)
	{
		alert("Vui lòng nhập Email!");
		frm.txt_email.focus();
		return false;
	}
	email= frm.txt_email.value
	if (!email.match(/^([-\d\w][-.\d\w]*)?[-\d\w]@([-\w\d]+\.)+[a-zA-Z]{2,6}$/)){
		alert('Địa chỉ email không hợp lệ.');
		frm.txt_email.focus();
		return false;
	}
	txt_noi_dung = frm.txt_noi_dung.value
	if(!txt_email)
	{
		alert("Vui lòng nhập nội dung!");
		frm.txt_noi_dung.focus();
		return false;
	}
	else
	{
		var	query	=	"act=comment&txt_ten="+txt_ten+"&txt_email="+txt_email+"&txt_noi_dung="+txt_noi_dung+"&id="+id;
		var http 	=	khoitao_ajax();
		try
		{
			$$$('comment').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)
					{
						$$$('comment').innerHTML = http.responseText;
					}
					else
					{
						alert('Co loi he thong. Vui long thu lai sau.');
					}
				}
			}
			http.send(query);
		}
		catch (e)
		{
		}
		return false;
	}
}
$(document).ready(function() { 
	$('ul.sf-menu').superfish(); 
});

