window.onload=function(){if($("mainContainer").offsetHeight<window.getHeight()){$("bodyContainer").style.height=(window.getHeight()-236)+"px"}if($("panel_todaywishes")){bwfu.resizePanels()}};var bwfu={register:{openDialog:function(){var a=new Element("DIV",{id:"screen",styles:{position:"absolute","z-index":"1","background-color":"black",top:0,left:0,width:window.getWidth(),height:$("mainContainer").offsetHeight,opacity:"0.85"}});document.body.appendChild(a);bwfu.loadtext.show("Loading registration form . . .");var b=new XHR({method:"get",onSuccess:function(){try{$("screen").scrollIntoView();$("registerFormContainer").setStyles({left:(window.getWidth()-600)/2,top:50,display:"block"});bwfu.loadtext.hide();$("registerFormContainer").innerHTML=b.response.text}catch(c){alert("Failed to load register form. Please re-try again.")}},onFailure:function(){alert("Error loading registration form. Please re-try again.")}}).send(resourcepath+"home/register","frmAction=getdialog")},DoCancel:function(){if($("registerFormContainer")){$("registerFormContainer").style.display="none"}bwfu.loadtext.hide();new Fx.Style($("screen"),"opacity",{duration:500}).start(0).chain(function(){$("screen").remove()})},DoRegister:function(){var remoteobj=new XHR({method:"post",headers:{"content-type":"application/x-www-form-urlencoded"},onRequest:function(){$("email").style.border="solid 1px black";$("cemail").style.border="solid 1px black";$("passw").style.border="solid 1px black";$("cpassw").style.border="solid 1px black";$("displayname").style.border="solid 1px black";$("firstname").style.border="solid 1px black";$("lastname").style.border="solid 1px black";$("dob_day").style.border="solid 1px black";$("dob_month").style.border="solid 1px black";$("dob_year").style.border="solid 1px black"},onSuccess:function(){try{var resobj=eval("("+remoteobj.response.text+")");if(resobj.error){if(resobj.focusControl){if(resobj.setmultiplecontrols){resobj.controls.each(function(ctl){$(ctl).style.border="solid 2px red"})}else{$(resobj.control).style.border="solid 2px red";$(resobj.control).focus()}}alert(resobj.errormsg)}else{new Fx.Style($("registerFormContainer"),"opacity",{duration:250}).start(0).chain(function(){var remoteobj=new XHR({method:"get",onSuccess:function(){$("registerFormContainer").innerHTML=remoteobj.response.text;new Fx.Style($("registerFormContainer"),"opacity",{duration:500}).start(1)}}).send(resourcepath+"home/register","frmAction=register_success")})}}catch(excep){alert("Error encountered. Please re-try again.")}},onFailure:function(){alert("Error encountered. Please re-try again.")}}).send(resourcepath+"home/register","frmAction=register&"+$("registerFrm").toQueryString())}},login:function(){if($("fpemail").value.trim()==""){alert("Please enter your login details.");$("fpemail").focus();return}if($("login_passw").value.trim()==""){alert("Password field cannot be empty.");$("login_passw").focus();return}var remoteobj=new XHR({method:"get",onRequest:function(){bwfu.screen.show();bwfu.loadtext.show("Please wait processing your request . . .")},onSuccess:function(){try{var jsonobj=eval("("+remoteobj.response.text+")");if(jsonobj.error){bwfu.loadtext.hide();alert(jsonobj.errormsg);bwfu.screen.hide()}else{bwfu.loadtext.hide();alert("You have been succesfully logged in. Click ok to continue ...");location.href=jsonobj.redirectlink}}catch(excep){bwfu.loadtext.hide();alert("Error encountered. Please re-try again.");bwfu.screen.hide()}},onFailure:function(){bwfu.loadtext.hide();alert("Error encountered. Please re-try again.");bwfu.screen.hide()}}).send(resourcepath+"member/ajaxlogin",$("loginform").toQueryString())},forgotpassword:function(){var remoteobj=new XHR({method:"get",onRequest:function(){bwfu.screen.show();bwfu.loadtext.show("Please wait processing your request . . .")},onSuccess:function(){try{var jsonobj=eval("("+remoteobj.response.text+")");if(jsonobj.error){bwfu.loadtext.hide();alert(jsonobj.errormsg);bwfu.screen.hide()}else{bwfu.loadtext.hide();alert("Email, containing your password, has been sent to your email account registered with us.");bwfu.screen.hide()}}catch(excep){bwfu.loadtext.hide();alert("Error encountered. Please re-try again.");bwfu.screen.hide()}},onFailure:function(){bwfu.loadtext.hide();alert("Error encountered. Please re-try again.");bwfu.screen.hide()}}).send(resourcepath+"member/ajaxlogin","frmAction=forgotpassword&email="+$("fpemail").value)},reportError:{createDialog:function(){var remoteobj=new XHR({method:"get",onRequest:function(){bwfu.screen.show();bwfu.loadtext.show("Please wait loading dialog . . .")},onSuccess:function(){try{var resobj=eval("("+remoteobj.response.text+")");if(resobj.error){bwfu.loadtext.hide();alert(resobj.errormsg);bwfu.screen.hide()}else{var dialog=new Element("DIV",{id:"reporterrordialog",styles:{position:"absolute","z-index":2,width:500,top:-1000,left:(window.getWidth()-500)/2,"background-color":"#bc0000"}});dialog.setHTML(Base64.decode(resobj.dialogdata));document.body.appendChild(dialog);bwfu.reportError.showDialog()}}catch(excep){bwfu.loadtext.hide();alert("Failed to load dialog. Please re-try again.");bwfu.screen.hide()}},onFailure:function(){bwfu.loadtext.hide();alert("Failed to load dialog. Please re-try again.");bwfu.screen.hide()}}).send(resourcepath+"home/reporterror","calledby=js&frmAction=getdialog")},showDialog:function(){if($("reporterrordialog")){bwfu.loadtext.hide();var a=$("reporterrordialog");new Fx.Style(a,"top",{duration:750}).start(window.getScrollTop()+((window.getHeight()-a.offsetHeight)/2))}},hideDialog:function(b){if($("reporterrordialog")){var a=$("reporterrordialog");new Fx.Style(a,"opacity",{duration:500}).start(0).chain(function(){a.setStyle("top",-1000);a.setStyle("opacity",1);if(b){bwfu.reportError.destroyDialog()}})}},destroyDialog:function(){if($("reporterrordialog")){var a=$("reporterrordialog");a.remove();bwfu.screen.hide()}},send:function(){var remoteobj=new XHR({method:"post",headers:{"content-type":"application/x-www-form-urlencoded"},onRequest:function(){bwfu.reportError.hideDialog();bwfu.loadtext.show("Please wait sending error report . . .")},onSuccess:function(){try{var resobj=eval("("+remoteobj.response.text+")");if(resobj.error){bwfu.loadtext.hide();alert(resobj.errormsg);bwfu.reportError.showDialog()}else{bwfu.loadtext.hide();alert("Your error report has been sent successfully.");bwfu.reportError.hideDialog(true)}}catch(excep){bwfu.loadtext.hide();alert("Failed to send error report. Please re-try again.");bwfu.reportError.showDialog()}},onFailure:function(){bwfu.loadtext.hide();alert("Failed to send error report. Please re-try again.");bwfu.reportError.showDialog()}}).send(resourcepath+"home/reporterror","calledby=js&frmAction=sendreport&"+$("errorreportfrm").toQueryString())}},addListBoxEntry:function(d,c){if(d.selectedIndex==-1){return}for(var a=0;a<c.options.length;a++){if(d.options[d.selectedIndex].text==c.options[a].text){return}}var b=new Element("OPTION",{value:d.options[d.selectedIndex].value});b.setHTML(d.options[d.selectedIndex].text);b.selected=true;c.appendChild(b)},removeListBoxEntry:function(a){if(a.selectedIndex==-1){return}if(!confirm("Are you sure to remove this from list ?")){return}a.options[a.selectedIndex].remove()},selectAllListData:function(b){if(b){for(counter=0;counter<b.length;counter++){var a=b[counter];for(itemcounter=0;itemcounter<a.options.length;itemcounter++){a.options[itemcounter].selected=true}}}},gmailFriendsServer:{initiate:function(){if($("invitegmailfriends").checked==true){this.createDialog()}else{this.discard()}},createDialog:function(){bwfu.screen.show();var a=new Element("DIV",{id:"logindialog",styles:{position:"absolute","z-index":"2",width:300,left:(window.getWidth()-300)/2,top:-500,"background-color":"#ac0000"}});a.setHTML('<div style="text-align: center; background-color: #bc0000; padding: 5px; color: white; font: bold 12px Arial;">Please enter your gmail account details</div>                             <div style="font: 11px verdana; color: black; background-color: white; padding: 10px;">                                 <table style="width: 100%;" cellspacing="5">                                     <tr>                                         <td align="left">Username</td>                                         <td align="left"><input id="gmail_username" type="text" class="textbox" style="width: 150px;" maxlength="255" />                                     </tr>                                     <tr>                                         <td align="left">Password</td>                                         <td align="left"><input id="gmail_password" type="password" class="textbox" style="width: 150px;" maxlength="255" />                                     </tr>                                 </table>                                 <div style="padding: 2px; text-align: center; font-size: 9px; font-family: verdana;"><Strong>Note : </strong>Your login details are never saved.</div>                             </div>                             <div style="background-color: #bc0000; padding: 5px; text-align: right;">                                 <button onclick="bwfu.gmailFriendsServer.getFriends()" style="font: 9px verdana;">Get It !</button>                                 <button onclick="$(\'invitegmailfriends\').checked=false; bwfu.gmailFriendsServer.destroyDialog();" style="font: 9px verdana;">Cancel</button>                             </div>');document.body.appendChild(a);this.showDialog()},showDialog:function(){if($("logindialog")){var a=$("logindialog");new Fx.Style(a,"top",{duration:500}).start(window.getScrollTop()+((window.getHeight()-a.offsetHeight)/2)).chain(function(){$("gmail_username").focus()})}},hideDialog:function(){if($("logindialog")){var a=$("logindialog");new Fx.Style(a,"top",{duration:500}).start(-500)}},destroyDialog:function(){this.hideDialog();if($("logindialog")){var a=$("logindialog");a.remove();bwfu.loadtext.hide();bwfu.screen.hide()}},getFriends:function(){if($("gmail_username").value.trim()===""){alert("Please enter your gmail username.");$("gmail_username").focus()}else{if($("gmail_password").value.trim()===""){alert("Please enter your password.");$("gmail_password").focus()}else{var remoteobj=new XHR({method:"post",headers:{"content-type":"application/x-www-form-urlencoded"},onRequest:function(){bwfu.gmailFriendsServer.hideDialog();bwfu.loadtext.show("Please wait loading your friends list . . .")},onSuccess:function(){try{var resobj=eval("("+remoteobj.response.text+")");if(resobj.error){bwfu.loadtext.hide();alert(resobj.errormsg);bwfu.gmailFriendsServer.showDialog()}else{var gmailfriends=resobj.friends;var container=$("friendslistcontainer");if(gmailfriends.length==0){container.setStyles({padding:10,"text-align":"center","font-family":"Arial, Sans-serif, helvetica","font-size":"14","font-weight":"bold"});container.setHTML("No contacts found !!!")}else{container.setStyles({padding:10,"padding-left":"25px","text-align":"center","font-family":"Arial, Sans-serif, helvetica","font-size":"12px"});var result='<table style="width: 100%" cellpadding="3" cellspacing="5">';var counter=0;for(;counter<gmailfriends.length;counter++){result+='<tr><td align="left"><input type="checkbox" name="gmailfriends['+counter+'][selected]" value="1" checked="checked" /> '+gmailfriends[counter].name+" [ "+gmailfriends[counter].email+' ]<input type="hidden" name="gmailfriends['+counter+'][name]" value="'+gmailfriends[counter].name+'" /><input type="hidden" name="gmailfriends['+counter+'][email]" value="'+gmailfriends[counter].email+'" /></td></tr>'}result+="</table>";container.setHTML(result);bwfu.gmailFriendsServer.destroyDialog()}}}catch(excep){bwfu.loadtext.hide();alert("Failed to fetch friends list. Please re-try again.");bwfu.gmailFriendsServer.showDialog()}},onFailure:function(){bwfu.loadtext.hide();alert("Failed to fetch friends list. Please re-try again.");bwfu.gmailFriendsServer.showDialog()}}).send(resourcepath+"home/getgmailfriends","calledby=js&u="+$("gmail_username").value+"&p="+$("gmail_password").value)}}},discard:function(){$("friendslistcontainer").setHTML(" ");$("friendslistcontainer").setStyle("padding",0)}},screen:{show:function(){if(window.ie){$$("select").each(function(b){b.style.visibility="hidden"})}var a=new Element("DIV",{id:"screen",styles:{position:"absolute","z-index":1,top:0,left:0,width:window.getWidth(),height:$("mainContainer").offsetHeight,"background-color":"black",opacity:0.85}});document.body.appendChild(a)},hide:function(){if($("screen")){var a=$("screen");new Fx.Style(a,"opacity",{duration:500}).start(0).chain(function(){a.remove();if(window.ie){$$("select").each(function(b){b.style.visibility="visible"})}})}}},loadtext:{show:function(a){var b=new Element("DIV",{id:"loadtext",styles:{position:"absolute","z-index":2,left:(window.getWidth()-400)/2,top:window.getScrollTop()+((window.getHeight()-16)/2),width:400,height:16,font:"bold 16px Tahoma",color:"white","text-align":"center"}});b.setHTML(a);document.body.appendChild(b)},hide:function(){if($("loadtext")){$("loadtext").remove()}}},resizePanels:function(){var d=$("panel_todaywishes").offsetHeight;var b=$("panel_mostwishedperson").offsetHeight;var c=$("panel_topwishers").offsetHeight;var a=0;if(d>=b){if(b>=c){a=d}else{if(d>=c){a=d}else{a=c}}}else{if(b>=c){a=b}else{a=c}}$("panel_todaywishes").setStyle("height",a);$("panel_mostwishedperson").setStyle("height",a);$("panel_topwishers").setStyle("height",a)}};var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(c){var a="";var k,h,f,j,g,e,d;var b=0;c=Base64._utf8_encode(c);while(b<c.length){k=c.charCodeAt(b++);h=c.charCodeAt(b++);f=c.charCodeAt(b++);j=k>>2;g=((k&3)<<4)|(h>>4);e=((h&15)<<2)|(f>>6);d=f&63;if(isNaN(h)){e=d=64}else{if(isNaN(f)){d=64}}a=a+this._keyStr.charAt(j)+this._keyStr.charAt(g)+this._keyStr.charAt(e)+this._keyStr.charAt(d)}return a},decode:function(c){var a="";var k,h,f;var j,g,e,d;var b=0;c=c.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(b<c.length){j=this._keyStr.indexOf(c.charAt(b++));g=this._keyStr.indexOf(c.charAt(b++));e=this._keyStr.indexOf(c.charAt(b++));d=this._keyStr.indexOf(c.charAt(b++));k=(j<<2)|(g>>4);h=((g&15)<<4)|(e>>2);f=((e&3)<<6)|d;a=a+String.fromCharCode(k);if(e!=64){a=a+String.fromCharCode(h)}if(d!=64){a=a+String.fromCharCode(f)}}a=Base64._utf8_decode(a);return a},_utf8_encode:function(b){b=b.replace(/\r\n/g,"\n");var a="";for(var e=0;e<b.length;e++){var d=b.charCodeAt(e);if(d<128){a+=String.fromCharCode(d)}else{if((d>127)&&(d<2048)){a+=String.fromCharCode((d>>6)|192);a+=String.fromCharCode((d&63)|128)}else{a+=String.fromCharCode((d>>12)|224);a+=String.fromCharCode(((d>>6)&63)|128);a+=String.fromCharCode((d&63)|128)}}}return a},_utf8_decode:function(a){var b="";var d=0;var e=c1=c2=0;while(d<a.length){e=a.charCodeAt(d);if(e<128){b+=String.fromCharCode(e);d++}else{if((e>191)&&(e<224)){c2=a.charCodeAt(d+1);b+=String.fromCharCode(((e&31)<<6)|(c2&63));d+=2}else{c2=a.charCodeAt(d+1);c3=a.charCodeAt(d+2);b+=String.fromCharCode(((e&15)<<12)|((c2&63)<<6)|(c3&63));d+=3}}}return b}};