﻿// xydudu start:6.13

var xue = {
	err:{
		0:'不能为空！',	
		1:'输入字符过长！',
		2:'输入字符过短！',
		3:'输入的邮箱错误！',
		4:'发生错误！',
		5:'邮箱已被注册！'
	},
	re: {
		loginpass: /^[\x21-\x7e]{4,32}$/ig,
		newpass: /^[\x21-\x7e]{4,32}$/ig,
		verifypass: /^[\x21-\x7e]{4,32}$/ig,
		email: /^[a-z0-9_+.-]+\@([a-z0-9-]+\.)+[a-z0-9]{2,4}$/i,
		//email: /^[\w\.\-\+]+@([\w\-]+\.)+[a-z]{2,4}$/ig,
		msn: /^[\w\.\-\+]+@([\w\-]+\.)+[a-z]{2,4}$/ig,		
		mobile: /^1(3|5)[0-9]{9}$/
	},
	page : 'index',
	search_o :{
		box:$('#search_box'),
		li:$('#search_box>ul>li'),
		tab:$('.tab'),
		inbox:$('#searchin'),
		input:[$('#land_name'),$('#province'),$('#city'),$('#province2'),$('#city2')]
	},
	cmd_url : 'http://www.keeuu.com/cmd',
	site : 'http://www.keeuu.com'	
};

xue.form_pattern = {
	register : {
		list:'user_mail,user_name,user_pass,@r_pass',
		verify:{'@r_pass':'user_pass'},
		filedname :{
			user_mail : 'Email',
			user_name : '名字',
			user_pass : '密码'		
		},
		textlimit : {
			user_mail :['4','50'],
			user_name : ['2','20'],
			user_pass : ['4','60']
		},
		ajaxcheck :{
			user_mail :['../cmd','ajax_c_mail']
		}
	},
	i_profile_name : {
		list:'user_name',
		verify:{},
		filedname:{
			user_name:'用户名'
		},
		textlimit:{
			user_name:['2','20']
		},
		ajaxcheck:{}
	},
	login : {
		list:'user_mail,user_pass',
		verify:{},
		filedname :{
			user_mail : 'Email',			
			user_pass : '密码'
		},
		textlimit : {
			user_mail :['4','50'],
			user_pass : ['4','60']			
		},
		ajaxcheck :{}		
	},
	trip : {
		list:'title,content',
		verify:{},
		textlimit : {
			title :['4','200'],
			content : ['4','5000000000000000']
		},
		ajaxcheck :{},
		filedname :{
			title : '标题',
			content : '正文'
		}
	},
	add_comment_reply : {
		list:'content',
		verify:{},
		textlimit : {content:['4','5000']},
		ajaxcheck :{},
		filedname :{content:'正文'}		
	},
	ablum_create : {
		list:'album_name',
		verify:{},
		textlimit : {album_name:['1','50']},
		ajaxcheck :{},
		filedname :{album_name:'相册名称'}
	},
	sendmail : {
		list:'getmail',
		verify:{},
		textlimit : {getmail:['1','100']},
		ajaxcheck :{},
		filedname :{getmail:'Email'}
	},
	addcomment :{
		list:'comment_title,comment_content',
		verify:{},
		textlimit : {comment_title:['1','50'],comment_content:['1','5000000000']},
		ajaxcheck :{},
		filedname :{comment_title:'标题',comment_content:'内容'}	
	},
	card_order_form:{
		list:'name,address,postcode,email,tel',
		verify:{},
		textlimit:{name:['1','20'],address:['2','500'],postcode:['1','10'],email:['1','100'],tel:['5','15']},
		ajaxcheck:{},
		filedname:{name:'收件人姓名',address:'地址',postcode:'邮编',email:'常用邮箱',tel:'联系电话'}
	},
	guest_form_book:{
		list:'content',
		verify:{},
		textlimit:{content:['1','300']},
		ajaxcheck:{},
		filedname:{content:'内容'}
	},
	new_group:{
		list:'group_name',
		verify:{},
		textlimit:{group_name:['1','300']},
		ajaxcheck:{},
		filedname:{group_name:'部落名称'}
	},
	write_group_topic:{
		list:'title,content',
		verify:{},
		textlimit:{title:['1','200'],content:['1','10000000000']},
		ajaxcheck:{},
		filedname:{title:'标题',content:'内容'}
	},	
	modify_group_topic:{
		list:'title,content',
		verify:{},
		textlimit:{title:['1','200'],content:['1','10000000000']},
		ajaxcheck:{},
		filedname:{title:'标题',content:'内容'}
	},
	modify_group:{
		list:'group_name',
		verify:{},
		textlimit:{group_name:['1','300']},
		ajaxcheck:{},
		filedname:{group_name:'部落名称'}
	},
	group_topic_reply:{
		list:'reply_content',
		verify:{},
		textlimit:{reply_content:['1','300000000']},
		ajaxcheck:{},
		filedname:{reply_content:'内容'}
	},
	add_landscape:{
		list:'name,intro',
		verify:{},
		textlimit:{name:['2','200'],intro:['1','30000000000']},
		ajaxcheck:{},
		filedname:{name:'景区名称',intro:'景区介绍'}
	},
	write_topic:{
		list:'title,content',
		verify:{},
		textlimit:{name:['2','200'],intro:['1','30000000000']},
		ajaxcheck:{},
		filedname:{name:'标题',intro:'内容'}
	}
}

xue.check = {
	textLimit : function (o,_min,_max) {
		
		if(o.value.length == 0)	return 0;
		if(o.value.length > _max)	return 1;		
		if(o.value.length < _min)	return 2;
		return 3
	},
	isEmail : function(o){
		return o.value ==''|| xue.re['email'].test(o.value);		
	},
	textSpan : function(id){		
		return xue.textspan[id]?xue.textspan[id]:'';
	}
}

