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

function $pi(str){return parseInt(str);}
var mozilla=(navigator.userAgent.toLowerCase().indexOf("msie")==-1);String.prototype.escapeForXML=function(){return this.replace('&','&amp;').replace('"','&quot;').replace('<','&lt;').replace('>','&gt;');}
String.prototype.escapeForDisplay=function(){return this.replace('<','&lt;');}
String.prototype.len=function(){var data=this.toString();var len=0;for(var i=0;i<data.length;i++){var c=data.charCodeAt(i);if(c>0x80)
len+=2;else
len+=1;}
return len;}
String.prototype.brief=function(length){var len=0;var buf='';for(var i=0;i<this.length;i++){var c=this.charCodeAt(i);if(c>0x80)
len+=2;else
len+=1;if(len<=length)
buf+=this.charAt(i);else
return buf;}
return buf;}
var Photo=Class.create();Photo.prototype={initialize:function(params){this.id=params.id;this.title=params.title;this.description=params.description;this.host=params.host;this.path=params.path;this.filename=params.filename;this.ext=params.ext;this.order=params.order;this.has_saved=params.has_saved;this.album=null;this.icon=params.icon;this.rand=params.rand;},getIcon:function(){if(this.icon!=null&&this.icon!=undefined&&this.icon!='')return this.icon;return this.getUrl('i');},getUrl:function(v){var f=this.filename;if((this.rand!='')&&(this.rand!=undefined)&&(this.rand!=null))
f=f+'_'+this.rand;return this.host+this.path+'/'+f+'_'+v+this.ext;},getMidImg:function(){var f=this.filename;if((this.rand!='')&&(this.rand!=undefined)&&(this.rand!=null))
f=f+'_'+this.rand;return this.host+this.path+'/'+f+this.ext;}};var Album=Class.create();Album.prototype={initialize:function(id,title,description,date,cover,default_cover,cover_photo_id,count,order,album_url){this.id=id;this.title=title;this.description=description;this.date=date;this.cover=cover;this.orignal_cover=default_cover;this.cover_photo_id=cover_photo_id;this.order=order;this.count=count;this.album_url=album_url;this.has_change=false;this.photos=new Array();this.photos_dnd=new Array();},getDefaultCover:function(){return theme_dir+'/images/album_default_cover.jpg';},getIcon:function(){return this.cover;},get_icon:function(){return this.getIcon();},getPhotos:function(){return this.photos;},clearArray:function(o){o.splice(0,o.length);o.length=0;},setPhotos:function(photos){this.photos=photos;this._updateCount();},addPhoto:function(photo){if(this.containsPhoto(photo))
return false;this.photos.push(photo);this._updateCount();return true;},removePhoto:function(photo){if(!this.containsPhoto(photo))
return false;this.photos.removeItem(photo);this._updateCount();return true;},removePhotoById:function(photoId){if(!this.containsPhotoID(photoId))
return false;for(var i=0;i<this.photos.length;i++){if(this.photos[i].id==photoId)
{this.photos.remove(i);this._updateCount();return true;}}
return false;},removePhotoDndById:function(photoId){for(var i=0;i<this.photos_dnd.length;i++){if(this.photos_dnd[i].id==photoId)
{this.photos_dnd.remove(i);return true;}}
return false;},containsPhoto:function(photo){if(!photo)
return false;if(this.photos.contains(photo))
return true;for(var i=0;i<this.photos.length;i++){if(this.photos[i].id==photo.id)
return true;}
return false;},containsPhotoID:function(photoID){if(!photoID)
return false;for(var i=0;i<this.photos.length;i++){if(this.photos[i].id==photoID)
return true;}
return false;},_updateCount:function(){this.count=this.photos.length;}};function parseAlbum(node){var album_id=node.getAttribute('id');var album_title=node.getAttribute('title');var album_description=node.getAttribute('description');var album_icon=node.getAttribute('icon');var album_date=node.getAttribute('date');var album_count=node.getAttribute('count');var album_order=node.getAttribute('order');var album_url=node.getAttribute('album_url');var default_cover=node.getAttribute('default_icon');var cover_photo_id=node.getAttribute('cover_photo_id');var params={id:album_id,title:album_title,description:album_description,date:album_date,cover:album_icon,default_cover:default_cover,cover_photo_id:cover_photo_id,order:album_order,count:album_count,album_url:album_url};var album=new Album(params.id,params.title,params.description,params.date,params.cover,params.default_cover,params.cover_photo_id,params.count,params.order,params.album_url);return album;}
function parseContextPhoto(node){var photo_id=node.getAttribute('id');var photo_title=node.getAttribute('title');var photo_description=node.getAttribute('description');var album_id=node.getAttribute('album_id');var photo_date=node.getAttribute('date');var photo_order=node.getAttribute('order');var photo_filename=node.getAttribute('filename');var photo_host=node.getAttribute('host');var photo_path=node.getAttribute('path');var photo_ext=node.getAttribute('ext');var photo_icon=node.getAttribute('icon');var photo_rand=node.getAttribute('rand');var photo_saved=false;var photo_param={id:photo_id,title:photo_title,description:photo_description,icon:photo_icon,rand:photo_rand,host:photo_host,path:photo_path,filename:photo_filename,ext:photo_ext,order:photo_order,has_saved:photo_saved};var photo=new Photo(photo_param);return photo;}
var ImageStore=Class.create();ImageStore.prototype={initialize:function(){this.images={};},load:function(name,location){if(this.images[name])
return;var image=new Image();image.src=location;this.images[name]=image;},get:function(name){return this.images[name];}};var imageStore=new ImageStore();