// Build 20090624163704@JAMES-NB  Copyright(c) 2006-2008, Walkr.CN http://www.walkr.cn

var AJAXAPI=Class.create();AJAXAPI.prototype={initialize:function(domain,session_id){this.domain=domain;var url='/api/ajax_service/';if(this.domain){url='http://'+this.domain+url;}
this.END_POINT=url;this.session_id=session_id;},_get:function(method,callback,params){var url=this.END_POINT;if((url.indexOf('://')<0)&&(this.domain)){url='http://'+this.domain+url;}
var query=this._queryString(method,params);new Ajax.Request(url,{parameters:query,postBody:null,method:"get",methodName:method,onComplete:callback});},_post:function(method,callback,params,postBody){var url=this.END_POINT;if((url.indexOf('://')<0)&&(this.domain)){url='http://'+this.domain+url;}
var query=this._queryString(method,params);new Ajax.Request(url,{parameters:query,postBody:postBody,method:"post",methodName:method,onComplete:callback});},_queryString:function(method,params){var query='method='+method;if(this.session_id)
query+='&psessionid='+this.session_id;for(var name in params){if(params[name]){var value=params[name]+'';if(value.isInChinese())
value=escape_utf8(value);else
value=escape(value);if(value=='')value=' ';query+='&'+name+'='+value;}}
if(query){query+='&ts='+this._gettime();}
return query;},_gettime:function(){　　　　var s='';　　　　d=new Date();　　　　s+=d.getHours();　　　　s+=d.getMinutes();　　　　s+=d.getSeconds();　　　　s+=d.getMilliseconds();　　　　return s;},walkr_photos_addTags:function(params,callback){this._post('walkr.photos.addTags',callback,params);},walkr_photos_home:function(params,callback){this._post('walkr.photos.home',callback,params);},walkr_photos_batchAddTags:function(params,callback){this._post('walkr.photos.batchAddTags',callback,params);},walkr_photos_deleteTag:function(params,callback){this._get('walkr.photos.deleteTag',callback,params);},walkr_photos_editMeta:function(params,callback){this._post('walkr.photos.editMeta',callback,params);},walkr_photos_batchEditMeta:function(params,callback){this._post('walkr.photos.batchEditMeta',callback,params);},walkr_photos_batchSet:function(params,callback){this._post('walkr.photos.batchSet',callback,params);},walkr_photos_batchSetPos:function(params,callback){this._post('walkr.photos.batchSetPos',callback,params);},walkr_photos_getByDest:function(params,callback){this._post('walkr.photos.getByDest',callback,params);},walkr_photos_getPostDest:function(params,callback){this._post('walkr.photos.getPostDest',callback,params);},walkr_photos_getDetail:function(params,callback){this._post('walkr.photos.getDetail',callback,params);},walkr_photos_deletePhoto:function(params,callback){this._post('walkr.photos.deletePhoto',callback,params);},walkr_photos_deletePhotos:function(params,callback){this._post('walkr.photos.deletePhotos',callback,params);},walkr_photos_createNote:function(params,callback){this._post('walkr.photos.createNote',callback,params);},walkr_photos_editNote:function(params,callback){this._post('walkr.photos.editNote',callback,params);},walkr_photos_deleteNote:function(params,callback){this._post('walkr.photos.deleteNote',callback,params);},walkr_photos_getNotes:function(params,callback){this._post('walkr.photos.getNotes',callback,params);},walkr_photos_albumsByPhotoid:function(params,callback){this._post('walkr.photos.albumsByPhotoid',callback,params);},walkr_photos_sendtoAlbum:function(params,callback){this._post('walkr.photos.sendtoAlbum',callback,params);},walkr_photos_sendtoTrip:function(params,callback){this._post('walkr.photos.sendtoTrip',callback,params);},walkr_photos_AlbumsOrder:function(params,callback){this._post('walkr.photos.AlbumsOrder',callback,params);},walkr_photos_removefromAlbum:function(params,callback){this._post('walkr.photos.removefromAlbum',callback,params);},walkr_photos_rotate:function(params,callback){this._post('walkr.photos.rotate',callback,params);},walkr_photos_getAlbums:function(params,callback){this._get('walkr.photos.getAlbums',callback,params);},walkr_photos_editAlbumMeta:function(params,callback){this._post('walkr.photos.editAlbumMeta',callback,params);},walkr_photos_byAlbum:function(params,callback){this._get('walkr.photos.byAlbum',callback,params);},walkr_photos_deleteAlbum:function(params,callback){this._get('walkr.photos.deleteAlbum',callback,params);},walkr_photos_addtobookmark:function(params,callback){this._post('walkr.photos.addtobookmark',callback,params);},walkr_photos_getContext:function(params,callback){this._post('walkr.photos.getContext',callback,params);},walkr_photos_myPhotos:function(params,callback){this._post('walkr.photos.myPhotos',callback,params);},walkr_photos_exchange_wh:function(params,callback){this._post('walkr.photos.exchange.wh',callback,params);},walkr_photos_saveUploadPhotos:function(params,callback){this._post('walkr.photos.saveUploadPhotos',callback,params);},walkr_comments_previewComment:function(params,callback){this._post('walkr.comments.preview',callback,params);},walkr_comments_deleteComment:function(params,callback){this._get('walkr.comments.deleteComment',callback,params);},walkr_comments_editComment:function(params,callback){this._post('walkr.comments.editComment',callback,params);},walkr_comments_addComment:function(params,callback){this._post('walkr.comments.addComment',callback,params);},walkr_digg_save:function(params,callback){this._get('walkr.digg.save',callback,params);},walkr_user_checkEmailValid:function(params,callback){this._get('walkr.user.checkEmailValid',callback,params);},walkr_user_sendConfirmMail:function(params,callback){this._get('walkr.user.sendConfirmMail',callback,params);},walkr_user_sendChangeEmailConfirmMail:function(params,callback){this._get('walkr.user.sendChangeEmailConfirmMail',callback,params);},walkr_dest_getAreaByLevel:function(params,callback){this._post('walkr.destination.getbylevel',callback,params);},walkr_dest_getDestination:function(params,callback){this._post('walkr.destination.get',callback,params);},walkr_dest_addDestination:function(params,callback){this._post('walkr.destination.add',callback,params);},walkr_dest_track:function(params,callback){this._post('walkr.destination.track',callback,params);},walkr_map_getMapDests:function(params,callback){this._post('walkr.map.getMapDests',callback,params);},walkr_map_searchPhotos:function(params,callback){this._post('walkr.map.searchPhotos',callback,params);},walkr_map_getMapDestDetail:function(params,callback){this._post('walkr.map.getMapDestDetail',callback,params);},walkr_map_getMapPhotos:function(params,callback){this._post('walkr.map.getMapPhotos',callback,params);},walkr_map_mapNavDests:function(callback){this._post('walkr.map.navDests',callback,{});},walkr_trip_myDests:function(params,callback){this._post('walkr.trip.myDests',callback,params);},walkr_trip_changepublic:function(params,callback){this._post('walkr.trip.changepublic',callback,params);},walkr_trip_editSchedule:function(params,callback){this._post('walkr.trip.editSchedule',callback,params);},walkr_trip_deleteSchedule:function(params,callback){this._post('walkr.trip.deleteSchedule',callback,params);},walkr_trip_removePhoto:function(params,callback){this._post('walkr.trip.removePhoto',callback,params);},walkr_trip_getPhotos:function(params,callback){this._post('walkr.trip.getPhotos',callback,params);},diggit:function(digg_type,item_id,callback){this._get('user.digg',callback,{digg_type:digg_type,item_id:item_id});},getUserMessage:function(callback){this._get('user.get.message',callback,{});},checkout_wiki_ifcan:function(params,callback){this._get('wiki.can_checkout_paragraph',callback,params);},checkout_wiki_update:function(params,callback){this._get('wiki.checkout_update',callback,params);},checkin_wiki_update:function(params,callback){this._get('wiki.checkin_update',callback,params);},saveWikiContent:function(dest_id,head_id,user_id,head_title,content,callback){this._post('wiki.saveWikiContent',callback,{dest_id:dest_id,head_id:head_id,user_id:user_id,head_title:head_title,content:content});},getUserTags:function(params,callback){this._get('user.gettags',callback,params);},getUserDests:function(params,callback){this._get('user.getdests',callback,params);},getUserAlbums:function(callback){this._get('albums.getbyUser',callback,{});},getAlbumPhotos:function(album_id,callback){this._get('albums.getAlbumPhotos',callback,{album_id:album_id});},get_photos:function(params,callback){this._get('albums.getPhotos',callback,params);},get_photos_by_dests:function(params,callback){this._get('getPhotos.bydests',callback,params);},get_photos_by_trip:function(params,callback){this._get('getPhotos.bytrip',callback,params);},changeTripIcon:function(params,callback){this._get('trip.change_icon',callback,params);},get_albums:function(user_id,callback){this._get('albums.getAlbums',callback,{user_id:user_id});},get_single_album:function(album_id,callback){this._get('albums.getSingleAlbum',callback,{album_id:album_id});},editAlbumMeta:function(album_id,title,description,callback){this._post('albums.editMeta',callback,{album_id:album_id,album_title:title,album_description:description});},editAlbum:function(album_id,photos_count,album_cover,album_photos,callback){this._post('albums.edit',callback,{album_id:album_id,photos_count:photos_count,album_cover:album_cover,album_photos:album_photos});},deleteAlbum:function(album_id,callback){this._post('albums.delete',callback,{album_id:album_id});},editAlbumOrder:function(albumIds,callback){this._post('albums.order',callback,{albums:albumIds});},editPhotoMeta:function(photo_id,title,description,callback){this._post('photos.editMeta',callback,{photo_id:photo_id,photo_title:title,photo_description:description});},addPhotosToTrip:function(params,callback){this._post('trip.addphotos',callback,params);},getDestItems:function(params,callback){this._post('travelmate.destitem.get',callback,params);},editTravelMateItemMeta:function(value_type,item_id,item_value,callback){this._post('travelmate.editItemMeta',callback,{value_type:value_type,item_id:item_id,item_value:item_value});},addTravelMateDestItem:function(params,callback){this._post('travelmate.destitem.add',callback,params);},addDestItemToSchedle:function(params,callback){this._post('travelmate.destitem.addtoschedule',callback,params);},deleteTravelMateDestItem:function(schedule_id,item_id,callback){this._post('travelmate.destitem.delfromschedule',callback,{schedule_id:schedule_id,item_id:item_id});},addTravelMateSchedule:function(topic_id,start_dt,end_dt,selected_dest_ids,callback){this._post('travelmate.addSchedule',callback,{topic_id:topic_id,start_dt:start_dt,end_dt:end_dt,selected_dest_ids:selected_dest_ids});},editTravelMateSchedule:function(topic_id,dt_id,start_dt,end_dt,selected_dest_ids,callback){this._post('travelmate.editSchedule',callback,{topic_id:topic_id,dt_id:dt_id,start_dt:start_dt,end_dt:end_dt,selected_dest_ids:selected_dest_ids});},deleteTravelMateSchedule:function(topic_id,dt_id,callback){this._post('travelmate.deleteSchedule',callback,{topic_id:topic_id,dt_id:dt_id});},editTravelMateNote:function(params,callback){this._post('travelmate.notes.edit',callback,params);},getTravelMateNotes:function(callback){this._get('travelmate.notes.get',callback);},getPhoto:function(photo_id,callback){this._post('photos.getPhoto',callback,{photo_id:photo_id});},getDestination:function(keywords,callback){this._post('destination.get',callback,{keywords:keywords});},addDestination:function(dest_name,parent_id,callback){this._post('destination.add',callback,{dest_name:dest_name,parent_id:parent_id});},wishDestination:function(params,callback){this._post('destination.wishgo',callback,params);},goneDestination:function(params,callback){this._post('destination.gone',callback,params);},getAreaByLevel:function(level,keywords,callback){this._post('destination.getbylevel',callback,{level:level,keywords:keywords});},sendConfirmMail:function(user_id,callback){this._post('mail.send.confirmcode',callback,{user_id:user_id});},sendBatchMail:function(params,callback){this._post('mail.send.normal',callback,params);},cancelBatchMail:function(batch_id,callback){this._post('mail.send.normalcancel',callback,{batch_id:batch_id});},checkEmailValid:function(email,callback){this._post('auth.email.valid',callback,{email:email});},changeNewEmail:function(old_email,new_email,old_pwd,callback){this._post('auth.email.change',callback,{old_email:old_email,new_email:new_email,old_pwd:old_pwd});},getMapLocation:function(params,callback){this._post('destination.map.get',callback,params);},getPhotoMapLocation:function(params,callback){this._post('destination.photomap.get',callback,params);},getPhotoGlobalMapLocation:function(params,callback){this._post('destination.photoglobalmap.get',callback,params);},getPhotoCAMapLocation:function(params,callback){this._post('destination.photo_ca_map.get',callback,params);},getDestinationMyGone:function(params,callback){this._post('destination.my_gone',callback,params);},getDestinationMyGoneGlobal:function(params,callback){this._post('destination.my_gone_global',callback,params);},getDestinationMyGoneCA:function(params,callback){this._post('destination.my_gone_ca',callback,params);},getHotIndexChina:function(callback){this._post('hot.index.china',callback);},getHotIndexGlobal:function(callback){this._post('hot.index.global',callback);},createPhotoNote:function(params,callback){this._post('photos.notes.add',callback,params);},deletePhotoNote:function(note_id,callback){this._post('photos.notes.delete',callback,{note_id:note_id});},editPhotoNote:function(params,callback){this._post('photos.notes.edit',callback,params);},getPhotoNotes:function(photo_id,callback){this._get('photos.notes.get',callback,{photo_id:photo_id});},photoRotate:function(photo_id,angle,callback){this._get('photos.rotate',callback,{photo_id:photo_id,angle:angle});},getPhotoContext:function(photo_id,option,callback){this._get('photos.getContext',callback,{photo_id:photo_id,option:option});},getAlbumPhotoContext:function(album_id,photo_id,option,callback){this._get('photos.getAlbumContext',callback,{album_id:album_id,photo_id:photo_id,option:option});},photoNewTags:function(photo_id,tags,callback){this._get('photos.newtags',callback,{photo_id:photo_id,tags:tags});},getGlobalImg:function(group_id,topic_id,callback){this._get('group.globalimg.get',callback,{group_id:group_id,topic_id:topic_id});},thumbnailGlobalImg:function(img_url,img_title,group_id,callback){this._get('group.globalimg.thumbnail',callback,{img_url:img_url,img_title:img_title,group_id:group_id});},thumbnailForumImg:function(img_url,img_title,group_id,callback){this._get('wikiforum.globalimg.thumbnail',callback,{img_url:img_url,img_title:img_title,group_id:group_id});},saveUploadPhotos:function(user_id,sid,str_xml,callback){this._post('albums.saveUploadPhotos',callback,{user_id:user_id,sid:sid,str_xml:str_xml});},editBookmarkItem:function(params,callback){this._post('bookmark.editBookmarkItem',callback,params);},getMyFriends:function(user_id,callback){this._post('home.getMyFriends',callback,{user_id:user_id});},blogAutoSave:function(params,callback){this._post('blog.autosave',callback,params);},get_dest_articles:function(params,callback){this._post('destination.getArticles',callback,params);},get_dest_photos:function(params,callback){this._post('destination.getPhotos',callback,params);},photo_rotate_right:function(params,callback){this._post('photo.rotate.right',callback,params);},photo_rotate_left:function(params,callback){this._post('photo.rotate.left',callback,params);},photo_exchange_wh:function(photo_id,callback){this._post('photo.exchange.wh',callback,{photo_id:photo_id});},editBlogTopic:function(topic_id,title,callback){this._post('blog.editTopic',callback,{topic_id:topic_id,topic_title:title});},toggleBlogEntryHidden:function(entry_id,is_hidden,callback){this._post('blog.toggleBlogEntryHidden',callback,{'entry_id':entry_id,'is_hidden':is_hidden});},toggleBlogCommentValidate:function(comment_id,is_validate,callback){this._post('blog.toggleBlogCommentValidate',callback,{'comment_id':comment_id,'is_validate':is_validate});},editBlogCategory:function(category_id,category_name,callback){this._post('blog.editCategory',callback,{category_id:category_id,category_name:category_name});},searchPhotos:function(params,callback){this._post('map.searchPhotos',callback,params);},getMapDests:function(params,callback){this._post('map.getMapDests',callback,params);},getMapDestDetail:function(params,callback){this._post('map.getMapDestDetail',callback,params);},mapNavDests:function(callback){this._post('map.navDests',callback,{});},getMapPhotos:function(params,callback){this._post('map.getMapPhotos',callback,params);}};String.prototype.isInChinese=function(){return(this.length!=this.replace(/[^\x00-\xff]/g,"**").length);}