xue.Fun = {
	getOffset : function(node){
		var x = node.offsetLeft;
		var y = node.offsetTop;
		var parent = node.offsetParent;
		while (parent != null){
			x += parent.offsetLeft;
			y += parent.offsetTop;
			parent = parent.offsetParent;
		}
		return {x: x, y: y};
	},
	msgBox : function(msg,fun){
		var msgbox,w;
		if($('.msgbox').length>0){
			msgbox = $('.msgbox');			
			msgbox.show().html(boxHtml());
			$('.msgbox_content').html(msg);
			msgbox.css('position','fixed');
			if($.browser.msie&&$.browser.version=='6.0'){
				msgbox.css({position:"absolute"});
			}
			w = msgbox.width();
			msgbox.css({left:'50%',marginLeft:-w/2,top:10});
			setTimeout(
				function(){				
					msgbox.fadeOut(200,fun);				
				}
				,w*10<2000?2000:w*10
			); 
		}else{
			xue.Fun.showMsg(msg,fun);
		};

		function boxHtml(){
			var html = [
			'<div class="msgbox_left"></div>',
            '<div class="msgbox_content"></div>',
            '<div class="msgbox_right"></div>'
			];
			return html.join('');
		}		
	},
	msgBox_New : function(msg,param,fun){
		var msgbox,w,times = 0,msgbox=!param['msgbox']?$('.msgbox'):param['msgbox'];		
			
		if(msgbox.length>0){
			//msgbox = $('.msgbox');
			msgbox.show().html(boxHtml());
			$('.msgbox_content').html(msg);
			msgbox.css('position','fixed');
			if($.browser.msie&&$.browser.version=='6.0'){
				msgbox.css({position:"absolute"});
			}
			w = msgbox.width();
			if(!param['pos']){
				msgbox.css({left:'50%',marginLeft:-w/2,top:10});
			}else{
				msgbox.css({left:param['pos'].left,top:param['pos'].top});
			}
			times = !param['time']?(w*10<2000?2000:w*10):param['time'];
			setTimeout(
				function(){
					msgbox.fadeOut(200,fun);
				}
				,times
			); 
		}else{
			xue.Fun.showMsg(msg,fun);
		};

		function boxHtml(){
			var html = [
			'<div class="msgbox_left"></div>',
            '<div class="msgbox_content"></div>',
            '<div class="msgbox_right"></div>'
			];
			return html.join('');
		}		
	},
	showMsg : function(msg,fun){		
		var		
		_msg = document.createElement('span');
		$(_msg).html(msg)
		.appendTo(document.body);		
		w = $(_msg).width()+30;		
		$(_msg).css({
			width: w-30,		
			color: "#fff",
			background:"#F71145",
			position:"fixed",			
			left:"100%",
			top:"3px",
			marginLeft: -w+"px",
			padding:"2px 10px",
			border:"none"
		});
		if($.browser.msie&&$.browser.version=='6.0'){
			$(_msg).css({position:"absolute"});
		}
		setTimeout(
			function(){				
				$(_msg).fadeOut(200,fun);				
			}
			,1000
		); 
	},	
	dataList : function(data,o_id,for_id,_pos){	
	
		var 
		html_arr = [],
		html_div,
		offset = $('#'+for_id).offset(),
		pos = !_pos?{x:offset.left,y:offset.top,w:$('#'+for_id).width(),h:$('#'+for_id).height()}:_pos
		;
		for(var i=0;i<data.length;i++){
			html_arr[i] = '<li lang="'+ for_id +'" value="'+ data[i].id +'">'+data[i].name+'</li>';			
		}		
		html_div = $('#'+o_id).length>0?$('#'+o_id):$(document.createElement('div'));
		
		html_div.show().appendTo('body')
		.attr({id:o_id,className:o_id+'list'})
		.css({position:'absolute',left:pos.x,top:(pos.y+pos.h+5),width:pos.w+5})
		.html('')
		.append('<ul>'+html_arr.join('')+'</ul>');
		
	},
	loadSelect: function (value,o){
		for(var i=0;i<o.length;i++){
			(function(){
				if($(o[i]).val()==value){
					$(o[i]).attr('selected','selected');	
				}else{
					$(o[i]).removeAttr('selected');	
				}
			})();
		}	
	},
	inputDefVal: function(o,value){
		var get_val = $(o).val(),this_val = '';
		if(get_val == ''){
			o.css('color','#cccccc').val(value).bind(
				'focus',
				function(){
					this_val = $(this).val();
					$(this)
					.css('color','#666666')
					.val((this_val==value||this_val=='')?'':this_val);
					return false;
				}
			).bind(
				'blur',
				function(){
					this_val = $(this).val();
					$(this)
					.css('color',(this_val==value||this_val=='')?'#cccccc':'#666666')
					.val((this_val==value||this_val=='')?value:this_val);
					return false;
				}
			);		
		}
	},
	getCity : function(province_id){
		var citys = area['city'],new_citys = [];
		for(var i=0;i<citys.length;i++){
			if(citys[i].province_id==province_id){
				new_citys.push(citys[i]);
			}	
		}
		return new_citys;
	},
	subForm : function(o){
		o.submit();	
	},
	checkBoxAll : function(o){
		$(o+' input:checkbox').attr('checked','checked');		
	},
	checkBoxAllOff : function(o){
		$(o+' input:checkbox').removeAttr('checked');		
	},
	selectIn:function(o,o_input,o_value){
		o_input['id'].val(o_value['id']);
		o_input['name'].val(o_value['name']);
		o.fadeOut(100);		
		return false;
	},
	ShowHide :function (Oshow,Ohide){
		if(Oshow.length>0)Oshow.show();
		if(Ohide.length>0)Ohide.hide();
		//return false;
	},
	copyText:function(id) {
		var text2copy=$(id).val(),pos=$(id).offset();
		xue.Fun.msgBox_New('复制成功，快去告诉朋友们吧！',{time:1000,pos:pos});
		if (window.clipboardData) {   
			window.clipboardData.setData("Text",text2copy);   
		 } else {   
				  var flashcopier = 'flashcopier';
				   if (!document.getElementById(flashcopier)){
						var divholder = document.createElement('div');
						divholder.id = flashcopier;
						document.body.appendChild(divholder);
					}
		document.getElementById(flashcopier).innerHTML = '';
		var divinfo = '<embed src="'+ xue.site +'/up_inc/_clipboard.swf" FlashVars="clipboard='+escape(text2copy)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
		document.getElementById(flashcopier).innerHTML = divinfo;	
 		}
	},
	getCookie:function(name){
		var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));		
    	if(arr != null) return unescape(arr[2]); return null;
	},
	delCookie:function(name){
		var exp = new Date();
		exp.setTime(exp.getTime() - 1);
		var cval=getCookie(name);
		if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
	
	},
	setCookie:function(name,value){
		var Days = 30; //此 cookie 将被保存 30 天
		var exp  = new Date();    //new Date("December 31, 9998");
		exp.setTime(exp.getTime() + Days*24*60*60*1000);
		document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
	},
	htmlFaceboxFoot:function(html){
		var o=$('#facebox .footer');
		o.html(html);
	},
	showHeadimg:function(src){
		$('#user_headimg').html("<img src=\""+ src +"\" style=\"border:5px solid #eeeeee\" align=\"top\" />");
		return false;
	},
	reply:function(date){
		$('#reply_name').html('回复：'+date.name).show();
		$('#reply_id').val(date.id);
		$('#reply_user_id').val(date.user_id);
		$('#content').focus();
	},
	valToobj:function(o,to){
 		to.val(o.attr('title')); 
	},
	valToobjArea:function(o){
		var province_id = o.attr('title').substr(0,3),city_id=o.attr('title').substr(-3);
		var province=xue.Fun.getAreaById(province_id,'province'),city=xue.Fun.getAreaById(city_id,'city');
		$('#province_id').val(province_id);
		$('#city_id').val(city_id);
		$('#province').val(province);
		$('#city').val(city);
		xue.Search.temp_list.city=xue.Fun.getCity(province_id);
	 },
	getAreaById:function(id,type){
		var o=area[type],l=o.length;
		for(var i=0;i<l;i++){
			if(o[i].id==id){
				return o[i].name;
			}
		}
	 }
}

xue.menu = {	
	init : function(){
		var
		O = xue.menu,
		o = {menu:$('#menu'),on:$('#ison'),li:$('#menu>ul>li')},
		pos = ['pos0','pos1','pos2','pos3','pos4','pos5'],
		old_pos
		;		
		if(o['menu'].length>0&&o['on'].length>0&&o['li'].length>0){			
			old_pos = o['on'].attr('class');
			o['li'].hover(
				function(){								
					o['on'].stop().attr('class',pos[$(this).children('a').attr('rel')]);
					$(this).children('a').css('color','#000');
					return false;
				},
				function(){
					o['on'].stop().attr('class',old_pos);
					$(this).children('a').css('color','#fff');
					return false;
				}
			)			
		}		
	}	
}

xue.Search = {
	isover : false,	
	init : function(){
		if($('#search_box').length>0){			
			this.scorll();
			this.input();
		}else{
			return;	
		}
	},
	temp_list : {},
	scorll:function(){		
		var
		o =  {
		box:$('#search_box'),
		li:$('#search_box>ul>li'),
		tab:$('.tab'),
		inbox:$('#searchin'),
		input:[$('#land_name'),$('#province'),$('#city'),$('#province2'),$('#city2')]
		},
		def_y = 200,
		offset,
		box_offset = xue.Fun.getOffset(document.getElementById('search_box')),
		scrollY = 0;
		
		o['li'].bind(
			'click',
			function(){
				offset = xue.Fun.getOffset(this);				
				o['tab'].stop().animate({top: (offset.y-box_offset.y)}, {duration:600,easing:'easeOutExpo'});
				scrollY = offset.y?(parseInt((offset.y-box_offset.y)/30)*def_y)+'px':0;				
				o['inbox'].stop().scrollTo(scrollY,600,{easing:'easeOutExpo',axis:'y'});
				return false;						
			}
		)
	},
	input:function(){
		var
		O = xue.Search,
		o = {
		box:$('#search_box'),
		li:$('#search_box>ul>li'),
		tab:$('.tab'),
		inbox:$('#searchin'),
		input:[$('#land_name'),$('#province'),$('#city'),$('#province2'),$('#city2'),$('#type'),$('#level')]
		}		
		;
		xue.Fun.inputDefVal($(o['input'][0]),'请输入你要找的风景区');
		
		$.each([o['input'][1],o['input'][2],o['input'][3],o['input'][4],o['input'][5],o['input'][6]], 
		function(){
			$(this).attr('readonly','readonly').hover(
				function(){$(this).css({backgroundPosition:'right -22px',backgroundColor:'#ffffff'});},
				function(){$(this).css({backgroundPosition:'right 0',backgroundColor:'#eeeeee'});}	
			).bind(
				'focus',
				function(){					
					xue.Fun.dataList(xue.Search.temp_list[$(this).attr('name')],'search',$(this).attr('id'));
					O.addFun('search');					
					return false;					
				}
			).bind(
				'click',
				function(){
					xue.Fun.dataList(xue.Search.temp_list[$(this).attr('name')],'search',$(this).attr('id'));
					O.addFun('search');					
					return false;					
				}
			).bind(
				'blur',
				function(){
					if($('#search').length>0&&!O.isover){
						$('#search').hide();						
					}
					return false;
				}
			)			
		});		
	},
	addFun:function(id){
		var O = xue.Search;
		if($('#'+id).length>0){
			$('#'+id).children('ul').children('li').hover(
				function(){
					$(this).css('backgroundColor','#eeeeee');
					O.isover = true;
					return false;
				},
				function(){
					$(this).css('backgroundColor','#fff');
					O.isover = false;
					return false;
				}		
			).bind(
				'click',
				function(){
					var _id = $(this).attr('lang');
					$('#'+_id).focus().val($(this).text());
					$('#'+_id+'_id').val($(this).attr('value'));					
					if($(this).attr('lang')=='province'||$(this).attr('lang')=='province2'){
						$('#city').val('');
						$('#city2').val('');
						xue.Search.temp_list['city'] = xue.Fun.getCity($(this).attr('value'));
					}
					$('#'+id).hide();
					return false;
				}
			);	
			$('#'+id).hover(
				function(){
					O.isover = true;
					return false;
				},
				function(){
					O.isover = false;
					$(this).children('ul').children('li').css('backgroundColor','#fff');
					return false;
				}			
			)	
		}
	}
}

function initform(){
	var 
	form_arr = $('form'),
	isfm = false,
	err = ''
	;
	if (form_arr.length == 0) return;	
	for (var i=0; i<form_arr.length; i++) {
		var fm = form_arr[i];		
		var id = fm.getAttribute('id');
		//fm.elements[0].focus();
		
		if (xue.form_pattern[id]) {
			//for (var j=0; j<fm.elements.length; j++){
//				var element = fm.elements[j];
//				alert(xue.form_pattern[id].ajaxcheck[element.name].length);
//				if(element.name && xue.form_pattern[id].ajaxcheck[element.name].length!=0){
//					
//					var	ajax = xue.form_pattern[id].ajaxcheck[$(this).attr('name')]?xue.form_pattern[id].ajaxcheck[$(this).attr('name')]:'';					
//						$(element).blur(function(){
//							$.post(ajax[0], {'@cmd_type':ajax[1],'user_mail':$(this).val()},function(msg){
//								if(msg){
//									err= xue.err[5];
//									xue.Fun.msgBox(err);
//								}else{
//									err = '';
//								}
//							});	
//						});
//				}
//				
//			}
		isfm = fm;
		}
	}
	if(isfm!=false) $(isfm).submit(function(){if(err!=''){xue.Fun.msgBox(err);return false};return chkform(isfm)});
}

