// 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);
}
$(document).ready(function()
{
$(function(){
   Cufon.replace('.tgp_navigation ul li a', {fontFamily:'HP-Impact',color: '-linear-gradient(#FFFFFF, #FFFFFF)',textShadow: '1px 1px 1px #025f02'});  
   Cufon.replace('h1.tour_content_title', {fontFamily:'HP-Impact',color: '-linear-gradient(#FFFFFF, #FFFFFF)',textShadow: '1px 1px 1px #025f02'});  
   Cufon.replace('h1.content_title', {fontFamily:'HP-Impact',color: '-linear-gradient(#FFFFFF, #FFFFFF)',textShadow: '1px 1px 1px #025f02'});  
   Cufon.replace('h1.book_title', {fontFamily:'HP-Impact',color: '-linear-gradient(#FFFFFF, #FFFFFF)',textShadow: '1px 1px 1px #962c09'});  
   Cufon.replace('h1.thoi_tiet_title, h1.thong_tin_title', {fontFamily:'HP-Impact',color: '-linear-gradient(#FFFFFF, #FFFFFF)',textShadow: '1px 1px 1px #234a61'});  
   Cufon.replace('h1.right_title', {fontFamily:'HP-Impact',color: '-linear-gradient(#FFFFFF, #FFFFFF)',textShadow: '1px 1px 1px #962c09'});  
   Cufon.replace('h1.service', {fontFamily:'HP-Impact',color: '-linear-gradient(#483d42, #483d42)',textShadow: '1px 1px 1px #000000'});  
   Cufon.replace('h1.news_event_title', {fontFamily:'HP-Impact',color: '-linear-gradient(#ff7200, #ff7200)',textShadow: '1px 1px 1px #866f5e'});  
   Cufon.replace('h1.abc', {fontFamily:'HP-Impact',color: '-linear-gradient(#ff7200, #ff7200)',textShadow: '1px 1px 1px #866f5e'});  
   Cufon.replace('h1.search_title', {fontFamily:'HP-Impact',color: '-linear-gradient(#ff7200, #ff7200)',textShadow: '1px 1px 1px #866f5e'});  
   Cufon.replace('.tour_nb_content .hotline', {fontFamily:'HP-Impact'});  
});
/*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); 
} 
jQuery(window).load(function(){ 
    EqualHeight(jQuery(".tgp_body_content, .tgp_right")); 
    jQuery(window).resize(function(){ 
        EqualHeight(jQuery(".tgp_body_content, .tgp_right")); 
    }); 
});
	$("#slider").easySlider({
		auto: true,
		continuous: true,
		pause	:	6000
	});
	function formatText(index, panel) {
	  return index + "";
	}
	jQuery(function( $ ){
	$('.newsSlider').css('display','block').anythingSlider({
		easing: "easeInOutBack",        // Anything other than "linear" or "swing" requires the easing plugin
		autoPlay: false,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
		delay: 3000,                    // How long between slide transitions in AutoPlay mode
		startStopped: false,            // If autoPlay is on, this can force it to start stopped
		animationTime: 600,             // How long the slide transition takes
		hashTags: false,                 // Should links change the hashtag in the URL?
		buildNavigation: false,          // If true, builds and list of anchor links to link to each slide
		pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
		startText: "Go",             // Start text
		stopText: "Stop",               // Stop text
		navigationFormatter: formatText       // Details at the top of the file on this use (advanced use)
	});
	});
});
//Phongtx
$(document).ready(function(){
	$(".book_title").click(function()
	{
		$(this).next(".book_content").slideToggle(300).siblings(".book_content").slideUp("slow");

	});
	/*$(".thoi_tiet_title").click(function()
	{
		$(this).next(".thoi_tiet_content").slideToggle(300).siblings(".thoi_tiet_content").slideUp("slow");

	});
		$(".right_title").click(function()
	{
		$(this).next(".tgp_container .tgp_body .tgp_right ul").slideToggle(300).siblings(".tgp_container .tgp_body .tgp_right ul").slideUp("slow");

	});*/
	//hotel tab menu
	$("#menu").lavaLamp({
		fx: "linear",
		speed: 500
	});
});
//phongtx
function book_hotel(frm)
{
	if (frm.txt_ten.value == '')
	{
		 alert('Xin vui lòng nhập tên');
		 frm.txt_ten.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_ten_ks		=	frm.txt_ten_ks.value;
	txt_ten			=	encodeURIComponent(frm.txt_ten.value);
	txt_phone		=	encodeURIComponent(frm.txt_phone.value);
	txt_email		=	encodeURIComponent(frm.txt_email.value);
	txt_address		=	encodeURIComponent(frm.txt_address.value);
	txt_ngay_den	=	encodeURIComponent(frm.txt_ngay_den.value);
	txt_ngay_di		=	encodeURIComponent(frm.txt_ngay_di.value);
	
	var date = new Date();
	var month = date.getMonth() + 1;
	month = (month < 10)? "0" + month : ""+ month;
	
	var day = date.getDate();
	day = (day < 10)? "0" + day : ""+ day;
	
	var year = date.getFullYear();
	var today = year + "-" + month + "-" + day;

	if (txt_ngay_den > txt_ngay_di || txt_ngay_den < today)
	{
		alert('Vui lòng kiểm tra ngày đến và ngày đi !');
		return false;
	}
	txt_rooms	=	encodeURIComponent(frm.txt_rooms.value);
	txt_class	=	encodeURIComponent(frm.txt_class.value);
	txt_guests	=	encodeURIComponent(frm.txt_guests.value);
	txt_occupacy	=	encodeURIComponent(frm.txt_occupacy.value);
	txt_description	=	encodeURIComponent(frm.txt_description.value);	
	var	query	=	"act=book_hotel&txt_ten_ks="		+	txt_ten_ks	+
					"&txt_rooms="		+	txt_rooms	+
					"&txt_guests="		+	txt_guests	+
					"&txt_class="		+	txt_class	+
					"&txt_occupacy="	+	txt_occupacy+
					"&txt_ngay_den="	+	txt_ngay_den+
					"&txt_ngay_di="		+	txt_ngay_di	+
					"&txt_ten="			+	txt_ten		+
					"&txt_email="		+	txt_email	+
					"&txt_phone="		+	txt_phone	+
					"&txt_address="		+	txt_address	+
					"&txt_description="	+	txt_description;
	var http 	=	khoitao_ajax();
	try
	{
		$$$('loading').innerHTML = '<img src="/images/ajax-loader.gif" alt="Loading..." align="middle" />';
		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.readyState == 4)
				{
					if (http.status == 200)
					{
						$$$('inner').innerHTML = http.responseText;
					}
					else
					{
						alert('Có lỗi hệ thống. Xin vui lòng thử lại sau');
					}
				}
			}
		}
		http.send(query);
	}
	catch (e)
	{
	}
	return false;
}
//phongtx
function book_tour(frm)
{
	if (frm.txt_ten.value == '')
	{
		 alert('Xin vui lòng nhập tên');
		 frm.txt_ten.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_ten_tour		=	frm.txt_ten_tour.value;
	txt_ten			=	encodeURIComponent(frm.txt_ten.value);
	txt_phone		=	encodeURIComponent(frm.txt_phone.value);
	txt_duration		=	encodeURIComponent(frm.txt_duration.value);
	txt_email		=	encodeURIComponent(frm.txt_email.value);
	txt_nationality		=	encodeURIComponent(frm.txt_nationality.value);
	txt_address		=	encodeURIComponent(frm.txt_address.value);
	txt_ngay_di		=	encodeURIComponent(frm.txt_ngay_di.value);
	
	var date = new Date();
	var month = date.getMonth() + 1;
	month = (month < 10)? "0" + month : ""+ month;
	
	var day = date.getDate();
	day = (day < 10)? "0" + day : ""+ day;
	
	var year = date.getFullYear();
	var today = year + "-" + month + "-" + day;

	if (txt_ngay_di < today)
	{
		alert('Vui lòng kiểm tra ngày đi !');
		return false;
	}
	txt_description	=	encodeURIComponent(frm.txt_description.value);	
	var	query	=	"act=book_tour&txt_ten_tour="		+	txt_ten_tour	+
					"&txt_ten="		+	txt_ten	+
					"&txt_phone="		+	txt_phone	+
					"&txt_duration="		+	txt_duration	+
					"&txt_email="	+	txt_email+
					"&txt_nationality="	+	txt_nationality+
					"&txt_address="		+	txt_address	+
					"&txt_ngay_di="			+	txt_ngay_di		+
					"&txt_description="	+	txt_description;
	var http 	=	khoitao_ajax();
	try
	{
		$$$('loading').innerHTML = '<img src="/images/ajax-loader.gif" alt="Loading..." align="middle" />';
		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)
				{
					$$$('inner').innerHTML = http.responseText;
				}
				else
				{
					alert('Có lỗi hệ thống. Xin vui lòng thử lại sau');
				}
			}
		}
		http.send(query);
	}
	catch (e)
	{
	}
	return false;
}
