
var SendToFriend=new Class({Extends:Widget,initialize:function(){this.tags={};this.dom="<div class='menu_panel'>"+" <div id='status'><b>"+loc.text("sendtofriend_status")+"</b>"+" <hr><br>"+" <table width='95%'>"+"  <tr><td width='30%' align='right'>"+loc.text('sendtofriend_your_name')+"</td><td><input typpee='text' id='yname' size='30'></td></tr>"+"  <tr><td width='30%' align='right'>"+loc.text('sendtofriend_your_email')+"</td><td><input type='text' id='yemail' size='30'></td></tr>"+"  <tr><td width='30%' align='right'>"+loc.text('sendtofriend_friend_email')+"</td><td><input type='text' id='femail' size='30'></td></tr>"+"  <tr><td width='30%' align='right'>"+loc.text('sendtofriend_message')+"</td><td><textarea id='msg' rows='9' cols='50' style='width:90%'></textarea></td></tr>"+"  <tr><td colspan='2' align='center'><input type='button' id='btn' value='"+loc.text('sendtofriend_send')+"'></td></tr>"+" </table>"+"</div>";this.cfg={hasSizeBtn:false,hasRefreshBtn:false,hasSettingsBtn:false,hasDrag:false,hasProfile:false,title:"",module:"SendToFriend",uniqueId:SYS_WIDGETS_ID+9}},onBuildInterface:function(){var t=this;t.setTitle(loc.text('sendtofriend_title'));t.mid.getElement('.box-content').style.height='300px';t.mid.getElement('.box-content').innerHTML=t.dom;t.tags['status']=t.mid.getElement('div[id=status]');t.tags['yname']=t.mid.getElement('input[id=yname]');t.tags['yemail']=t.mid.getElement('input[id=yemail]');t.tags['femail']=t.mid.getElement('input[id=femail]');t.tags['msg']=t.mid.getElement('textarea[id=msg]');t.tags['btn']=t.mid.getElement('input[id=btn]');t.tags['btn'].addEvent('click',function(){t.doSend();});if(ident.user.email)t.tags['yemail']=ident.user.email;t.tags['msg']="http://"+baseUrl;},close:function(){board.hideActivePopup();},dispatchMsg:function(msg){switch(msg.status){case'ok':showEl(this.tags['btn']);this.tags['status'].innerHTML='<font color=green>'+loc.text('sendtofriend_send_ok')+'</font>';break;case'failed':this.tags['status'].innerHTML='<font color=red>'+loc.text('sendtofriend_send_failed')+'</font>';showEl(this.tags['btn_send']);break;}},doSend:function(){var t=this;if(t.tags['yemail'].value==''){alert(loc.text('sendtofriend_email_empty'));t.tags['yemail'].focus();return;}
if(t.checkEmail(t.tags['yemail'].value)==false){alert(loc.text('sendtofriend_email_invalid'));t.tags['yemail'].focus();return;}
if(t.tags['femail']==""){alert(loc.text('sendtofriend_femail_empty'));t.tags['femail'].focus();return;}
if(t.checkEmail(t.tags['femail'].value)==false){alert(loc.text('sendtofriend_femail_invalid'));t.tags['femail'].focus();return;}
t.tags['status'].innerHTML=loc.text("msg_processing");hideEl(this.tags['btn']);request.send({act:"send_to_friend",name:t.tags['yname'].value,email:t.tags['yemail'].value,femail:t.tags['femail'].value,msg:t.tags['msg'].value},this);},checkEmail:function(mail){if(mail.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi))
return true;else
return false;}});