function chkform(fm){	
	id = fm.getAttribute('id'),	
	p_list = xue.form_pattern[id].list,
	p_verify = xue.form_pattern[id].verify,
	err = '';	
	
	for (var j=0; j<fm.elements.length; j++) {
		var element = fm.elements[j];
		if(xue.form_pattern[id].textlimit[element.getAttribute('id')]){
			
			var
			_id = element.getAttribute('id'),
			et = xue.form_pattern[id].textlimit[_id],
			_name = !xue.form_pattern[id].filedname[_id]?'':xue.form_pattern[id].filedname[_id];
			;
			if(xue.check.textLimit(element,et[0],et[1])!=3){				
				err = err+_name+xue.err[xue.check.textLimit(element,et[0],et[1])];
			}			
		}
		if(element.name && element.name.indexOf('mail') != -1&&!xue.check.isEmail(element)){			
			err = err+xue.err[3];				
		}
		if(p_verify[element.name]&&$('#'+p_verify[element.name]).attr('value')!=$(element).attr('value')){			
			err = err+'重复'+xue.form_pattern[id].filedname[p_verify[element.name]]+xue.err[4];			
		}
	}
	if(err!=''){
		xue.Fun.msgBox(err,null);
		return false;
	}else{return true;}
}

xue.box = {
	init:function(){	
		$('a[rel*=facebox]').facebox(); 
	}	
}

xue.dealImg = {
	selection : {},
	imgWH :{},
	init:function(o){
		if($(o).length==0) return;
		var 
		O = this,
		o = $(o),
		w = o.width(),
		h = o.height(),
		x=96,y=96;
		
		O.imgWH = {w:o.width(),h:o.height()},
		$('#preview1').html('<img src="'+o.attr('src')+'" />').css('border','1px solid #eeeeee');
		$('#preview2').html('<img src="'+o.attr('src')+'" />').css('border','1px solid #eeeeee');
		$('#preview1>img').width((w<96&&h<96)?96:w).height((w<96&&h<96)?96:h);
		$('#preview2>img').width($('#preview1>img').width()/2).height($('#preview1>img').height()/2);
		//if(w<96&&h<96) {x=w,y=h}else{x=96,y=96};		
		if(w<96){x=w,y=w}
		if(h<96){x=h,y=h}
		o.imgAreaSelect({aspectRatio:'1:1',x1:0,y1:0,x2:x,y2:y,minHeight:30,minWidth:30,
			onSelectChange:O.preview,
			onSelectEnd:O.cutImg
		 }); 
	},
	preview : function(img, selection){
				
		var scaleX = 96 / selection.width;
		var scaleY = 96 / selection.height;
		var WH = xue.dealImg.imgWH;

		$('#preview1>img').css({
		 width: Math.round(scaleX * WH.w) + 'px',
		 height: Math.round(scaleY * WH.h) + 'px',
		 marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px',
		 marginTop: '-' + Math.round(scaleY * selection.y1) + 'px' 
		 });
		 $('#preview2>img').css({
		 width: Math.round(scaleX/2 * WH.w) + 'px',
		 height: Math.round(scaleY/2 * WH.h) + 'px',
		 marginLeft: '-' + Math.round(scaleX/2 * selection.x1) + 'px',
		 marginTop: '-' + Math.round(scaleY/2 * selection.y1) + 'px' 
		 });
	},
	cutImg : function(img, selection){
		$('#icon_info_x').val(selection.x1);
		$('#icon_info_y').val(selection.y1);
		$('#icon_info_w').val(selection.width);
		$('#icon_info_h').val(selection.height);		
	}
}

xue.dealHeight = function(){
	var o = [$('.i_center_box'),$('.i_left_box'),$('.i_right_box')],maxH=0;
	if($('.i_right').length>0){
		maxH = $('.i_right').height()>$('.i_left_box').height()?$('.i_right').height():$('.i_left_box').height();
		$('.i_right').height(maxH);
		$('.i_left_box').height(maxH);
	}
	
	if(o[0].length==0||o[1].length==0||o[2].length==0) return;
	var
	H = [$('.i_center_box').height(),$('.i_left_box').height(),$('.i_right_box').height()],
	maxH = Math.max(H[0],Math.max(H[1],H[2]));
	for(var i=0;i<o.length;i++){
		o[i].height(maxH);	
	}	
}

xue.ajax = {
	init:function(){
		this.getIntro();
		this.landbe();
		this.del();
		this.update();
		this.updateRead();
		this.common();
		this.recommend();
		this.new_recommend();
	},
	getIntro:function(){
			if($('a.xueajax').length==0) return;
			var
			o = $('a.xueajax'),
			O = this,			
			old,
			x;			
			$(o).toggle(						
				function(){
					x = $(this).attr('rel');
					old = $('.'+x).html(),
					$('#loaddiv').show();
					$.getJSON($(this).attr('href'),function(date){
						if(date.err){
							return false;
						}else{
							$('.'+x).html(date.msg);	
						}
						$('#loaddiv').hide();
					});
					$(this).html('<img border="0" src="'+xue.site+'/img/icon_a2.gif"/>');					
					return false;
				},
				function(){
					//x = $(this).attr('rel');
					$('.'+x).html(old);
					$(this).html('<img border="0" src="'+xue.site+'/img/icon_a.gif"/>');
					return false;	
				}
			)
	},
	landbe:function(){
		if($('a.landbe').length==0) return;
		var
		o = $('a.landbe')		
		;
		$(o).bind(
			'click',
			function(){
				var count_box = $(this).parent().next('dd');				
				$.get($(this).attr('href'),function(msg){
						var date = eval('('+msg+')');						
						if(!date['err']){
							xue.Fun.msgBox(date['msg'],function(){
								count_box.fadeOut(300,function(){
									count_box.html(date['count']).fadeIn(300);						   
								});
							});								
						}else{
							xue.Fun.msgBox(date['msg']);	
						}
				});	
				return false;
			}
		);
		
	},
	recommend:function(){
		if($('a#recommend').length==0) return;		
		var o = $('a#recommend'),to = $('span#recommend_num');
		o.bind(
			'click',
			function(){
				//alert('55');
				var a = $(this);				
				$.get(a.attr('href'),function(msg){
					var date = eval('('+msg+')');
					var pos = a.offset();
					pos.left = pos.left-20
					pos.top = pos.top-5
					
					if(date['err']){
						
						xue.Fun.msgBox_New(date['msg'],{pos:pos,time:300,msgbox:$('.msgbox2')});
					}else{							
						xue.Fun.msgBox_New(date['msg'],{pos:pos,time:300,msgbox:$('.msgbox2')},function(){
							$('#recommend_num').fadeOut(200,function(){$('#recommend_num').html(date['num']).fadeIn(200)})
						});
					}
				});
				return false;
			}
		);
	},
	new_recommend:function(){		
		if($('a.ajaxrecommend').length==0) return;
		var o = $('a.ajaxrecommend'),to;
		o.bind(
			'click',
			function(){
				var a = $(this);
				to = $(this).attr('rel');
				$.get(a.attr('href'),function(msg){
					var date = eval('('+msg+')');
					var pos = a.offset();
					pos.left = pos.left-20
					pos.top = pos.top-5
					
					if(date['err']){						
						xue.Fun.msgBox_New(date['msg'],{pos:pos,time:300,msgbox:$('.msgbox2')});
					}else{							
						xue.Fun.msgBox_New(date['msg'],{pos:pos,time:300,msgbox:$('.msgbox2')},function(){
							$('#'+to).fadeOut(200,function(){$('#'+to).html(date['num']).fadeIn(200)})
						});
					}
				});
				return false;
			}
		);
	},
	del : function(){
		if($('a.ajax_del').length==0) return;		
		var o = $('a.ajax_del');
		$(o).bind(
			'click',
			function(){
				var a = $(this),o_show = false,o_hide;
				if(a.attr('show')){o_show = $('#'+a.attr('show'))};
				if(a.attr('hide')){o_hide = $('#'+a.attr('hide'))};
				
				if(window.confirm(a.attr('title'))){
					$.get(a.attr('href'),function(msg){
						var date = eval('('+msg+')');
						var pos = a.offset();
						pos.left = pos.left-20
						pos.top = pos.top-5
						if(date['err']){
							xue.Fun.msgBox_New(date['msg'],{pos:pos,time:300});
						}else{							
							xue.Fun.msgBox_New(date['msg'],{pos:pos,time:300},function(){
								if(!o_show){
									$('#'+a.attr('lang')).fadeOut(200).remove();
								}else{
									o_hide.fadeOut(300,function(){o_show.fadeIn(300)})
								}							
							});
						}
					})	
				}
				return false;
			}
		);
	},
	update : function(){
		if($('a.ajax_update').length==0) return;
		var o = $('a.ajax_update'),o_len = o.length,obj = [];
		for(var i=0;i<o_len;i++){
			obj[i] = $('#photo_title_'+$(o[i]).attr('lang'));
			$(obj[i]).hover(
				function(){				
					$(this).css({backgroundColor:'#eeeeee',padding:'5px'});
					return false;
				},
				function(){
					$(this).css({backgroundColor:'#ffffff',padding:0});
					return false;
				}
			).bind(
				'click',
				function(){
					o.parent('p').hide().prev('p').show();
					$(this).hide().next('p').show();
					return false;
				}
			);			
		}
		o.bind(
			'click',
			function(){
				var a = $(this),lang = a.attr('lang'),title = $('#title_'+lang).val(),id=$('#id_'+lang).val();	

				$.post(a.attr('href'),{"title":title,"id":id},function(msg){
					var date = eval('('+msg+')');
					var pos = a.offset();
					pos.left = pos.left-20
					pos.top = pos.top-5
					if(date['err']){
						xue.Fun.msgBox_New(date['msg'],{pos:pos,time:500});
					}else{						
						xue.Fun.msgBox_New(date['msg'],{pos:pos,time:500},function(){a.parent('p').hide().prev('p').html(title).show()});
					}
				})
				return false;
			}
		)
		
	},
	updateRead : function(){
		if($('a.update_read').length==0) return;
		var o = $('a.update_read');
		o.bind(
			'click',
			function(){
				var a = $(this),box = $(':checked'),len = box.length,value='',type=a.attr('type');
				var pos = a.offset();
					pos.left = pos.left;
					pos.top = pos.top;
				if(len==0){
					xue.Fun.msgBox_New('请选择条目',{pos:pos,time:500});
				}else{
					value = getValue(box);
						$.post(a.attr('href'),{"@cmd_type":type,"id":value},function(msg){
							var date = eval('('+msg+')');						
							if(date['err']){
								xue.Fun.msgBox_New(date['msg'],{pos:pos,time:500});
							}else{						
								xue.Fun.msgBox_New(date['msg'],{pos:pos,time:500},function(){
									if(type=='ajax_p_update_msg_read'){
										box.removeAttr('checked').parent('td').parent('tr').removeAttr('class');
									}else{
										box.parent('td').parent('tr').fadeOut(300).remove();
									}								
								});
							}						
					})
				}				
				return false;
			}
		);
		
		function getValue(o){
			var value = [];
			for(var i=0;i<o.length;i++){
				value.push($(o[i]).val());
			}
			return value.join(',');
		}		
	},
	common : function(){
		if($('a.ajax_common').length==0) return;
		var o = $('a.ajax_common');
		o.bind(
			'click',
			function(){
				var a = $(this),pos = a.offset();
				pos.left = pos.left;
				pos.top = pos.top;
				$.get(a.attr('href'),function(msg){
					var date = eval('('+msg+')');						
					xue.Fun.msgBox_New(date['msg'],{pos:pos,time:1000});
				})
				return false;
			}
		);
	
	},
	sendMail : function(o){
		var mail=$('#invite_mail').val(),code=$('#invite_code').val();
		$.post(xue.cmd_url,{'@cmd_type':'ajax_p_send_invitemail','mail':mail,'code':code},function(msg){
				var date = eval('('+msg+')'),pos=$(o).offset();
				xue.Fun.msgBox_New(date['msg'],{pos:pos,time:1000});
		})
	},
	checkEmail : function(o){
		var pos = {left:'85px',top:'85px'},val=$(o).val();
		if(!xue.check.isEmail(o)){
			xue.Fun.msgBox_New('邮件格式错误',{pos:pos,time:1000,msgbox:$('#msg')});			
		};
		$.post(xue.cmd_url, {'@cmd_type':'ajax_c_mail','user_mail':val},function(msg){
			if(msg){
				err= xue.err[5];
				xue.Fun.msgBox_New(err,{pos:pos,time:1000,msgbox:$('#msg')});
			}
		});			
	}
}

