function iKeyword(obj,type){
var init="60字以内";
switch(type){
case 1:
if(obj.value==init){obj.value="";}
break;
case 2:
if(obj.value==""){
obj.value=init;
}else{
}
break;
}
}
function ubb(vstr){
if(vstr==null)return '';
vstr = vstr.replace("&", "&");
vstr = vstr.replace(">", ">")
vstr = vstr.replace("<", "<")
vstr = vstr.replace(" ", " ")
vstr = vstr.replace("\r\n", "\n");
vstr = vstr.replace("\n", "
");
vstr = vstr.replace("\t", " ");
var emoteUrl = "
";
vstr = vstr.replace(/\[em([0-9]*)]/ig, emoteUrl);
return vstr;
}
function trimString(s){
s=s.replace(/\r\n/g,"");
//trim space
s=s.replace(/^\s*|\s*$/g, "");
return s;
}
function submitAjaxFormNow(formId,returnFunc){
var options = {
beforeSubmit: function(formData, jqForm, options) {
//$.blockUI('
正在提交...
', { border: '1px solid #0066FF' });
$.blockUI('
正在提交...
', { border: '1px solid #0066FF', height: '30px', padding:'10px 0px 10px 30px'});
return true;
},
success:function (responseText, statusText) {
$.unblockUI();
responseText=responseText.replace(/\r\n/g,"");
//trim space
responseText=responseText.replace(/^\s*|\s*$/g, "");
if (returnFunc) returnFunc(responseText,statusText);
},
timeout:10000,
type:"POST"
};
// bind form using 'ajaxForm'
$(formId).ajaxError(function(request, settings){
alert("读取数据超时,请重新刷新页面或稍后再试");
$.unblockUI();
});
$(formId).ajaxSubmit(options);
}
function submitAjaxForm(formId,returnFunc){
var options = {
beforeSubmit: function(formData, jqForm, options) {
//$.blockUI('正在提交...
', { border: '1px solid #0066FF' });
$.blockUI('
正在提交...
', { border: '1px solid #0066FF', height: '30px', padding:'10px 0px 10px 30px'});
return true;
},
success:function (responseText, statusText) {
$.unblockUI();
responseText=responseText.replace(/\r\n/g,"");
//trim space
responseText=responseText.replace(/^\s*|\s*$/g, "");
if (returnFunc) returnFunc(responseText,statusText);
},
timeout:10000,
type:"POST"
};
// bind form using 'ajaxForm'
$(formId).ajaxError(function(request, settings){
alert("读取数据超时,请重新刷新页面或稍后再试");
$.unblockUI();
});
$(formId).ajaxForm(options);
}
function echoErrorMessage(form,msg){
var errors=msg.split(";");
var s="";
var first="";
for(var i=0;i 0){ //如果为text,textarea,select直接focus
if(form[first].type == 'text' || form[first].type == 'textarea' || form[first].type == 'select' || form[first].type == 'radio' || form[first].type == 'checkbox'){
form[first].focus();
}
if(form[first].length > 0 && (form[first][0].type == 'radio' || form[first][0].type == 'checkbox')){
form[first][0].focus();
}
}
return false
}
function blockOpen(u,w,h){
//$.blockUI('333333333333',{width:'700px',height:'400px'});
$.blockUI('', { width: w+'px',height:h+'px',border:'1px solid #888'});
}
function blockClose(b){
$.unblockUI();
if (b)
window.location.reload(false);
}
function showhidden(){
document.getElementById('diary_info').style.display = 'block';
}
var photoCurrent=0;
var photoCounts=9;
var photoArray=new Array();
var play = false;
function photoPlay(){
//alert(photoCurrent);
play = true;
autoRun();
}
function autoRun(){
if(play){
photoNext();
setTimeout('autoRun()', 3000 );
}
}
function photoStop(){
play = false;
}
function photoPrev(){
photoShow(--photoCurrent);
}
function photoNext(){
photoShow(++photoCurrent);
}
function photoShow(i){
if (photoArray.length==0) return;
if (photoArray.length<=i || i/1<0){
i=0;
}
$("#idShowPhoto").html($('#'+photoArray[i]).html()).fadeIn('slow');
photoCurrent=i;
}
function isGbk(s) {
for (var j = 0; j < s.length; j++) {
if (s.charCodeAt(j) > 255){
return true;
}
}
return false;
}
function fucCheckLength(strTemp) {
var i,sum;
sum = 0;
for (i = 0; i < strTemp.length; i++)
{
if ((strTemp.charCodeAt(i) >= 0) && (strTemp.charCodeAt(i) <= 255))
sum = sum + 1;
else
sum = sum + 2;
}
return sum;
}
function lengthStr(str) {
var ret = 0;
var count = true;
for (var i = 0; i < str.length; i++) {
var c = (str.charAt(i)) + "";
if (c == "\r" || c == "\n" || c == "\t" || c == " ") continue;
if (isGbk(c)) {
ret++;
//alert(c)
count = true;
} else {
if (c == "&" || c == "<") {
count = false;
//alert("off")
}
if (c == ";" || c == ">") {
count = true;
//alert("on")
}
if (count) {
ret++;
}
}
}
return ret;
}
/* ignore whitespace */
function isEmpty(s) {
return !Boolean(s.replace(/^\s*|\s*$/g, "").length);
}
function toFixedString(str,length,id) {
if (isEmpty(str))
return "";
//去掉一开始的html
while (str.indexOf(" ") == 0) {
str = str.substring(6);
}
var sb = "";
var count = true;
//是否计数
for (var x = 0, y = 0; x < str.length && y < length * 2; x++) {
var c = str.charAt(x);
if (c == "'\r" || c == "\n" || c == "\t") continue;
if (count && c == " ") continue;
if (isGbk(c)) {
y += 2;
count = true;
} else {
if (c == "&" || c == "<") {
count = false;
}
if (c == ";" || c == ">") {
count = true;
}
if (count) {
y++;
}
}
sb += c;
}
if (lengthStr(str) > length) {
sb += '… >>查看全文 ';
}
return sb;
}
function toFriend(id){
if (!isLogined()){
alert("您必须先登录才能继续操作");
return;
}
if (!confirm("确定加为好友么?\n只有对方同意了您的请求才能成为好友.")){
return;
}
$.get('/do_click.jsp', {
doAction:"tofriend",
userId:id,
r:Math.random()
}, function(responseText, statusText) {
alert(trimString(responseText));
});
}
function toMessage(userId){
if (!isLogined()){
alert("您必须先登录才能发送小纸条");
return;
}
blockOpen("/send_message.jsp?userId="+userId,734,300);
}
function addFoucs(domId){
$.get('/do_click.jsp', {
doAction:"diaryAgree",
id:domId,
r:Math.random()
}, function(responseText, statusText) {
//alert("感谢您的关注!");
$("#"+domId).text(trimString(responseText));
});
}
function addFocusPhoto(domId){
$.get('/do_click.jsp', {
doAction:"photoAgree",
id:domId,
r:Math.random()
}, function(responseText, statusText) {
alert("感谢您的关注!");
$("#"+domId).text(trimString(responseText));
});
}
function doComment(formId){
submitAjaxForm("#postCommentForm",function(responseText,statusText){
if (responseText.length>0){
echoErrorMessage($("#postCommentForm")[0],responseText);
}else{
alert("填写成功,感谢您的参与");
}
});
}
function isLogined(){
return false;
}
function needLogin(){
$('#loginForm')[0].username.focus();
}
function newDiary(referId,canrefer){
//判断是否登录
if (!isLogined()){
alert("您需要登录才能发表日志");
needLogin();
return;
}
if(referId!=null&&canrefer!=null){
if(canrefer==-1){
alert("此日志不允许与我晒");
return;
}
}
blockOpen("/user/diary_insert.jsp?referId="+referId,734,566);
}
function loadGroupMember(d){
$.get('/do_count.jsp', {
doAction:"groupMember",
id:d,
r:Math.random()
}, function(responseText, statusText) {
$("#groupMember").text(trimString(responseText));
});
}
function joinGroup(d){
$.get('/do_click.jsp', {
doAction:"joinGroup",
id:d,
r:Math.random()
}, function(responseText, statusText) {
alert(trimString(responseText));
});
}
function setTop(d){
$.get('/do_click.jsp', {
doAction:"setTop",
id:d,
r:Math.random()
}, function(responseText, statusText) {
alert(trimString(responseText));
window.location.reload(false);
});
}
function selectOptionsValue(options,v){
for(var i=0;i(divWidth+75)){
//alert("right");
//$("body").append('');//right side
$('#'+objId).removeClass("show_left").addClass("show_right");
var arrowOffset = getElementWidth(linkId) + 11;
var clickElementx = getAbsoluteLeft(linkId) + arrowOffset - 80; //set x position
clickElementy = getAbsoluteTop(linkId) + 40 ;
}else{
$('#'+objId).removeClass("show_right").addClass("show_left");
//$("body").append('');//left side
var clickElementx = getAbsoluteLeft(linkId) - (divWidth + 15) + 80; //set x position
clickElementy = getAbsoluteTop(linkId) + 40 ;
}
//alert("f");
$('#'+objId).css({left: clickElementx+"px", top: clickElementy+"px"});
$('#'+objId).show();
//读取用户信息
$('#i_'+objId).load("/js_tip_user.jsp?id="+linkId);
$(document).click(function (){
hideFloatTip();
});
}
function getElementWidth(objectId) {
x = document.getElementById(objectId);
return x.offsetWidth;
}
function getAbsoluteLeft(objectId) {
// Get an object left position from the upper left viewport corner
o = document.getElementById(objectId)
oLeft = o.offsetLeft // Get left position from the parent object
while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
oParent = o.offsetParent // Get parent object reference
oLeft += oParent.offsetLeft // Add parent left position
o = oParent
}
return oLeft
}
function getAbsoluteTop(objectId) {
// Get an object top position from the upper left viewport corner
o = document.getElementById(objectId)
oTop = o.offsetTop // Get top position from the parent object
while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
oParent = o.offsetParent // Get parent object reference
oTop += oParent.offsetTop // Add parent top position
o = oParent
}
return oTop
}
function showFind(){
if(document.searchf.career.value != null && document.searchf.career.value.length > 0){
document.searchf.highFind.value = 1;
}
}
function showFrind(){
if(document.findFrind.blogName.value != null && document.findFrind.blogName.value.length > 0){
document.findFrind.highFind.value = 1;
}
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}