
function GE(a){return document.getElementById(a);}

//
function isEmail(strEmail) {
if (strEmail.search(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/) != -1){
return true;
}
}

//
function isTel(strVar) {
if (strVar.search(/\d{3}-\d{8}|\d{4}-\d{7}/) != -1){
    return true;
}else if (strVar.search(/((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)/) != -1){
	return true;
	}
}

//
function isDate(str){ 
var reg = /^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$/;
if (reg.test(str)) return true;
return false;
}

String.prototype.trim = function() 
{ 
return this.replace(/(^\s*)|(\s*$)/g, ""); 
} 

String.prototype.ltrim = function() 
{ 
return this.replace(/(^\s*)/g, ""); 
} 

String.prototype.rtrim = function() 
{ 
return this.replace(/(\s*$)/g, ""); 
} 

function VF_BookTicket(){
    if(GE('txt_FirstName').value.trim() == '') {
	    alert('Error:Please input your first name.');
		GE('txt_FirstName').focus();
		return false;
	}else if(GE('txt_LastName').value.trim() == '') {
	    alert('Error:Please input your last name.');
		GE('txt_LastName').focus();
		return false;
	}else if(GE('ddl_Country').value.trim() == 'ldg') {
	    alert('Error:Please select your country.');
		GE('ddl_Country').focus();
		return false;
	}else if(!isDate(GE('txt_GetDate').value.trim())) {
	    alert('Error:Please input departure date.');
		GE('txt_GetDate').focus();
		return false;
	}else if (!isEmail(GE('txt_Email').value.trim())) {
	    alert('Error:Please input your e-mail.');
		GE('txt_Email').focus();
		return false;
	}else {
	    return true;
	};
} 