xue.weather = {
	init : function(){
		if($('#c').length==0) return;		
		var city = $('#c').text();
		$.get(xue.site+'/weather/getweather.php?area='+city,function(msg){
			var weath_info = {},weath_html = [];	
			try  {
				weath_info =eval('('+msg+')');			
				weath_html = [
					'<table align="center" border="0">',
						'<tr>',
							'<td>今天</td>',
							'<td>明天</td>',
							'<td>后天</td>',
						'</tr>',
						'<tr>',
							'<td><img src="'+ weath_info.now.src +'" border="0" /></td>',
							'<td><img src="'+ weath_info.today.src +'" border="0" /></td>',
							'<td><img src="'+ weath_info.tomorrow.src +'" border="0" /></td>',
						'</tr>',
						'<tr>',
							'<td>'+weath_info.now.low+'-'+weath_info.now.high+'°C</td>',
							'<td>'+weath_info.today.low+'-'+weath_info.today.high+'°C</td>',
							'<td>'+weath_info.tomorrow.low+'-'+weath_info.tomorrow.high+'°C</td>',                
						'</tr>',
				   '</table>'
				];
				$('.land_weather').html(weath_html.join(''));
			}catch(exception) {
				$('.land_weather').html("<p>获取<span id='c'>"+ city +"</span>的天气信息失败，请<a href='#' onclick='xue.weather.init();return false;'>重试</a></p>");
			}	
		});
		
	}
}

xue.date = {
	year:function(minY,maxY){
		var years = [];
		for(var i=(maxY+1);i>minY;i--){years.push(i);}		
		return years;
	},
	month:function(){
		return [1,2,3,4,5,6,7,8,9,10,11,12];		
	},
	day:function(y,m){
		var days = [];		
		switch(parseInt(m)){
			case 1: case 3: case 5: case 7: case 8: case 10: case 12:
				days = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31];
			break;
			case 4: case 6: case 9: case 11:				
				days = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30];
			break;
			case 2:
				days = y%4==0?[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28]:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29];
			break;
		}		
		return days;
	}	
}

xue.Select = {
	init:function(){
		this.birthSelect(1920,2002,{y:0,m:0,d:0});
		this.areaSelect($('#homeprovince'),$('#homecity'),{p:0,c:0});
		this.areaSelect($('#liveprovince'),$('#livecity'),{p:0,c:0});
	},
	birthSelect : function(minY,maxY,values){
		if($('select#birthyear').length==0||$('select#birthmonth').length==0||$('select#birthday').length==0) return ;
		var 
		o = {y:$('select#birthyear'),m:$('select#birthmonth'),d:$('select#birthday')},
		date = {y:xue.date.year(minY,maxY),m:xue.date.month()}	
		;
		o['y'].css('width','60px').html(getHtml(date['y'],values['y']));	
		o['m'].css('width','40px').html(getHtml(date['m'],values['m'])).bind(
			'change',
			function(){
				var
				y = o['y'].val(),
				m = $(this).val();
				if(y==0){
					xue.Fun.msgBox('请先选择年份',function(){o['y'].focus()})	
				}else{				
					o['d'].css('width','40px').html(getHtml(xue.date.day(y,m)));
				}
				return false;
			}
		);
		if(values['y']!=0&&values['m']!=0){
			o['d'].css('width','40px').html(getHtml(xue.date.day(values['y'],values['m']),values['d']));
		}		
		function getHtml(arr,value){
			var html = value!=0?['<option value="0" ></option>']:['<option value="0" selected="selected"></option>'];
			for(var i=0;i<arr.length;i++){
				if(arr[i]==value){
					html.push('<option value="'+ arr[i] +'" selected="selected">'+ arr[i] +'</option>')
				}else{
					html.push('<option value="'+ arr[i] +'">'+ arr[i] +'</option>')
				}
			}
			return html.join('');
		}	
	},
	areaSelect : function(province,city,values){
		if(province.length==0||province.length==0) return ;
		province.css('width','60px').html(getHtml(area['province'],values['p'])).bind(
			'change',
			function(){
				var 
				p = $(this).val();								
				city.show().html(getHtml(xue.Fun.getCity(p)));
				return false;
			}
		);
		if(values['p']!=0){
			city.show().html(getHtml(xue.Fun.getCity(values['p']),values['c']));		
		}
		
		function getHtml(arr,value){
			var html = value!=0?['<option value="0">请选择...</option>']:['<option value="0" selected="selected">请选择...</option>'];			
			for(var i=0;i<arr.length;i++){
				if(arr[i]['id']==value){
					html.push('<option value="'+ arr[i]['id'] +'" selected="selected">'+ arr[i]['name'] +'</option>')
				}else{
					html.push('<option value="'+ arr[i]['id'] +'">'+ arr[i]['name'] +'</option>')
				}
			}
			return html.join('');			
		}		
	}
}

xue.pointBox = {
	hand :{
		on:xue.site+'/img/hand.gif',
		out:xue.site+'/img/hand1.gif'
	},
	ok : false,
	N: 0,
	initStar :function(star){
		if(parseInt(star)==0) return;
		var 
		N = parseInt(star)-1,
		o = $($('#point_box>img')[N]),
		O = this,		
		hand = O.hand,
		msg = $('.point_show'),
		pos = o.offset(),
		out_pos = $('.point').offset();
		$('#point_box>img').attr('src',hand.out);
		o.attr('src',hand.on).prevAll().attr('src',hand.on);
		msg.show().css('left',pos.left-out_pos.left).html(o.attr('point')+'分');
		O.ok = true;
		O.N = star;
	},
	init :function (){
		if($('#point_box').length==0)return;
		var O = this,hand = O.hand,o = $('#point_box>img'),msg = $('.point_show');		
		o.hover(			
			function(){
				$('#point_box>img').attr('src',hand.out);
				$(this).attr('src',hand.on).prevAll().attr('src',hand.on);
				var pos = $(this).offset(),out_pos = $('#point_box').offset();				
				msg.show().css('left',pos.left-out_pos.left).html($(this).attr('point')+'分');
				return false;
			},
			function(){
				if(O.ok){
					O.initStar(O.N);
				}else{
					$(this).attr('src',hand.out).prevAll().attr('src',hand.out);
					msg.hide();
				}
				return false;
			}
		).bind(
			'click',
			function(){
				var star = $(this).attr('point');
				$.post($(this).attr('cmd'),{'@cmd_type':'ajax_p_point','land_id':$(this).attr('land'),'star':star},function(msg){					
					var date = eval('('+msg+')');
					if(date['err']){
						xue.Fun.msgBox(date['msg']);						
					}else{
						xue.Fun.msgBox(date['msg'],function(){
							O.initStar(star);								
							$('.point_big').fadeOut(100,function(){
								$('.point_big').html(date['avg'][0]).fadeIn(300);								 
							});
							$('.point_small').fadeOut(100,function(){								
								$('.point_small').html('.'+date['avg'][1]).fadeIn(300);								   
							});
							
							$('.point_user_num').html(date['num']);
						});
					}
				});
				return false;
			}
		);
		
	}
}

