// 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);
}
// Khanhtq - poll
function poll(frm)
{
	var val = 0;
	for( i = 0; i < frm.radio_poll.length; i++ )
	{
	if( frm.radio_poll[i].checked == true )
	val = frm.radio_poll[i].value;
	}
	if(val==0)
	{
		alert('Bạn vui lòng chọn câu trả lời');
		return false;
	}
	else
	{
		txt_cat = frm.txt_cat.value
		var	query	=	"act=poll&val="+val+"&txt_cat="+txt_cat;
		var http 	=	khoitao_ajax();
		try
		{
			$$$('poll_'+txt_cat).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)
					{
						$$$("poll_"+txt_cat).innerHTML = http.responseText;
					}
					else
					{
						alert('Co loi he thong. Vui long thu lai sau.');
					}
				}
			}
			http.send(query);
		}
		catch (e)
		{
		}
		return false;
	}
}

function isIE()
	{
	  return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);
	}

function open_tab(i)
{
	$("#tab_1").slideUp('fast',function(){
		$("#tab_2").slideUp('fast',function(){
			$("#tab_3").slideUp('fast',function(){
				$("#tab_"+i).slideDown();
			});
		});
	});
	/*$("#tab_1").css({"display":"none"});
	$("#tab_2").css({"display":"none"});
	$("#tab_3").css({"display":"none"});
	$("#tab_"+i).css({"display":"block"});*/
	$("#tb1").css({"color":"#000"});
	$("#tb2").css({"color":"#000"});
	$("#tb3").css({"color":"#000"});
	$("#tb1").removeClass("active");
	$("#tb2").removeClass("active");
	$("#tb3").removeClass("active");
	$("#tb"+i).addClass("active");
	$("#tb"+i).css({"color":"#8A0000"});
}

jQuery(window).load(function(){ 
							 
	$(document).ready(function(){
		if (isIE())
		{
			$("#container_pro").css({"display":"none"});
			open_tab(1);
		}
		else
		{
			$("#container_ie").css({"display":"none"});
		}
		
		Cufon.replace('h1.title', {fontFamily: 'Tahoma', color: '-linear-gradient(#A80000,#A80000)'});
		Cufon.replace('.tgp_body .right .box_pro_quang_cao .label', {fontFamily: 'Tahoma', color: '-linear-gradient(#A80000,#A80000)'});
		$("ul.menu_main li.menu_main ").hover(function(){													   
			$(this).find(".left_hover_menu_main").css({background:"url(/images/left_hover_menu_main.png) no-repeat left center"});
			$(this).find(".right_hover_menu_main").css({background:"url(/images/right_hover_menu_main.png) no-repeat left center"});
			},
			function (){
				$(this).find(".left_hover_menu_main, .right_hover_menu_main").stop().css({background:'none'});	
			});
		//$('#container_1').tabs({ fxAutoHeight: true });
		$('#container_pro').tabs({ fxSlide: true, fxAutoHeight: true });
		$('.container_2').tabs({ fxAutoHeight: true });
	});
	$('.container_1').tabs({ fxAutoHeight: true });
}); 
function setHomepage() 
{ 
if (document.all) 
 	{ 
	document.body.style.behavior='url(#default#homepage)'; 
	document.body.setHomePage('http://www.hypertech.com.vn/'); 
	} 
	 else if (window.sidebar) 
	 { 
	 if(window.netscape) 
	 { 
		  try 
		  {   
			 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");   
		  }   
		  catch(e)   
		  {   
			alert("Không thể đặt làm trang chủ trên trình duyệt của bạn!"); 
		  } 
	 }  
	 var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch); 
	 prefs.setCharPref('browser.startup.homepage','http://www.hypertech.com.vn/'); 
	} 
} 
function CheckForm ()
{
	if ((document.frmsearch.query.value == '')||(document.frmsearch.query.value == 'Nhập từ khóa...')){
		 alert('Bạn chưa nhập chuỗi tìm kiếm.');
		 document.frmsearch.query.focus();
		 return false;
		}
}
