
var resizeTimer;var workingObj;var finalSize;var ffTimer;var inAction=false;var widgetOn;var friendsOn="recent";var entryLive=false;var mapLat=0;var mapLng=0;var map=null;var showedMap=false;var geocoder=null;var mrk=new Array();var marker=new Array();var markerText=new Array();var co=1;var isIndex=false;var isS=0;var journalLink="journal.php";var thuju=0;var FRIENDSMAX=15;var widgets=Array("journals","map","friends","events");var my_widgets=Array("journals","blog","map","events");var friend_widgets=Array("friends","updates","giftrocks");var AJAXDIR="/ajax/";function setIndex(i){isIndex=true;}
var processWidget=false;function widget(){if(!processWidget){processWidget=true;var callScript="";var callBack=processMyWidgetData;var haveArr=false;oSel=arguments[0];if(arguments[1]!=undefined){for(t in my_widgets){if(my_widgets[t]==oSel){thisArr=my_widgets;haveArr=true;break;}}
if(!haveArr){thisArr=friend_widgets;}}
else{thisArr=widgets;}
widgetOn=oSel;for(var t=0;t<thisArr.length;t++){if(thisArr[t]!=oSel&&$("widget_"+thisArr[t])){if(thisArr[t]!="map"||showedMap){$("widget_"+thisArr[t]).style.display="none";}}}
$("widget_"+oSel).style.display="block";switch(oSel){case"journals":callScript="journals.php";break;case"blog":callScript="blogs.php";break;case"events":callScript="events.php";break;case"map":if(!showedMap){$("widget_map").style.position="relative";$("widget_map").style.left="0px";$("widget_map").style.top="0px";if(mapLng!=0){point=new GLatLng(mapLat,mapLng);marker=new GMarker(point);map.addOverlay(marker);map.setCenter(point,2);window.setTimeout(function(){map.panTo(point);},1000);}
showedMap=true;}
processWidget=false;break;case"friends":if($("friends_list")){callBack=processFriendsWidgetData;callScript="friends.php";}
break;case"giftrocks":callScript="giftrock_list.php";callBack=processGift;break;default:processWidget=false;}
if(callScript!=""){try{var TRAjax=new ajaxObject(AJAXDIR+callScript,callBack);TRAjax.update("ju="+thuju+"&json=1","GET");}catch(R){alert(R);}}}else{var A,B=0;if(typeof arguments[0]!='undefined'){A=arguments[0];}
if(typeof arguments[1]!='undefined'){B=arguments[1];}
var buffer=function(){widget(A,B);}
setTimeout(buffer,1000);}}
function processMyWidgetData(responseText,responseStatus){if(responseStatus==200){var newStr="<table border='0' cellpadding='0' cellspacing='0'>";var c=0;switch(widgetOn){case"journals":case"blog":var out=eval('('+responseText+')');var rowCount=out.entry.length;if(rowCount>MAXROWS){rowCount=MAXROWS;}
for(var ii=0;ii<rowCount;ii++){entryLive=out.entry[ii].live;switch(widgetOn){case"journals":linkStr="journal_view.php";journalLink="journal.php?id="+thuju;blogStr="";thumbStr="";break;case"blog":linkStr="blog_view.php";journalLink="blog.php?id="+thuju;blogStr=out.entry[ii].blogBody;thumbStr=out.entry[ii].thumb;break;}
newStr+=createRow(out.entry[ii].id,out.entry[ii].date,out.entry[ii].title,linkStr+"?jId="+out.entry[ii].id,blogStr,thumbStr);c++;}
if(c<MAXROWS&&widgetOn!="blog"){for(;c<MAXROWS;c++){newStr+=emptyRow;}}else{if(widgetOn=="blog"&&rowCount=="0"){newStr+="<tr><td colspan='2' class='red_text_boldSM' style='text-align: right; padding-right: 5px'>This user has not posted any blog entries yet.</td></tr>";}
if((widgetOn=="blog"&&c>=MAXROWS)||(widgetOn!="blog"&&c>=MAXROWS)){newStr+="<tr><td colspan='2' class='lightBlue' style='text-align: right; padding-right: 5px'><a href='"+journalLink+"' class='red_link'>MORE>></a></td></tr>";}}
newStr+="</table>";if(widgetOn=="journals"){$("journal_list").innerHTML=newStr;}
else if(widgetOn=="blog"){$("blog_list").innerHTML=newStr;}
else{}
break;case"events":var out=eval('('+responseText+')');var rowCount=out.events.length;if(rowCount>MAXROWS){rowCount=MAXROWS;}
for(var ii=0;ii<rowCount;ii++){newStr+=createRow(out.events[ii].id,out.events[ii].date,out.events[ii].title,"events_view.php?id="+out.events[ii].orderItem+"&c="+out.events[ii].orderCat,"","");c++;}
if(c<MAXROWS){for(;c<MAXROWS;c++){newStr+=emptyRow;}}
newStr+="</table>";$("events_list").innerHTML=newStr;break;case"friends":var out=eval('('+responseText+')');var myFriendMax=FRIENDSMAX;newStr+="<tr><td>";if(out.queryType=="view"){if(out.friendCount<FRIENDSMAX){myFriendMax=out.friendCount;}
newStr+="<div style='width: 368px; text-align: left; padding-bottom: 5px; padding-top: 0px' class='red_text'>Showing "+myFriendMax+" of "+out.friendCount+" friends</div>";}
for(var ii=0;ii<out.friends.length;ii++){newStr+=createFriends(out.queryType,out.friends[ii].id,out.friends[ii].name,out.friends[ii].photo,out.friends[ii].latestId,out.friends[ii].latestDate,out.friends[ii].latestTitle,out.friends[ii].latestText,out.friends[ii].mantra);c++;}
if(out.queryType=="view"&&out.friendCount>FRIENDSMAX){newStr+="</td></tr><tr><td><div class='lightBlue' style='width: 368px; text-align: right; padding-right: 5px'><a href='friends.php' class='red_link_bold'>MORE >></a></div>";}
newStr+="</td></tr></table>";if($("friends_list")){$("friends_list").innerHTML=newStr;}
break;}}else{}
processWidget=false;}
function processFriendsWidgetData(responseText,responseStatus){if(responseStatus==200){var newStr="<table border='0' cellpadding='0' cellspacing='0'>";var c=0;switch(widgetOn){case"friends":var out=eval('('+responseText+')');var myFriendMax=FRIENDSMAX;newStr+="<tr><td>";if(out.queryType=="view"){if(out.friendCount<FRIENDSMAX){myFriendMax=out.friendCount;}
newStr+="<div style='width: 368px; text-align: left; padding-bottom: 5px; padding-top: 0px' class='red_text'>Showing "+myFriendMax+" of "+out.friendCount+" friends</div>";}
for(var ii=0;ii<out.friends.length;ii++){newStr+=createFriends(out.queryType,out.friends[ii].id,out.friends[ii].name,out.friends[ii].photo,out.friends[ii].latestId,out.friends[ii].latestDate,out.friends[ii].latestTitle,out.friends[ii].latestText,out.friends[ii].mantra);c++;}
if(out.queryType=="view"&&out.friendCount>FRIENDSMAX){newStr+="</td></tr><tr><td><div class='lightBlue' style='width: 368px; text-align: right; padding-right: 5px'><a href='friends.php' class='red_link_bold'>MORE >></a></div>";}
newStr+="</td></tr></table>";if($("friends_list")){$("friends_list").innerHTML=newStr;}
break;}}else{}
processWidget=false;}
function createFriends(thisType,thisId,thisName,thisPhoto,entryId,entryDate,entryTitle,entryText,myMantra){if(entryDate!=""){entryDate="- "+entryDate;}
var str="";if(thisPhoto==""||thisPhoto=="/images/photo_.gif"){thisPhoto="images/photo_male.gif";}
switch(thisType){case"recent":str="<div class='friend_container'>";str+="<div class='friend_photo'><a href='profile_view.php?id="+thisId+"'><img src='"+thisPhoto+"' width='50' /></a></div>";str+="<div class='friend_desc'>";str+="<div class='lightBlue friend_title'><a href='profile_view.php?id="+thisId+"' class='red_link_bold'>"+thisName+"</a>&nbsp;"+entryDate+"</div>";if(entryTitle!=""){str+="<div class='body_text friend_entry'><a href='journal_view.php?jId="+entryId+"' class='recent_title'>"+entryTitle+":</a> "+entryText+"</div>";}
break;case"profile":str="<div class='friend_container'>";str+="<div class='friend_photo'><a href='profile_view.php?id="+thisId+"' class='red_link_bold'><img src='"+thisPhoto+"' width='50' alt='"+thisName+"' /></a></div>";str+="<div class='friend_desc'>";str+="<div class='lightBlue friend_title'><a href='profile_view.php?id="+thisId+"' class='red_link_bold'>"+thisName+"</a>&nbsp;"+entryDate+"</div>";str+="<div class='body_text friend_entry' style='eight:20px'>"+myMantra+"</div>";break;case"view":thisName=html_wordwrap(thisName,8);str="<div style='float: left; width: 73px; height: 110px;'><div class='single_friend_container'>";str+="<div tyle='display: block' class='friend_photo'><a href='profile_view.php?id="+thisId+"' class='red_link'><img src='"+thisPhoto+"' width='50' />";str+=thisName;str+="</a></div>";break;}
str+="</div></div>";return str;}
function friends(oSection){widgetOn="friends";for(var i=0;i<friendsWidgets.length;i++){if(oSection==friendsWidgets[i]){friendsOn=friendsWidgets[i];if($("friends_"+friendsWidgets[i])){$("friends_"+friendsWidgets[i]).src="/images/widget_friends_"+friendsWidgets[i]+"_on.gif";}
if(oSection=="find"){location.href='friends_find.php';return true;}}else{$("friends_"+friendsWidgets[i]).src="/images/widget_friends_"+friendsWidgets[i]+"_off.gif";}}
if($("friends_list")){$("friends_list").innerHTML="";var TRAjax=new ajaxObject(AJAXDIR+"friends.php",processMyWidgetData);TRAjax.update("ju="+thuju+"&json=1&qry="+oSection+"&r=1");}}
var emptyRow="<tr><td class='darkBlue red_text'>&nbsp;</td><td class='lightBlue' style='text-align: right'>&nbsp;</td></tr>";function createRow(id,thisDate,thisTitle,thisLink,bodyText,thumb){var str="<tr><td class='darkBlue red_text' ";if(bodyText!=""){}
str+=">"+thisDate+"</td><td id='ji_"+id+"' onmouseover='TREffects.do_colorChange(this, \"bed2e8\");' onmouseout='TREffects.do_colorChange(this, \"e6eef6\");' class='lightBlue'><a href='"+thisLink+"' class='red_link'";if(entryLive=="0"){str+=" style='color: #5A7FA7;' ";}
str+=">"+thisTitle+"</td></tr>";if(bodyText!=""){str+="<tr><td style='text-align: center'>";if(thumb!='undefined'&&thumb!=""&&thumb!="0"){str+="<img src='"+thumb+"' width='50' />";}
str+="</td><td  class='body_text' style='padding-left: 3px'>"+bodyText+"</td></tr><tr><td colspan='2'><img src='/images/spacer.gif' height='3' /></td></tr>";}
return str;}
function moreRow(oStr){return"<tr><td class='darkBlue red_text'>&nbsp;</td><td class='lightBlue' style='text-align: right'><a href='"+oStr+"'><img src='images/widget_blue_more.gif' alt='more' /></a></td></tr>";}
function setupBlocks(){if($("body_container").offsetHeight<"500"){finalHeight=$("left_side_container").offsetHeight+$("body_container").offsetHeight;}else{finalHeight=$("body_container").offsetHeight;}
clearTimeout(ffTimer);if(showInterestMore){height_interestBlockOver=$("interestBlockOver").offsetHeight;}
if(showAboutMore){height_aboutBlockOver=$("aboutBlockOver").offsetHeight;}
if(showInterestMore&&(height_interestBlockOver<1)){ffTimer=setTimeout("setupBlocks()",500);}else{setupSliders();}}
function setupSliders(){if(showInterestMore){$("interestMore").style.display="block";}
if(showAboutMore){$("aboutMore").style.display="block";}
if($("interestBlockOver")){$("interestBlockOver").style.top="0px";$("interestBlockOver").style.left="0px";$("interestBlockOver").style.display="none";}
if($("aboutBlockOver")){$("aboutBlockOver").style.top="0px";$("aboutBlockOver").style.left="0px";$("aboutBlockOver").style.display="none";}}
function showMoreInterests(){if(!TREffects._inAction){$("interestMore").style.display="none";TREffects.increase("interestBlockOver",height_interestBlockOver);$("interestLess").style.display="block";}}
function showLessInterests(){if(!TREffects._inAction){$("interestLess").style.display="none";TREffects.decrease("interestBlockOver",20);$("interestMore").style.display="block";}}
function showMoreAbout(){if(!TREffects._inAction){$("aboutMore").style.display="none";TREffects.increase("aboutBlockOver",height_aboutBlockOver);$("aboutLess").style.display="block";}}
function showLessAbout(){if(!TREffects._inAction){$("aboutLess").style.display="none";TREffects.decrease("aboutBlockOver",20);$("aboutMore").style.display="block";}}
function updateMantra(){var msg=encodeURIComponent($("newMantra").value);var TRAjax=new ajaxObject("http://www.trujournal.com/ajax/update_mantra.php",processCaption);TRAjax.update("msg="+msg,'POST');}
function processCaption(responseText,responseStatus){if(responseStatus==200){var m=eval('('+responseText+')');$("mantraSpan").innerHTML=m.msg;TREffects.hideObj("mantraEditDiv");}}
function processGift(responseText,responseStatus){if(responseStatus==200){var m=eval('('+responseText+')');var GIFTROWS=5;var newStr="<table border='0' cellpadding='0' cellspacing='0' style='vertical-align: top'>";var emptyRow="<tr><td style='width: 34px; background-color: #BED2E8; border-bottom: solid 1px #ffffff'><img src='/images/spacer.gif' height='21' width='34' /></td><td colspan='2' class='lightBlueListBold'>&nbsp;</td></tr>";var c=0;var thisPage="1";var out=eval('('+responseText+')');if(out.entry!=undefined){if(out.entry.length>GIFTROWS){showRows=GIFTROWS;}else{showRows=out.entry.length;}
for(var ii=0;ii<showRows;ii++){try{newStr+=addGiftrock(0,out.entry[ii].idd,out.entry[ii].date,out.entry[ii].title,out.entry[ii].live,out.entry[ii].recip,out.entry[ii].toFrom,out.entry[ii].photo,out.entry[ii].public,out.entry[ii].pics,out.entry[ii].journalId,out.entry[ii].journalTitle,out.entry[ii].giftImg);}catch(e){alert(e);}
c++;}
if(c<GIFTROWS){for(;c<GIFTROWS;c++){newStr+=emptyRow;}}
if(out.entry.length>GIFTROWS){newStr+="<tr><td style='width: 34px; padding: 0px; background-color: #BED2E8'><img src='/images/spacer.gif' height='21' width='34' /></td><td colspan='2' class='lightBlueListBold' style='text-align: right; padding-right: 5px'><a href='giftrocks.php?id="+gift_ju+"' class='red_link'>MORE>></td></tr>";}}else{if(out.msg){msgStr=out.msg;}else{msgStr="You currently have no gift rock entries.";}
newStr+="<tr><td class='red_text_boldSM'>"+msgStr+"</td></tr>";}
newStr+="</table>";$("my_gift_container").innerHTML=newStr;}
processWidget=false;}
var lastDate="";var showedFirst=0;function addGiftrock(isAll,entryId,entryDate,entryTitle,entryLive,entryRecip,toFrom,recipPhoto,entryPublic,entryPics,journalId,journalTitle,giftPhoto){var privateImg;var str="";entryTitle=html_wordwrap(entryTitle,60);entryRecip=html_wordwrap(entryRecip,20);journalTitle=html_wordwrap(journalTitle,30);if(toFrom=="0"){bgColor="e1dddb";}
else{bgColor="e6eef6";}
var thisDate=entryDate.split("/");var curDate=thisDate[0]+thisDate[2];if((curDate!=lastDate)&&showedFirst&&!isAll){str+=spacerRow;lastDate=curDate;}
var cutLength=30;var origLen=entryTitle.length;entryTitle=entryTitle.substr(0,cutLength);if(origLen>cutLength){entryTitle+="...";}
var rowId="gr_"+entryId;str+="<tr><td><img src='"+giftPhoto+"' width='34' height='21' /></td><td class='lightBlueListBold' style='width:205px; border-right: 0' id='td_"+rowId+"_0'  onmouseover='TREffects.highLight(this, \"bed2e8\", \""+rowId+"\", 2);' onmouseout='TREffects.highLight(this, \"e6eef6\", \""+rowId+"\", 2);' onclick='showGiftrock("+entryId+");' >";if(entryLive=="0"){str+="<span style='color: #5A7FA7'>*"+entryTitle+"</span>";}else{str+=entryTitle;}
str+="</td><td class='lightBlueList' style='width: 135px; font-size: 10px' id='td_"+rowId+"_1'  onmouseover='TREffects.highLight(this, \"bed2e8\", \""+rowId+"\", 2);' onmouseout='TREffects.highLight(this, \"e6eef6\", \""+rowId+"\", 2);' onclick='showGiftrock("+entryId+");'>";if(toFrom=="1"){str+="<img src='images/giftrock_to.gif' style='vertical-align: middle' />";}else{str+="<img src='images/giftrock_from.gif' style='vertical-align: middle'  />";}
str+=" <b>"+entryRecip+"</b></td>";str+="</tr>";return str;}