xue.tag = {
	init:function(){
		if($('.tags_hot').length==0||$('#tags').length==0) return;		
		var tag_txt = $('.tags_hot>a'),tag_input = $('#tags'),O = this;
		xue.Fun.inputDefVal(tag_input,'请用空格间隔');
		tag_txt.bind(
			'click',
			function(){				
				var
				o = $(this),tag = o.text(),
				input_val = tag_input.val(),
				tags = input_val==''?input_val:(input_val=='请用空格间隔'?'':input_val+' ');
				if(!O.checkTag(tag)){					
					tag_input.css('color','#666666').val(tags+tag);
				}
				return false;
			}
		);
	},
	checkTag :function(tag){
			var 
			tags = $('#tags').val(),
			tag_arr = tags.split(' ');
			for(var i=0;i<tag_arr.length;i++){
				if(tag_arr[i]==tag){
					return true;	
				}				
			}
			return false;
	}
	
}

xue.boxChooseLand = {
	closeImg:xue.site+'/img/del.gif',
	loadProvince : function(){
		var 
		o = $('.land_list_inbox'),
		O = this,
		province = area.province,		
		p_len = province.length,
		html = [];		
		
		if($('#backspan').length>0){
			$('#backspan').parent('span').remove();
		}		
		for(var i=0;i<p_len;i++){
			html[i] = '<a href="#" province='+ province[i].id +' >'+ province[i].name +'</a>';
		}
		
		o.fadeOut(300,function(){
			o.html('').removeAttr('style').html(html.join(''));
		}).fadeIn(300,function(){
			O.loadCity();
		})
	},
	loadCity : function(){
		var
		o = $('.land_list_inbox'), 
		O = this,
		a = $('.land_list_inbox>a'),
		html = [];
		
		a.bind(
			'click',
			function(){
				var
				p_id = $(this).attr('province'),
				city = xue.Fun.getCity(p_id),
				c_len = city.length
				;
				for(var i=0;i<c_len;i++){
					html[i] = '<a href="#" city='+ city[i].id +' >'+ city[i].name +'</a>';
				}
				o.fadeOut(300,function(){
					o.html('').html(html.join(''));
					$('.land_list_box>h3').prepend('<span><a href="#" id="backspan">返回</a></span>');
				}).fadeIn(300,function(){
					$('#backspan').bind(
						'click',
						function(){
							O.loadProvince();
							return false;
						}
					);
					O.loadLand();					
				});								
				return false;
			}
		);		
	},
	loadLand : function(){
		var
		o = $('.land_list_inbox'), 
		O = this,
		a = $('.land_list_inbox>a'),		
		city_id = 0,
		date = '';
		
		a.bind(
			'click',
			function(){
				city_id = $(this).attr('city');
				o.html('等待加载...');				
				$.post(xue.cmd_url,{'@cmd_type':'ajax_g_land','cityid':city_id},function(msg){					
					o.ajaxStart(function(){
						$(this).html('正在加载...');
					}).ajaxSend(function(){
						$(this).html('正在加载...');
					}).ajaxSuccess(function(){						
						date = eval('('+msg+')');
						if(date['err']){
							$(this).html('加载失败...');
						}else{
							$(this).css({height:'500px',overflow:'auto'}).html(O.htmlLand(date['date']));
							$('#cheese_ok').bind(
								'click',
								function(){
									var gets = O.getCheckBoxVal();
									$.facebox.close();									
									$('#about_land').html(gets['name'].join('<cite>,</cite>'));
									O.moveIdToAbout();
									return false;
								}
							);
						}					
					});				
				})				
				return false;
			}
		);
	},
	del : function(id){		
		if($('#item_'+id).next().next('cite').length==0){
			$('#item_'+id).prev('cite').fadeOut(300).remove();
		}else{
			$('#item_'+id).next().next('cite').fadeOut(300).remove();
		}
		$('#item_'+id).next().fadeOut(300).remove();		
		$('#item_'+id).fadeOut(300).remove();		
		return false;		
	},
	htmlLand : function(lands){
		var
		len = lands.length,
		html = [];
		for(var i=0;i<len;i++){
			html.push('<div class="land_item"><input type="checkbox" name="landid" id="land_'+ lands[i].id +'" value="'+ lands[i].id +'" landname="'+ lands[i].name +'"/><label for="land_'+ lands[i].id +'">'+ lands[i].name +'</label></div>');
		}
		html.push('<div class="choose_button"><input type="button" style="margin: 0pt 30px 0pt 0pt;" class="reg_button" id="cheese_ok" value="我选好了"/></div>');
		return html.join('');
	},
	getCheckBoxVal : function(){
		var
		O = this,
		o = $('.land_list_inbox input:checkbox'),
		len = o.length,
		values = {id:[],name:[]};		
		for(var i=0;i<len;i++){
			(function(){
				if(o[i].checked){
					var getid = $(o[i]).val();
					if(getid!=$('#send_id').val()){
						values['id'].push(getid);
						values['name'].push('<span class="land_list_item" id="item_'+ getid +'">'+$(o[i]).attr('landname')+'</span><img onclick="xue.boxChooseLand.del('+ getid +')" src="'+ O.closeImg +'" /> ');
					}
				}			
			})();
		}		
		return values;
	},
	moveIdToAbout : function(){
		var item_len = $('.land_list_item ').length,ids = [];
		for(var i=0;i<item_len;i++){
			(function(){
				var getid = ($($('.land_list_item ')[i]).attr('id')).replace('item_','');
				ids.push(parseInt(getid));
			})();		
		}
		if($('#send_id').length>0){
			ids.push($('#send_id').val());
		}
		//alert(ids.join(','));
		$('#about_land_id').val(ids.join(','));
	},
	checkLand : function(){
		if($('.land_list_item ').length==0&&$('#send_id').val()==0){
			xue.Fun.msgBox('请选择相关景区');return false;
		}	
	}
}	

xue.uploadNew = function(){
	var 
	swf_url = xue.site+'/up_inc/yuploadcomponent.swf',
	//swf_url = 'http://www.yupoo.com/images/uploader_fl_10.swf',
	url = xue.site+'/i/up',
	uploader = {},
	file_list,
	date_list=[],
	uploadCounter=0,
	uploadItem=0,
	max_size=10240,
	max_one=51200,
	total_size=0,
	album_id,uid,up_ok,photo_ids=[],
	e_select,e_template,e_uplist,e_li,e_remove,e_totalSize,e_count,e_clear,e_more,e_up,e_process,e_failed,e_foot;
	var
	onContentReady = function(){
		$('#x_loading').hide();
		$('#x_upload_box_1').fadeIn(100);
		$('#x_upload_box_2').fadeIn(100);
		uploader.setAllowLogging(true);      
		uploader.setAllowMultipleFiles(true); 
		var ff = new Array({description:"Images", extensions:"*.jpg;*.png;*.gif"});                         
		uploader.setFileFilters(ff); 
	},
	onFileSelect = function(e){		
		file_list=checkSize(e.fileList);
		if(!file_list) return;
		createList(file_list);
		showBar();
	},
	onUploadStart = function(e){
		
	},
	onUploadProgress = function(e){
		var html = e_process.html();
		html = html.replace('%uploaded%',uploadItem).replace('%total%',uploadCounter);		
		var prog = Math.round(100*(e["bytesLoaded"]/e["bytesTotal"]));		
		$('#'+e['id']).css({backgroundPosition: -(2-(prog/100))*390+"px 2px" });
		if(prog==100){
			e_foot.html(html);
		}
	},
	onUploadResponse = function(e){
		var html;	
		up_ok = eval('('+e.data+')');
		if(up_ok.err){
			html = e_failed.html();
			html = html.replace('%filename%',up_ok.date[0]).replace('%msg%',up_ok.msg);	
			e_foot.html(html);
			uploadItem++;
			upload();
		}else{
			$('#'+e['id']+'>div.i_upload_select').html('<a class="i_upload_ok" >&nbsp;</a>');
			
			if (uploadItem<uploadCounter-1) {				
				uploadItem++;
				upload();
				photo_ids.push(up_ok.date[0]);
			}
			else {
				uploader.clearFileList();
				uploadCounter = 0;
				photo_ids.push(up_ok.date[0]);
				html = $('#i_upload_complete').html();
				html = html.replace('%id%',up_ok.date[1]).replace('%photo_ids%',photo_ids.join(','));				
				e_foot.html(html).fadeOut(10,xue.Fun.subForm($('#upload_done')));
			}
		}
	},
	browse = function(){		
		//uploader.browse(true, [{description:"Images", extensions:"*.jpg;*.png;*.gif"}]);
	},	
	initBar = function(){
		e_up.bind(
			'click',
			function(){
				upload();return false;
			}
		)
	},
	createList = function(entries){
		var
		tpl=e_template.html(),
		data_arr=[],
		count=0,
		html=[]
		;
		$.each(entries, function(i, n){
			html.push('<li id="'+i+'">'+tpl.replace('%file%',n.name).replace('%size%',(n.size/1024).toFixed(2)+'KB').replace('%fileid%',i)+'</li>');
			count++;
		}); 
		e_uplist.html('<ul>'+html.join(' ')+'</ul>');
		uploadCounter = count;
		addRemove();
	},
	checkSize = function(entries){
		total_size=0;
		$.each(entries, function(i, n){
			if((n.size/1024)>max_one){
				xue.Fun.msgBox_New(n.name+'超过最大上传大小',{time:1000});							
				delete entries[i];
				uploader.removeFile(i);
			}
			total_size=total_size+n.size;			
		});
		if((total_size/1024)>max_size){
			xue.Fun.msgBox_New('总大小超过10M',{time:1000});
			clearList();
			entries={};
			total_size=0; 
		};		
		return entries;
	},
	clearList = function(){		
		uploader.clearFileList();
		uploadCounter = 0;
		total_size = 0;
		//showBar();
		e_uplist.children('ul').fadeOut(500).remove();
	},
	addRemove = function(o){		
		var get_fileid;
		$('.i_upload_remove').hover(
			function(){$(this).css({backgroundPosition:'-10px 2px'});return false;},
			function(){$(this).css({backgroundPosition:'0 2px'});return false;}
		).bind(
			'click',
			function(){
				get_fileid = this.lang;								 
				$(this).parent().parent('li').fadeOut(500,function(){
					removeFilelist(get_fileid);
				}).remove();
				return false;
			}
		);	
	},
	doRemove = function(o){
		get_fileid = o.lang;								 
		$(o).parent().parent('li').fadeOut(500,function(){
			removeFilelist(get_fileid);
		}).remove();
		return false;
	},
	removeFilelist = function(fileID){
		uploader.removeFile(fileID);		
		uploadCounter--;
		total_size=total_size-file_list[fileID].size;
		delete file_list[fileID];		
		showBar();
	},
	showBar = function(){
		e_select.html('继续添加');
		e_totalSize.html('总大小：'+(total_size/1024).toFixed(2)+'KB');
		e_count.html(uploadCounter +' 张照片');
		
		e_clear.html('清空').click(
			function(){clearList();return false}
		);
		if(uploadCounter==0){
			e_select.html('选择照片');
		}
		getList();
	},
	getList = function(){
		var o=e_uplist.children().children('li');
		uploadCounter = o.length;
		date_list=[];
		for(var i=0;i<uploadCounter;i++){
			date_list.push($(o[i]).attr('id'));
		}
	},
	upload = function(){
		if(file_list == null) return;
		if(file_list[date_list[uploadItem]]){
			uploader.upload(date_list[uploadItem], url,'post',{uid:uid,album:album_id});
		}else{
			uploadItem++;
			uploader.upload(date_list[uploadItem], url,'post',{uid:uid,album:album_id});
		}
	}
	;
	return{
		init:function(){
			e_select=$('.fileSelect');
			e_template=$('#i_upload_template');
			e_uplist=$("#uplist");
			e_totalSize=$('#upload-total-bytes');
			e_count=$('#i-total-files');
			e_clear=$('#i_upload_clear');
			e_up=$('#up');
			e_process=$('#i_upload_process');
			e_failed=$('#i_upload_failed');
			e_foot=$('.i_upload_footbar');
			album_id = $('#album_id').val();
			uid = $('#uid').val();
			
			initBar();
			YAHOO.widget.Uploader.SWFURL = swf_url;			
			uploader = new YAHOO.widget.Uploader( "uploaderOverlay" );
			uploader.addListener('fileSelect',onFileSelect);
			uploader.addListener('contentReady',onContentReady);
			uploader.addListener('uploadStart',onUploadStart);
			uploader.addListener('uploadProgress',onUploadProgress);
			uploader.addListener('uploadCompleteData',onUploadResponse);
		},
		remove:function(o){
			doRemove(o);
			return false;
		},
		selectPhoto:function(){
			browse();return false;
		}
	}
}();

