// 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 dang_ky_email(frm_email)
{
	email=frm_email.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_email		=	encodeURIComponent(frm_email.txt_email.value);
	var	query	=	"txt_email=" + txt_email;
	var http 	=	khoitao_ajax();
	try
	{
		http.open("POST", "../dang_ky_email.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)
				{
					alert("Đã đăng ký email thành công.");
				}
				else
				{
					alert('Có lỗi hệ thống. Xin vui lòng thử lại sau');
				}
			}
		}
		http.send(query);
	}
	catch (e)
	{
	}
	return false;
}
$(function(){
Cufon.replace('h1', {color:'-linear-gradient(#FFF, #FC0)'});
   $("#select-wrapper").jqTransform();
});
$(document).ready(function() { 
	$('ul.sf-menu').superfish(); 
});
//Hover san pham
//$(window).load(function(){
	/* //for each description div...
	$('div.description').each(function(){
		//...set the opacity to 0...
		$(this).css('opacity', 0);
		//..set width same as the image...
		$(this).css('width', $(this).siblings('img').width());
		//...get the parent (the wrapper) and set it's width same as the image width... '
		$(this).parent().css('width', $(this).siblings('img').width());
		//...set the display to block
		$(this).css('display', 'block');
	});
	
	$('div.pro_box').hover(function(){
		//when mouse hover over the wrapper div
		//get it's children elements with class descriptio
		//and show it using fadeTo
		$(this).children('.description').stop().fadeTo(500, 0.7);
	},function(){
		//when mouse out of the wrapper div
		//use fadeTo to hide the div
		$(this).children('.description').stop().fadeTo(500, 0);
	});
});*/
//	});
	 jQuery(window).resize(function(){ 
        EqualHeight(jQuery(".tgp_navigation")); 
    });
	// Xử lý menu
	var timeout = 10;
	var closetimer = 0;
	var ddmenuitem = 0;
	
	function jsddm_open()
	{ jsddm_canceltimer();
	jsddm_close();
	ddmenuitem = $(this).find('ul').css('visibility', 'visible');}
	
	function jsddm_close()
	{ if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}
	
	function jsddm_timer()
	{ closetimer = window.setTimeout(jsddm_close, timeout);}
	
	function jsddm_canceltimer()
	{ if(closetimer)
	{ window.clearTimeout(closetimer);
	closetimer = null;}}
	document.onclick = jsddm_close;
	//-------------------------
	
	$(document).ready(function(){
		$('#menu > li').bind('mouseover', jsddm_open)
		$('#menu > li').bind('mouseout', jsddm_timer)
	});
$(function() {
	$('#pix .box a').lightBox();
});

