function echeck(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		  // alert("E-mail is invalid")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("E-mail is invalid")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   // alert("E-mail is invalid")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("E-mail is invalid")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   // alert("E-mail is invalid")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   // alert("E-mail is invalid")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		   // alert("E-mail is invalid")
		    return false
		 }

 		 return true					
	}


function DestinationJumper(destination)
{
	if (destination!='empty') 
	{
	window.location = '/Guide/' + escape(destination) + "/default.asp";
	}
}


// ------------------ popup Window chua hinh anh
function popupWindow(text, path, top, left, width, height)
{
	window.open("/popup.asp?path=" + escape(path) + "&title=" + escape(text), "_blank", "resizable=yes,titlebar=yes,top=" + top + ",left=" + left + ",width=" + width + ",height=" + height);
}

function popupWindow2(text, path)
{
	window.open("/popup.asp?path=" + escape(path) + "&title=" + escape(text), "_blank", "resizable,top=50,left=50,width=1,height=1");
}


function showPicture(URL)
{
	window.open("/popup.asp?path=" + escape(URL), "_blank", "resizable,top=50,left=50,width=1,height=1");
}

//-------------------- popup Window chua trang web
function popupWnd(URL, WndName)
{
	window.open(URL, WndName, "top=30, width=560, height=450, left=120, resizable=yes, status=no, scrollbars=yes");
	return false;
}

function popupWnd2(URL, WndName, width, height)
{
	window.open(URL, WndName, "top=30, width=" + width + ", height=" + height + ", left=120, resizable=yes, status=no, scrollbars=no");
	return false;
}

function popupWnd3(URL, WndName, left, top, width, height)
{
	window.open(URL, WndName, "resizable,top="+top+",left="+left+",width="+width+",height="+height);	
	return false;
}
//----------------- Amend reservation
function Amend_Reservation()
{
	window.name = "AmendReservation"
	popupWnd3("/CustomerService/TrackOrder/AmendReservation.asp", "AmendReservation", 200, 180, 420, 230);
	return false;
}
// ----------------- Booking
function Book_Lodging(UnitTypeID)
{
	window.name = "BookLodging" + UnitTypeID;
	popupWnd3("/hotel/book.asp?UnitTypeID=" + UnitTypeID, "Book_Lodging", 200, 180, 420, 230);
	return false;
}


function Book_Package(TicketID)
{
	window.name = "BookPackage" + TicketID;
	popupWnd3("/tour/book.asp?TicketID=" + TicketID, "Book_Package", 200, 180, 420, 175);
	return false;
}

//--------------- Stub
function stub()
{
	alert("COMING SOON!\nThis section is under construction.");
}


//--------------- Time
function GetDays(month, year)
{
	if ((month==1) || (month==3) || (month==5) || (month==7) || (month==8) || (month==10) || (month==12))
		return 31;
	else if (month==2)
		if (year % 4 == 0) return 29;
		else return 28;		
	else
		return 30;
}


function printTime()
{
	var today=new Date();
	var thisyear;

	thisyear=today.getYear();
	if (thisyear<1000) thisyear+=1900;
	document.write(today.getMonth() + "/" + today.getDate() + "/" + thisyear);
}


function printTimeZone()
{
	var today=new Date();
	var timezone, str;

	timezone=today.getTimezoneOffset();

	str=" GMT";
	if (timezone<0) str+="+";
	else if (timezone>0) str+="-";

	timezone=Math.round(Math.abs(timezone)/60);
	str+=timezone;

	document.write(str);
}

function getTimeZoneOffset()
{
	var today=new Date();
	var timezone;

	timezone=-today.getTimezoneOffset();
	return timezone;
}


// ----------------- Validation
function validateDate(monthField, dayField, yearField, actionOn)
{
	var month, day, year;
	var i, number, maxnumber;

	month=monthField.options[monthField.selectedIndex].value;
	day=dayField.options[dayField.selectedIndex].value;
	year=yearField.options[yearField.selectedIndex].value;

	maxnumber=dayField.length;

	switch (actionOn)
	{
	case 1: 	number=GetDays(month, year);
		
		while (dayField.options[--maxnumber].value=="")	{}	
		maxnumber++;
	
		if (number<maxnumber)
		{
			for (i=number; i<maxnumber; i++)
			{
				dayField.options[i].text="";
				dayField.options[i].value="";
			}
			if (dayField.selectedIndex>=number) dayField.selectedIndex=number-1;
		}
		else if (number>maxnumber)
		{
			for (i=maxnumber; i<number; i++)
			{
				dayField.options[i].text=i+1;
				dayField.options[i].value=i+1;
			}	
		}	 
		break;
	case 2:		
		while (dayField.options[--maxnumber].value=="")	{}
		if (day=="") dayField.selectedIndex=maxnumber;
		break;
	case 3:
		if (month==2)
		{
			if (year % 4 == 0)
			{
				dayField.options[28].text="29";
				dayField.options[28].value="29";
			}
			else
			{
				if (day==29) dayField.selectedIndex=27;
				dayField.options[28].text="";
				dayField.options[28].value="";
			}
		}
		break;
	}

}

function validateEmpty(field)
{
	var value=field.options[field.selectedIndex].value;
	var index=0;

	if (value=="")
	{
		while (field.options[index].value=="") {index++;}
		field.selectedIndex = index;
	}
}


// dung cho hover mot cell cua table
function Highlight(src, clrOver) //object, color
{
	src.bgColor = clrOver;
}