xue.photo = {	
	init :function(){
		if($('.photo_view_context').length==0) return;
		this.over();
		this.barClass();
		this.trigger();
	},	
	curID :1,
	easing :'easeInOutQuad',	
	barClass : function(){		
		if(!$('.p_bar>span')&&$('.p_bar>span').length!=2) return;
		var 
		o = $('.p_bar>span')
		;
		$(o[0]).click(
			function(){				
				xue.photo.scrollImg('right');
				$(o[1]).show();
				return false;
			}
		);
		$(o[1]).click(
			function(){					
				xue.photo.scrollImg('left');
				$(o[0]).show();
				return false;
			}
		);		
		o.mousedown(
			function(){$(this).addClass(' bar_click')}
		);
		o.mouseup(
			function(){$(this).removeClass(' bar_click')}
		);					
		o.hover(
			function(){$(this).addClass(' bar_over')},
			function(){$(this).removeClass('bar_over')}
		);
		
	},
	scrollImg : function(direct){		
		var	
		O = this,		
		oAdd = $('#store_'+direct+' a:last-child'),
		appto = direct=='left'?'right':'left',
		oa = $('#imglist>a')	
		;		
		if(direct=='left'){			
			if(oa.length==(O.curID+2)){
				if($('#store_left>a').length==0){
					$('.bar_next').hide();
					return ;
				}				
				oAdd.insertAfter($(oa[O.curID+1]));
				$('#imglist').width($('#imglist').width()+75);
			}			
			O.curID +=1;
			O.over();
			$('.xxx').stop().scrollTo(oa[O.curID-1],500,{ easing:O.easing,axis:'x',onAfter:function(){}});		
		}else{
			if(O.curID==1){				
				if($('#store_right>a').length==0){
					$('.bar_prev').hide();
					return;
				}				
				oAdd.insertBefore($(oa[O.curID-1])).hide().animate(
						{width: 'show'},
						500,O.easing
				);
				$('#imglist').width($('#imglist').width()+75);
			}else if(O.curID>1){				
				$('.xxx').stop().scrollTo(oa[O.curID-2],500,{ easing:O.easing,axis:'x',onAfter:function(){}});
				O.curID -=1;
			}				
			O.over();			
		}
	},	
	over : function(){
		if(!$('#imglist>a:visible')) return;
		var
		O = this;		
		o = [$('#imglist>a')[O.curID],$('#imglist>a')[O.curID-1],$('#imglist>a')[O.curID+1]]
		;		
		$(o).hover( 
			function(){addX($(this),75,36);return false;},
			function(){addX($(this),49,49);return false;}						
		);		
		function addX(oN,maxW,minW){			
			for(var n=0;n<3;n++){				
				$(o[n]).stop().animate(
					{width: minW},
					{duration:200,easing:O.easing}
				);
			}
			$(oN).stop().animate(
					{width: maxW},
					{duration:200,easing:O.easing}
			);
			
			return false;
		}												
	},
	trigger : function(){
		var o = $('#context_stream_trigger'),photo_box = $('#photo_box'),ctx_head = $('#context_head');
		o.hover(
			function(){
				$(this).css({backgroundPosition:'0 -25px'});
				return false;
			},
			function(){
				$(this).css({backgroundPosition:'0 0'});
				return false;
			}
				
		).toggle(
			function(){
				$(this).attr('class','context_trigger2');
				ctx_head.css('top','0');
				photo_box.fadeOut(300);
				return false;	
			},
			function(){
				$(this).attr('class','context_trigger');
				ctx_head.css('top','1px');
				photo_box.fadeIn(300);
				return false;	
			}
		);
	}
}

xue.album = {
	filename: '',
	init :function(){
		if($('.img_up_box_bar').length==0) return;
		var a=$('.img_up_box_bar>a');
		a.bind(
			'click',
			function(){
				a.removeAttr('id');
				$(this).attr('id','img_up_box_bar_checked');
				xue.Fun.ShowHide($('.'+$(this).attr('show')),$('.'+$(this).attr('hide')));				
				return false;
			}
		);
	},	
	loadPhoto : function(id){		
		if($('.img_choose_album_box').length==0) return;		
		var o=$('.img_choose_album_box');	
		o.html('正在加载...');
			$.post(xue.cmd_url,{'@cmd_type':'ajax_p_photo_byalbum','id':id},function(msg){
			o.ajaxStart(function(){
				$(this).html('正在加载...');
			}).ajaxSend(function(){
				$(this).html('正在加载...');
			}).ajaxSuccess(function(){						
				date = eval('('+msg+')');
				if(date['err']){
					$(this).html(date['msg']);
				}else{
					var list=date['msg'],len=list.length,html=[],html2='';
					for(var i=0;i<len;i++){
						html[i]='<li><img src="'+ xue.site +'/upload/album/'+ id +'/75/'+ list[i]['filename'] +'.jpg" onclick="xue.album.intoTextarea(this)" big="'+ xue.site +'/upload/album/'+ id +'/500/'+ list[i]['filename'] +'.jpg" name="'+ list[i]['filename'] +'" /></li>';
					}
					html2 = html.join('');
					$(this).html('<ul class="box_photo_list">'+html2+'</ul>');
					$('#back').show().bind(
						'click',
						function(){							
							$.facebox({ ajax: xue.site+'/inbox/choose_album' });
							return false;
						}
					);
				}					
			});
			
		})	
		
	},
	intoTextarea : function(img){
		var store = $('#img_store'),No=$('#img_store input').length+1,O=this,html=[];
		html = [
			'<dl id="dl_'+ No +'">',
			'<dt><img src="'+$(img).attr('src')+'" /></dt>',
			'<dd>[图片'+No+'] <a href="#" lang="dl_'+ No +'" name="'+ $(img).attr('name') +'" title="'+ No +'" onclick="xue.album.del(this);return false;">[删除]</a></dd>',
			'<input class="imgs" name="img_'+No+'" value="'+$(img).attr('big')+'" type=hidden />',
			'</dl>'			
		];
		store.append(html.join("\n")).fadeIn(200);		
		$('#content').insert_caret('[图片'+ No +']');
		$.facebox.close();
	},
	InsertString : function (id, value){
		var o = document.getElementById(id);
		o.focus();
		if(document.selection){
			document.selection.createRange().text = value;
		}else{
			o.value = o.value.substr(0, o.selectionStart) + value + o.value.substr(o.selectionEnd);
		}
	},
	startUp : function(){
		var loading = $('#img_upload_loading'),f=$('#up_form');
		loading.show();
		$.facebox.close();
		xue.Fun.subForm(f);
	},
	complete :function(){
		var
		msg = $('#frameup').contents().find('#upmsg').html(),
		O=this;
		msg = eval('('+msg+')');
		if(msg['err']){
			alert(msg['msg']);
		}else{
			this.filename = msg['date'][0];
			O.intoTextarea('<img src="'+ xue.site +'/upload/album/'+ msg['date'][1] +'/75/'+ msg['date'][0] +'.jpg"  big="'+ xue.site +'/upload/album/'+ msg['date'][1] +'/500/'+ msg['date'][0] +'.jpg"  name="'+ msg['date'][0] +'" />');
		}
		$('#img_upload_loading').hide();
		return false;
	},
	del : function(o){
		var
		v = $('#content').val(),
		re = new RegExp("\\[图片"+ $(o).attr('title') +"\\]","g");	
		$('#content').val(v.replace(re,''));
		$('#'+$(o).attr('lang')).fadeOut(300);
	},
	addAlbum : function(){
		var
		name = $('#album_name').val(),
		pos = {left:'120px',top:'40px'};
		if(name==''){			
			xue.Fun.msgBox_New('名称不能为空！',{msgbox:$('#msg'),pos:pos});
			return;
		}else{
			$.post(xue.cmd_url,{'@cmd_type':'ajax_p_addAblum','name':name},function(msg){
				msg = eval('('+msg+')');
				xue.Fun.msgBox_New(msg['msg'],{msgbox:$('#msg'),pos:pos,time:100},
					function(){
						if(msg['err']){					
							return;
						}else{
							xue.Fun.ShowHide($('#uploads'),$('#add'));
							$('#album_id').append('<option value="'+ msg['id'] +'"  selected="selected">'+ name +'</option>');
						}					
					}				
				);				
			});
		}
	}
}

