$.extend({
    AjPost:function(module_name,data,callback){
        var args=module_name.split('_'),
            module=args[1]+'-'+args[2];
        return $.post('index.php?_do='+module+'&r='+Math.random(),data,function(rdata){
            // eval('var m='+rdata);
             eval('callback(rdata)');
        })
    },
    AjGet:function(module_name,data,callback){
        var args=module_name.split('_');
            module=args[1]+'-'+args[2];
        return $.post('index.php?_do='+module+'&r='+Math.random(),data,function(rdata){
            // eval('var m='+rdata);
             eval('callback(rdata)');
        })
    }
});
(function(){
    ST.LANG={
        'tips':'提示',
        'faces':'表情',
        'confirm':'确认',
        'error':'错误',
        'success':'操作成功',
        'confirm_del':'确定要删除此心情吗?!',
        'success_del':'删除成功!',
        'edit_album':'修改相册信息',
        'err_no_aid':'对不起没有找到此相册信息!',
        'err_save_album':'保存相册信息失败,请重试!',
        'photo_set_cover_success':'设置相册封面成功!',
        'photo_set_cover':'设为封面',
        'photo_del':'确定要删除此照片吗?',
        'photo_delete_batch':'确定要删除所选择的照片吗?',
        'photo_del_success':'照片已经删除成功!',
        'photo_del_failed':'照片删除失败,请重试!',
        'photo_no_select':'您还没有选择照片,请先选择照片!',
        'photo_no_password':'相册密码不能为空',
        'photo_set_cover':'设为封面',
        'photo_cancle_cover':'取消封面',
        'photo_move_confirm':'确定要将所选照片移动到',
        'photo_album_not_exists':'对不起,相册不存在!',
        'batch_edit':'批量编辑',
        'batch_move':'批量移动',
        'batch_delete':'批量删除',
        'gift_no_user':'请先选择接受礼物的好友!',
        'gift_no_gift':'请先选择发送的礼物!',
        'diary_no_args':'参数错误,请刷新页面重试!',
        'diary_err_len':'留言内容长度不能小于5个汉字!',
        'diary_manage_category':'管理日记分类',
        'birth_error':'生日错误：',
        'birth_select_year':'请选择正确的年份!',
        'birth_select_month':'请选择正确的月份!',
        'birth_select_day':'请选择正确的日!',
        'move_no_select':'您还没有选择动作',
        'move_take':'打招呼',
        'cover':'设置头图',
        'cover_confirm':'确定要恢复默认头图吗?！',
        'user_name_no_empty':'用户姓名不能为空',
        'user_name_len_error':'姓名长度为4~12个字符',
        'user_email_no_empty':'用户邮箱不能为空',
        'mood_len_out':'心情最多40个字哦.'
    }
    ST.SPACE={
        UI:{
            
        },
        check:function(em,word,maxwords,F){
              var cnt, timeid=setInterval(function(){
                        cnt=em.val(),
                        len=cnt.length,
                        currnum=maxwords-len;
                        if(currnum<0){
                            F&&F(len);
                            currnum=0
                        }
                        word.html(currnum);
                });
                $(em).blur(function(){window.clearTimeout(timeid)})
        },
        
        Gift:{
            init:(function(){
                $('.gift_listwo a').click(function(){
                    $('.gift_listwo a').removeClass('gt_hover')
                    $(this).addClass('gt_hover')
                });
                //ST.MySpace.index.bindTab($('div[node-type="gift_tab"] a'),$('div[node-type="gift_cnt"]'))
            })(),
            send:function(){
                var arruid=new Array(),
                    gid=0;
                gid=parseInt($('.gt_hover').attr('id'));
                $('.select-name a').each(function(i){
                    arruid.push($(this).attr('uid'));
                });
                if(arruid.length==0){
                    ST.UI.showMessage(ST.LANG['error'],ST.LANG['gift_no_user']);
                    return false;
                }
                if(gid==0){
                    ST.UI.showMessage(ST.LANG['error'],ST.LANG['gift_no_gift']);
                    return false;
                }
                arruid=arruid.join(',');
                $.AjPost('blog_gift_sendGift',{'r_uid':arruid,'gift_id':gid},function(rdata){
                    eval('var rdata='+rdata+';');
                    ST.UI.showMessage(ST.LANG['tips'],rdata['msg']);
                    $('.select-name').html('')
                })
            },
            greet:function(){//打招呼 
                e=ST.Base.getEvent();       	
                target=e.target || e.srcElement;
                uid=$(target).attr('uid');
                if(!ST.Base.checkLogin())
                    return false;
                var html;
                ST.UI.ModeWindow({'ID':'SEND_MOVE','width':450,'TitleText':ST.LANG['move_take'],'submitcall':function(){
                    var moveid=$("input[name='move_id']:checked").val();
                    var remarks=$('#move_txt').val();
                    if(moveid==undefined){
                        ST.UI.showMessage(ST.LANG['error'],ST.move_take['move_no_select']);
                        return false;
                    }
                    $.AjPost('blog_move_actionSendMove',{'friendids':uid,'moveid':moveid,'remarks':remarks},function(rdata){
                        eval('var rdata='+rdata+';')
                        ST.UI.showMessage(ST.LANG['tips'],rdata);
                    })
                }}).setContent(ST.UI.loading()).load('index.php?_do=move');
            },
            sendGift:function(){
                e=ST.Base.getEvent();
                target=e.target || e.srcElement;
                uid=$(target).attr('uid');
                if(!ST.Base.checkLogin())
                    return false;
                ST.UI.ModeWindow({'ID':'SEND_GIFT','width':400,'TitleText':'送礼物','submitcall':function(){
                    var giftid=$("input[name='gift_radio']:checked").val(),
                        remark=$('#gift-remark').val()
                    if(giftid==undefined){
                        ST.UI.showMessage(ST.LANG['error'],'请选择要发送的礼物礼物');
                        return false;
                    }
                    $.AjPost('blog_gift_sendGift',{'r_uid':uid,'gift_id':giftid,'remark':remark},function(rdata){
                        eval('var rdata='+rdata+';');
                        ST.UI.showMessage(ST.LANG['tips'],rdata['msg']);
                    })
                }}).setContent(ST.UI.loading()).load('index.php?_do=gift-ajGetGift')
            },
            mkPage:function(num){
                $('#content_ui_SEND_GIFT').load('index.php?_do=gift-ajGetGift&page='+num)
            }
        }, 
        SetInfo:{
            init:(function(){
              ST.MySpace.index.bindTab($('div[node-type="setting_tab"] a'),$('.setting_controller'))  
            })(),
            setDefaultCover:function(){
                var defcover='space/teacher/images/imgteacher/gtitle01.jpg';
                ST.UI.ModeWindow({'ID':'SET_COVER_DEFAULT','TitleText':ST.LANG['cover'],'submitcall':function(){
                    $.AjPost('blog_my_ajsetDefCover',null,function(rdata){
                        $('img[node-type="face-cover"]').each(function(){
                            $(this).attr('src',publicurl+defcover);
                        });
                        
                    })
                    window.location='/?_do=my-disguiseRoom'
                }}).setContent(ST.LANG['cover_confirm'])
            },
            save:function(){
                    var provinceid =  $("#province").val(),
                	 cityid = $("#city").val(),
                	 countryid = $("#country").val(),
                     usercity = '('+provinceid+')'+','+'('+cityid+')'+','+'('+countryid+')',
                     domain=$('#domain').val(),
                    // 姓名
                     name=$("#name").val(),
                     sex=$(":input[name='sex']:checked").val(),
                     b_year = $("#b_year").val(),
                	 b_month = $("#b_month").val(),
                	 b_day = $("#b_day").val(),
                     qq=$('#qq').val(),
                     msn=$('#msn').val(),
                     mobile=$('#mobile').val();
                	
                	if ( parseInt(b_year,10) == 0  )
                	{
                		ST.UI.showMessage(ST.LANG['error'],ST.LANG['birth_error']+ST.LANG['birth_select_year']);
                		return false ;
                	}
                	if ( parseInt(b_month,10) == 0  )
                	{
                		ST.UI.showMessage(ST.LANG['error'],ST.LANG['birth_error']+ST.LANG['birth_select_month']);
                		return false ;
                	}
                	if ( parseInt(b_day,10) == 0  )
                	{
                		ST.UI.showMessage(ST.LANG['error'],ST.LANG['birth_error']+ST.LANG['birth_select_day']);
                		return false ;
                	}
                	
                    var birthday = b_year+'-'+b_month+'-'+b_day ;
                    
                    // 星座
                 //   var constellation=$("#constellation").val();
                    // 血型
                   // var blood=$(":input[name='blood_type']:checked").val();
                    // 地区
                
                    // 当前身份
                   // var current=$(":input[name='current_status']:checked").val();
                    //主题
                    var theme=$("input[name='theme']:checked").val();
                    // 邮箱
                    //var email=$("#email").val();
                    // 简介
                    var intro=$("#intro").val();
                    if(name==""){
                        ST.UI.showMessage(ST.LANG['error'],ST.LANG['user_name_no_empty']);
                        $("#name").focus() ;
                        return false;
                    }
                    var len = name.length;
                
                	if( len<2||len>12 ){
                         ST.UI.showMessage(ST.LANG['error'],ST.LANG['user_name_len_error']);
                        $("#name").focus() ;
                        return false;
                	}
                    $.AjPost('blog_my_actionEditUser',{'name':name,'domain':domain,'gender':sex,'birthday':birthday,'intro':intro,'city_id':usercity,'qq':qq,'msn':msn,'mobile':mobile},function(rdata){
                        eval('var r='+rdata+';');
                        if(r['err']){
                            ST.UI.showMessage(ST.LANG['error'],r['msg']);
                            return false;
                        }else{
                            ST.UI.showMessage(ST.LANG['success'],r['msg']);
                        }
                    })
                   // $.post('?_do=my-actonEditUser',{'name':name,'domain':domain,'gender':sex,'birthday':birthday,'blood_type':blood,'intro':intro,'city_id':usercity},function(data){
//                    	eval('var r='+data+';');
//                        if(r['err']){
//                            ST.UI.showMessage(ST.LANG['error'],r['msg']);
//                            return false;
//                        }else{
//                            ST.UI.showMessage(ST.LANG['success'],r['msg']);
//                        }  
//                    },'JSON')
                 //})
            } , 
            saveTheme : function(){
            	var  theme =$(":input[name='theme']:checked").val(); 
            	  $.ajax({
            	      type:'POST',
            	      url:'?_do=my-actionUserModel&ajax=1',
            	      data:'themes='+theme,
            	      success:function (data) {
            		  
            	            eval('var r='+data+';');
            	            if(r['err'])
            	            {
            	            	ST.UI.showMessage(ST.LANG['tips'],'模板没有修改',2000);
            	            }else
            	            {
	        	            	 ST.UI.ModeWindow({'ID':'EDIT_ALBUM','width':200,'button':'submit','TitleText':ST.LANG['success'],'submitcall':function(){
	        	            		 window.location.href='/?_do=my-index-uid-'+r['uid']+'.shtml';            
	        	                   }}).setContent(ST.Lang['success']);
            	            }
            	      }
            	  });
            }
        }  ,
        
        School:{
          init:(function(){
                ST.MySpace.index.bindTab($('div[node-type="school_tab"] a'),$('.class_list'))
          })() 
        },
        Photo:{
          init:(function(){
                $('a[node-type="edit_album"]').click(function(){
                    var aid=$(this).attr('aid');
                    if(!aid){
                        ST.UI.showMessage(ST.LANG['error'],ST.LANG['err_no_aid']);
                        return;
                    }
                    ST.UI.ModeWindow({'ID':'EDIT_ALBUM','width':460,'TitleText':ST.LANG['edit_album'],'submitcall':function(){
                        var albumname=$('#album_name').val(),
                            albumdesc=$('#album_desc').val(),
                            priv=$('input[name="Permission"]:checked').attr('id'),
                            pwd=$('#pwd_input').val()
                        if(priv=='P'){
                            if(pwd==''){
                                ST.UI.showMessage(ST.LANG['error'],ST.LANG['photo_no_password']);
                                return false;
                            }
                        }
                        $.AjPost('blog_photo_editalbum',{'albumid':aid,'albumname':albumname,'albumdesc':albumdesc,'priv':priv,'pwd':pwd},function(rdata){
                            eval('var rdata='+rdata+';');
                            if(rdata['err']){
                                $('#album_name_'+aid).html(albumname);
                                $('#album_desc_'+aid).html(albumdesc);
                            }else
                                ST.UI.showMessage(ST.LANG['error'],ST.LANG['err_save_album']);
                            
                        })
                    }}).load('?_do=photo-editalbum-albumid-'+aid);
                })
          })(),
          selectAll:function(){
                $('input[name="batch-photo"]').each(function(){
                    $(this).attr('checked',$('input[name="checkall"]').attr('checked'));
                })
          },
          setCover:function () {    
                var e=ST.Base.getEvent(),
                    target=e.target||e.srcElement,
                    parent=$(target).parents('span'),
                    aid=$(parent).attr('aid'),
                    pid=$(parent).attr('pid');
                $.AjPost('blog_photo_setAlbumFace',{'albumid':aid,'photoid':pid},function(rdata){
                    ST.UI.showMessage(ST.LANG['tips'],ST.LANG['photo_set_cover_success']);
                    $('a[node-type="set_cover"]').html(ST.LANG['photo_set_cover'])
                    var src=$('#cover_photo_'+pid).attr('src');
                    $('#set_cover_photo').attr('src',src);
                    //type?$(parent).html(calbtn):$(parent).html(setbtn);
                })
          },

          batchManage:function(type){
                var batchs=[],name=[],desc=[];
                var batchEdit=function(){
                    batchs.join(',');
                    ST.UI.ModeWindow({'ID':'BATCH_EDIT','top':100,'width':460,'TitleText':ST.LANG['batch_edit'],'submitcall':function()                   {
                        $('input[name="album_name"]').each(function(i){
                            name.push($(this).val());
                            desc.push($($('textarea[name="album_desc"]')[i]).val());
                        })
                        name.join(',');
                        desc.join(',');
                        $.AjPost('blog_photo_modPhotoDesc',{'photoid':$.toJSON(batchs),'photoTitle':$.toJSON(name),'photoDesc':$.toJSON(desc)},function(rdata){
                            for(var a=0;a<batchs.length;a++){
                                $('span[node-type="mod_desc_'+batchs[a]+'"]').html(desc[a].substr(0,10))
                                $('span[node-type="mod_name_'+batchs[a]+'"]').html(name[a].substr(0,10))
                            }
                        })
                    }}).load('?_do=photo-batcheditphoto-photoid-'+batchs+'&r='+Math.random())
                }
                var batchDelete=function(){
                    ST.UI.ModeWindow({'ID':'BATCH_DELETE','TitleText':ST.LANG['confirm'],'submitcall':function()                   {
                        $.AjPost('blog_photo_delPhoto',{'photoid':batchs},function(rdata){
                            eval('var rdata='+rdata+';');
                            if(rdata['succ']==1){
                                for(var i=0;i<batchs.length;i++)
                                    $('#photo_detail_'+batchs[i]).remove();
                                ST.UI.showMessage(ST.LANG['tips'],ST.LANG['photo_del_success'])
                            }else{
                                ST.UI.showMessage(ST.LANG['tips'],ST.LANG['photo_del_failed'])
                            }
                        })
                    }}).setContent(ST.LANG['photo_delete_batch'])
                }
                var batchMove=function(){
                    var ul=$('<ul>');
                    $.AjPost('blog_photo_getAlbumXML',null,function(rdata){
                        var nodes=rdata.documentElement.childNodes;
                        for(var i=0;i<nodes.length;i++){
                            var a=$('<a>').addClass('f14').attr('aid',nodes[i].getAttribute('aid')).attr('href','javascript:;').attr('title',nodes[i].firstChild.nodeValue).html(nodes[i].firstChild.nodeValue.substr(0,8)).unbind().bind('click',function(e){
                                ST.SPACE.Photo.movePhoto(e,batchs)
                            })
                            ul.addClass('pt_move mart10').append($('<li>').css('height',20).html(a))
                        }
                    })
                   var  e=ST.Base.getEvent(),
                        target=e.target||e.srcElement,
                        w=null,
                        newa=$('<a>').attr('href','javascript:;').bind('click',function(){
                            w.close();
                            ST.Photo.createPhotos();
                        }).html('新建相册');
                    w=ST.UI.StaticWindow({'ID':'MOVE_WINDOW','width':160,'button':'','buttonCssRep':{'text-align':'center'},'buttonText':newa,'TitleText':ST.LANG['batch_move'],'height':180,'top':$(target).position().top+22,'left':$(target).position().left,'submitcall':function(rdata){
                        
                    }})
                    var a=$('<a>').attr('href','javascript:;').html('移动').addClass('move_btn').click(function(){
                        w.close()
                    });
                    w.setContent($('<div>').addClass('marl10 c01 fb f14 mart05').append(a).append($('<div>').css({'overflow-y':'auto','height':130}).addClass('marl10 ').append(ul)))
                }
                var batchSelect=function(){
                    $('input[name="batch-photo"]:checked').each(function(){
                            batchs.push($(this).val())
                    })
                    if(batchs.length==0){
                        ST.UI.showMessage(ST.LANG['error'],ST.LANG['photo_no_select'])
                        return;
                    }
                     switch(type){
                        case 'edit':
                            batchEdit();
                        break;
                        case 'delete':
                            batchDelete();
                        break;
                        case 'move':
                            batchMove();
                        break;
                     }
                }()
                
                
          },
          movePhoto:function(){
            var target=arguments[0].target||arguments[0].srcElement,
            aid=target.getAttributeNode('aid').nodeValue,
            txt=target.firstChild.nodeValue,
            args=arguments[1],
            batchs=$.toJSON(args);
            ST.UI.ModeWindow({'ID':'MOVE_WINDOW','TitleText':ST.LANG['confirm'],'submitcall':function(){
                $.AjPost('blog_photo_movePhotoToalbum',{'aid':aid,'batchid':batchs},function(rdata){
                    if(rdata=='no_album'){
                        ST.UI.showMessage(ST.LANG['error'],ST.LANG['photo_album_not_exists']);
                        return false;
                    }else if(rdata=='ok'){
                        for(var i=0;i<args.length;i++){
                            $('#photo_detail_'+args[i]).remove();
                        }
                    }
                })
            }}).setContent(ST.LANG['photo_move_confirm']+txt+'?');
          },
          delPhotos:function(photoid){
                ST.UI.ModeWindow({'ID':'DEL_PHOTOS','TitleText':ST.LANG['confirm'],'submitcall':function(){
                    $.AjPost('blog_photo_delPhoto',{'photoid':photoid},function(rdata){
                        $('#photo_detail_'+photoid).remove();
                        ST.UI.showMessage(ST.LANG['tips'],ST.LANG['photo_del_success'])
                    })
                }}).setContent(ST.LANG['photo_del'])
          },
          selPriv:function(id){
                if(id==2){
                    $('#priv_2').show();
                }else
                    $('#priv_2').hide()
          },
          checkName:function(id){
                var btn=$('#album_name_'+id),
                    nameword=$('#name_word_'+id);
                ST.SPACE.check(btn,nameword,10);
          },
          checkDesc:function(id){
                var btn=$('#album_desc_'+id),
                    descword=$('#desc_word_'+id);
                ST.SPACE.check(btn,descword,16,function(n){
                    $('#desc_tips_'+id).show().html('您已经输入'+n+'个字,最多输入200字')
                });
          },
          checkPwd:function(){
                ST.SPACE.check($('#pwd_input'),$('#pwd_word'),20);
          }
        },
        Diary:{
          init:(function(){
                ST.MySpace.index.bindTab($('ul[node-type="article_tab"] a'),null,'click','hover',function(e){
                    e=e||window.event;
                    target=e.target;
                    act=$(target).attr('act');
                    act=act||'';
                    $('div[node-type="list"]').html(ST.UI.loading());
                    $.AjPost('blog_diary_ajDiarylist&gid='+gid+'&act='+act,null,function(rdata){
                        $('div[node-type="list"]').html(rdata)
                    })
                });
                $('a[node-type="init"]').trigger('click');
          })(), 
          setcategory:function(){
            var args=new Object(),txt,input,o,ntxt,p,c;
            ST.UI.ModeWindow({'ID':'SetFriendGroup','width':360,'TitleText':ST.LANG['diary_manage_category'],'submitcall':function(){
                savegroup();
            },'cancelcall':function(){
                if(args.edit.ength>0 || args['del'].length>0){
                    ST.UI.ModeWindow({'ID':'SHOW_MSG','TitleText':'警告','submitcall':function(){
                        savegroup();
                    }}).setContent('您的操作还没有保存,是否保存数据?');
                }
            }}).setContent(ST.UI.loading()).load('?_do=diary-actionShowDgroup',function(){
                args['del']=[];
                args.edit=new Object();
                $('.del_group').bind('click',function(){
                    p=$(this).parents('li');
                    id=p.attr('id')
                    delete args.edit[id];
                    args['del'].push(p.attr('id'));
                    p.remove();
                })
                $('.set_group li').bind('dblclick',function(){//双击编辑
                    o=$(this);
                    if(o.find('input').length>0)
                        return;
                    c=o.children('#title');
                    txt=c.html();
                    id=o.attr('id')
                    input=$('<input>').val(txt).attr('id',id).addClass('border1 w90').bind('blur',function(){
                        ntxt=$(this).val()
                        c.html(ntxt);
                        if(ntxt!=txt)
                            args.edit[id]=ntxt;
                    });
                    c.html(input)
                    input.focus()
                })
            });
            function savegroup(){
                ST.UI.showMessage('提示','正在保存数据...');
                var del=args['del'].join(','),
                    edit=$.toJSON(args.edit);
                ST.UI.ModeWindow({'ID':'Sure_Dialog','TitleText':'确认?','submitcall':function(){
                    $.AjPost('blog_diary_batchDelCategory',{'edit':edit,'del':del},function(rdata){
                        if(rdata=='ok'){
                            for(var i=0;i<args['del'].length;i++){
                                $('.category-'+args['del'][i]).remove()
                            }
                            for(var val in args.edit){
                                $('.category-'+val).attr('title',args.edit[val]).html(args.edit[val]);
                            }
                            if($('.navgroup span').length<5){
                                $('.relattve').hide()
                            }
                            ST.UI.showMessage('提示','操作成功',2000);
                        }  
                    })
                }}).setContent('确认此操作?')
            }
          },
          cancle:function(){
            $('#content').val('');
          },
          send:function(){
            var e=ST.Base.getEvent(),
                target=e.target||e.srcElement,
                did=$(target).attr('did'),
                aid=11,
                auid=$(target).attr('auid'),
                cnt=$('#content').val();
            //if(!did){
//                ST.UI.showMessage(ST.LANG['error'],ST.LANG['diary_no_args']);
//                return false;
//            }
            if(cnt.length<3){
                ST.UI.showMessage(ST.LANG['error'],ST.LANG['diary_err_len']);
                return false;
            }
            $.AjPost('blog_comment_actionReply',{'tid':did,'a_uid':auid,'aid':aid,'comment':cnt},function(rdata){
                eval('var rdata='+rdata)
                $.AjPost('blog_comment_actionGetCommentInfo',{'id':rdata,'uid':0},function(rdata){
                   $('#reply_comment').prepend(rdata) ;
                   $('#content').val('');
                })
            })
           
          },
          page:function(a,o){
                $('div[node-type="list"]').html(ST.UI.loading());
                url=$(o).attr('url');
                $('div[node-type="list"]').load(url)
          } 
        },
        Comment:{
            a:'',
            send:function(){
                var e=ST.Base.getEvent(),
                    target=e.target,
                    parent=$(target).parents('a'),
                    did=$(parent).attr('did'),
                    aid=1,
                    auid=$(parent).attr('auid'),
                    cnt=$('#content').val();
                    if(this.a==cnt){
                        alert(3);
                        return;
                    }
                //if(!did){
    //                ST.UI.showMessage(ST.LANG['error'],ST.LANG['diary_no_args']);
    //                return false;
    //            }
                if(cnt.length<5){
                    ST.UI.showMessage(ST.LANG['error'],ST.LANG['diary_err_len']);
                    return false;
                }
                $.AjPost('blog_comment_actionReply',{'tid':did,'a_uid':auid,'aid':aid,'comment':cnt},function(rdata){
                    eval('var rdata='+rdata)
                    $.AjPost('blog_comment_actionGetCommentInfo',{'id':rdata,'uid':0},function(rdata){
                        $('#content').val('')
                        $('#reply_comment').prepend(rdata)
                        this.a=cnt;
                    })
                })
            }   
        },
        Friend:{
          init:(function(){
                ST.MySpace.index.bindTab($('div[node-type="friend_tab"] a'),$('.marcontent'))
          })(),
          addgroup:function(){
                var addgroup=function(rdata){
                    var a='<li id="gp-'+rdata['id']+'">                            	<span class="fr"></span>                                <span class="rimg"><img src="'+publicurl+'space/teacher/images/imgteacher/ico11.png" align="absmiddle" ></span><a class="fl f14" gid="'+rdata['id']+'" onclick="ST.Friend.ltGroup()">'+rdata['name']+'</a>                            </li>';
                    $('.group-controller').append(a)
                }
                e=window.event;
                ST.Friend.addGroup(e,addgroup);
          }
        },
        Mood:{
             maxwords:40,
             timeid:0,
             getfaces:function(){
               var w= ST.UI.ModeWindow({'ID':'MY_FACES','button':'','width':420,'TitleText':ST.LANG['faces']}).load('/?_do=my-faces',function(){
                    $('.faceItemPicbgT a').click(function(){
                        $('#face_icon').html($(this).html())
                        w.close();
                    })
                });
            },
            del:function(id){
                ST.UI.ModeWindow({'ID':'DEL_DIALOG','TitleText':ST.LANG['confirm'],'submitcall':function(){
                    $.AjPost('blog_diary_actionDelMood-id-'+id,null,function(){
                        $('#mood_'+id).remove();
                        ST.UI.showMessage(ST.LANG['tips'],ST.LANG['success_del'],1000);
                    })
                }}).setContent(ST.LANG['confirm_del'])
            },
            elmRock:function(elm){
                if(!elm) return;
                var f=0, timeid=setInterval(function(){
                    if(f>3){
                        window.clearInterval(timeid);
                        return;
                    }
                    if(f%2==0){
                        $(elm).css('background','#ff0000')
                    }else{
                        $(elm).css('background','#fff')
                    }
                    f++;
                },200)
            },
            submit:function(){  //发布
                var cnt=$('#xq_cnt').val(),
                    faceimg=$('#face_icon').find('img').attr('src'),img='';
                faceimg=faceimg==undefined?'':faceimg;
                if(cnt.length==0){
                    this.elmRock($('#xq_cnt'));
                    return false;
                }
                if(cnt.length>40)
                {
                    ST.UI.showMessage(ST.LANG['error'],ST.LANG['mood_len_out'])
                    return false;
                }
                $.AjPost('blog_my_actionSaveMood',{'data':cnt,'faceimg':faceimg},function(rdata){
                    $('#xq_cnt').val('');
                    $('#face_icon').html('')
                    if(faceimg){
                        img='<img src="'+faceimg+'" />'
                    }
                    var a='<li id="mood_'+rdata+'"><span class="fr c04">刚刚 <a href="#" onclick="ST.SPACE.Mood.del(\''+rdata+'\')" class="c03">删除</a></span><span class="fl marr06">'+img+'</span>                            <span class="">'+cnt+'</span>                        </li>';
                    $('.mood_list ul').prepend(a)
                })   
                    
            },
            focus:function(){
                ST.SPACE.check($('#xq_cnt'),$('#wordsnum'),this.maxwords);
            }
        }
    };
})();
var tid=0;
function callbackreply(t){
    tid=t;
    getprepage();
}
function replyshow(id){
    $('#area-'+id).toggle()
}
function getprepage(pre){
    $('#rzfeed_0_list').html('正在加载请稍后...');
     $.get('?_do=photo-ajaxPhotoReply-uid-'+uid+'-tid-'+tid+'&page='+pre+'&rand='+Math.random(),function(msg){
        $('#lightbox-comment').html(msg).show();
            var arrPageSizes=___getPageSize();
            $('#jquery-overlay').css({
				width:		arrPageSizes[0],
				height:		arrPageSizes[1]
			});
            var intWidth=$('#lightbox-image').width();
            if(intWidth<307)
                intWidth=307
            $('#rzfeed_0_list').css({width:intWidth});
            $('.controlout').css({width:intWidth});
            $('.img-width').css({width:intWidth-70});
    })
}
function submitphoto(o){
    var tid=$(o).attr('tid');
    submitphotoReply(tid)
}
// 照片评论
function submitphotoReply(did) {
	var r_c = $('#photo_reply');
	if ($.trim(r_c.val()) == '') {
		if(ST.UI.showMessage){
		  ST.UI.showMessage('错误提示', '请输入留言内容');
		}else
          ST.UI.showmessage('错误提示', '请输入留言内容');
		r_c.focus();
		return false;
	}
	// 提交留言
    $.AjGet('blog_photo_ajaxDoComment-tid-'+did+'-replycnt-'+r_c.val(),null,function(msg){
          r_c.val('');
		  $("#lightbox-comment").prepend(msg);
    })
}
//返回窗口宽高
function ___getPageSize() {
			var xScroll, yScroll;
			if (window.innerHeight && window.scrollMaxY) {
				xScroll = window.innerWidth + window.scrollMaxX;
				yScroll = window.innerHeight + window.scrollMaxY;
			} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
				xScroll = document.body.scrollWidth;
				yScroll = document.body.scrollHeight;
			} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
				xScroll = document.body.offsetWidth;
				yScroll = document.body.offsetHeight;
			}
			var windowWidth, windowHeight;
			if (self.innerHeight) {	// all except Explorer
				if(document.documentElement.clientWidth){
					windowWidth = document.documentElement.clientWidth;
				} else {
					windowWidth = self.innerWidth;
				}
				windowHeight = self.innerHeight;
			} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
				windowWidth = document.documentElement.clientWidth;
				windowHeight = document.documentElement.clientHeight;
			} else if (document.body) { // other Explorers
				windowWidth = document.body.clientWidth;
				windowHeight = document.body.clientHeight;
			}
			// for small pages with total height less then height of the viewport
			if(yScroll < windowHeight){
				pageHeight = windowHeight;
			} else {
				pageHeight = yScroll;
			}
			// for small pages with total width less then width of the viewport
			if(xScroll < windowWidth){
				pageWidth = xScroll;
			} else {
				pageWidth = windowWidth;
			}
			arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
			return arrayPageSize;
		};
