function Mag_SiteConnect(URL){this.req=null;this.url=URL;this.method='GET';this.async=true;this.status=null;this.statusText='';this.postData=null;this.readyState=null;this.responseText=null;this.responseXML=null;this.handleResp=null;this.responseFormat='text';this.setRequestHeader=null;this.mimeType=null;this.init=function()
{if(this.req!=null&&this.req.readyState!=0&&this.readyState!=4){this.req.abort();}
try
{this.req=new XMLHttpRequest();}
catch(e)
{var XmlHttpVersions=new Array("MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.5.0","MSXML2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP");for(var i=0;i<XmlHttpVersions.length&&!this.req;i++)
{try
{this.req=new ActiveXObject(XmlHttpVersions[i]);}
catch(e){return false;}}}
return this.req;};this.sendReq=function(){if(!this.init()){alert('Could not create XMLHttpRequest object.');return;}
this.req.open(this.method,this.url,this.async);(this.method=='POST')?this.req.setRequestHeader("Content-Type","application/x-www-form-urlencoded"):this.postData=null;if(this.mimeType){try{this.req.overrideMimeType(this.mimeType);}
catch(e){}}
var self=this;this.req.onreadystatechange=function()
{var resp=null;if(self.req.readyState==4){switch(self.responseFormat){case'text':resp=self.req.responseText;break;case'xml':resp=self.req.responseXML;break;case'object':resp=req;break;}
if(self.req.status>=200&&self.req.status<=299){HN_health=1;self.handleResp(resp);}
else{HN_health=0;self.handleErr(resp);}}};this.req.send(this.postData);};this.handleError=function(){try{OSLA.HN._pS.hide();}catch(e){}
try{OSLA.HN._shade.h();}catch(e){}
try{var ermsg="<span style='color:red;'><b>Error:</b> cannot complete request. Check internet connection and try again</span><br />Status Code: "+this.req.status+"<br />Status Desc.: "+this.req.statusText;OSLA.HN.BringDialog(ermsg,12000);}
catch(e){alert('Cannot connect to complete request:.\n'
+'Please check internet connection and\n '
+'try again.\n'
+'\n'
+'Status Code: '+this.req.status+'\n'
+'Status Description: '+this.req.statusText);}};this.setHandlerBoth=function(funcRef){this.handleResp=funcRef;this.handleErr=funcRef;};this.abort=function()
{if(this.req){this.req.onreadystatechange=function(){};this.req.abort();this.req=null;}};this.State=function()
{return this.readyState;}
this.reqStatus=function(){return this.req.status;};this.makeReq=function(post,hand,method,format,handErr)
{this.postData=post;this.handleResp=hand;this.responseFormat=format||'text';this.handleErr=handErr||this.handleError;this.method=method||'GET';this.sendReq();};this.fine=function()
{return this.init();}}
OSLA.HN.Friends={"container":'',"closeInterval":'',"friendListData":'',"url":HOMEURL+"processFriend.php","html":{"requestBox":'<table><tbody><tr><td><span>Add <b><i>#-username-#</i></b> to your contacts</span><p><label>Contact Group:</label>#-SelectField-#</p>\n\
             <p><label>New Group: <input type="checkbox" id="new_friend_group_checkbox" onclick="javascript:#-chkBxFunction-#;" /></label>\n\
             <input type="text" style="visibility:hidden" id="new_friend_group" /></p><p class="msgP"><label>\n\
             Short Message:<br />(<i>Optional</i>)</label><textarea style="height:25px" id="request_friend_message" onkeyup="OSLA.HN.inputCount(this,\'100\');" onchange="OSLA.HN.inputCount(this,\'100\');"></textarea></p><!--<p><label>Match Character:\n\
             </label><input type="text" id="character_match" /></p>--><p><label>&nbsp;</label>\n\
             <input type="button" value="Add to Contacts" id="contact-add-btn" class="button-submit" onclick="javascript:#-clickFunction-#;" /></td></tr></tbody></table>',"isFriend":'You are already a friend of #-username-#',"friendRejected":'<table><tbody><tr><td>Your previous friend request was rejected by #-username-#</td></tr></tbody></table>',"friendAdded":'<table><tbody><tr><td>Your friend request has been sent to #-username-#</td></tr></tbody></table>',"friendAddErr":'<table><tbody><tr><td>Your friend request was unsuccessful. Please try again</td></tr></tbody></table>',"friendAddmsg":'<table><tbody><tr><td>#-response-#</td></tr></tbody></table>'},"removeDiv":function(){document.getElementsByTagName("body")[0].removeChild(this.container);},"showNewGroupInput":function(){var chkBox=OSLA.HN._e.byId("new_friend_group_checkbox");var input=OSLA.HN._e.byId("new_friend_group");var select=OSLA.HN._e.byId("friend_group");if(chkBox.checked==true){input.style.visibility='visible';select.disabled=true;}
else{input.style.visibility='hidden';select.disabled=false;}},"createDiv":function(){clearTimeout(this.closeInterval);var self=this;this.container=document.createElement("div");this.container.className="friendaddDiv";var bar=document.createElement("div");bar.className="friendaddTitle";var close=document.createElement("span");close.appendChild(document.createTextNode('x'));close.onclick=function(){document.getElementsByTagName("body")[0].removeChild(self.container)};bar.appendChild(close);var content=document.createElement("div");content.setAttribute("id","friend_Add_Div");this.container.appendChild(bar);this.container.appendChild(content);document.getElementsByTagName("body")[0].appendChild(this.container);middlePositionBox(this.container);},"sendBring":new Mag_SiteConnect(HOMEURL+"processFriend.php"),"addFriend":function(user){OSLA.HN._pS.open();var param="action=isNotFriend&friend="+user;var self=this;var hand=function(str){try{OSLA.HN._pS.hide();if(str.indexOf("ERRNO")>=0||str.indexOf("error:")>=0||str.length==0){throw(str.length==0?"Void server response.":str);}
var grpObj=JSON.parse(str);var response='';var can=OSLA.HN._e.byId("friend_Add_Div");if((grpObj instanceof Array)&&('groupid'in grpObj[0])){response=self.html.requestBox;try{if(can==null){throw("error");}}
catch(e){self.createDiv();}
var select="<select id='friend_group'>";for(var i=0;i<grpObj.length;i++){select+='<option value="'+grpObj[i].groupid+'">'+grpObj[i].groupname+'</option>';}
select+='</select>';response=response.replace(/#-chkBxFunction-#/,"OSLA.HN.Friends.showNewGroupInput()");response=response.replace(/#-clickFunction-#/,"OSLA.HN.Friends.request('"+user+"')");response=response.replace(/#-SelectField-#/,select);response=response.replace(/#-username-#/i,user);OSLA.HN._e.byId("friend_Add_Div").innerHTML=response;middlePositionBox(self.container);}
else if('infriend'in grpObj){var txt=grpObj['infriend'][1];response=self.html.friendAddmsg;try{if(can==null){throw("error");}}
catch(e){self.createDiv();}
response=response.replace(/#-response-#/,txt);response=response.replace(/#-username-#/ig,user);OSLA.HN._e.byId("friend_Add_Div").innerHTML=response;middlePositionBox(self.container);}
else{OSLA.HN.BringDialog("Unknown error adding "+user+". Please try again");}}
catch(e){OSLA.HN.BringDialog(" Unknown error adding "+user+". Please try again");}}
this.sendBring.makeReq(param,hand,'POST');},"sendRequest":function(user){OSLA.HN._pS.open();var friendgroup=OSLA.HN._e.byId("friend_group").value;var newfriendgroup=OSLA.HN._e.byId("new_friend_group").value;var newfriendgroupbox=OSLA.HN._e.byId("new_friend_group_checkbox");var requestmsg=OSLA.HN._e.byId("request_friend_message").value;var self=this;var param="action=requestFriend&";if(newfriendgroupbox.checked==true){param+="creategroup=yes&newgroupname="+newfriendgroup+"&msg="+requestmsg+"&friend="+user;}
else{param+="group="+friendgroup+"&msg="+requestmsg+"&friend="+user;}
var hand=function(str){OSLA.HN._pS.hide();var response=self.html.friendAddmsg;try{if(str.indexOf("ERRNO")>=0||str.indexOf("error:")>=0||str.length==0){throw(str.length==0?"Void server response.":str);}
var rqObj=JSON.parse(str);try{var can=OSLA.HN._e.byId("friend_Add_Div");if(can==null){throw("error");}}
catch(e){this.createDiv();}
if(rqObj['status']=="no"){response=self.html.friendAddmsg;response.replace(/#-response-#/,rqObj['response']);response.replace(/#-username-#/i,user);OSLA.HN._e.byId("friend_Add_Div").innerHTML=response;self.closeInterval=setTimeout(self.removeDiv,'5000');}
else if(rqObj['status']=="yes"){response=self.html.friendAddmsg;response=response.replace(/#-response-#/,rqObj['response']);response=response.replace(/#-username-#/i,user);OSLA.HN._e.byId("friend_Add_Div").innerHTML=response;self.closeInterval=setTimeout(self.removeDiv,'5000');}
else{OSLA.HN.BringDialog("unknown problem adding friend");OSLA.HN._e.butEnable('contact-add-btn');}}
catch(e){OSLA.HN._e.butEnable('contact-add-btn');OSLA.HN.BringDialog("Unknown error: might already become your friend. Try again if not");}}
this.sendBring.makeReq(param,hand,'POST');},"request":function(user){OSLA.HN._e.butDisable('contact-add-btn');this.sendRequest(user);},"blockuser":function(user){if(confirm("are you sure you want to block "+user+"?")){var param="action=blockuser&blockuser="+user;var hand=function(str){try
{if(str.indexOf("ERRNO")>=0||str.indexOf("error:")>=0||str.length==0){throw(str.length==0?"Void server response.":str);}
var respObj=JSON.parse(str);OSLA.HN.BringDialog(respObj['response']);}
catch(e)
{OSLA.HN.BringDialog(respObj['response']);}}
this.sendBring.makeReq(param,hand,'POST');}},"listFriends":function(){OSLA.HN._pS.open();var container=OSLA.HN._e.byId('friendsPlace');var self=this;var hand=function(str){try
{OSLA.HN._pS.hide();if(str.indexOf("ERRNO")>=0||str.indexOf("error:")>=0||str.length==0){throw(str.length==0?"Void server response.":str);}
self.friendListData=str;var respObj=JSON.parse(str);var friendhtml='';var vales='';if(typeof respObj['0']!='undefined'&&respObj['0']=="//"){friendhtml=respObj['1'];}
else{for(var name in respObj){friendhtml+="<ul class='bar-friends'><li class='group'><img src='"+ICONSURL+"/folder_friend.png' width='16' height='16'/> "+name+" (<i>"+respObj[name].length+"</i>)</li><ul>";vales='';for(var i=0;i<respObj[name].length;i++){vales+="<li class='friend'><img class='userphoto' src='"+HOMEURL+"pixframe.php?type=thumb-30' width='30' height='30' border='0' style='background:transparent url("+HOMEURL+"userpix.php?user="+respObj[name][i]['0']+"&type=small) no-repeat top center' /><h6>"+respObj[name][i]['1']+" <img alt='' src='"+HOMEURL+"onlineicon.php?for=16&usr="+respObj[name][i]['1']+"' hspace='0' vspace='0' style='width:16px;height:16px;border:0;padding:0;position:absolute;' /></h6><span><a onclick='OSLA.HN.OpenUrl(\""+PROFILELINK+respObj[name][i]['1']+"\");return false;'> <img alt='VP' src='"+IMAGEURL+"16-profile.gif' hspace='0' vspace='0' style='width:16px;height:16px;border:0;padding:0;margin:1px;' title='View "+respObj[name][i]['1']+" Profile' /> </a>  <a onclick='OSLA.HN.OpenUrl(\""+HOMEURL+"sendmessage.php?value="+respObj[name][i]['1']+"\");return false;'> <img alt='SM' src='"+IMAGEURL+"16-email.gif' hspace='0' vspace='0' style='width:16px;height:16px;border:0;padding:0;margin:1px;' title='Send "+respObj[name][i]['1']+" a message' /> </a> <a onclick='OSLA.MC._bW(\""+respObj[name][i]['1']+"\",\"msg\");return false;'> <img alt='IM' src='"+IMAGEURL+"16-ichat.gif' hspace='0' vspace='0' style='width:16px;height:16px;border:0;padding:0;margin:1px;' title='Converse with "+respObj[name][i]['1']+"' /> </a></span></li>";}
vales+="</ul></ul>";friendhtml+=vales;}}
container.innerHTML=friendhtml;}
catch(e){}}
if(this.friendListData==''){var param="action=listFriend";this.sendBring.makeReq(param,hand,'POST');}
else{hand();}},"rejectFriend":function(user,divTowipe){OSLA.HN._pS.open();var wipediv=(divTowipe)?OSLA.HN._e.byId(divTowipe):null;var param="action=rejectFriend&friendid="+user;var hand=function(str){try
{OSLA.HN._pS.hide();if(str.indexOf("ERRNO")>=0||str.indexOf("error:")>=0||str.length==0){throw(str.length==0?"Void server response.":str);}
var respObj=JSON.parse(str);if(wipediv!=null&&respObj['status']=='yes'){OSLA.HN._e.hide(divTowipe)}
OSLA.HN.BringDialog(respObj['response']);}
catch(e)
{OSLA.HN._pS.hide();OSLA.HN.BringDialog(respObj['response']);}}
this.sendBring.makeReq(param,hand,'POST');}};OSLA.HN.FriendsBox={init:function(id,originH,targetH,callback)
{this.frameRate=10;this.duration=1;this.div=OSLA.HN._e.byId(id);this.callbackfnc=(callback!=undefined)?function(){eval(callback)}:false;if(parseInt(this.div.style.height)>=targetH){this.div.style.height=originH+"px";this.div.style.display='none';return;}
this.div.style.display='block';this.targetY=targetH;this.originY=originH;this.increment=Math.ceil((this.targetY-this.originY)/(this.duration*this.frameRate));this.y=this.originY;this.interval=setInterval("OSLA.HN.FriendsBox.animate()",Math.ceil(10/this.frameRate))},animate:function()
{this.y+=this.increment;if((this.targetY>this.originY&&this.y>this.targetY)||(this.targetY<=this.originY&&this.y<=this.targetY))
{clearInterval(this.interval);delete this.interval;this.y=this.targetY;this.div.style.height=Math.round(this.y)+"px";(this.callbackfnc!=false)?this.callbackfnc():false;}
else
{this.div.style.height=Math.round(this.y)+"px";}}};