xue.landImgUp = {
	i : 0,
	msg : [],
	start : function(o){
		$(this).attr('disabled','disabled');
		$('#up_loading').show();
	},
	complete : function(){
		var 
		O = this,		
		msg = $('#upframe').contents().find('#upmsg').html();		
		msg = '['+msg.substr(0,msg.length-1)+']';
		msg = eval('('+msg+')');
		O.msg = msg;
		$('#up_init').hide();		
		$('#up_complete').show();		
		xue.landImgUp.insetHtml();

	},
	insetHtml : function(msg,i){
		var 
		O = this,
		msg = O.msg,
		len = msg.length,
		i = O.i;
		if(i<len){	
			var
			tf = $('#template_failed').html(),
			ts = $('#template_success').html(),
			box = $('#up_complete_list'),
			html = '';
			if(msg[i]['err']){
				html = tf.replace('-name-',msg[i]['date'][0]);
				html = html.replace('-msg-',msg[i]['msg']);				
			}else{
				html = ts.replace('-name-',msg[i]['date'][0]);
				html = html.replace('-filename-',msg[i]['date'][1]);
				html = html.replace('-areacode-',msg[i]['date'][3]);
				html = html.replace('-landid-',msg[i]['date'][2]);				
			}			
			box.append(html);
			i++;
			O.i=i;
			setTimeout("xue.landImgUp.insetHtml()",500);
		}
	},
	addInput : function(o){
		$(o).before('<p><input type="file" name="file[]" /></p>'); 
	}
}

xue.albumImgUp = {

	complete : function(){
		var 
		ids = [],		
		msg = $('#upframe').contents().find('#upmsg').html();		
		msg = '['+msg.substr(0,msg.length-1)+']';
		msg = eval('('+msg+')');
		for(var i=0;i<msg.length;i++){
			var it=msg[i];
			if(it.err){
				alert(it.msg);
			}else{
				ids.push(it.date[0]);
			}		
		}
		$('#photo_ids').val(ids);
		$('#send_id').val(msg[0].date[1]);
		xue.Fun.subForm($('#upload_done'));
	},
	
	start : function(o){
		$(this).attr('disabled','disabled');
		$('#up_loading').show();
	},
	
	addInput : function(o){
		$(o).before('<p><input type="file" name="file[]" size="30" /></p>'); 
	}
}

xue.tripPreview = {
	init : function(){
		var 
		o_title = $('#pre_title'),
		o_content = $('#pre_content'),
		title = $('#title').val(),
		content = $('#content').val(),
		imgs = $('input.imgs'),len = imgs.length,
		patten = {'@cmd_type':"ajax_p_preview",'title':title,'content':content};		
		for(var i=0;i<len;i++){
			patten['img_'+(i+1)] = $(imgs[i]).val();
		}
		$.post(xue.cmd_url, patten, function(msg){
            date = eval('('+msg+')');
			o_title.html(date.title);
			o_content.html(date.content);
        });
	}
}

xue.photoDetail={
	init:function(){
		this.one();
		this.more();
	},
	more:function(){
		if($('.photo_detail_modify').length==0) return;
		var text=$('.photo_item_detail'),i,input,save,cancel,textarea,filename;
		text.hover(
			function(){
				$(this).css({backgroundColor:'#eeeeee',padding:'5px'});
				return false;
			},
			function(){
				$(this).css({backgroundColor:'#ffffff',padding:'0'});
				return false;
			}
		).bind(
			'click',
			function(){
				i=$(this).attr('item');
				input=$('#photo_detail_input_'+i);
				save=$('#photo_detail_save_'+i);
				cancel=$('#photo_detail_cancel_'+i);
				textarea=$('#photo_detail_textarea_'+i);
				filename=$('#photo_title_textarea_'+i);				
				cancel.bind(
					'click',
					function(){
						xue.Fun.ShowHide(text,input);
						return false;
					}
				);
				save.bind(
					'click',
					function(){
						$.post(xue.cmd_url,{'@cmd_type':'ajax_p_photo_detail','detail':textarea.val(),'id':filename.val()},function(msg){
							var date = eval('('+msg+')'),pos=$(save).offset();
							xue.Fun.msgBox_New(date['msg'],{pos:pos,time:1000},function(){
								text.html(textarea.val()).css({backgroundColor:'#ffffff',padding:'0'});
								xue.Fun.ShowHide(text,input);					
							});				
						})
						return false;
					}
				);
				xue.Fun.ShowHide(text,$('.photo_detail_modify'));
				xue.Fun.ShowHide(input,$(this));
				return false;
			}
		);		
		
	},
	one:function(){
		if($('#photo_detail_input').length==0) return;
		var 
		text=$('#photo_detail_text'),
		input=$('#photo_detail_input'),
		save=$('#photo_detail_save'),
		cancel=$('#photo_detail_cancel'),
		textarea=$('#photo_detail_textarea'),
		filename=$('#photo_title_textarea')
		;
		text.hover(
			function(){
				$(this).css({backgroundColor:'#eeeeee',padding:'5px'});
				return false;
			},
			function(){
				$(this).css({backgroundColor:'#ffffff',padding:'0'});
				return false;
			}
		).bind(
			'click',
			function(){
				xue.Fun.ShowHide(input,text);
				return false;
			}
		);
		save.bind(
			'click',
			function(){
				$.post(xue.cmd_url,{'@cmd_type':'ajax_p_photo_detail','detail':textarea.val(),'id':filename.val()},function(msg){
					var date = eval('('+msg+')'),pos=$(save).offset();
					xue.Fun.msgBox_New(date['msg'],{pos:pos,time:1000},function(){
						text.html(textarea.val()).css({backgroundColor:'#ffffff',padding:'0'});
						xue.Fun.ShowHide(text,input);					
					});				
				})
				return false;
			}
		);
		cancel.bind(
			'click',
			function(){
				xue.Fun.ShowHide(text,input);
				return false;
			}
		);
	}
}

xue.dialogBox = {
	config:{
		hide:8000,
		late:2000,
		show:200
	},
	show:function(msg,h){
		var O=this,o=O.html(msg),x,
			box=($('#dialog_box').length==0)?O.box():$('#dialog_box');
		$(o).appendTo('#dialog_box').stop().animate(
			{height:50},O.config.show,'easeInOutCirc',
			function(){
				$('div.dialog_inbox').ifixpng();
				if(h){
					O.goHide($(this));
				}else{
					$(this).attr('title','点击关闭').css('cursor','pointer').bind('click',function(){O.config.hide=100;O.goHide($(this));O.config.hide=5000;})
				}	
			}
		)		
		return false;
	},
	html:function(msg){
		return [
			'<div class="dialog_inbox"  style="display:none">',
			'<div class="dialog_content">',
			msg,
			'</div>',
			'</div>'		
		].join("\n");
	},
	box:function(){
		var html=[
			'<div class="dialog_box" id="dialog_box">',
			'</div>'
		].join("\n");
		$(html).appendTo('body');
		return html;
	},
	goHide:function(o){
		var O=this;
		setTimeout(function(){
			o.animate({height:0},O.config.show,'easeInOutCirc',function(){$(this).remove()});
			},O.config.hide
		)
	},
	showArray:function(arr){
		var O=this,arr=arr,l=arr.length;
		for(var i=0;i<l;i++){
			O.late(i,arr);
		}
	},
	late:function(i,arr){
		var O=this,t;
		t=setTimeout(function(){O.show(arr[i],true);},O.config.late*i);
	}
}

xue.card = {
	preview:function(){
		html = [
			'<dt>收件人姓名</dt>'	,
			'<dd>'+$('#name').val()+'</dd>',
			'<dt>联系电话/手机</dt>',
			'<dd>'+$('#tel').val()+'</dd>',
			'<dt>地址</dt>',
			'<dd>'+$('#address').val()+'</dd>',
			'<dt>邮编</dt>',
			'<dd>'+$('#postcode').val()+'</dd>',
			'<dt>常用E-mail</dt>',
			'<dd>'+$('#email').val()+'</dd>',
			'<dt>备注</dt>',
			'<dd>'+$('#detail').val()+'</dd>',
		];
		$.facebox(html.join(' '));
	}
}

xue.pageload = function(){
	if($('#loaddiv').length>0)	$('#loaddiv').hide();
	$.getJSON(xue.site+"/dialog?a="+xue.page, function(json){
		if(json.arr.length>0)xue.dialogBox.showArray(json.arr);
	}); 
	
}

