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 getObject(name){
    if (document.getElementById){
        return document.getElementById(name);
    }else if (document.all){
        return document.all[name];
    }else if (document.layers){
        return document.layers[name];
    }
}

function initpage(){
	try{
		getObject("province").selectedIndex = 0;
	}catch(e){
	}
}
function searchHotel(){
	var _compare = compare();
	if(_compare == true){
		getObject("area_code").value = getObject("city").value;	
		getObject("SearchForm").submit();
	}
	return _compare;
}
function searchHotel2(){
	getObject("area_code").value = getObject("city").value;
  	getObject("SearchForm").submit();
}
function selectArea(area_code){	
window.open("/select-area-"+area_code,'select_area','width=230,height=385,resizable=0,scrollbars=1,status=no,toolbar=no,location=no,menu=no,left=200,top=100');
}
function loadArea(area_code){
	window.opener.location="/city/"+area_code;
}
function closeSelf(){
	if(!window.opener){
		window.opener = "self";
	}
	window.close();
}
function check_email(_email){    
    var myReg = /(\S)+[@]{1}(\S)+[.]{1}(\w)+/;
    if(myReg.test( _email )){
		return true;
	}
    alert("请输入合法的电子邮件地址！");
    return false;
}  
function review(){
	var _author = getObject("author_").value;
	var _from = getObject("from_").value;
	var _contact = getObject("contact_").value;
	var _content = getObject("content_").value;
	if(_author.trim() == ""){
		alert("请输入您的姓名！");
		return;
	}
	if(_from.trim() == ""){
		alert("请输入您来自何处！");
		return;
	}	
	if(_content.trim() == ""){
		alert("请您输入对该酒店的评论！");
		return;
	}
	
	var _author_length = _author.replace(/[^\x00-\xff]/g,'**').length;
	var _from_length = _from.replace(/[^\x00-\xff]/g,'**').length;
	var _contact_length = _contact.replace(/[^\x00-\xff]/g,'**').length;
	var _content_length = _content.replace(/[^\x00-\xff]/g,'**').length;
	
	if(_author_length > 40){
		alert("您输入的姓名过长！");
		return;
	}
	if(_from_length > 40){
		alert("您输入的来处过长！");
		return;
	}
	if(_contact_length > 250){
		alert("您输入的联系方式过长！");
		return;
	}
	if(_content_length > 1000){
		alert("您输入的酒店评论过长！");
		return;
	}
	getObject("ReviewForm").submit();
}
function feedback(){
	var _title = getObject("title_").value;
	var _author = getObject("author_").value;
	var _contact = getObject("contact_").value;
	var _content = getObject("content_").value;
	if(_title.trim() == ""){
		alert("请输入您留言的主题！");
		return;
	}
	if(_author.trim() == ""){
		alert("请输入您的姓名！");
		return;
	}
	if(_contact.trim() == ""){
		alert("请输入您的联系方式！");
		return;
	}
	if(_content.trim() == ""){
		alert("请输入您对我们的留言！");
		return;
	}
	
	var _title_length = _title.replace(/[^\x00-\xff]/g,'**').length;
	var _author_length = _author.replace(/[^\x00-\xff]/g,'**').length;
	var _contact_length = _contact.replace(/[^\x00-\xff]/g,'**').length;
	var _content_length = _content.replace(/[^\x00-\xff]/g,'**').length;
	
	if(_title_length > 80){
		alert("您输入的标题过长！");
		return;
	}
	if(_author_length > 40){
		alert("您输入的姓名过长！");
		return;
	}
	if(_contact_length > 80){
		alert("您输入的联系方式过长！");
		return;
	}
	if(_content_length > 1000){
		alert("您输入的留言过长！");
		return;
	}
	getObject("FeedbackForm").submit();
}