function areasub(Cid){
	if(Cid!=""){
		$.ajax({
			type:"post",
			url:"/Code/Axfile/xmlcity.asp",
			data:"cid="+Cid+"&Action=area",
			ajaxSend:function(){$("<img>").attr("src","images/loading.gif").appendTo("#areasub");},
			success:function(data){$("#areasub").fadeOut("fast",function(){
			   $(this).fadeIn("slow");
			   $('#areasub').html(data);
			 });
			}
		});
	}else{
		$("#areasub").html("信息获得失败！");
	}
}
/*auto*/
function searchgo(){
	var baseUrl="http://hotel.51yo.com/"
	var urlcode="cen-pr1-pr2-hotel_cid.html?tm1=stm1&tm2=stm2&hnm=words&key=maptag"
	if($('#cid') && $('#cid').val()!='' && $('#cid').attr('en')!=''){
		urlcode=urlcode.replace('cen',$('#cid').attr('en'));
		urlcode=urlcode.replace('cid',$('#cid').val());
	}else{
		return false;
	}
	var pr1=$('#pr1').val();
	var pr2=$('#pr2').val();
	if( pr1 >= 0 &&  pr2 > 0){
		if(pr1 > pr2){alert('价格范围输入错误!');return false;}
		urlcode=urlcode.replace('hotel','hotels').replace('pr1-pr2',pr1+'-'+pr2);
	}else{
		urlcode=urlcode.replace('-pr1-pr2','');
	}
	if($('#tm1').val()!='' && $('#tm2').val()!=''){
		urlcode=urlcode.replace('stm1',$('#tm1').val());
		urlcode=urlcode.replace('stm2',$('#tm2').val());
	}else{
		urlcode=urlcode.replace('tm1=stm1&tm2=stm2&','');
	}
	if($('#keyname').val()!=''){
		urlcode=urlcode.replace('words',encodeURI($('#keyname').val()));
	}else{
		urlcode=urlcode.replace('&hnm=words','');
	}
	if($('#key').val()!=''){
		urlcode=urlcode.replace('maptag',encodeURI($('#key').val()));
	}else{
		urlcode=urlcode.replace('&key=maptag','');
	}
	window.location=baseUrl+urlcode;
}
/*auto*/
function format(mail) {
	return "<span class=\"cn\">"+ mail.cn +"</span><span class=\"en\">" + mail.en + "</span>";
}
$(document).ready(function(){ 
	$.init_slide('imgstore','showhere',0,1,1000,1,3000,1,'_self');
	$.jtabber({
		mainLinkTag: "#nav a", // much like a css selector, you must have a 'title' attribute that links to the div id name
		activeLinkClass: "selected", // class that is applied to the tab once it's clicked
		hiddenContentClass: "textbox", // the class of the content you are hiding until the tab is clicked
		showDefaultTab: 1, // 1 will open the first tab, 2 will open the second etc.  null will open nothing by default
		showErrors: true, // true/false - if you want errors to be alerted to you
		effect: 'fade', // null, 'slide' or 'fade' - do you want your content to fade in or slide in?
		effectSpeed: 'slow' // 'slow', 'medium' or 'fast' - the speed of the effect
	})
	$.jtabber({
		mainLinkTag: "#nav2 a", // much like a css selector, you must have a 'title' attribute that links to the div id name
		activeLinkClass: "selected", // class that is applied to the tab once it's clicked
		hiddenContentClass: "showbox", // the class of the content you are hiding until the tab is clicked
		showDefaultTab: 1, // 1 will open the first tab, 2 will open the second etc.  null will open nothing by default
		showErrors: true, // true/false - if you want errors to be alerted to you
		effect: 'fade', // null, 'slide' or 'fade' - do you want your content to fade in or slide in?
		effectSpeed: 'slow' // 'slow', 'medium' or 'fast' - the speed of the effect
	})
	$(".destination dd:first").addClass("after");
	$(".destination dd").bind("mouseover",function(){$(".destination dd").removeClass("after");$(this).addClass("after")});
	$('#city').click(function(event){$(this).val('');});
	$('#tm1').click(function(){showCalendars('tm1','tm2');});
	$('#tm2').click(function(){showCalendars('tm2');});
	$('#tm1img').click(function(){showCalendars('tm1','tm2');});
	$('#tm2img').click(function(){showCalendars('tm2');});
	$('#searbnt').click(function(){searchgo();});
    $('.table tr:odd').addClass('double');
	$("#city").autocomplete('/Code/ajax/searcharea.asp?action=city', {
		caption: "输入拼音，使用↑↓选择",
		autoFill: false,
		minChars: 0,
		width: 217,
		scroll:false,
		multiple: false,
		dataType: "json",
		parse: function(data) {
			return $.map(data, function(row) {
				return {
					data: row,
					value: row.en,
					result: row.cn
				}
			});
		},
		formatItem: function(item) {
			return format(item);
		}
	}).result(function(event, data, formatted) {
		if (formatted != ''){
			var tag=false;
			$('#cid').val(data.id);
			$('#cid').attr('en',data.en);
		}
	});
});
