function Trim(iStr)
{
	while (iStr.charCodeAt(0) <= 32)
	{
		iStr=iStr.substr(1);
	}

	while (iStr.charCodeAt(iStr.length - 1) <= 32)
	{
		iStr=iStr.substr(0, iStr.length - 1);
	}

	return iStr;
}

function checkContactForm(f){	
	f.name.value = Trim(f.name.value);
	if(f.name.value=="" || f.name.value==null){
		window.alert(T_NAME_REQUIRED);
		f.name.focus();
		return false;
	}

	if (isNaN(f.name.value)==false){
		window.alert(T_NAME_TYPE);
		f.name.focus();
		return false;
	}
//email
	var regex = /^(([\-\w]+)\.?)+@(([\-\w]+)\.?)+\.[a-zA-Z]{2,4}$/;
	if(f.email.value=="" || f.email.value==null){
		window.alert(T_EMAIL_REQUIRED);
		f.email.focus();
		return false;
	}	
	if (!regex.test(f.email.value)){
		window.alert(T_EMAIL_TYPE);
		f.email.focus();
		return false;
	}
	f.content.value = Trim(f.content.value);
	if(f.content.value=="" || f.content.value==null){
		window.alert(T_CONTENT_REQUIRED);
		f.content.focus();
		return false;
	}
	f.scode.value = Trim(f.scode.value);
	if(f.scode.value=="" || f.scode.value==null){
		window.alert(T_SPAM);
		f.scode.focus();
		return false;
	}
	return true;
}

function cruise_compare(id,name){
	var sParams = "scrollbars=yes,toolbar=no,menubar=no,resizable=yes,location=no,height=800,width=1250,top=20,left=20";
	var wname = "ShowSlide_print";
	var dest = "cruise-compare.php?"+id+"="+name;
	window.open(dest,wname,sParams);
}

function checkHotelForm(f){
//date 
	f.room.value = Trim(f.room.value);
	if(f.room.value=="" || f.room.value==null){
		window.alert(T_ROOM_REQUIRED);
		f.room.focus();
		return false;
	}
	f.checkin.value = Trim(f.checkin.value);
	if(f.checkin.value=="" || f.checkin.value==null){
		window.alert(T_CHECKIN_REQUIRED);
		f.checkin.focus();
		return false;
	}
	f.checkout.value = Trim(f.checkout.value);
	if(f.checkout.value=="" || f.checkout.value==null){
		window.alert(T_CHECKOUT_REQUIRED);
		f.checkout.focus();
		return false;
	}
//name 
	f.name.value = Trim(f.name.value);
	if(f.name.value=="" || f.name.value==null){
		window.alert(T_NAME_REQUIRED);
		f.name.focus();
		return false;
	}
	if (isNaN(f.name.value)==false){
		window.alert(T_NAME_TYPE);
		f.name.focus();
		return false;
	}
//email
	var regex = /^(([\-\w]+)\.?)+@(([\-\w]+)\.?)+\.[a-zA-Z]{2,4}$/;
	if(f.email.value=="" || f.email.value==null){
		window.alert(T_EMAIL_REQUIRED);
		f.email.focus();
		return false;
	}
	if (!regex.test(f.email.value)){
		window.alert(T_EMAIL_TYPE);
		f.email.focus();
		return false;
	}
//code spam
	f.scode.value = Trim(f.scode.value);
	if(f.scode.value=="" || f.scode.value==null){
		window.alert(T_SPAM);
		f.scode.focus();
		return false;
	}
	return true;
}
function getRadio(o)
{
	var get = document.book_form.getElementsByName(o);
	for (var i=0; i < get.length; i++){
   		if (get[i].checked){
      		return get[i].value;
      	}
   	}
}
function checkTrainForm(f){
//date 
	f.room.value = Trim(f.room.value);
	if(f.room.value=="" || f.room.value==null){
		window.alert(T_TICKET_NUM_REQUIRED);
		f.room.focus();
		return false;
	}
	
	f.checkin.value = Trim(f.checkin.value);
	if(f.checkin.value=="" || f.checkin.value==null){
		window.alert(T_DEPART_REQUIRED);
		f.checkin.focus();
		return false;
	} 
	var get = document.f.way;
	for (var i=0; i < get.length; i++){
   		if (get[i].checked){
      		var val = get[i].value;
      	}
   	}
	if(val==2){
		f.checkout.value = Trim(f.checkout.value);
		if(f.checkout.value=="" || f.checkout.value==null){
			window.alert(T_ARRIVAL_REQUIRED);
			f.checkout.focus();
			return false;
		}
	}
//name 
	f.name.value = Trim(f.name.value);
	if(f.name.value=="" || f.name.value==null){
		window.alert(T_NAME_REQUIRED);
		f.name.focus();
		return false;
	}
	if (isNaN(f.name.value)==false){
		window.alert(T_NAME_TYPE);
		f.name.focus();
		return false;
	}
//email
	var regex = /^(([\-\w]+)\.?)+@(([\-\w]+)\.?)+\.[a-zA-Z]{2,4}$/;
	if(f.email.value=="" || f.email.value==null){
		window.alert(T_EMAIL_REQUIRED);
		f.email.focus();
		return false;
	}
	if (!regex.test(f.email.value)){
		window.alert(T_EMAIL_TYPE);
		f.email.focus();
		return false;
	}
//code spam
	f.scode.value = Trim(f.scode.value);
	if(f.scode.value=="" || f.scode.value==null){
		window.alert(T_SPAM);
		f.scode.focus();
		return false;
	}
	return true;
}


var left =  document.getElementById('left_right_content') ;
if(document.getElementById('id_2')) var right = document.getElementById('id_2') ;
else{ var right = document.getElementById('right_right_content') ;}

if(left.offsetHeight>right.offsetHeight) var max = left.offsetHeight;
else max = right.offsetHeight;

var mainright = document.getElementById('right_main') ;
var height2 = mainright.offsetHeight - 110;
if(max>height2) var max2 = max;
else max2 = height2;

left.style.height = max2 + 'px';
right.style.height = max2 + 'px';
mainright.style.height = max2 + 110+ 'px';