xue.ad={
	init:function(o){
		var O=this;	
		if($(o).length==0) return;
		setTimeout(
			function(){
				O.doScroll(o);
			},2500
		)
	},
	doScroll:function(o){
		var O=this,o=o;
		$(o).fadeOut(500,function(){
			o=o=='#ad2'?'#ad1':'#ad2';
			$(o).fadeIn(500);
		});
		O.init(o);
	}
}	

xue.inputdate = {
	init:function(type){
		var y=$('#'+ type +'_year'),
			m=$('#'+ type +'_month'),
			v,			
			O=this;		
		y.bind(
			'keyup',
			function(){
				v=y.val();
				y.val(v.replace(/[^\d]/,''));
			}
		).bind(
			'blur',
			function(){
				v=$(this).val();
				if(v=='') return;
				return O.checkDate(type,'Y',v);
			}
		);
		m.bind(
			'keyup',
			function(){
				v=m.val();			
				m.val(v.replace(/[^\d]/,''));
			}
		).bind(
			'blur',
			function(){
				v=$(this).val();
				if(v=='') return;	
				return O.checkDate(type,'M',v);
			}
		);		
	},
	checkDate:function(type,y_or_m,date){
		var t=new Date(),
			Y=t.getFullYear(),
			M=t.getMonth()+1,
			err=$('#be_box_err'),
			y=$('#'+ type +'_year');
		if(y_or_m=='Y'){	
			if(type=='be'&&date<Y){err.html('你打算来个时空旅行吗？');return false;}
			if(type=='be'&&date>2038){err.html('请不要超过2038年！');return false;}
			if(type=='been'&&date>Y){err.html('这个时间还没到呢！');return false;}
			if(type=='been'&&date<1900){err.html('这个，太早了吧？您那时多大？');return false;}
		}else{
			if(type=='be'&&y.val()==Y&&date<M){err.html('这个时间已经过去了。');return false;}
			if(type=='been'&&y.val()==Y&&date>M){err.html('这个时间还没到呢。');return false;}
			if(date<1){err.html('月份有问题吧。');return false;}
			if(date>12){err.html('有这个月份吗？');return false;}
		}
		return true;
	},
	subF:function(type){
		var O=this,
			y=$('#'+ type +'_year').val(),
			m=$('#'+ type +'_month').val(),
			err=$('#be_box_err');
			if($('#no_time').attr("checked")){
				y=0;m=0;
			}else{
				if(y==''||m==''){err.html('时间请不要留空！');return false;}
				if(!O.checkDate(type,'Y',y)) return false;
				if(!O.checkDate(type,'M',m)) return false;
			}
			err.html('<img src="'+xue.site+'/img/loading2.gif" /> 正在处理...');
			$.post(xue.cmd_url,{'@cmd_type':'ajax_p_'+type,'landid':$('#landid').val(),'y':y,'m':m},function(msg){
				var date = eval('('+msg+')');						
				if(!date['err']){
					xue.Fun.msgBox(date['msg'],function(){
				   		window.location=xue.site+'/landscape/'+$('#landid').val();
					});								
				}else{					
					xue.Fun.msgBox(date['msg']);
				}																								   
			})
	},
	befoot:function(){
		xue.Fun.htmlFaceboxFoot('<input type="button" class="button" value=" 确定 " onclick="xue.inputdate.subF(\'be\');"  /> 或者 <a href="javascript:void(0)" onclick="$.facebox.close();return false;" >取消</a>');
		xue.inputdate.init('be');
	},
	beenfoot:function(){
		xue.Fun.htmlFaceboxFoot('<input type="button" class="button" value=" 确定 " onclick="xue.inputdate.subF(\'been\');"  /> 或者 <a href="javascript:void(0)" onclick="$.facebox.close();return false;" >取消</a>');
		xue.inputdate.init('been');
	}
}

xue.group = {
	subF:function(cmd_type){
		$('#type').val(cmd_type);
		$('#normal_group_user').submit();
	}
}

xue.addfriend ={
	a:'',
	onClick:function(id,o){
		xue.addfriend.a=o;
		var html = '';
		$.getJSON(xue.site+"/cmd?@cmd_type=get_user_verify&id="+id,function(json){
			if(json.err){
				xue.Fun.showMsg(json.msg);
			}else{
				switch(json.date.verify){
					case 1:
						xue.addfriend.sendDate(xue.site+"/cmd?@cmd_type=ajax_g_makefriend&id="+id);
					break;
					case 2:						
						html = [				
							'<div class="commentbox">',
							'<h3><label for="memo">'+json.date.name+'需要验证你的身份</label></h3>',
							'<p><textarea class="textinput" row="10" cols="50" id="memo" name="memo"></textarea></p>',
							'<input type="hidden" id="user_id" value="'+ id +'"  />',
							'<p><input type="button" value="发送验证消息" class="login_button" onclick="xue.addfriend.sendDate(false)" /></p>',		
							'</div>'
						];
						$.facebox(html.join("\n"));
					break;
					case 3:
						html = '<div class="text_box" style="font-size:13px;line-height:1.75em;color:red">'+json.date.name+'不允许别人加他为好友。有点酷，你再想想别的办法吧，加油，不要气馁。</div>';
						$.facebox(html);
					break;
					default:
						$.facebox('此人好像是火星人！');
				}
			}
		});
	},
	sendDate:function(url){
		var cmd='';
		if(url){
			cmd = url;
		}else{
			cmd = xue.site+"/cmd?@cmd_type=ajax_g_makefriend&id="+$('#user_id').val()+"&memo="+escape($('#memo').val());
		}
		$.getJSON(cmd,function(json){
			if(json.err){
				xue.Fun.showMsg(json.msg);
			}else{
				switch(json.msg){
					case '100':
						xue.dialogBox.show('<img src="'+ json.img +'" width="24" height="24" />你成功把'+ json.name +'加为好友',true);
						$(xue.addfriend.a).hide();
					break;
					case '200':
						xue.dialogBox.show('<img src="'+ json.img +'" width="24" height="24" />发送验证成功<br />你需要等待'+ json.name +'的验证',true);
					break;
					case '303':
						xue.dialogBox.show('<img src="'+ json.img +'" width="24" height="24" />你已发送过验证<br />你需要等待'+ json.name +'的验证',true);
					break;	
					default:
						xue.Fun.showMsg('操作失败');
				}				
			}			
			$.facebox.close();
		});
	}
}

xue.Find = {
	MSN:function(o){
		var o=$(o),name=$('#msn_name').val(),psw=$('#msn_psw').val();
		if(name==''||psw==''){$('#err').html('请输入MSN帐号和密码').show()}
		o.attr({disabled:"disabled"});
		$('#x_loading').show();
		$('#err').hide();
		/*
		$.getJSON(xue.cmd_url,{"@cmd_type":"find_user_bymsn","c":$('#code').val(),"name":name,"psw":psw},function(json){
		  	$('#x_loading').hide();
		  	if(json.err){
				alert(json.msg);
				o.removeAttr('disabled');
			}else{
				$('#date').val(json.date);
				$('#send_result').submit();							
			}
		}); 
		*/
		$.ajax({
		  type: "POST",
		  url: xue.cmd_url,
		  dataType: 'json',
		  data: {"@cmd_type":"find_user_bymsn","c":$('#code').val(),"name":name,"psw":psw},
		  beforeSend: function(XMLHttpRequest){
				$('#x_loading').show();
		  },
		  success: function(json, textStatus){
				if(json.err){
					alert(json.msg);
					o.removeAttr('disabled');
				}else{
					$('#date').val(json.date);
					$('#send_result').submit();							
				}
		  },
		  complete: function(XMLHttpRequest, textStatus){
				$('#x_loading').hide();
		  },
		  error:function(){
				alert('获取数据超时！');
				o.removeAttr('disabled');
		  }

});
		
	},
	step_2:function(){
		xue.Fun.ShowHide($('#step_2'),$('#step_1'));
		$('#send_result').submit();	
	}	

}


jQuery.fn.extend({
    set_len_limit : function(limit){
        var s = this.find(':submit');
        var oldv = s.attr('value');
        var check = function(){
            if(this.value && this.value.length > limit){
                s.attr('disabled',1).attr('value','字数不能超过'+limit+'字');
            } else {
                s.attr('disabled',0).attr('value', oldv);
            }
        }
        $('textarea', this).focus(check).blur(check).keydown(check).keyup(check);
    },

    set_caret: function(){
        if(!$.browser.msie) return;
        var initSetCaret = function(){this.p = document.selection.createRange().duplicate()};
        this.click(initSetCaret).select(initSetCaret).keyup(initSetCaret);
    },

    insert_caret:function(t){
        var o = this[0];
        if(document.all && o.createTextRange && o.p){
            var p=o.p;
            p.text = p.text.charAt(p.text.length-1) == '' ? t+'' : t;
        } else if(o.setSelectionRange){
            var s=o.selectionStart;
            var e=o.selectionEnd;
            var t1=o.value.substring(0,s);
            var t2=o.value.substring(e);
            o.value=t1+t+t2;
            o.focus();
            var len=t.length;
            o.setSelectionRange(s+len,s+len);
            o.blur();
        } else {
            o.value+=t;
        }
    },
    
    get_sel:function(){
        var o = this[0];
        return document.all && o.createTextRange && o.p ? 
            o.p.text : o.setSelectionRange ? 
            o.value.substring(o.selectionStart,o.selectionEnd) : '';
    }
})

$(document).ready(function(){
	$('img[@src$=.png]').ifixpng();
	xue.box.init();
	initform();
	xue.menu.init();
	xue.Search.init();
	xue.dealImg.init('#uicon');
	xue.dealHeight();
	xue.ajax.init();
	xue.weather.init();
	xue.Select.init();
	xue.pointBox.init();
	xue.tag.init();
	xue.photo.init();
	xue.photoDetail.init();
	xue.pageload();
}); 

