
var catIdHolder;var contentTypeHolder;YAHOO.util.Event.onDOMReady(function(){catIdHolder=new GupShup.forms.controls({name:'picCategory.catId'});contentTypeHolder=new GupShup.forms.controls({name:'picCategory.richContentType'});});GupShup.util.disableRightClick();(function(){GupShup.html.picLib={};GupShup.html.picLib.activeId=-1;GupShup.html.picLib.isGalleryPage=false;GupShup.html.picLib.setActiveId=function(id){GupShup.html.picLib.activeId=id;};GupShup.html.picLib.setPreviewGreeting=function(img){switch(img.contentType)
{case"IMAGE":case"GREETINGS":{GupShup.html.util.hideElement("polytuneAVGreetingContainer");GupShup.html.util.showElement("webarooGreetings");var picList=document.getElementsByName("selectedImage");for(var i=0;i<picList.length;i++)
{picList[i].src=img.url;var descDiv=picList[i].parentNode.getElementsByTagName("DIV");for(var j=0;j<descDiv.length;j++)
descDiv[j].innerHTML=img.text;}
document.forms['greetingInfo'].type.value="IMAGE";}break;case"POLYTONE":case"TRUETONE":case"WALLPAPER":case"THEME":case"AUDIO":case"VIDEO":GupShup.html.util.hideElement("webarooGreetings");GupShup.html.util.showElement("polytuneAVGreetingContainer");GupShup.util.setInnerHTML("polytuneAVGreeting",GupShup.html.picLib.getHTMLStringOfPictures([img],true,false));document.forms['greetingInfo'].type.value=img.contentType;break;}
GupShup.util.setInnerHTML("attachedGreetingHeader",GupShup.conf.richContentTypes[img.contentType].camelCase);document.forms['greetingInfo'].cost.value=img.cost;document.forms['greetingInfo'].desc.value=img.text;};GupShup.html.picLib.renderCategoryList=function(catStr){var catObj=GupShup.util.getJsonFromResponse(catStr);var sortedCats=catObj.smsRichContentCategories.sort(GupShup.html.picLib.sortCategoryList);var html=GupShup.util.expandTemplate(GupShup.util.getInnerHTML('catTemplate'),GupShup.html.picLib.map.catTemplate,sortedCats);GupShup.util.setInnerHTML('catListContainer',html);};GupShup.html.picLib.sortCategoryList=function(cat1,cat2){return GupShup.conf.richContentTypes[cat1.richContentType].rank-GupShup.conf.richContentTypes[cat2.richContentType].rank;};GupShup.html.picLib.renderFeaturedContent=function(content){var contentObj=GupShup.util.getJsonFromResponse(content);var html=GupShup.util.expandTemplate(GupShup.util.getInnerHTML('featuredRichContentTemplate'),GupShup.html.picLib.map.featuredRichContent,[contentObj]);GupShup.util.setInnerHTML('featuredRichContent',html);GupShup.html.picLib.showFeaturedContent();};GupShup.html.picLib.clearCategoryHighlighting=function(){var catList=document.getElementsByName('richContentCategory');for(var i=0;i<catList.length;i++)
{catList[i].className="";}}
GupShup.html.picLib.highlightSubCategory=function(catId,type){GupShup.html.picLib.clearCategoryHighlighting();var catList=document.getElementsByName('richContentCategory');for(var i=0;i<catList.length;i++)
{if(catList[i].id==("richContentCategory_"+type+"_"+catId))
catList[i].className="active";}};GupShup.html.picLib.highlightCategory=function(type){GupShup.html.picLib.clearCategoryHighlighting();GupShup.html.picLib.expandCategoryList(type);var catList=document.getElementsByName('richContentCategory');for(var i=0;i<catList.length;i++)
{if(catList[i].id==("richContentCategory_"+type))
catList[i].className="active";}};GupShup.html.picLib.collapseCategoryList=function(){var catList=document.getElementsByName('richContentSubCategories');for(var i=0;i<catList.length;i++)
{catList[i].style.display="none";}}
GupShup.html.picLib.expandCategoryList=function(type){GupShup.html.picLib.collapseCategoryList();var catList=document.getElementsByName('richContentSubCategories');for(var i=0;i<catList.length;i++)
{if(catList[i].id==("richContentSubCategories_"+type))
{catList[i].style.display="block";}}};GupShup.html.picLib.showFeaturedContent=function(){GupShup.html.picLib.clearCategoryHighlighting();GupShup.html.picLib.collapseCategoryList();GupShup.util.setInnerHTML("paginationContent","");GupShup.util.setInnerHTML("catRichContent","");GupShup.html.util.showElement("featuredRichContent");};GupShup.html.picLib.getContentType=function(pic){if(pic.contentType!="IMAGE")
return pic.contentType;if(parseInt(pic.cost)>0||GupShup.util.trim(pic.text).length>0)
return"GREETINGS";else
return"IMAGE";};GupShup.html.picLib.unselectGreeting=function(){GupShup.html.picLib.setActiveId(-1);};GupShup.html.picLib.getSelectedGreeting=function()
{var picList=document.getElementsByName("picMsg");for(var i=0;i<picList.length;i++)
{switch(picList[i].tagName)
{case"IMG":if(picList[i].alt==GupShup.html.picLib.activeId)
return picList[i];case"EMBED":case"OBJECT":var idStr=picList[i].id;if(idStr.indexOf(GupShup.html.picLib.activeId)>-1)
return picList[i];}}
return{};};GupShup.html.picLib.selectGreeting=function(imgId)
{var picList=document.getElementsByName("picMsg");for(i=0;i<picList.length;i++)
{switch(picList[i].tagName)
{case"IMG":if(picList[i].alt==imgId)
GupShup.html.picLib.setActiveId(imgId);break;case"EMBED":case"OBJECT":var idStr=picList[i].id;if(idStr.indexOf(imgId)>-1)
GupShup.html.picLib.setActiveId(imgId);break;}}};GupShup.html.picLib.getHTMLStringOfPictures=function(picList,forPicGallery,show_Cost){var op='';for(var i=0;i<picList.length;i++)
{picList[i].showCost=show_Cost;picList[i].greetingClass=show_Cost?"greetingFloat":"";var pic=picList[i];if(typeof pic.imageUrl=="undefined")
pic.imageUrl="";var tmpl='';var ele='';var clearFix='';var contentType=GupShup.html.picLib.getContentType(pic);if(forPicGallery)
{switch(contentType)
{case'IMAGE':ele='picGalleryImageTemplate';clearFix="<div style=\"clear:both\"></div>";break;case'GREETINGS':ele='greetingGalleryImageTemplate';clearFix="<div style=\"clear:both\"></div>";break;case'AUDIO':case'TRUETONE':case'POLYTONE':ele='tonesContainerTemplate';break;case'VIDEO':ele='videoContainerTemplate';break;case'WALLPAPER':case'THEME':ele='themesContainerTemplate';break;}}
else
{switch(contentType)
{case'IMAGE':ele='picLibImageTemplate';clearFix="<div style=\"clear:both\"></div>";break;case'GREETINGS':ele='greetingLibImageTemplate';clearFix="<div style=\"clear:both\"></div>";break;case'AUDIO':case'TRUETONE':case'POLYTONE':ele='tonesContainerTemplate';break;case'VIDEO':ele='videoContainerTemplate';break;case'WALLPAPER':case'THEME':ele='themesContainerTemplate';break;}}
tmpl=GupShup.util.getInnerHTML(ele);if(i>0&&i%3==0)
op+=clearFix;var html=GupShup.util.expandTemplate(tmpl,GupShup.templates.picLibImageMap,[pic]);op+=html.replace('<!--','').replace('-->','');var formName="greetingInfo_"+pic.id;GupShup.util.createAndAppendDummyForm(formName,"desc",pic.text,"cost",pic.cost,"type",contentType,"src",pic.url,"title",pic.title,"id",pic.id,"imageUrl",pic.imageUrl);}
return op;};GupShup.html.picLib.getPicListStringWithPagination=function(smsRichContentGal,contentType,forPicGallery){var smsPictures=smsRichContentGal.smsRichContent;var paginationContent="";var galleryContent="";var ele=new Array();var paginationObj={start:smsRichContentGal.params.start,total:smsRichContentGal.totalForPg,returned:smsPictures.length,windowSize:GupShup.conf.windowSize,listType:GupShup.conf.richContentTypes[contentType].name};var reqObj={url:GupShup.conf.readUrl,queryStr:"type=SMS_RICH_CONTENT_LIST&catId="+smsRichContentGal.catId+"&richContentType="+contentType,callBack:{success:GupShup.callback.processPicLibResponse,failure:GupShup.callback.processPicLibResponse,argument:smsRichContentGal.argument}};paginationContent=GupShup.util.expandPaginationTemplate(reqObj,paginationObj,'PICGALLERY_'+contentType+"_"+(smsRichContentGal.catId>0?smsRichContentGal.catId:''));var op=GupShup.html.picLib.getHTMLStringOfPictures(smsPictures,forPicGallery,true);return{content:op,pagination:paginationContent};};GupShup.html.picLib.getCategoryContent=function(type){if((catIdHolder.get('value')==-1)&&(contentTypeHolder.get('value')==type))
return;catIdHolder.set(-1);contentTypeHolder.set(type);GupShup.html.picLib.highlightCategory(type);var callback={success:GupShup.callback.processPicLibResponse,failure:GupShup.callback.processPicLibResponseErr}
GupShup.html.util.submitFormUsingAjax('POST',GupShup.conf.readUrl,callback,'picCategory');};GupShup.html.picLib.getSubCategoryContent=function(catId,type){if((catIdHolder.get('value')==catId)&&(contentTypeHolder.get('value')==type))
return;catIdHolder.set(catId);contentTypeHolder.set(type);GupShup.html.picLib.highlightSubCategory(catId,type);var callback={success:GupShup.callback.processPicLibResponse,failure:GupShup.callback.processPicLibResponseErr}
GupShup.html.util.submitFormUsingAjax('POST',GupShup.conf.readUrl,callback,'picCategory');};GupShup.html.picLib.processPicLibCustomResponse=function(text){var xhr=new Object();xhr.responseText=text;GupShup.callback.processPicLibResponse(xhr);};GupShup.callback.processPicLibResponse=function(xhr){var smsPicGal=GupShup.util.getJsonFromResponse(xhr.responseText);var op=GupShup.html.picLib.getPicListStringWithPagination(smsPicGal,contentTypeHolder.getValue(),GupShup.html.picLib.isGalleryPage);var subCatheaderObj={};if(smsPicGal.catId>0)
subCatheaderObj.title=smsPicGal.catDetails.title;else
subCatheaderObj.title=smsPicGal.title;subCatheaderObj.richContentType=smsPicGal.params.richContentType;var subCatheader=GupShup.util.expandTemplate(GupShup.util.getInnerHTML("richContentSubHeader"),GupShup.html.picLib.map.richContentSubHeader,[subCatheaderObj]);GupShup.html.util.hideElement("featuredRichContent");GupShup.util.setInnerHTML('catRichContent',subCatheader+op.content);GupShup.util.setInnerHTML('paginationContent',op.pagination);};GupShup.callback.processPicLibResponseErr=function(){};})();(function(){GupShup.html.picLib.map={};GupShup.html.picLib.map.methods={getSuperCatExpansion:function(richContent_Type){var expObj=[{richContentType:richContent_Type,title:richContent_Type}];return GupShup.util.expandTemplate(GupShup.util.getInnerHTML('superCatListTemplate'),GupShup.html.picLib.map.superCatListTemplate,expObj);},getSubCatExpansion:function(subCatList,data){if(subCatList.length<1)
return"";else
{for(var i=0;i<subCatList.length;i++)
subCatList[i].richContentType=data.richContentType;return GupShup.util.expandTemplate(GupShup.util.getInnerHTML('subCatListTemplate'),GupShup.html.picLib.map.subCatListTemplate,subCatList);}},getRichSubContentExpansion:function(smsRichContent){return GupShup.html.picLib.getHTMLStringOfPictures(smsRichContent,GupShup.html.picLib.isGalleryPage,true);},getRichSubContentExpansionClass:function(type){return((type=="AUDIO")||(type=="POLYTONE")||(type=="TRUETONE"))?"tones":"";},getSubCatHeaderExpansion:function(type){var expObj=[{richContentType:type}];return GupShup.util.expandTemplate(GupShup.util.getInnerHTML('featuredSubContentHeaderTemplate'),GupShup.html.picLib.map.featuredRichSubHeader,expObj);},getFeaturedRichContent:function(data){var sortedCats=data.sort(GupShup.html.picLib.sortCategoryList);return GupShup.util.expandTemplate(GupShup.util.getInnerHTML('featuredRichSubContentTemplate'),GupShup.html.picLib.map.featuredRichSubContent,sortedCats);},getSuperCatTitle:function(type){return GupShup.conf.richContentTypes[type].name;}};GupShup.html.picLib.map.superCatListTemplate=[{key:'$CONTENT_TYPE$',dataMember:'richContentType'},{key:'$CAT_TITLE$',dataMember:'richContentType',dataProcessor:GupShup.html.picLib.map.methods.getSuperCatTitle}];GupShup.html.picLib.map.subCatListTemplate=[{key:'$CONTENT_TYPE$',dataMember:'richContentType'},{key:'$CATID$',dataMember:'id'},{key:'$CAT_TITLE$',dataMember:'title'}];GupShup.html.picLib.map.catTemplate=[{key:'$CONTENT_TYPE$',dataMember:'richContentType'},{key:'$SUPER_CAT_EXPANSION$',dataMember:'richContentType',dataProcessor:GupShup.html.picLib.map.methods.getSuperCatExpansion},{key:'$SUBCATLIST$',dataMember:'subCategories',dataProcessor:GupShup.html.picLib.map.methods.getSubCatExpansion}];GupShup.html.picLib.map.featuredRichSubHeader=[{key:'$CONTENT_TYPE$',dataMember:'richContentType'},{key:'$CAT_TITLE$',dataMember:'richContentType',dataProcessor:GupShup.html.picLib.map.methods.getSuperCatTitle}];GupShup.html.picLib.map.richContentSubHeader=[{key:'$CONTENT_TYPE$',dataMember:'richContentType'},{key:'$CAT_TITLE$',dataMember:'title'},{key:'$SUPER_CAT_TITLE$',dataMember:'richContentType',dataProcessor:GupShup.html.picLib.map.methods.getSuperCatTitle}];GupShup.html.picLib.map.featuredRichSubContent=[{key:'$RICHCONTENT_SUB_HEADER$',dataMember:'richContentType',dataProcessor:GupShup.html.picLib.map.methods.getSubCatHeaderExpansion},{key:'$RICHCONTENT_UNITS$',dataMember:'smsRichContent',dataProcessor:GupShup.html.picLib.map.methods.getRichSubContentExpansion},{key:'$TONE_CLASS$',dataMember:'richContentType',dataProcessor:GupShup.html.picLib.map.methods.getRichSubContentExpansionClass}];GupShup.html.picLib.map.featuredRichContent=[{key:'$FEATURED_RICH_CONTENT$',dataMember:'featuredRichContent',dataProcessor:GupShup.html.picLib.map.methods.getFeaturedRichContent}];})();(function(){GupShup.html.picLib.popupId='picGalleryPopUp';;GupShup.html.picLib.showPostPopUp=function(ref,imgId,forGreeting){var popup='mainPopUp';if(forGreeting==true)
popup='mainPopUpForGreeting';var obj=document.getElementById(popup);var pos=GupShup.html.util.getElementPosition(ref);var objW=obj.offsetWidth;if(typeof GupShup.html.picLib[popup]=='undefined')
{GupShup.html.picLib[popup]=new YAHOO.widget.Menu(popup,{position:"dynamic",x:(pos.x),y:(pos.y+pos.h+5),clicktohide:true});GupShup.html.picLib[popup].render();}
else
{GupShup.html.picLib[popup].cfg.setProperty("x",(pos.x));GupShup.html.picLib[popup].cfg.setProperty("y",(pos.y+pos.h+5));}
GupShup.html.picLib[popup].show();GupShup.html.picLib.setActiveId(imgId);}
GupShup.html.picLib.showRhtBarPostPopUp=function(ref,imgId,iframeId){var obj=document.getElementById('sidePopUp');var pos=GupShup.html.util.getElementPosition(ref);if(typeof iframeId=="string")
{var iframe=GupShup.html.util.getElementPosition(document.getElementById(iframeId));pos.x+=iframe.x;pos.y+=iframe.y;}
var objW=obj.offsetWidth;if(typeof GupShup.html.picLib.sidePopup=='undefined')
{GupShup.html.picLib.sidePopup=new YAHOO.widget.Menu("sidePopUp",{position:"dynamic",x:(pos.x),y:(pos.y+pos.h+5),clicktohide:true});GupShup.html.picLib.sidePopup.render();}
else
{GupShup.html.picLib.sidePopup.cfg.setProperty("x",(pos.x));GupShup.html.picLib.sidePopup.cfg.setProperty("y",(pos.y+pos.h+5));}
GupShup.html.picLib.sidePopup.show();GupShup.html.picLib.setActiveId(imgId);}
GupShup.html.picLib.closePicGallery=function(location){if(GupShup.html.picLib.activeId>0)
{var del="?";if(location.indexOf("?")>0)
del="&";GupShup.html.actions.pageReload(location+del+"picId="+GupShup.html.picLib.activeId);}}
GupShup.html.picLib.sendPicPendingAction=function(params){GupShup.html.pendingAction.sendPicPendingAction(params+GupShup.html.picLib.activeId);GupShup.html.util.hideElement(GupShup.html.picLib.popupId);}})();GupShup.html.picLib.showPreview=function(imgId){GupShup.html.picLib.selectGreeting(imgId);if(GupShup.html.picLib.activeId>0)
{var greeting=GupShup.html.picLib.getSelectedGreeting();if(greeting.tagName=="IMG"||greeting.tagName=="OBJECT"||greeting.tagName=="EMBED")
{var greetingForm="greetingInfo_"+imgId;var greetingCost=parseInt(document.forms[greetingForm].cost.value);var type=GupShup.util.trim(document.forms[greetingForm].type.value);var src=GupShup.util.trim(document.forms[greetingForm].src.value);var desc=GupShup.util.trim(document.forms[greetingForm].desc.value);var ttl=GupShup.util.trim(document.forms[greetingForm].title.value);var imgurl=GupShup.util.trim(document.forms[greetingForm].imageUrl.value);var imgObj={text:desc,url:src,cost:greetingCost,contentType:type,title:ttl,id:imgId,imageUrl:imgurl}
GupShup.html.picLib.setPreviewGreeting(imgObj);GupShup.html.picLib.switchGreetingForms(imgObj);GupShup.html.picLib.closeLib();}}
else
{GupShup.html.picLib.unselectGreeting();}};GupShup.html.picLib.switchGreetingForms=function(greeting){switch(greeting.contentType)
{case"GREETINGS":case"IMAGE":{if(greeting.cost>0||greeting.text.length>0)
{if(greeting.text.length>0)
GupShup.html.postUtils.switchMsgType('GREETING');else
GupShup.html.postUtils.switchMsgType('GREETING_TEXT');}
else
GupShup.html.postUtils.switchMsgType('PIC');}break;case"POLYTONE":case"TRUETONE":case"VIDEO":case"WALLPAPER":case"THEME":case"AUDIO":GupShup.html.postUtils.switchMsgType('GREETING');break;}};GupShup.html.picLib.closeLib=function(){if(GupShup.html.picLib.activeId<1)
{GupShup.html.postUtils.switchMsgType('TEXT');}
GupShup.html.util.hideElement('PICLIB_TABS');GupShup.html.util.hideElement('GREETINGLIB_TABS');GupShup.html.util.changeTagsDisplayTo(document,'SELECT','BLOCK');};GupShup.html.picLib.showLib=function(type){var ele="";switch(type)
{case'IMAGE':ele='PICLIB_TABS';break;case'GREETINGS':ele='GREETINGLIB_TABS';break;}
GupShup.html.util.showElement(ele);GupShup.html.util.changeTagsDisplayTo(document,'SELECT','none');};GupShup.html.picLib.showForwardedPic=function(selectedPicId,selectedPicJson){if(selectedPicId>0)
{var pic=GupShup.util.getJsonFromResponse(selectedPicJson);if(pic.id>0)
{GupShup.html.picLib.setActiveId(pic.id);GupShup.html.picLib.setPreviewGreeting(pic);GupShup.html.picLib.switchGreetingForms(pic);}}
return;};(function(){GupShup.html.postUtils={};GupShup.html.postUtils.validateMessage=function(msgControl){var content=msgControl.get('value');content=content.replace(/\r/gi,"");var len=msgControl.get('limit');if(content.length>len)
{GupShup.forms.showNotification(GupShup.html.errorMessages.getPostMsgLengthErr(len),{failure:true});return false;}
else if(!GupShup.util.isAscii(content))
{GupShup.forms.showNotification(GupShup.html.errorMessages.nonAsciiPostErr,{failure:true});return false;}
else
return true;}
GupShup.html.postUtils.postMsgResponseHandler=function(xhr){var status=GupShup.util.getJsonFromResponse(xhr.responseText);var msgDetails=xhr.argument.details;switch(status.status)
{case'FAILURE':{var msg="";if(typeof status.throttledMessage=='string')
msg=status.message+"<br/>"+status.throttledMessage;else
msg=status.message;GupShup.forms.showNotification(msg,{failure:true});}
break;case'SUCCESS':{var err=GupShup.util.trim(status.errorCode);switch(err)
{case'SUCCESS':case'SUCCESS_CUSTOM':case'NO_ERROR':case'SUCCESS_WITH_BANNED_WORDS':case'P2P_PART_FAILURE':case'P2P_OWH_FAILURE':case'OWH':case'SPAM':{var msg="";if(typeof status.throttledMessage=='string')
msg=status.message+"<br/>"+status.throttledMessage;else
msg=status.message;if(err=='P2P_PART_FAILURE'||err=='OWH'||err=='P2P_OWH_FAILURE')
GupShup.forms.showNotification(msg,{failure:true});else
GupShup.forms.showNotification(msg);GupShup.html.picLib.unselectGreeting();if(xhr.argument.type=='POST_GROUP')
{GupShup.html.postGroupMsg.methods.renderPage(status);GupShup.html.groupPage.clearInputBoxes();}
else
{GupShup.html.postP2PMsg.methods.renderPage(status);GupShup.html.p2pPage.clearInputBoxes();GupShup.html.postUtils.publishPostP2PEvent();}
if(msgDetails.cost>0||msgDetails.type=="REPLY"||status.params.isPaidMessage==true)
{GupShup.html.postUtils.publishSuccessFulTransactionEvent(status.params.accountDetails,xhr.argument.type);GupShup.html.paidItems.methods.showPaidItemSentPopUp(status.params.accountDetails,msgDetails,xhr.argument.type);}}
break;case'THROTTLED':case'DUPLICATE':case'HAS_NON_ASCII':default:{GupShup.forms.showNotification(status.message,{failure:true});}
break;}}
break;case'WARNING':{if(confirm(status.message))
GupShup.html.postUtils.postMsg(xhr.argument.type,xhr.argument.name,false,msgDetails);}
break;}}
GupShup.html.postUtils.publishSuccessFulTransactionEvent=function(acctDetails,actionType){var event=new GupShup.html.event({name:"UPDATE_TRANSACTION",params:{accountDetails:acctDetails},source:actionType});event.publish();};GupShup.html.postUtils.publishPostP2PEvent=function(){var event=new GupShup.html.event({name:"POST_P2P",params:{},source:'POST_P2P'});event.publish();};GupShup.html.postUtils.publishPostTypeChangedEvent=function(type){var event=new GupShup.html.event({name:"POSTING_TYPE_CHANGED",params:{type:type},source:'POST_P2P'});event.publish();};GupShup.html.postUtils.postMsg=function(actType,formName,isChkMsg,msgDetails){var callBack={success:GupShup.html.postUtils.postMsgResponseHandler,failure:GupShup.html.postUtils.postMsgResponseHandler};if(GupShup.html.spam.acceptedNoSpam==false)
{switch(actType)
{case'POST_GROUP':GupShup.html.spam.showPopUp({fwdFunct:GupShup.html.groupPage.submit,args:msgDetails.type});break;case'POST_P2P':GupShup.html.spam.showPopUp({fwdFunct:GupShup.html.p2pPage.submit,args:msgDetails.type});break;}
return;}
callBack.argument={type:actType,name:formName,chkMsg:isChkMsg,details:msgDetails};var returnMsgType="";if(actType=="POST_GROUP")
returnMsgType="GROUP";var url=GupShup.conf.writeUrl+'&type='+actType+'&returnMsgType='+returnMsgType+'&checkMessage='+isChkMsg+"&limit="+GupShup.conf.ITEMS_PER_PAGE;GupShup.html.util.submitFormUsingAjax('POST',url,callBack,formName);}
GupShup.html.postUtils.switchToPaid=function(val){var radioBtns=document.getElementsByName("isPaidMessage");for(var i=0;i<radioBtns.length;i++)
{if(radioBtns[i].value==val)
radioBtns[i].checked=true;else
radioBtns[i].checked=false;}
var isGroupPost=false,isPaidMsg=false;if(typeof GupShup.html.groupPage=='object')
isGroupPost=true;if(val=='true')
isPaidMsg=true;var ele=GupShup.html.util.getElementsByClass("paidFreeMsgTip");var limit=isPaidMsg?(isGroupPost?GupShup.conf.paidGroupTextMessageLength:GupShup.conf.paidP2PTextMessageLength):(isGroupPost?GupShup.conf.grpMessageLength:GupShup.conf.textMessageLength);for(var i=0;i<ele.length;i++)
{if(isPaidMsg)
{ele[i].innerHTML=GupShup.html.toolTips.getPaidMsgTip(limit);}
else
{ele[i].innerHTML=GupShup.html.toolTips.freeMsgTip;}}
if(isPaidMsg)
GupShup.html.util.showElement('smsMsgCountHolder',true);else
GupShup.html.util.hideElement('smsMsgCountHolder');if(isGroupPost)
{GupShup.html.groupPage.controls[0].setAttr('limit',limit);GupShup.html.groupPage.controls[0].setFocus();}
else
{GupShup.html.p2pPage.controls[1].setAttr('limit',limit);GupShup.html.p2pPage.controls[1].setFocus();}}
GupShup.html.postUtils.isPaid=function(formName){var radioBtns=document.forms[formName].isPaidMessage;if(typeof radioBtns=="object")
{for(var i=0;i<radioBtns.length;i++)
{if((radioBtns[i].checked==true)&&(radioBtns[i].value=="true"))
return true;}}
return false;}
GupShup.html.postUtils.switchMsgType=function(type){switch(type)
{case'GREETING':document.forms['textMsg'].style.display='none';document.forms['picMsg'].style.display='none';document.forms['greetingMsg'].style.display='block';document.forms['greetingTextMsg'].style.display='none';break;case'GREETING_TEXT':document.forms['textMsg'].style.display='none';document.forms['picMsg'].style.display='none';document.forms['greetingMsg'].style.display='none';document.forms['greetingTextMsg'].style.display='block';break;case'PIC':document.forms['textMsg'].style.display='none';document.forms['picMsg'].style.display='block';document.forms['greetingMsg'].style.display='none';document.forms['greetingTextMsg'].style.display='none';break;case'TEXT':document.forms['picMsg'].style.display='none';document.forms['textMsg'].style.display='block';document.forms['greetingMsg'].style.display='none';document.forms['greetingTextMsg'].style.display='none';GupShup.html.picLib.unselectGreeting();break;}
GupShup.html.postUtils.publishPostTypeChangedEvent(type);}})();(function(){GupShup.html.errorMessages=GupShup.html.errorMessages||{incorrectLoginInfo:"Incorrect mobile phone or password. Please check your phone and password.",blankPhone:"Mobile number is not valid. Please enter a valid mobile number.",blankPassword:"Password is blank. Please enter your current password.",blankCaptcha:"Letters do not match. Please enter all the letters you see in the image above.",blankCaptchaAlert:"Please enter security code as shown in image",invalidPhone:"Mobile number is not valid. Please enter a valid mobile number.",invalidEmail:"Please select a valid Gtalk IM. For e.g. rakesh@gmail.com (We do not support Yahoo/MSN IM).",invalidEmailId:"Please enter valid email address. For e.g. rakesh@gmail.com",invalidVerifyCode:"The verification code should be 4 characters long.",invalidFileUpload:"Please upload valid .xls or .xlsx or .csv or .zip file.",invalidlogoUpload:"Please upload valid .jpg or .gif or .png file.",invalidHelpUpload:"Please upload valid .pdf file.",userBlocked:"User account blocked. Contact support@smsgupshup.com for more information.",internalError:"Something went wrong. It's probably a server error. Please try again.",blankCurrentPass:"Password is incorrect. Please enter your current password.",blankNewPass:"Password must be at least 5 characters in length.",verifyPassMismatch:"Passwords do not match.",passwordMismatch:"Please enter your current password.",currentPassLength:"Password must be at least 5 characters in length.",selectGender:"Please select your gender.",blankLocation:"Please enter a valid location.",blankName:"Name is not valid. Name must be less than 15 characters and must contain only letters, numbers and basic symbols (eg. , / ; &).",blankNick:"Nickname must be less than 10 characters and contain only letters or numbers or _.",invalidNick:"Nickname must be less than 10 characters and contain only letter or numbers or _.",blockedNick:"The Nick is not Allowed",PinvalidDescription:"About me section must be less than 500 characters and only contain letters, number and basic symbols (e.g. , / ; &).",GinvalidDescription:"Description is not valid. Description must be less than 200 characters and must only contain letters, numbers and basic symbols (e.g. , / ; &).",invalidDOB:"The date of birth is invalid.",blankDOB:"Date of birth is not valid. Please select your date, month and year of birth.",nonAsciiChar:"Some characters you entered are not permitted.",invalidImage:"Image must be in JPG or GIF format and smaller than 2MB.",blockedGroupName:"This group name is not allowed.",groupNameLength:"Group name is invalid. Group name must be 5-15 characters and only contain letters, numbers or '_'.",groupNameGivenLength:function(minLen,maxLen){return"Group name is invalid. Group name must be "+minLen+"-"+maxLen+" characters and only contain letters, numbers or '_'."},groupNameInUse:"Group name is taken.",invalidCharInGroup:"Please use letters, numbers and '_' only. No other special characters or spaces are allowed.",invalidGroupName:"Group name is invalid. Group name must be 5-15 characters and only contain letters, numbers or '_'.",invalidGreetingMsg:"Greeting message not valid. Greeting message must be less than 100 characters and contain only letters or numbers.",partnerInvalidGreetingMsg:"Greeting message not valid. Greeting message must be upto 1500 characters and contain only letters or numbers.",stopWordsInGreetingMsg:'Please do not use objectionable words in your greeting message.',p2pReceiverLimitReached:'You are not allowed to send a personal message to more than 15 mobile numbers at a time.',p2pInvalidReceiver:'One or more mobile numbers or group names are incorrectly entered. Please enter valid mobile numbers and group names.',p2pDuplicate:'One or more mobile numbers/group names are repated. Please remove duplicate numbers/group names.',postInvalidPicErr:'Please select picture to send to your friends.',postEmptyMsgErr:'Please enter message to send to your friends.',getPostMsgLengthErr:function(len){return"Message should be at most "+len+" characters long";},nonAsciiPostErr:'Unable to post the message. Only letters, numbers and basic symbols (e.g. , ; & /) are allowed.',groupPostDeleteFailure:'Error deleting the post. Please try again.',groupAvailible:'Group name available',invalidInvitePhone:'Some mobile numbers are invalid. Please enter valid Indian mobile numbers separated by commas. We do not support non-Indian mobile numbers. <br/>For example:9876543210, 9889198891, 9977199771.',invalidInviteEmail:'Some email addresses are invalid. Please enter valid email addresses separated by comma. <br/> For example:<br/>rakesh@gmail.com, anita@yahoo.com.',invalidInvite:'Please enter phone number or email addresses or both.',shareInvalidPhones:'Some mobile numbers are invalid. Please enter valid Indian mobile numbers separated by commas. We do not support non-Indian mobile numbers. <br/>For example:9876543210, 9889198891, 9977199771.',shareInvalidEmail:'Some email addresses are invalid. Please enter valid email addresses separated by comma. <br/> For example:rakesh@gmail.com, anita@yahoo.com.',shareLimitReached:'You are allowed to share the group with at most 15 users at a time.',shareInvalidFromEmail:'Email addresses are incorrectly entered, please enter valid email addresses in <b>From</b> field',reportOffensiveSuccess:'Thank you! The message has been flagged.',invalidDomain:'Please select valid domain.',invalidPassword:'Password is incorrect. Please enter your current password.',importContactsFail:'Error importing contacts from your account. Please try again.',importAuthFail:'Error importing contacts from your account. Please provide correct login information.',importSelectFreiend:'Please select friend(s) to whom you want to invite.',loginToGupShupMsg:'To use all features of GupShup you first need to <a href="'+GupShup.conf.contextPath+'/login">Log in</a> to GupShup. Don\'t have an account? <a href="'+GupShup.conf.contextPath+'/signup">Join Now</a>.',loginToForwardMsg:'You need to <a href="'+GupShup.conf.contextPath+'/login">login</a> to forward this message. Not on GupShup? <a href="'+GupShup.conf.contextPath+'/signup">Join now</a>.',loginToFlagMsg:'You need to <a href="'+GupShup.conf.contextPath+'/login">login</a> to flag this message. Not on GupShup? <a href="'+GupShup.conf.contextPath+'/signup">Join now</a>.',loginToJoinMsg:'You need to <a href="'+GupShup.conf.contextPath+'/login">login</a> to join this group. Not on GupShup? <a href="'+GupShup.conf.contextPath+'/signup">Join now</a>.',loginToJoinComMsg:'You need to <a href="'+GupShup.conf.contextPath+'/login">login</a> to join this Community. Not on GupShup? <a href="'+GupShup.conf.contextPath+'/signup">Join now</a>.',blankCategory:'Please select a category from the drop-down list that describes your group.',mergeSubscriber:'The new mobile number is already registered on GupShup. This number will be linked to your current account and all groups subscribed to this number will be removed. You can login using the new mobile number to access all groups subscribed to this number.',spamError:'You must agree to the GupShup Community Guidelines',noSubsriberSelected:'Please select subscriber to delete',pendingAjaxRequest:'Your current request is being processed.. Please try again later.',groupCreated:'You have successfully created GupShup group.',noFlagTypeSelected:'Please select the flag type.',noSubSelected:'Please select subject.',bigComment:'Please restrict your comment to 200 characters.',noComment:'Please enter your comment (must be less than 200 characters).',maxTagName:'Each tag name cannot be more than 20 characters long.',blockedTagName:'The Tag name is not allowed',invalidCharInTag:"Please use letters, numbers and '_' only. No other special characters or spaces are allowed.",stopWordsInComment:'Please do not use objectionable words in your comments.',sessionExpired:'Your session has expired. Please <a href="'+GupShup.conf.contextPath+'/login">click here</a> to re-login.',sessionExpiredNoLoginLink:'Your session has expired. Please re-login.',invalidSearchQuery:'Please enter a valid search query.',premiumSubInactiveAlert:'Subscriptions to one or more of your premium groups are inactive. Go to <a href="'+GupShup.conf.contextPath+'/manageSubscriptions">Manage</a> groups to pay & renew your subscriptions.',premiumSubRenewAlert:'Subscriptions for one or more of your premium groups are about to expire. Go to <a href="'+GupShup.conf.contextPath+'/manageSubscriptions">Manage</a> groups and pay the subscription fee to maintain uninterrupted access.',paySysDownError:'We are facing some difficulties right now and are unable to retrieve your Gupshup Account Details to process this action. Please try again later.',invalidPollName:function(len){return'Poll name must be less than '+len+' characters and should contain letters or numbers only.';},blockedPollName:'The Poll name is not Allowed. Please try another one.',duplicatePollName:'The Poll name is already taken. Please try another one.',validPollName:'The Poll name is allowed.',invalidPollOptions:'Please enter valid options for your question. Options must be atmost of 12 characters and contain only letters, numbers, space, _ or \'',duplicatePollOptions:'You have entered duplicate options for your question. Please enter valid unique options for your question.',invalidPollQ:'Please enter valid question to start poll. Question must be less than 120 characters and must only contain letters, numbers and basic symbols (e.g. , / ; &).',objectionablePoll:'Please do not use objectionable words in your poll question.',invalidPollDates:'Please select valid start and end date for your poll. The maximum time a poll can run is 30 days from its start date.',invitePhoneDuplicates:'One or more mobile numbers are repated. Please remove duplicate numbers.',getPollLimitReachedMsg:function(len){return'You are not allowed to invite more than '+len+' mobile numbers at a time.';},pollInvitePhone:'Please enter mobile numbers of friends to whom you want to invite.',invalidQuantity:'Please enter a valid quantity required.',blankAddress:'Please enter your address.',blankCity:'Please enter your city name.',blankState:'Please enter your state name.',blankPinCode:'Please enter your pincode.',invalidPinCode:'Please enter a valid pincode.',blankFirstName:'Please enter your first name as a single word.',blankLastName:'Please enter your last name as a single word.',replyLengthOverFlow:'Your reply was longer than the allowed limit ('+GupShup.conf.replyMessageLength+' chars) and couldn\'t be sent. Please shorten your reply and try again',invalidReply:'Please enter valid reply text.',nonAsciiReplyErr:'Unable to send reply. Only letters, numbers and basic symbols (e.g. , ; & /) are allowed.',getActivateMobileErr:function(code){return'We haven\'t received your message yet. It may take a couple of minutes to receive your message. Please try in a while';},identifireLimitError:'Max character limit is '+GupShup.conf.maxIdentifierLimit+' characters.',maxMessageCountInRequestError:'Max message limit is '+GupShup.conf.maxMessageCountInRequest+' messages.',numericMessageCountInRequestError:'Please enter valid number of messages you need.',numericValidityExtensionInRequestError:'Please enter valid days.',maxValidityExtensionInRequestError:'Max validity Extension limit is '+GupShup.conf.maxValidityExtensionInRequest+' days.'}})();(function(){GupShup.html.toolTips=GupShup.html.toolTips||{enterPhone:"Enter the phone number you use to log on to GupShup",enterPassword:"Enter your password",forgotPasswordPhone:"Please enter the phone number you registered with SMS GupShup - a new password will be sent to the phone.",forgotPasswordEmail:"Enter your email address given at the time of registration",enterReceivers:"Enter your friends phone number",enterMessage:"Enter your message here",nickTip:"Entering your full name will help your friends in recognizing you when you invite them",freeMsgTip:'Free messages are '+GupShup.conf.grpMessageLength+' characters in length.',getPaidMsgTip:function(len){var eg="";for(var k=1;k<Math.ceil(GupShup.conf.paidGroupTextMessageLength/GupShup.conf.paidSingleTextMessageLength);k++)
{if(k>2)
break;var length=k*GupShup.conf.paidSingleTextMessageLength;var cost=(k*GupShup.conf.paidMessageCost);cost=Math.round(cost*100)/100;if(eg.length>0)
eg+=" ";eg+=length+" chars(Rs. "+cost+"),";}
var msg='Paid messages are upto '+GupShup.conf.paidGroupTextMessageLength+' chars in length, ads-free & have faster delivery. Cost of a paid message depends on the message length: '+eg+'.....,'+GupShup.conf.paidGroupTextMessageLength+' chars(Rs. '+GupShup.conf.paidMessageMaxCost+').';return msg;}}})();(function(){GupShup.html.p2pPage={};GupShup.html.p2pPage.controls=new Array();var p2pReceivers={};var p2pMessage={};var picMsgId={};var p2pIsSentMsg={};var p2pFwdMsgId={};var p2pShowMessages={};p2pReceivers['TEXT']=GupShup.html.p2pPage.controls[0]=new GupShup.forms.controls({name:'textMsg.recvrList',dimText:GupShup.html.toolTips.enterReceivers,limit:-1,toolTip:''});p2pMessage['TEXT']=GupShup.html.p2pPage.controls[1]=new GupShup.forms.controls({name:'textMsg.text',dimText:GupShup.html.toolTips.enterMessage,limit:GupShup.conf.textMessageLength,toolTip:''});p2pReceivers['PIC']=GupShup.html.p2pPage.controls[2]=new GupShup.forms.controls({name:'picMsg.recvrList',dimText:GupShup.html.toolTips.enterReceivers,limit:-1,toolTip:''});p2pMessage['PIC']=GupShup.html.p2pPage.controls[3]=new GupShup.forms.controls({name:'picMsg.text',dimText:GupShup.html.toolTips.enterMessage,limit:GupShup.conf.pictureMessageLength,toolTip:''});picMsgId['PIC']=GupShup.html.p2pPage.controls[4]=new GupShup.forms.controls({name:'picMsg.picId'});p2pIsSentMsg['TEXT']=GupShup.html.p2pPage.controls[5]=new GupShup.forms.controls({name:'textMsg.isSentMsg'});p2pIsSentMsg['PIC']=GupShup.html.p2pPage.controls[6]=new GupShup.forms.controls({name:'picMsg.isSentMsg'});p2pFwdMsgId['PIC']=GupShup.html.p2pPage.controls[7]=new GupShup.forms.controls({name:'picMsg.msgId'});p2pFwdMsgId['TEXT']=GupShup.html.p2pPage.controls[8]=new GupShup.forms.controls({name:'textMsg.msgId'});p2pShowMessages['PIC']=GupShup.html.p2pPage.controls[9]=new GupShup.forms.controls({name:'picMsg.showMessages'});p2pShowMessages['TEXT']=GupShup.html.p2pPage.controls[10]=new GupShup.forms.controls({name:'textMsg.showMessages'});p2pMessage['GREETING']=GupShup.html.p2pPage.controls[11]=new GupShup.forms.controls({name:'greetingMsg.text',limit:0,toolTip:''});p2pReceivers['GREETING']=GupShup.html.p2pPage.controls[12]=new GupShup.forms.controls({name:'greetingMsg.recvrList',dimText:GupShup.html.toolTips.enterReceivers,limit:-1,toolTip:''});picMsgId['GREETING']=GupShup.html.p2pPage.controls[13]=new GupShup.forms.controls({name:'greetingMsg.picId'});p2pIsSentMsg['GREETING']=GupShup.html.p2pPage.controls[14]=new GupShup.forms.controls({name:'greetingMsg.isSentMsg'});p2pFwdMsgId['GREETING']=GupShup.html.p2pPage.controls[15]=new GupShup.forms.controls({name:'greetingMsg.msgId'});p2pShowMessages['GREETING']=GupShup.html.p2pPage.controls[16]=new GupShup.forms.controls({name:'greetingMsg.showMessages'});p2pMessage['GREETING_TEXT']=GupShup.html.p2pPage.controls[17]=new GupShup.forms.controls({name:'greetingTextMsg.text',dimText:GupShup.html.toolTips.enterMessage,limit:GupShup.conf.pictureMessageLength,toolTip:''});p2pReceivers['GREETING_TEXT']=GupShup.html.p2pPage.controls[18]=new GupShup.forms.controls({name:'greetingTextMsg.recvrList',dimText:GupShup.html.toolTips.enterReceivers,limit:-1,toolTip:''});picMsgId['GREETING_TEXT']=GupShup.html.p2pPage.controls[19]=new GupShup.forms.controls({name:'greetingTextMsg.picId'});p2pIsSentMsg['GREETING_TEXT']=GupShup.html.p2pPage.controls[20]=new GupShup.forms.controls({name:'greetingTextMsg.isSentMsg'});p2pFwdMsgId['GREETING_TEXT']=GupShup.html.p2pPage.controls[21]=new GupShup.forms.controls({name:'greetingTextMsg.msgId'});p2pShowMessages['GREETING_TEXT']=GupShup.html.p2pPage.controls[22]=new GupShup.forms.controls({name:'greetingTextMsg.showMessages'});var MAX_RECEIVER_LENGTH=15;GupShup.html.p2pPage.init=function(){GupShup.forms.controls.initControls(GupShup.html.p2pPage.controls);p2pMessage['TEXT'].addListner('counter',{holder:'textMsgSize'});p2pMessage['PIC'].addListner('counter',{holder:'picMsgSize'});p2pMessage['TEXT'].addListner('sms-counter',{holder:'smsMsgCount',startMsgLimit:GupShup.conf.paidSingleTextMessageLength,smsLimit:GupShup.conf.paidSingleTextMessageLength});p2pMessage['GREETING_TEXT'].addListner('counter',{holder:'greetingMsgSize'});}
GupShup.html.p2pPage.submit=function(type){var res=GupShup.html.p2pPage.validateP2pReceivers(p2pReceivers[type]);switch(res.status)
{case'INVALID':p2pReceivers[type].showNotification(GupShup.html.errorMessages.p2pInvalidReceiver,{failure:true});break;case'LIMITS_REACHED':p2pMessage[type].showNotification(GupShup.html.errorMessages.p2pReceiverLimitReached,{failure:true});break;case'DUPLICATE':p2pMessage[type].showNotification(GupShup.html.errorMessages.p2pDuplicate,{failure:true});break;case'VALID':var status=GupShup.html.postUtils.validateMessage(p2pMessage[type]);if(status)
{var currentTab=GupShup.html.postP2PMsg.controls.tabs.get('activeTab');var val=(currentTab.gupshupConf.tabName==GupShup.html.postP2PMsg.vars.tabNames.inbox)?"false":"true";p2pIsSentMsg[type].set(val);p2pShowMessages[type].set(val);switch(type)
{case'TEXT':{var contentLength=p2pMessage[type].get('length');if(contentLength>0&&!p2pMessage[type].isDefaultText())
{GupShup.html.postUtils.postMsg('POST_P2P','textMsg',true,{type:type});}
else
GupShup.forms.showNotification(GupShup.html.errorMessages.postEmptyMsgErr,{failure:true});}
break;case'PIC':{picMsgId[type].set(GupShup.html.picLib.activeId);if(picMsgId[type].get('value')>0)
{if(p2pMessage[type].isDefaultText())
p2pMessage[type].set("");GupShup.html.postUtils.postMsg('POST_P2P','picMsg',true,{type:type});}
else
GupShup.forms.showNotification(GupShup.html.errorMessages.postInvalidPicErr,{failure:true});}
break;case'GREETING_TEXT':case'GREETING':{picMsgId[type].set(GupShup.html.picLib.activeId);if(picMsgId[type].get('value')>0)
{if(p2pMessage[type].isDefaultText())
p2pMessage[type].set("");var formName="greetingInfo";var greetingCost=document.forms[formName].cost.value;var greetingType=document.forms[formName].type.value;if(greetingCost>0)
{var details={cost:greetingCost,itemType:greetingType,count:res.total,type:type,actionType:'P2P',postFunction:GupShup.html.p2pPage.postGreeting,redirectFunction:GupShup.html.p2pPage.redirectGreeting};GupShup.html.paidItems.methods.checkUserAccountBalanceForPaidItems(details);}
else
GupShup.html.postUtils.postMsg('POST_P2P','greetingMsg',true,{type:type});}
else
GupShup.forms.showNotification(GupShup.html.errorMessages.postInvalidPicErr,{failure:true});}
break;}}}};GupShup.html.p2pPage.postGreeting=function(details){switch(details.type)
{case'GREETING_TEXT':GupShup.html.postUtils.postMsg('POST_P2P','greetingTextMsg',true,details);break;case'GREETING':GupShup.html.postUtils.postMsg('POST_P2P','greetingMsg',true,details);break;case'PIC':GupShup.html.postUtils.postMsg('POST_P2P','picMsg',true,details);break;case'TEXT':GupShup.html.postUtils.postMsg('POST_P2P','textMsg',true,details);break;}};GupShup.html.p2pPage.redirectGreeting=function(details){if(details.cost<GupShup.conf.minimumPay)
details.cost=GupShup.conf.minimumPay
GupShup.html.actions.forwardToPaymentSystem(details.cost,GupShup.conf.phoneNumber,GupShup.conf.fromUrl+"/p2pgupshupspace?isSentMsg="+p2pIsSentMsg['GREETING'].getValue());};GupShup.html.p2pPage.validateP2pReceivers=function(recvrListControl){var content=recvrListControl.get('value');var count=0;if(content.length<5)
return{status:'INVALID'};var recvList=content.split(',');var p2pRecvIndex=0;var validRecvrs=new Array();for(p2pRecvIndex=0;p2pRecvIndex<recvList.length;p2pRecvIndex++)
{var recvr=GupShup.util.trim(recvList[p2pRecvIndex]);if(recvr.length>0)
{if(GupShup.util.isNumber(recvr)&&!GupShup.util.validatePhoneNumber(recvr))
return{status:'INVALID'};else if(!GupShup.util.isNumber(recvr)&&GupShup.util.isValidGroupName(recvr).code!='VALID')
return{status:'INVALID'};count++;if(count>MAX_RECEIVER_LENGTH)
return{status:'LIMITS_REACHED'};var validEntry=GupShup.util.isNumber(recvr)?GupShup.util.getValidIndianPhoneNumber(recvr):recvr;for(var i=0;i<validRecvrs.length;i++)
{if(validRecvrs[i]==validEntry)
return{status:'DUPLICATE'};}
validRecvrs.push(validEntry);}}
return{status:'VALID',total:count};};GupShup.html.p2pPage.clearInputBoxes=function(event){p2pReceivers['TEXT'].set('');p2pMessage['TEXT'].set('');p2pReceivers['GREETING'].set('');p2pReceivers['GREETING_TEXT'].set('');p2pReceivers['PIC'].set('');p2pMessage['PIC'].set('');p2pMessage['GREETING'].set('');p2pMessage['GREETING_TEXT'].set('');p2pFwdMsgId['PIC'].set('');p2pFwdMsgId['TEXT'].set('');p2pFwdMsgId['GREETING'].set('');p2pFwdMsgId['GREETING_TEXT'].set('');GupShup.html.postUtils.switchMsgType('TEXT');}
GupShup.html.p2pPage.copyContent=function(event){var pic=p2pReceivers['PIC'].isDefaultText()?"":p2pReceivers['PIC'].getValue();var text=p2pReceivers['TEXT'].isDefaultText()?"":p2pReceivers['TEXT'].getValue();var greeting=p2pReceivers['GREETING'].isDefaultText()?"":p2pReceivers['GREETING'].getValue();var greeting_text=p2pReceivers['GREETING_TEXT'].isDefaultText()?"":p2pReceivers['GREETING_TEXT'].getValue();var val=pic.length>0?pic:(text.length>0?text:(greeting.length>0?greeting:greeting_text));switch(event.params.type)
{case'PIC':p2pReceivers['PIC'].set(val);break;case'TEXT':p2pReceivers['TEXT'].set(val);break;case'GREETING':p2pReceivers['GREETING'].set(val);break;case'GREETING_TEXT':p2pReceivers['GREETING_TEXT'].set(val);break;}}})();(function(){GupShup.events.register({name:'POSTING_TYPE_CHANGED',identifier:'GupShup.html.p2pPage.copyContent',handler:GupShup.html.p2pPage.copyContent});})();GupShup.html.msgNReplies=GupShup.html.msgNReplies||{};GupShup.html.msgNReplies.vars={};GupShup.html.msgNReplies.controls={};GupShup.html.msgNReplies.methods={};GupShup.html.msgNReplies.handlers={preMsgStream:null,postMsgStream:null,preReplyStream:null,postReplyStream:null,msgStreamModifier:null,replyStreamModifier:null,errorMsgStream:null,errorReplyStream:null,prependToMsgStrem:null,prependToReplyStrem:null,prePageProcessor:null,postPageProcessor:null};var myMethods=GupShup.html.msgNReplies.methods;var myVars=GupShup.html.msgNReplies.controls;GupShup.html.msgNReplies.vars.replyAjaxReqType="REPLIES";GupShup.html.msgNReplies.vars.messagesAjaxReqType='ENTITY_MESSAGES_EXTERNAL';GupShup.html.msgNReplies.vars.pageName="";GupShup.html.msgNReplies.vars.fromPage="";GupShup.html.msgNReplies.vars.checkSpam=false;GupShup.html.msgNReplies.vars.pageTitlePrefix="";GupShup.html.msgNReplies.vars.entityId="";GupShup.html.msgNReplies.vars.msgStart="";GupShup.html.msgNReplies.vars.msglimit="";GupShup.html.msgNReplies.vars.getAllReplies=false;GupShup.html.msgNReplies.vars.filterReplies=true;GupShup.html.msgNReplies.vars.replyStart="";GupShup.html.msgNReplies.vars.replyLimit="";GupShup.html.msgNReplies.vars.replyCount=0;GupShup.html.msgNReplies.vars.repliesStates={};GupShup.html.msgNReplies.vars.replyNoContentTemplate="emptyTemplate";GupShup.html.msgNReplies.vars.msgesNoContentTemplate="emptyTemplate";GupShup.html.msgNReplies.vars.replyDefaultTextTemplate="emptyTemplate";GupShup.html.msgNReplies.vars.showTabs=true;GupShup.html.msgNReplies.vars.userId="";GupShup.html.msgNReplies.methods={updatePage:function(groupMsgInfo){var updatePostTab=true;var updateReplyTab=false;if(groupMsgInfo.status=='SUCCESS')
{if(typeof GupShup.html.msgNReplies.handlers.prePageProcessor=="function")
{var op=GupShup.html.msgNReplies.handlers.prePageProcessor(groupMsgInfo);updatePostTab=op.showPostTab;updateReplyTab=op.showReplyTab;}
GupShup.html.msgNReplies.methods.extractDetails(groupMsgInfo);if(GupShup.html.msgNReplies.vars.showTabs)
{GupShup.html.msgNReplies.methods.setupTabs();if(updatePostTab)
{if(typeof GupShup.html.msgNReplies.handlers.preMsgStream=="function")
GupShup.html.msgNReplies.handlers.preMsgStream(groupMsgInfo);GupShup.html.msgNReplies.methods.renderMsgStream(groupMsgInfo);if(typeof GupShup.html.msgNReplies.handlers.postMsgStream=="function")
GupShup.html.msgNReplies.handlers.postMsgStream(groupMsgInfo);}
else if(updateReplyTab)
{if(typeof GupShup.html.msgNReplies.handlers.preReplyStream=="function")
GupShup.html.msgNReplies.handlers.preReplyStream(groupMsgInfo);GupShup.html.msgNReplies.methods.renderReplyMsgStream(groupMsgInfo);if(typeof GupShup.html.msgNReplies.handlers.postReplyStream=="function")
GupShup.html.msgNReplies.handlers.postReplyStream(groupMsgInfo);}}
if(typeof GupShup.html.msgNReplies.handlers.postPageProcessor=="function")
GupShup.html.msgNReplies.handlers.postPageProcessor(groupMsgInfo);}
else
{GupShup.html.msgNReplies.methods.handleError(groupMsgInfo);if(updatePostTab)
{if(typeof GupShup.html.msgNReplies.handlers.errorMsgStream=="function")
GupShup.html.msgNReplies.handlers.errorMsgStream(groupMsgInfo);}
else if(updateReplyTab)
{if(typeof GupShup.html.msgNReplies.handlers.errorReplyStream=="function")
GupShup.html.msgNReplies.handlers.errorReplyStream(groupMsgInfo);}}},extractDetails:function(groupMsgInfo){if(GupShup.util.isInitialized(groupMsgInfo.entityDetails))
{GupShup.html.msgNReplies.vars.entityId=groupMsgInfo.entityDetails.id;GupShup.html.msgNReplies.vars.userId=groupMsgInfo.entityDetails.userId;if(typeof(groupMsgInfo.showPosts)!="undefined")
GupShup.html.msgNReplies.vars.showTabs=groupMsgInfo.showPosts;}},changePostTabName:function(totalForPg){GupShup.html.msgNReplies.controls.tabs.yahooTabView.getTab(0).set('label',GupShup.html.msgNReplies.vars.tabNames.posts+" ("+totalForPg+")");},changeReplyTabName:function(totalForPg){GupShup.html.msgNReplies.controls.tabs.yahooTabView.getTab(1).set('label',GupShup.html.msgNReplies.vars.tabNames.replies+" ("+totalForPg+")");},setupTabs:function(){if(!GupShup.util.isInitialized(GupShup.html.msgNReplies.controls.tabs))
GupShup.html.msgNReplies.methods.createTabs();},clearTabs:function(){GupShup.html.msgNReplies.controls.tabs=null;GupShup.util.setInnerHTML('groupMessagesTabContainer','');},createTabs:function(){var commonUrl=GupShup.conf.readUrl
+'&entityId='+GupShup.html.msgNReplies.vars.entityId
+'&checkSessionId=true'
+'&start=0'
+'&fromPage='+GupShup.html.msgNReplies.vars.fromPage
+'&checkSpam='+GupShup.html.msgNReplies.vars.checkSpam;GupShup.html.msgNReplies.vars.tabsConfig[0].gupshupConf.url=commonUrl+"&getReplyCount=true&&type="+GupShup.html.msgNReplies.vars.messagesAjaxReqType+'&limit='+GupShup.conf.ITEMS_PER_PAGE;;GupShup.html.msgNReplies.vars.tabsConfig[1].gupshupConf.url=commonUrl+"&type="+GupShup.html.msgNReplies.vars.replyAjaxReqType+"&getAll="+GupShup.html.msgNReplies.vars.getAllReplies+"&filterReplies="+GupShup.html.msgNReplies.vars.filterReplies+'&limit='+(GupShup.html.msgNReplies.vars.filterReplies?(GupShup.conf.ITEMS_PER_PAGE+1):GupShup.conf.ITEMS_PER_PAGE);GupShup.html.msgNReplies.controls.tabs=GupShup.util.createTabView(GupShup.html.msgNReplies.vars.tabsConfig,'groupMessagesTabContainer');GupShup.html.msgNReplies.controls.tabs.yahooTabView.addListener('activeTabChange',GupShup.html.msgNReplies.methods.handleActiveTabChange);},handleActiveTabChange:function(e){var oldTab=e.prevValue;var newTab=e.newValue;GupShup.connectionManager.addTransaction({obj:newTab.dataConnection,type:'TABSWITCH',onAbort:function(){newTab._loading=false;}});if(oldTab==newTab)
return;else
{GupShup.html.dynamicBar.update(oldTab.gupshupConf.tabType,newTab.gupshupConf.tabType,'right');var pageTitle=GupShup.html.msgNReplies.vars.pageTitlePrefix;if(newTab.gupshupConf.tabName==GupShup.html.msgNReplies.vars.tabNames.posts)
pageTitle+=" (Posts)";else
pageTitle+=" (Replies)";document.title=pageTitle;}},updatePageOnAjaxSuccess:function(request){var groupMsgInfo=GupShup.util.getJsonFromResponse(request.responseText);GupShup.html.msgNReplies.methods.updatePage(groupMsgInfo);},renderMsgStream:function(groupMsgInfo){var innerHTML='';if(GupShup.util.isInitialized(groupMsgInfo.params))
{if(GupShup.util.isInitialized(groupMsgInfo.params.start))
GupShup.html.msgNReplies.vars.msgStart=groupMsgInfo.params.start;else
GupShup.html.msgNReplies.vars.msgStart=0;if(GupShup.util.isInitialized(groupMsgInfo.params.limit))
GupShup.html.msgNReplies.vars.msglimit=groupMsgInfo.params.limit;else
GupShup.html.msgNReplies.vars.msglimit=GupShup.conf.ITEMS_PER_PAGE;}
if(groupMsgInfo.entityMessages.length>0)
{innerHTML=GupShup.html.msgNReplies.methods.expandGroupMsgs(groupMsgInfo);innerHTML+=GupShup.html.msgNReplies.methods.expandPagination(groupMsgInfo,GupShup.html.msgNReplies.vars.messagesAjaxReqType);}
else
{innerHTML=GupShup.util.getInnerHTML(GupShup.html.msgNReplies.vars.msgesNoContentTemplate);}
if(GupShup.html.msgNReplies.controls.tabs.get('activeIndex')!=0)
{GupShup.html.msgNReplies.methods.clearTabs();GupShup.html.msgNReplies.methods.setupTabs();}
if(typeof groupMsgInfo.replyCount=='number')
GupShup.html.msgNReplies.vars.replyCount=groupMsgInfo.replyCount;GupShup.html.msgNReplies.methods.changePostTabName(groupMsgInfo.totalForPg);if(!GupShup.html.msgNReplies.vars.filterReplies)
GupShup.html.msgNReplies.methods.changeReplyTabName(GupShup.html.msgNReplies.vars.replyCount);GupShup.html.msgNReplies.controls.tabs.set(0,innerHTML);},renderReplyMsgStream:function(replyMsgInfo){var innerHTML='';if(GupShup.util.isInitialized(replyMsgInfo.params))
{if(GupShup.util.isInitialized(replyMsgInfo.params.start))
GupShup.html.msgNReplies.vars.replyStart=replyMsgInfo.params.start;else
GupShup.html.msgNReplies.vars.replyStart=0;if(GupShup.util.isInitialized(replyMsgInfo.params.limit))
GupShup.html.msgNReplies.vars.replyLimit=replyMsgInfo.params.limit;else
{if(GupShup.html.msgNReplies.vars.filterReplies)
GupShup.html.msgNReplies.vars.replyLimit=GupShup.conf.ITEMS_PER_PAGE+1;else
GupShup.html.msgNReplies.vars.replyLimit=GupShup.conf.ITEMS_PER_PAGE;}}
var rArray=replyMsgInfo.entityReplies;if(rArray.length>0)
{GupShup.html.msgNReplies.vars.currPageStart=replyMsgInfo.params.start;GupShup.html.msgNReplies.vars.repliesStates[replyMsgInfo.params.start]=rArray[0].id;GupShup.html.msgNReplies.vars.nextPageStartId=rArray[rArray.length-1].id;var pg=GupShup.html.msgNReplies.methods.expandPagination(replyMsgInfo,GupShup.html.msgNReplies.vars.replyAjaxReqType);if(GupShup.html.msgNReplies.vars.filterReplies&&(rArray.length>GupShup.conf.ITEMS_PER_PAGE))
replyMsgInfo.entityReplies=replyMsgInfo.entityReplies.slice(0,GupShup.conf.ITEMS_PER_PAGE);innerHTML=GupShup.util.expandTemplate(GupShup.util.getInnerHTML(GupShup.html.msgNReplies.vars.replyDefaultTextTemplate),[{key:'$ENTITY_ID$',dataMember:'id'}],[{'id':GupShup.html.msgNReplies.vars.entityId}]);innerHTML+=GupShup.html.msgNReplies.methods.expandReplyMsgs(replyMsgInfo)+pg;}
else
{innerHTML=GupShup.util.getInnerHTML(GupShup.html.msgNReplies.vars.replyNoContentTemplate);}
GupShup.html.msgNReplies.controls.tabs.set(1,innerHTML);if(!GupShup.html.msgNReplies.vars.filterReplies)
GupShup.html.msgNReplies.methods.changeReplyTabName(replyMsgInfo.totalForPg);},expandGroupMsgs:function(groupMsgInfo){var tmplMap=GupShup.msgTemplates.msgExpansionMap;var msgArr=groupMsgInfo.entityMessages;if(typeof GupShup.html.msgNReplies.handlers.msgStreamModifier=="function")
msgArr=GupShup.html.msgNReplies.handlers.msgStreamModifier(groupMsgInfo);var template=GupShup.util.getInnerHTML('msgTemplate');return GupShup.util.expandTemplate(template,tmplMap,msgArr);},expandReplyMsgs:function(replyMsgInfo){var tmplMap=GupShup.msgTemplates.replyMsgTemplateMap;var msgArr=replyMsgInfo.entityReplies;if(typeof GupShup.html.msgNReplies.handlers.replyStreamModifier=="function")
msgArr=GupShup.html.msgNReplies.handlers.replyStreamModifier(replyMsgInfo);var template=GupShup.util.getInnerHTML('replyTemplate');return GupShup.util.expandTemplate(template,tmplMap,msgArr);},getReplies:function(req){var start=req.start;req.queryStr=req.queryStr+"&replyId=";if(req.start==0)
req.queryStr+="";else
req.queryStr+=((start>GupShup.html.msgNReplies.vars.currPageStart)?GupShup.html.msgNReplies.vars.nextPageStartId:GupShup.html.msgNReplies.vars.repliesStates[req.start]);GupShup.util.getJsonItems(req);},expandPagination:function(msgInfo,type){var length=0;var list_type='';var navOnClickFunction="javascript:GupShup.util.getJsonItems";var windowSize=GupShup.conf.windowSize;var needTotalForPg=true;if(type==GupShup.html.msgNReplies.vars.messagesAjaxReqType)
{length=(GupShup.util.isInitialized(msgInfo.entityMessages)?msgInfo.entityMessages.length:0);list_type='messages';}
else
{length=(GupShup.util.isInitialized(msgInfo.entityReplies)?msgInfo.entityReplies.length:0);list_type='replies';if(GupShup.html.msgNReplies.vars.filterReplies)
{navOnClickFunction="javascript:GupShup.html.msgNReplies.methods.getReplies";windowSize=1;needTotalForPg=false;}}
var paginationObj={start:msgInfo.params.start,total:msgInfo.totalForPg,returned:length,windowSize:windowSize,listType:list_type};var reqObj={url:GupShup.conf.readUrl,queryStr:"type="+type
+'&entityId='+GupShup.html.msgNReplies.vars.entityId
+'&checkSessionId=true'
+'&getAll='+GupShup.html.msgNReplies.vars.getAllReplies
+'&fromPage=gupshupspace'
+'&getReplyCount=true'
+'&filterReplies='+GupShup.html.msgNReplies.vars.filterReplies
+'&needTotalForPg='+needTotalForPg,navOnClickFunction:navOnClickFunction,callBack:{success:GupShup.html.msgNReplies.methods.updatePageOnAjaxSuccess,failure:GupShup.html.msgNReplies.methods.updatePageOnAjaxFailure}};return GupShup.util.expandPaginationTemplate(reqObj,paginationObj,GupShup.html.msgNReplies.vars.pageName+type);},updatePageOnPostReply:function(request){var groupMsgInfo=GupShup.util.getJsonFromResponse(request.responseText);if(groupMsgInfo.status=='SUCCESS')
{GupShup.html.actions.showReplyBox(request.argument.form,false);GupShup.html.msgNReplies.methods.updatePage(groupMsgInfo);GupShup.forms.showNotification(groupMsgInfo.message,{success:true});if(groupMsgInfo.autoGrpCreated==true)
GupShup.html.msgNReplies.methods.publishGroupCreatedEvent();}
else
GupShup.forms.showNotification(groupMsgInfo.message,{failure:true});},updatePageOnStreamUpdateSuccess:function(request){var groupMsgInfo=GupShup.util.getJsonFromResponse(request.responseText);if(groupMsgInfo.status=='SUCCESS')
{GupShup.html.msgNReplies.methods.updatePage(groupMsgInfo);GupShup.forms.showNotification(groupMsgInfo.message,{success:true});}
else
GupShup.forms.showNotification(groupMsgInfo.message,{failure:true});},updatePageOnAjaxFailure:function(){GupShup.forms.showNotification(GupShup.html.errorMessages.internalError,{failure:true});},handleError:function(groupMsgInfo){switch(groupMsgInfo.errorCode)
{case'INVALID_PAGE':var tmplMap=GupShup.msgTemplates.noMsgFoundTemplateMap;var tmplHTML=GupShup.util.getInnerHTML('noMsgFoundTemplate');var content=GupShup.util.expandTemplate(tmplHTML,tmplMap);content+=GupShup.html.msgNReplies.methods.expandPagination(groupMsgInfo,GupShup.html.msgNReplies.vars.messagesAjaxReqType);GupShup.util.setInnerHTML('groupMessagesContainer',content);break;case'SESSION_TIMEOUT':case'INVALID_REQUEST':case'INVALID_PARAMS':case'INTERNAL_ERROR':default:if(GupShup.util.trim(groupMsgInfo.message)!="")
GupShup.forms.showNotification(groupMsgInfo.message,{failure:true});break;}},publishGroupCreatedEvent:function(){var event=new GupShup.html.event({name:"CREATE_GROUP",params:{},source:GupShup.html.msgNReplies.vars.pageName});event.publish();}};GupShup.html.msgNReplies.vars.tabNames={posts:"Posts",replies:"Replies"};GupShup.html.msgNReplies.vars.tabsConfig=[{yahooConf:{label:GupShup.html.msgNReplies.vars.tabNames.posts,isActive:true},gupshupConf:{url:"",reqType:'AJAX',success:{callBack:GupShup.html.msgNReplies.methods.updatePageOnAjaxSuccess},failure:{callBack:GupShup.html.msgNReplies.methods.updatePageOnAjaxFailure},tabName:GupShup.html.msgNReplies.vars.tabNames.posts,tabType:'ENTITY_MESSAGES_EXTERNAL'}},{yahooConf:{label:GupShup.html.msgNReplies.vars.tabNames.replies,isActive:false},gupshupConf:{url:"",reqType:'AJAX',success:{callBack:GupShup.html.msgNReplies.methods.updatePageOnAjaxSuccess},failure:{callBack:GupShup.html.msgNReplies.methods.updatePageOnAjaxFailure},tabName:GupShup.html.msgNReplies.vars.tabNames.replies,tabType:'REPLIES'}}];GupShup.html.postGroupMsg=GupShup.html.postGroupMsg||{};GupShup.html.postGroupMsg.vars={};GupShup.html.postGroupMsg.templateMaps={};GupShup.html.postGroupMsg.methods={};GupShup.html.postGroupMsg.vars.initHandlers=false;GupShup.html.postGroupMsg.vars.inviteLinkUrl=GupShup.conf.contextPath+'/invite?entityName=';GupShup.html.postGroupMsg.vars.settingsLinkUrl=GupShup.conf.contextPath+'/groupSettings?entityId=';GupShup.html.postGroupMsg.methods={preMsgStreamRenderH:function(groupMsgInfo){GupShup.html.postGroupMsg.methods.publishPostingGroupUpdatedEvent(groupMsgInfo.entityDetails);if(GupShup.util.isInitialized(groupMsgInfo.entityDetails.acceptedNoSpam))
{GupShup.html.spam.setParams('ENTITY',GupShup.html.msgNReplies.vars.entityId,groupMsgInfo.entityDetails.acceptedNoSpam);}
groupMsgInfo.entityDetails.showPostCount=true;GupShup.util.expandTemplateInDiv('group-desc','myGroupDescTemplate',GupShup.templates.myGroupDescMap,[groupMsgInfo.entityDetails]);GupShup.html.postGroupMsg.methods.renderNewGroupCreatedMsg(groupMsgInfo);return;},prePageRenderH:function(groupMsgInfo){var resp={};resp.showPostTab=(groupMsgInfo.params.type==GupShup.html.msgNReplies.vars.messagesAjaxReqType)||(groupMsgInfo.params.type==GupShup.conf.actions.deletePost)||(groupMsgInfo.params.type=="POST_GROUP");resp.showReplyTab=(groupMsgInfo.params.type==GupShup.html.msgNReplies.vars.replyAjaxReqType)||(groupMsgInfo.params.type==GupShup.conf.actions.updateReply||(groupMsgInfo.params.type=="BLOCK_USER")||(groupMsgInfo.params.type=="UNBLOCK_USER"));return resp;},renderPage:function(groupMsgInfo){var o=this;if(GupShup.html.postGroupMsg.vars.initHandlers==false)
{GupShup.html.msgNReplies.handlers.preMsgStream=o.preMsgStreamRenderH,GupShup.html.msgNReplies.handlers.errorMsgStream=o.handleError,GupShup.html.msgNReplies.handlers.errorReplyStream=o.handleError,GupShup.html.msgNReplies.handlers.prePageProcessor=o.prePageRenderH,GupShup.html.msgNReplies.handlers.replyStreamModifier=o.updateRepliesForGupShupStream
GupShup.html.msgNReplies.handlers.msgStreamModifier=o.updateMsgForGupShupStream;GupShup.html.msgNReplies.vars.pageName="postGroupMsg";GupShup.html.msgNReplies.vars.fromPage="gupshupspace";GupShup.html.msgNReplies.vars.replyNoContentTemplate="gupshupspaceNoReplies";GupShup.html.msgNReplies.vars.msgesNoContentTemplate="gupshupspaceNoMessages";GupShup.html.msgNReplies.vars.replyDefaultTextTemplate="replyDefaultText";GupShup.html.msgNReplies.vars.checkSpam=true;GupShup.html.msgNReplies.vars.getAllReplies=true;GupShup.html.postGroupMsg.vars.initHandlers=true;GupShup.html.msgNReplies.vars.filterReplies=false;}
GupShup.html.msgNReplies.methods.updatePage(groupMsgInfo);},navigateToGroup:function(event){var groupName=event.params.name;var uId=GupShup.html.msgNReplies.vars.userId;GupShup.html.msgNReplies.methods.clearTabs();var queryUrl=GupShup.conf.readUrl+"&type="+GupShup.html.msgNReplies.vars.messagesAjaxReqType
+'&checkSessionId=true'
+"&getReplyCount=true"
+'&fromPage='+GupShup.html.msgNReplies.vars.fromPage
+"&checkSpam="+GupShup.html.msgNReplies.vars.checkSpam
+"&entityName="+groupName+"&start=0&limit="+GupShup.conf.ITEMS_PER_PAGE;var callBack={success:GupShup.html.msgNReplies.methods.updatePageOnAjaxSuccess,failure:GupShup.html.msgNReplies.methods.updatePageOnAjaxFailure};GupShup.ajax.send("POST",queryUrl,callBack,"TABSWITCH");GupShup.html.dynamicBar.update("","GUPSHUPSPACE","RIGHT",{entityId:event.params.id,userId:uId});},renderNewGroupCreatedMsg:function(groupMsgInfo){if(GupShup.util.isInitialized(groupMsgInfo.showNewGroupCreatedMsg)&&groupMsgInfo.showNewGroupCreatedMsg)
{var map=GupShup.html.postGroupMsg.templateMaps.newGroupCreatedMsgTemplateMap;var dataObj={name:groupMsgInfo.entityDetails.name,inviteLink:GupShup.html.postGroupMsg.vars.inviteLinkUrl+groupMsgInfo.entityDetails.name,settingsLink:GupShup.html.postGroupMsg.vars.settingsLinkUrl+groupMsgInfo.entityDetails.id}
GupShup.util.expandTemplateInDiv('newGroupCreatedMsgContainer','newGroupCreatedMsgTemplate',map,[dataObj]);GupShup.html.util.showElement('newGroupCreatedMsgContainer');}
else
{GupShup.util.copyContent('emptyTemplate','newGroupCreatedMsgContainer');GupShup.html.util.hideElement('newGroupCreatedMsgContainer');}},deleteMsg:function(msgId){var entityId=GupShup.html.msgNReplies.vars.entityId;var start=GupShup.html.msgNReplies.vars.msgStart;var limit=GupShup.html.msgNReplies.vars.msglimit;var callback={success:GupShup.html.msgNReplies.methods.updatePageOnStreamUpdateSuccess,failure:GupShup.html.msgNReplies.methods.updatePageOnAjaxFailure}
GupShup.html.actions.deleteMsg(entityId,msgId,start,limit,callback);},updateReplyStatus:function(msgId,action){var entityId=GupShup.html.msgNReplies.vars.entityId;var start=GupShup.html.msgNReplies.vars.replyStart;var limit=GupShup.html.msgNReplies.vars.replyLimit;var callback={success:GupShup.html.msgNReplies.methods.updatePageOnStreamUpdateSuccess,failure:GupShup.html.msgNReplies.methods.updatePageOnAjaxFailure}
GupShup.html.actions.updateReplyStatus(entityId,msgId,start,limit,action,callback);},handleError:function(groupMsgInfo){switch(groupMsgInfo.errorCode)
{case'INVALID_PAGE':if(groupMsgInfo.errorCode=='INVALID_PAGE')
{document.forms['textMsg'].entityId=GupShup.html.msgNReplies.vars.entityId;document.forms['picMsg'].entityId=GupShup.html.msgNReplies.vars.entityId;GupShup.util.expandTemplateInDiv('group-desc','myGroupDescTemplate',GupShup.templates.myGroupDescMap,[groupMsgInfo.entityDetails]);}
break;}},hideNewGroupCreatedMsgContainer:function(){GupShup.html.util.hideElement('newGroupCreatedMsgContainer');},updateMsgForGupShupStream:function(groupMsgInfo){var msgArr=groupMsgInfo.entityMessages;for(var i=0;i<msgArr.length;i++)
{msgArr[i].isPrivate=(groupMsgInfo.isPrivate==true);msgArr[i].isAdult=groupMsgInfo.isAdult;msgArr[i].isOwner=true;msgArr[i].allowDelete=true;msgArr[i].onsuccess="";msgArr[i].onfailure="";msgArr[i].msgClass="postGroupMessageContent messageWrapper";}
return msgArr;},updateRepliesForGupShupStream:function(replyMsgInfo){var msgArr=replyMsgInfo.entityReplies;for(var i=0;i<msgArr.length;i++)
{msgArr[i].isOwner=true;msgArr[i].entityId=GupShup.html.msgNReplies.vars.entityId;msgArr[i].allowBlock=true;msgArr[i].msgClass="postGroupMessageContent messageWrapper";msgArr[i].onsuccess="GupShup.html.msgNReplies.methods.updatePageOnPostReply";msgArr[i].onfailure="GupShup.html.msgNReplies.methods.updatePageOnAjaxFailure";}
return msgArr;},publishPostingGroupUpdatedEvent:function(eventParams){var event=new GupShup.html.event({name:"POSTING_GROUP_UPDATED",params:eventParams,source:'gupshupspace'});event.publish();},blockUnblockSender:function(entity,action){var start=GupShup.html.msgNReplies.vars.replyStart;var limit=GupShup.html.msgNReplies.vars.replyLimit;var callback={success:GupShup.html.msgNReplies.methods.updatePageOnStreamUpdateSuccess,failure:GupShup.html.msgNReplies.methods.updatePageOnAjaxFailure}
GupShup.html.actions.blockUnblockSender(entity,GupShup.html.msgNReplies.vars.entityId,action,callback,start,limit);}};GupShup.html.postGroupMsg.templateMaps.newGroupCreatedMsgTemplateMap=[{key:'$GROUP_NAME$',dataMember:'name'},{key:GupShup.util.getPlaceHolderUrl('$INVITE_LINK$'),dataMember:'inviteLink'},{key:GupShup.util.getPlaceHolderUrl('$REVIEW_LINK$'),dataMember:'settingsLink'}];(function(){GupShup.events.register({name:'POSTING_GROUP_CHANGED',identifier:'GupShup.html.postGroupMsg.methods.navigateToGroup',handler:GupShup.html.postGroupMsg.methods.navigateToGroup});})();(function(){GupShup.html.groupPage={};GupShup.html.groupPage.vars={entity:null}
GupShup.html.groupPage.controls=new Array();var entityIds={};var groupMessage={};var picMsgId={};var groupFwdMsgId={};entityIds['TEXT']=new GupShup.forms.controls({name:'textMsg.entityId'});entityIds['PIC']=new GupShup.forms.controls({name:'picMsg.entityId'});entityIds['GREETING']=new GupShup.forms.controls({name:'greetingMsg.entityId'});entityIds['GREETING_TEXT']=new GupShup.forms.controls({name:'greetingMsg.entityId'});groupMessage['TEXT']=GupShup.html.groupPage.controls[0]=new GupShup.forms.controls({name:'textMsg.text',dimText:GupShup.html.toolTips.enterMessage,limit:GupShup.conf.grpMessageLength,toolTip:''});groupMessage['PIC']=GupShup.html.groupPage.controls[1]=new GupShup.forms.controls({name:'picMsg.text',dimText:GupShup.html.toolTips.enterMessage,limit:GupShup.conf.pictureMessageLength,toolTip:''});picMsgId['PIC']=GupShup.html.groupPage.controls[2]=new GupShup.forms.controls({name:'picMsg.picId'});groupFwdMsgId['PIC']=GupShup.html.groupPage.controls[3]=new GupShup.forms.controls({name:'picMsg.msgId'});groupFwdMsgId['TEXT']=GupShup.html.groupPage.controls[4]=new GupShup.forms.controls({name:'textMsg.msgId'});groupMessage['GREETING']=GupShup.html.groupPage.controls[5]=new GupShup.forms.controls({name:'greetingMsg.text',limit:0,toolTip:''});picMsgId['GREETING']=GupShup.html.groupPage.controls[6]=new GupShup.forms.controls({name:'greetingMsg.picId'});groupFwdMsgId['GREETING']=GupShup.html.groupPage.controls[7]=new GupShup.forms.controls({name:'greetingMsg.msgId'});groupMessage['GREETING_TEXT']=GupShup.html.groupPage.controls[8]=new GupShup.forms.controls({name:'greetingTextMsg.text',dimText:GupShup.html.toolTips.enterMessage,limit:GupShup.conf.pictureMessageLength,toolTip:''});picMsgId['GREETING_TEXT']=GupShup.html.groupPage.controls[9]=new GupShup.forms.controls({name:'greetingTextMsg.picId'});groupFwdMsgId['GREETING_TEXT']=GupShup.html.groupPage.controls[10]=new GupShup.forms.controls({name:'greetingTextMsg.msgId'});GupShup.html.groupPage.init=function(){GupShup.forms.controls.initControls(GupShup.html.groupPage.controls);groupMessage['TEXT'].addListner('counter',{holder:'textMsgSize'});groupMessage['TEXT'].addListner('sms-counter',{holder:'smsMsgCount',startMsgLimit:GupShup.conf.paidSingleTextMessageLength,smsLimit:GupShup.conf.paidSingleTextMessageLength});groupMessage['PIC'].addListner('counter',{holder:'picMsgSize'});groupMessage['GREETING_TEXT'].addListner('counter',{holder:'greetingMsgSize'});};GupShup.html.groupPage.submit=function(type){var status=GupShup.html.postUtils.validateMessage(groupMessage[type]);if(status)
{var chkForReplyStatus=GupShup.html.util.getDestinationsForReplies(groupMessage[type].get('value'));var isReply=(chkForReplyStatus.count>0);switch(type)
{case'TEXT':{var contentLength=groupMessage[type].get('length');if(contentLength>0&&!groupMessage[type].isDefaultText())
{var smsCount=Math.floor(contentLength/GupShup.conf.paidSingleTextMessageLength);if((contentLength%GupShup.conf.paidSingleTextMessageLength)>0)
smsCount++;if(GupShup.html.postUtils.isPaid('textMsg'))
{var details={cost:GupShup.conf.paidMessageCost*smsCount,itemType:"Paid Text Message",type:type,actionType:'GROUP',count:GupShup.html.groupPage.vars.entity.totalSubscribers,postFunction:GupShup.html.groupPage.postPaidItem,redirectFunction:GupShup.html.groupPage.redirectForPaidItem};if(isReply&&chkForReplyStatus.isTextPresent)
{details.itemType="Paid Reply";details.type='REPLY';details.actionType='REPLY';details.count=chkForReplyStatus.count;GupShup.html.paidItems.methods.checkUserAccountBalanceForPaidItems(details);}
else
{if(details.count>0)
GupShup.html.paidItems.methods.checkUserAccountBalanceForPaidItems(details);else
GupShup.html.paidItems.methods.showZeroMemberPopUp(GupShup.html.groupPage.vars.entity,type);}}
else
if(!isReply||(isReply&&chkForReplyStatus.isTextPresent))
GupShup.html.postUtils.postMsg('POST_GROUP','textMsg',true,{type:type});}
else
GupShup.forms.showNotification(GupShup.html.errorMessages.postEmptyMsgErr,{failure:true});}
break;case'PIC':{picMsgId[type].set(GupShup.html.picLib.activeId);if(picMsgId[type].get('value')>0)
{if(groupMessage[type].isDefaultText())
groupMessage[type].set("");GupShup.html.postUtils.postMsg('POST_GROUP','picMsg',true,{type:type});}
else
GupShup.forms.showNotification(GupShup.html.errorMessages.postInvalidPicErr,{failure:true});}
break;case'GREETING_TEXT':case'GREETING':{picMsgId[type].set(GupShup.html.picLib.activeId);if(groupMessage[type].isDefaultText())
groupMessage[type].set("");if(picMsgId[type].get('value')>0)
{var formName="greetingInfo"
var greetingCost=document.forms[formName].cost.value;var greetingType=document.forms[formName].type.value;if(greetingCost>0)
{var details={cost:greetingCost,itemType:greetingType,type:type,actionType:'GROUP',count:GupShup.html.groupPage.vars.entity.totalSubscribers,postFunction:GupShup.html.groupPage.postPaidItem,redirectFunction:GupShup.html.groupPage.redirectForPaidItem};if(isReply&&chkForReplyStatus.isTextPresent)
{details.itemType="Paid Reply";details.type='GREETING_REPLY';details.subType=type;details.count=chkForReplyStatus.count;GupShup.html.paidItems.methods.checkUserAccountBalanceForPaidItems(details);}
else
{if(details.count>0)
GupShup.html.paidItems.methods.checkUserAccountBalanceForPaidItems(details);else
GupShup.html.paidItems.methods.showZeroMemberPopUp(GupShup.html.groupPage.vars.entity,type);}}
else
if(!isReply||(isReply&&chkForReplyStatus.isTextPresent))
GupShup.html.postUtils.postMsg('POST_GROUP','greetingMsg',true,{type:type});}
else
GupShup.forms.showNotification(GupShup.html.errorMessages.postInvalidPicErr,{failure:true});}
break;}}};GupShup.html.groupPage.postPaidItem=function(details){if(details.type=="GREETING_REPLY")
details.type=details.subType;switch(details.type)
{case'GREETING_TEXT':GupShup.html.postUtils.postMsg('POST_GROUP','greetingTextMsg',true,details);break;case'GREETING':GupShup.html.postUtils.postMsg('POST_GROUP','greetingMsg',true,details);break;case'PIC':GupShup.html.postUtils.postMsg('POST_GROUP','picMsg',true,details);break;case'REPLY':case'TEXT':GupShup.html.postUtils.postMsg('POST_GROUP','textMsg',true,details);break;}};GupShup.html.groupPage.redirectForPaidItem=function(details){if(details.cost<GupShup.conf.minimumPay)
details.cost=GupShup.conf.minimumPay
GupShup.html.actions.forwardToPaymentSystem(details.cost,GupShup.conf.phoneNumber,GupShup.conf.fromUrl+"/gupshupspace?entityName="+GupShup.html.groupPage.vars.entity.name);};GupShup.html.groupPage.clearInputBoxes=function(event){groupMessage['TEXT'].set('');groupMessage['PIC'].set('');groupFwdMsgId['PIC'].set('');groupFwdMsgId['TEXT'].set('');groupFwdMsgId['GREETING'].set('');groupMessage['GREETING'].set('');groupFwdMsgId['GREETING_TEXT'].set('');groupMessage['GREETING_TEXT'].set('');GupShup.html.postUtils.switchMsgType('TEXT');};GupShup.html.groupPage.resetEntityDetails=function(event){entityIds['TEXT'].set(event.params.id);entityIds['PIC'].set(event.params.id);entityIds['GREETING'].set(event.params.id);entityIds['GREETING_TEXT'].set(event.params.id);GupShup.html.groupPage.vars.entity=event.params;};})();(function(){GupShup.events.register({name:'POSTING_GROUP_CHANGED',identifier:'GupShup.html.postGroup.methods.navigateToGroup',handler:GupShup.html.groupPage.clearInputBoxes});GupShup.events.register({name:'POSTING_GROUP_UPDATED',identifier:'GupShup.html.postGroup.methods.navigateToGroup',handler:GupShup.html.groupPage.resetEntityDetails});})();(function(){GupShup.html.paidItems={};GupShup.html.paidItems.vars={popUpContainer:'paidItemAlertPopUp',sentPopUpContainer:'paidAlertSentPopUp',zeroMemberPopUpContainer:'zeroMemberPopUpContainer',popupDetails:null};GupShup.html.paidItems.methods={getButtonName:function(redirect,data){if(redirect==true)
return"Recharge";else if(data.type!="SHOP_ITEM")
{return"Pay & Post";}
else
{return"Pay & Buy";}},getActionType:function(actionType){if(actionType=='POST_GROUP')
return"group members";else
return"friends";},getItemTypeDisplayName:function(type){var name="";try
{name=GupShup.conf.richContentTypes[type].camelCase;}
catch(e)
{name=type;}
return name;},getQtyClass:function(subType){if(typeof subType!="undefined"&&subType=="INCOMING")
return"template";else
return"";},getExtraInfo:function(extraInfo){if(typeof extraInfo!="undefined")
return extraInfo;else
return"";},getItemTypeDwnldWarning:function(type){if(type=="IMAGE")
return GupShup.util.getInnerHTML("greetingCdmaWarning");else
return GupShup.util.getInnerHTML("greetingPhonyTuneWarning");},processPaidItem:function(){var popupDetails=GupShup.html.paidItems.vars.popupDetails;if(popupDetails.redirect==true)
popupDetails.redirectFunction(GupShup.html.paidItems.vars.popupDetails);else
popupDetails.postFunction(GupShup.html.paidItems.vars.popupDetails);GupShup.html.paidItems.methods.closePaidItemAlertPopUp();},showZeroMemberPopUp:function(entityDetails,itemType){var container=GupShup.html.util.createElement('DIV',GupShup.html.paidItems.vars.zeroMemberPopUpContainer);GupShup.html.util.setClass(container,"absPopUp");var dataObj=[entityDetails];var template="";switch(itemType)
{case'GREETING_TEXT':case'GREETING':template="zeroMemberGreetingTemplate";break;case'TEXT':template="zeroMemberMsgTemplate";break;}
if(GupShup.conf.browserVersion=='IE6')
GupShup.html.util.changeTagsDisplayTo(document,'SELECT','none');GupShup.util.expandTemplateInDiv(GupShup.html.paidItems.vars.zeroMemberPopUpContainer,template,GupShup.html.paidItems.maps.zeroMembersTemplateMap,dataObj);GupShup.html.util.alignBoxAtCenter(GupShup.html.paidItems.vars.zeroMemberPopUpContainer);},closeZeroMemberPopUp:function(){if(GupShup.conf.browserVersion=='IE6')
GupShup.html.util.changeTagsDisplayTo(document,'SELECT','block');GupShup.html.util.hideElement(GupShup.html.paidItems.vars.zeroMemberPopUpContainer);},closePaidItemSentPopUp:function(){if(GupShup.conf.browserVersion=='IE6')
GupShup.html.util.changeTagsDisplayTo(document,'SELECT','block');GupShup.html.util.hideElement(GupShup.html.paidItems.vars.sentPopUpContainer);},showPaidItemSentPopUp:function(acctDetails,msgDetails,actionType){var container=GupShup.html.util.createElement('DIV',GupShup.html.paidItems.vars.sentPopUpContainer);GupShup.html.util.setClass(container,"absPopUp");acctDetails.actionType=actionType;acctDetails.itemType=msgDetails.itemType;var dataObj=[acctDetails];var template="";switch(msgDetails.type)
{case'GREETING_REPLY':'greetingReplySentTemplate';break;case'GREETING_TEXT':case'GREETING':template="greetingSentTemplate";break;case'TEXT':template="publisherPaidMsgSentTemplate";break;case'INCOMING':template="shopSelectedPackSuccessTemplate";break;case'OFFLINE':template="shopSelectedItemSuccessTemplate";break;case'REPLY':template="publisherPaidReplySentTemplate";break;}
if(GupShup.conf.browserVersion=='IE6')
GupShup.html.util.changeTagsDisplayTo(document,'SELECT','none');GupShup.util.expandTemplateInDiv(GupShup.html.paidItems.vars.sentPopUpContainer,template,GupShup.html.paidItems.maps.paidAlertSentTemplateMap,dataObj);GupShup.html.util.alignBoxAtCenter(GupShup.html.paidItems.vars.sentPopUpContainer);},closePaidItemAlertPopUp:function(){GupShup.html.util.hideElement(GupShup.html.paidItems.vars.popUpContainer);},showPaidItemAlertPopUp:function(popupDetails){GupShup.html.paidItems.vars.popupDetails=popupDetails
var container=GupShup.html.util.createElement('DIV',GupShup.html.paidItems.vars.popUpContainer);GupShup.html.util.setClass(container,"absPopUp");popupDetails.warning="";var template="";switch(popupDetails.type)
{case'GREETING_TEXT':case'GREETING_REPLY':case'GREETING':template="greetingAlertTemplate";break;case'SHOP_ITEM':template="shopItemAlertTemplate";break;case'REPLY':case'TEXT':template="publisherPaidMsgTemplate";break;}
if(popupDetails.redirect==true)
popupDetails.warning=GupShup.util.getInnerHTML("paidItemWarningTemplate");var dataObj=[popupDetails];GupShup.util.expandTemplateInDiv(GupShup.html.paidItems.vars.popUpContainer,template,GupShup.html.paidItems.maps.paidItemAlertTemplateMap,dataObj);GupShup.html.util.alignBoxAtCenter(GupShup.html.paidItems.vars.popUpContainer);},checkUserAccountBalanceForPaidItems:function(details){GupShup.html.paidItems.vars.popupDetails=null;var callBack={success:GupShup.html.paidItems.methods.postPaidItem,failure:GupShup.html.paidItems.methods.onFailure,argument:details};GupShup.html.actions.requestAccountBalance(callBack);},onFailure:function(o){},postPaidItem:function(xhr){var acctDetails=GupShup.util.getJsonFromResponse(xhr.responseText);var cost=xhr.argument.cost;cost=parseFloat(cost);cost=cost.toFixed(2);xhr.argument.cost=cost;var totalNumFriends=xhr.argument.count;if(acctDetails.status=="SUCCESS")
{if(acctDetails.errorCode=="NO_ERROR")
{var bal=parseFloat(acctDetails.info[0].actualBalance);xhr.argument.balance=acctDetails.info[0].actualBalanceFormatted;xhr.argument.total=cost*totalNumFriends;xhr.argument.total=xhr.argument.total.toFixed(2);if(bal>=parseFloat(cost*totalNumFriends))
xhr.argument.redirect=false;else
xhr.argument.redirect=true;GupShup.html.paidItems.methods.showPaidItemAlertPopUp(xhr.argument);}
else
{if(acctDetails.errorCode=="INVALID_PARAM")
GupShup.forms.showNotification(GupShup.html.errorMessages.sessionExpired,{failure:true});else
GupShup.forms.showNotification(GupShup.html.errorMessages.paySysDownError,{failure:true});}}
else
{if(acctDetails.errorCode=="INVALID_PARAM")
GupShup.forms.showNotification(GupShup.html.errorMessages.sessionExpired,{failure:true});else
GupShup.forms.showNotification(GupShup.html.errorMessages.paySysDownError,{failure:true});}}}
GupShup.html.paidItems.maps={paidItemAlertTemplateMap:[{key:'$TOTAL_COST$',dataMember:'total'},{key:'$COST$',dataMember:'cost'},{key:'$ITEM$',dataMember:'itemType',dataProcessor:GupShup.html.paidItems.methods.getItemTypeDisplayName},{key:'$EXTRA_INFO$',dataMember:'extraInfo',dataProcessor:GupShup.html.paidItems.methods.getExtraInfo},{key:'$GREETING_DWNLD_WARNING$',dataMember:'itemType',dataProcessor:GupShup.html.paidItems.methods.getItemTypeDwnldWarning},{key:'$MEMBERS$',dataMember:'count'},{key:'$BALANCE$',dataMember:'balance'},{key:'$WARNIG$',dataMember:'warning'},{key:'$BUTTON_NAME$',dataMember:'redirect',dataProcessor:GupShup.html.paidItems.methods.getButtonName},{key:'$QTY_CLASS$',dataMember:'subType',dataProcessor:GupShup.html.paidItems.methods.getQtyClass}],paidAlertSentTemplateMap:[{key:'$BALANCE$',dataMember:'actualBalanceFormatted'},{key:'$MEMBERS$',dataMember:'actionType',dataProcessor:GupShup.html.paidItems.methods.getActionType},{key:'$ITEM$',dataMember:'itemType',dataProcessor:GupShup.html.paidItems.methods.getItemTypeDisplayName}],zeroMembersTemplateMap:[{key:'$NAME$',dataMember:'orgName'}]};})();(function(){GupShup.html.spam={};GupShup.html.spam.acceptedNoSpam=false;GupShup.html.spam.formName='spamControl';GupShup.html.spam.forwardFunct=null;GupShup.html.spam.showPopUp=function(fwdFunct){GupShup.html.spam.forwardFunct=fwdFunct;GupShup.html.util.changeTagsDisplayTo(document,'SELECT','none');GupShup.html.util.showLightBox({element:'spamPopUpDiv'});};GupShup.html.spam.setParams=function(type,id,value){switch(type){case'ENTITY':document.forms[GupShup.html.spam.formName].userId.value=-1;document.forms[GupShup.html.spam.formName].entityId.value=id;if(value)
GupShup.html.spam.acceptedNoSpam=true;else
GupShup.html.spam.acceptedNoSpam=false;break;case'USER':document.forms[GupShup.html.spam.formName].userId.value=id;document.forms[GupShup.html.spam.formName].entityId.value=-1;if(value)
GupShup.html.spam.acceptedNoSpam=true;else
GupShup.html.spam.acceptedNoSpam=false;break;}};GupShup.html.spam.enableButton=function(){if(document.forms["spamControl"].spamBox.checked==true)
{GupShup.html.util.enableBtn("spamBtn");document.forms["spamControl"].status.value="true";}
else
{GupShup.html.util.disableBtn("spamBtn");document.forms["spamControl"].status.value="false";}};GupShup.html.spam.process=function(){GupShup.html.actions.processNoSpam();};GupShup.callback.processNoSpamSuccess=function(xhr){var response=GupShup.util.getJsonFromResponse(xhr.responseText);if(response.status!="SUCCESS")
{GupShup.html.spam.close();GupShup.forms.showNotification(response.message,{failure:true});return;}
else
{GupShup.html.spam.close();GupShup.html.spam.acceptedNoSpam=true;if(typeof GupShup.html.spam.forwardFunct=='object')
{if(typeof GupShup.html.spam.forwardFunct.fwdFunct=='function')
GupShup.html.spam.forwardFunct.fwdFunct(GupShup.html.spam.forwardFunct.args);}
return;}};GupShup.html.spam.close=function(){GupShup.html.util.hideElement('spamPopUpDiv');GupShup.html.util.destroyElement('blurBg');GupShup.html.util.changeTagsDisplayTo(document,'SELECT','block');};GupShup.callback.processNoSpamErr=function(){};})();GupShup.html.groupMessages=GupShup.html.groupMessages||{vars:{isViewerAdult:"",ajaxReqType:"",pageName:"",isPremiumEntity:false,alreadySubscribed:false,hidePremiumPosts:false,getReplies:false,msgIdCommentTotalMap:{},entityId:-1,repliesPerPage:5,enitityName:"",repliesStates:{}},expandEntityDetails:function(entityDataObjForExpansion){var entityTemplateMap=GupShup.templates.groupMessages.entityDetailsTemplateMap;GupShup.util.expandTemplateInDiv('entityDetailsContainer','entityDetailsTemplate',entityTemplateMap,entityDataObjForExpansion);},expandEntityDetailsWithAdultWarning:function(entityDataObjForExpansion){GupShup.html.util.hideElement('msgListContainer');GupShup.html.util.hideElement('paginagtionContainer');var entityTmplMap=GupShup.templates.groupMessages.entityDetailsTemplateMap;var entityTmpl=document.getElementById('entityDetailsTemplate');var entityTmplHTML=entityTmpl.innerHTML;entityDataObjForExpansion[0].entityTmplExpansion=GupShup.util.expandTemplate(entityTmplHTML,entityTmplMap,entityDataObjForExpansion);var adultEntityTmplMap=GupShup.templates.groupMessages.adultEntityDetailsTemplateMap;GupShup.util.expandTemplateInDiv('entityDetailsContainer','adultEntityDetailsTemplate',adultEntityTmplMap,entityDataObjForExpansion);},expandReplies:function(msgArr){var tmplMap=GupShup.msgTemplates.replyMsgTemplateMap;for(var i=0;i<msgArr.length;i++)
{msgArr[i].isOwner=false;msgArr[i].entityId=GupShup.html.groupMessages.vars.entityId;msgArr[i].replyClass="recentReplies";msgArr[i].msgClass="";msgArr[i].onsuccess="";msgArr[i].onfailure="";}
var template=GupShup.util.getInnerHTML('replyTemplate');return GupShup.util.expandTemplate(template,tmplMap,msgArr);},expandMessages:function(msgArr,skipAdultWarning,isEntityPrivate,isOwner,name,pageNo){var msgListHTML="";GupShup.html.groupMessages.updateMsgForPrivateGroups(msgArr,isEntityPrivate);if(msgArr.length>0)
{for(var i=0;i<msgArr.length;i++)
{var fPost=(pageNo==0&&i==0)?" firstPost":"";msgArr[i].isPremium=(GupShup.html.groupMessages.vars.isPremiumEntity&&GupShup.html.groupMessages.vars.hidePremiumPosts);msgArr[i].isAdult=(msgArr[i].isAdult&&!skipAdultWarning);msgArr[i].msgClass="msgpost"+fPost;msgArr[i].isOwner=isOwner;msgArr[i].allowDelete=false;msgArr[i].entityName=name;msgArr[i].replyEntityId=GupShup.html.groupMessages.vars.entityId;msgArr[i].returnMsgType='REPLY';msgArr[i].onsuccess="GupShup.html.groupMessages.processReplyAjaxResp";msgArr[i].onfail="GupShup.html.groupMessages.processReplyAjaxResp";msgListHTML+=GupShup.util.expandTemplate(GupShup.util.getInnerHTML('msgTemplate'),GupShup.msgTemplates.msgExpansionMap,[msgArr[i]]);}}
else
{msgListHTML=GupShup.util.getInnerHTML('noMessagesTemplate');}
var msgListContainer=document.getElementById('msgListContainer');msgListContainer.innerHTML=msgListHTML;},updateMsgForPrivateGroups:function(entityMessages,isPrivate){if(GupShup.util.isInitialized(isPrivate)&&isPrivate)
{for(var i=0;i<entityMessages.length;i++)
{entityMessages[i].isPrivate=true;}}},showInvalidEntityBlock:function(entityName){var objForExpansion=new Array();objForExpansion[0]=new Object();objForExpansion[0].name=entityName;var mapObj=GupShup.msgTemplates.restrictedEntityMap;GupShup.util.expandTemplateInDiv('entityDetailsContainer','invalidEntityTemplate',mapObj,objForExpansion);},showPrivateEntityBlock:function(entityDetails){GupShup.util.setInnerHTML('entityDetailsContainer',GupShup.msgTemplates.methods.showPrivateEntityBlock(entityDetails));},showBlockedEntityBlock:function(entityName){var objForExpansion=new Array();objForExpansion[0]=new Object();objForExpansion[0].name=entityName;var mapObj=GupShup.msgTemplates.restrictedEntityMap;GupShup.util.expandTemplateInDiv('entityDetailsContainer','blockedEntityTemplate',mapObj,objForExpansion);},showPartnerEntityBlock:function(entityName){var objForExpansion=new Array();objForExpansion[0]=new Object();objForExpansion[0].name=entityName;var mapObj=GupShup.msgTemplates.restrictedEntityMap;GupShup.util.expandTemplateInDiv('entityDetailsContainer','partnerEntityTemplate',mapObj,objForExpansion);},getReplies:function(req){var start=req.start;req.queryStr=req.queryStr+"&replyId=";if(req.start==0)
req.queryStr+="";else
req.queryStr+=((start>GupShup.html.groupMessages.vars.currPageStart)?GupShup.html.groupMessages.vars.nextPageStartId:GupShup.html.groupMessages.vars.repliesStates[req.start]);GupShup.util.getJsonItems(req);},expandReplyPagination:function(replyMsgInfo){var tmpl=GupShup.templates.methods.getRHSPaginationTemplate(replyMsgInfo.entityReplies,replyMsgInfo.params.start,GupShup.html.groupMessages.vars.repliesPerPage);var paginationObj={start:replyMsgInfo.params.start,returned:replyMsgInfo.entityReplies.length,windowSize:1,listType:'replies',itemsPerPage:GupShup.html.groupMessages.vars.repliesPerPage,template:tmpl};var navOnClickFunction="javascript:GupShup.html.groupMessages.getReplies";var reqObj={url:GupShup.conf.readUrl,queryStr:"type=REPLIES"
+'&entityId='+GupShup.html.groupMessages.vars.entityId
+'&checkSessionId=true'
+'&getAll=false'
+'&filterReplies='+true
+'&needTotalForPg=false'
+'&fromPage=groups',navOnClickFunction:navOnClickFunction,callBack:{success:GupShup.html.groupMessages.processReplyAjaxResp,failure:GupShup.html.groupMessages.processReplyAjaxResp}};return GupShup.util.expandPaginationTemplate(reqObj,paginationObj,"REPLIES");},expandPagination:function(entityMessagesInfo){var firstMsgIndex=entityMessagesInfo.params.start;var totalMsgCount=entityMessagesInfo.totalForPg;var retrievedMsgCount=entityMessagesInfo.entityMessages.length;var paginationObj={start:entityMessagesInfo.params.start,total:entityMessagesInfo.totalForPg,returned:entityMessagesInfo.entityMessages.length,windowSize:GupShup.conf.windowSize};var reqObj={url:GupShup.conf.readUrl,queryStr:'type='+GupShup.html.groupMessages.vars.ajaxReqType
+'&entityId='+entityMessagesInfo.entityDetails.id+"&getReplies=false",additionalParams:{generator:GupShup.html.groupMessages.queryParamGenerator},callBack:{success:GupShup.html.groupMessages.processSuccesAjaxResponseOnPageNav,failure:GupShup.html.groupMessages.processFailureAjaxResponseOnPageNav}};GupShup.util.expandPaginationTemplateInDiv("paginagtionContainer",reqObj,paginationObj,GupShup.html.groupMessages.vars.pageName);},queryParamGenerator:function(){return('adult='+GupShup.html.groupMessages.vars.isViewerAdult);},processReplyAjaxResp:function(resp){GupShup.html.groupMessages.processReplyResp(resp.responseText);if(typeof resp.argument=="object"&&typeof resp.argument.form=="string")
GupShup.html.actions.showReplyBox(resp.argument.form,false);},processReplyResp:function(resp){var innerHTML='';var replyMsgInfo=GupShup.util.getJsonFromResponse(resp);if((typeof(replyMsgInfo.status)!='undefined')&&(replyMsgInfo.status=='SUCCESS'))
{var rArray=replyMsgInfo.entityReplies;var params=replyMsgInfo.params;if(rArray.length>0)
{GupShup.html.groupMessages.vars.currPageStart=params.start;GupShup.html.groupMessages.vars.repliesStates[params.start]=rArray[0].id;GupShup.html.groupMessages.vars.nextPageStartId=rArray[rArray.length-1].id;var pagination=GupShup.html.groupMessages.expandReplyPagination(replyMsgInfo);if(rArray.length>GupShup.html.groupMessages.vars.repliesPerPage)
rArray=rArray.slice(0,GupShup.html.groupMessages.vars.repliesPerPage);innerHTML=GupShup.html.groupMessages.expandReplies(rArray);innerHTML=innerHTML+pagination;}
else
innerHTML='<p><i>No replies yet!</i></p>';var map=[{key:'$ENTITY_NAME$',dataMember:'name'},{key:'$REPLIES_EXPANSION$',dataMember:'replyData'}];var data={name:GupShup.html.groupMessages.vars.enitityName,replyData:innerHTML};GupShup.util.expandTemplateInDiv('repliesContainer','recentRepliesTab',map,[data]);}
if(replyMsgInfo.errorCode=="MOBILE_NOT_ACTIVE")
{GupShup.forms.showNotification(replyMsgInfo.message,{failure:true});return;}
if((typeof replyMsgInfo.params=="object")&&(replyMsgInfo.params.type=="POST_REPLY"))
{switch(replyMsgInfo.status)
{case"SUCCESS":GupShup.forms.showNotification(replyMsgInfo.message,{success:true});break;default:GupShup.forms.showNotification(replyMsgInfo.message,{failure:true});break;}}},processSuccesAjaxResponseOnPageNav:function(request){var entityMessagesInfo=GupShup.util.getJsonFromResponse(request.responseText);GupShup.html.groupMessages.processTemplates(entityMessagesInfo);},processFailureAjaxResponseOnPageNav:function(request){},processTemplates:function(entityMessagesInfo){GupShup.html.groupMessages.vars.isPremiumEntity=entityMessagesInfo.isPremium;GupShup.html.groupMessages.vars.alreadySubscribed=entityMessagesInfo.alreadySubscribed;GupShup.html.groupMessages.vars.hidePremiumPosts=entityMessagesInfo.hidePremiumPosts;GupShup.util.copyContent('emptyTemplate','entityDetailsContainer');GupShup.util.copyContent('emptyTemplate','msgListContainer');GupShup.util.copyContent('emptyTemplate','paginagtionContainer');if((entityMessagesInfo.status!='SUCCESS')&&(entityMessagesInfo.errorCode!='INVALID_PAGE')&&(entityMessagesInfo.errorCode!='INVALID_PARAMS'))
{GupShup.util.copyContent('invalidEntityTemplate','entityDetailsContainer');GupShup.html.util.hideElement('about_group');GupShup.html.util.hideElement('repliesContainer');return;}
if(entityMessagesInfo.showPosts)
{var entityDataObjForExpansion=new Array();entityDataObjForExpansion[0]=entityMessagesInfo;GupShup.html.groupMessages.vars.entityId=entityMessagesInfo.entityDetails.id;GupShup.html.groupMessages.vars.enitityName=entityMessagesInfo.entityDetails.orgName;var msgArr=entityMessagesInfo.entityMessages;var msgHTML="";if(!entityMessagesInfo.isAdultEntity||GupShup.html.groupMessages.vars.isViewerAdult)
GupShup.html.groupMessages.expandEntityDetails(entityDataObjForExpansion);else
GupShup.html.groupMessages.expandEntityDetailsWithAdultWarning(entityDataObjForExpansion);GupShup.util.expandTemplateInDiv('about_group','groupDescTemplate',GupShup.templates.groupMessages.entityDetailsTemplateMap,entityDataObjForExpansion);if(entityMessagesInfo.errorCode=='INVALID_PAGE')
{GupShup.util.copyContent('invalidPageTemplate','msgListContainer');}
else
{var skipAdultWarning=(entityMessagesInfo.isAdultEntity||GupShup.html.groupMessages.vars.isViewerAdult);GupShup.html.groupMessages.expandMessages(msgArr,skipAdultWarning,entityMessagesInfo.isPrivate,entityMessagesInfo.isOwner,entityMessagesInfo.entityDetails.name,entityMessagesInfo.params.start);GupShup.html.groupMessages.expandPagination(entityMessagesInfo);}
if(entityMessagesInfo.isLoggedIn)
GupShup.html.share.init(entityMessagesInfo.showShareBox,entityMessagesInfo.entityDetails.id,entityMessagesInfo.entityDetails.name);if(entityMessagesInfo.isPremium)
GupShup.html.util.hideElement('rssLinkContainer_'+entityMessagesInfo.entityDetails.id);if(entityMessagesInfo.isPremium)
{if(!entityMessagesInfo.alreadySubscribed)
GupShup.util.expandTemplateInDiv('premiumGroupAlert','premiumGroupAlertTemplate',GupShup.templates.groupMessages.premiumGroupAlertMap,[entityMessagesInfo]);else if(entityMessagesInfo.hidePremiumPosts)
GupShup.util.expandTemplateInDiv('premiumGroupAlert','premiumGroupSuspendTemplate',GupShup.templates.premiumGroupSuspendMap,[entityMessagesInfo]);}}
else
{if(entityMessagesInfo.isPartner)
GupShup.html.groupMessages.showPartnerEntityBlock(entityMessagesInfo.entityDetails.name);else if(entityMessagesInfo.isPrivate)
GupShup.html.groupMessages.showPrivateEntityBlock(entityMessagesInfo.entityDetails);else if(entityMessagesInfo.isBlocked)
GupShup.html.groupMessages.showBlockedEntityBlock(entityMessagesInfo.entityDetails.name);else
GupShup.util.copyContent('invalidEntityTemplate','entityDetailsContainer');GupShup.html.util.hideElement('about_group');GupShup.html.util.hideElement('repliesContainer');}},showAdultEntityOnConsent:function(){GupShup.html.util.hideElement('adultEntityDetailsWarning');GupShup.html.util.showElement('adultEntityDetailsConainer');GupShup.html.util.showElement('msgListContainer');GupShup.html.util.showElement('paginagtionContainer');GupShup.html.groupMessages.vars.isViewerAdult=true;}};(function(){GupShup.html.share.updateEntityDetails=function(info){GupShup.html.groupMessages.expandEntityDetails([info]);}})();var shopCatIdHolder=new GupShup.forms.controls({name:'shopCategory.catId'});(function(){GupShup.html.shop={};GupShup.html.shop.vars={qtyCtrl:null,costCtrl:null,attrValIdCtrl:null,fNameCtrl:null,lNameCtrl:null,addressCtrl:null,cityCtrl:null,stateCtrl:null,pinCodeCtrl:null,productAttrs:{},product:null,bigImageUrl:false,inOwnContainer:false};GupShup.html.shop.renderCategoryList=function(catStr){var catObj=GupShup.util.getJsonFromResponse(catStr);var categories=catObj.categories;if(GupShup.html.shop.vars.inOwnContainer)
{for(var i=0;i<categories.length;i++)
{var html=GupShup.util.expandTemplate(GupShup.util.getInnerHTML('shopCatTemplate'),GupShup.html.shop.map.shopCatTemplate,[categories[i]]);GupShup.util.setInnerHTML('shopCatListContainer_'+categories[i].catDetails.id,html);}}
else
{var html=GupShup.util.expandTemplate(GupShup.util.getInnerHTML('shopCatTemplate'),GupShup.html.shop.map.shopCatTemplate,categories);GupShup.util.setInnerHTML('shopCatListContainer',html);}};GupShup.html.shop.renderCategoryContainers=function(catStr){GupShup.html.shop.vars.inOwnContainer=true;var catObj=GupShup.util.getJsonFromResponse(catStr);var html=GupShup.util.expandTemplate(GupShup.util.getInnerHTML('shopContentContainerTemplate'),GupShup.html.shop.map.shopCatTemplate,catObj.categories);GupShup.util.setInnerHTML('shopContentContainer',html);};GupShup.html.shop.renderFeaturedContent=function(content){var catProucts=GupShup.util.getJsonFromResponse(content);GupShup.html.util.hideElement('shopSelectedItem');var content=catProucts.featuredShopProducts;if(GupShup.html.shop.vars.inOwnContainer)
{for(var i=0;i<content.length;i++)
{var html=GupShup.util.expandTemplate(GupShup.util.getInnerHTML('shopFeaturedContentTemplate'),GupShup.html.shop.map.featuredShopContent,[content[i]]);GupShup.util.setInnerHTML('shopContentContainer_'+content[i].category.catDetails.id,html);}}
else
return;};GupShup.html.shop.renderCatContent=function(content,args){var catProucts=GupShup.util.getJsonFromResponse(content);if((typeof(catProucts.status)!='undefined')&&(catProucts.status=='SUCCESS'))
{GupShup.html.util.hideElement('shopSelectedItem');var html=GupShup.html.shop.map.methods.getFeaturedShopContentExpansion(catProucts.products);catProucts.params.totalForPg=catProucts.totalForPg;var pId=catProucts.params.catId;if(typeof args!="undefined")
pId=args.pId;var paginationContent=GupShup.html.shop.getPagination(catProucts.products,catProucts.params,pId);html+="<div style=\"clear:both\"></div>";GupShup.util.setInnerHTML('shopContentContainer_'+pId,html+paginationContent);}};GupShup.html.shop.processShopCatResponse=function(xhr){GupShup.html.shop.renderCatContent(xhr.responseText,xhr.argument);};GupShup.html.shop.collapseCategoryList=function(name){var catList=document.getElementsByName(name);for(var i=0;i<catList.length;i++)
{catList[i].style.display="none";}}
GupShup.html.shop.expandCategoryList=function(catId,name){GupShup.html.shop.collapseCategoryList(name);var catList=document.getElementsByName(name);for(var i=0;i<catList.length;i++)
{if(catList[i].id==(name+"_"+catId))
{catList[i].style.display="block";}}};GupShup.html.shop.clearCategoryHighlighting=function(name){var catList=document.getElementsByName(name);for(var i=0;i<catList.length;i++)
{catList[i].className="";}};GupShup.html.shop.highlightCategory=function(catId,name){GupShup.html.shop.clearCategoryHighlighting(name);GupShup.html.shop.highlight(catId,name);};GupShup.html.shop.highlight=function(catId,name){var catList=document.getElementsByName(name);for(var i=0;i<catList.length;i++)
{if(catList[i].id==(name+"_"+catId))
catList[i].className="active";}};GupShup.html.shop.highlightSubCategory=function(catId,name){GupShup.html.shop.clearCategoryHighlighting(name);GupShup.html.shop.highlight(catId,name);};GupShup.html.shop.getCategoryContent=function(catId,isSubCat,pId){if(!GupShup.html.shop.vars.inOwnContainer)
{GupShup.html.actions.pageReload(GupShup.conf.contextPath+"/shop");return;}
if((shopCatIdHolder.get('value')==catId))
return;shopCatIdHolder.set(catId);if(!isSubCat)
GupShup.html.shop.highlightCategory(catId,'shopCategory');else
GupShup.html.shop.highlightSubCategory(catId,'shopCategory');if(isNaN(parseInt(pId)))
pId=catId;var callback={success:GupShup.html.shop.processShopCatResponse,failure:GupShup.html.shop.processShopCatResponse,argument:{pId:parseInt(pId)}}
GupShup.html.util.submitFormUsingAjax('POST',GupShup.conf.readUrl,callback,'shopCategory');};GupShup.html.shop.getPagination=function(dataArray,params,pId){var paginationObj={start:params.start,total:params.totalForPg,returned:dataArray.length,windowSize:GupShup.conf.windowSize,listType:'Shop Items'};var reqObj={url:GupShup.conf.readUrl,queryStr:"type="+params.type+"&catId="+params.catId+"&needTotalForPg=true",callBack:{success:GupShup.html.shop.processShopCatResponse,failure:GupShup.html.shop.processShopCatResponse,argument:{pId:pId}}};var paginationContent=GupShup.util.expandPaginationTemplate(reqObj,paginationObj,params.type+"_"+params.catId);return paginationContent;};GupShup.html.shop.buyShopContent=function(id,name,isPremium){if(isPremium)
{GupShup.html.actions.pageReload(GupShup.conf.contextPath+"/groups/"+name);return;}
GupShup.html.actions.pageReload(GupShup.conf.contextPath+"/buy?itemId="+id);};GupShup.html.shop.gotoShop=function(){GupShup.html.actions.pageReload(GupShup.conf.contextPath+"/shop");};GupShup.html.shop.showPreview=function(bigImageUrl){GupShup.html.util.showLoader("Loading Image..");var img=new Image();img.onload=function(){GupShup.html.util.hideLoader();GupShup.html.shop.showLoadedPreview(img);};img.src=bigImageUrl;};GupShup.html.shop.closePreview=function(){GupShup.html.util.closeLightBox();GupShup.html.util.changeTagsDisplayTo(document,'SELECT','block');};GupShup.html.shop.showLoadedPreview=function(image){var lbObj={msg:'<img src="'+image.src+'" />',contentClass:'shopItempreviewContent',containerClass:'shopItemPreview',width:image.width+10,callBack:GupShup.html.shop.closePreview};GupShup.html.util.showLightBox(lbObj);GupShup.html.util.changeTagsDisplayTo(document,'SELECT','none');};GupShup.html.shop.showSelectedItem=function(selectedItem){var product=GupShup.util.getJsonFromResponse(selectedItem);var html=GupShup.util.expandTemplate(GupShup.util.removeHTMLComments(GupShup.util.getInnerHTML('shopSelectedItemTemplate')),GupShup.html.shop.map.shopSelectedItemTemplate,[product]);GupShup.util.setInnerHTML('shopSelectedItem',html);GupShup.html.shop.initSelectedShopItemCtrls();};GupShup.html.shop.initSelectedShopItemCtrls=function(){var id=GupShup.html.shop.vars.product.id;var formName='shopSelectedItemForm_'+id;var vars=GupShup.html.shop.vars;vars.qtyCtrl=new GupShup.forms.controls({name:formName+'.qty'});vars.costCtrl=new GupShup.forms.controls({name:formName+'.cost'});vars.attrValIdCtrl=new GupShup.forms.controls({name:formName+'.attrValId'});vars.fNameCtrl=new GupShup.forms.controls({name:formName+'.fName'});vars.lNameCtrl=new GupShup.forms.controls({name:formName+'.lName'});vars.addressCtrl=new GupShup.forms.controls({name:formName+'.addr',limit:500});var delDetails=GupShup.html.shop.vars.product.showDeliveryDetails;if(delDetails)
vars.addressCtrl.init();vars.cityCtrl=new GupShup.forms.controls({name:formName+'.city'});vars.stateCtrl=new GupShup.forms.controls({name:formName+'.state'});vars.pinCodeCtrl=new GupShup.forms.controls({name:formName+'.pin'});}
GupShup.html.shop.buyShopItemStep1=function(formName){if(GupShup.html.shop.validateShopForm())
{var product=GupShup.html.shop.vars.product;var isSubPack=(product.type=="INCOMING");var attrs=GupShup.html.shop.vars.productAttrs;var details={cost:document.forms[formName].cost.value,itemType:product.displayName,extraInfo:isSubPack?("("+attrs.msgPerDay[0].value+" msg/day, valid for "+Math.floor(attrs.duration[0].value/30)+" month(s))"):"",type:"SHOP_ITEM",subType:product.type,count:isSubPack?1:document.forms[formName].qty.value,postFunction:GupShup.html.shop.buyShopItemStep2,redirectFunction:GupShup.html.shop.buyShopItemRedirect};if(details.count>0)
{window.location="#";GupShup.html.paidItems.methods.checkUserAccountBalanceForPaidItems(details);}}};GupShup.html.shop.changeAmountDetails=function(){var id=GupShup.html.shop.vars.product.id;var total="shopItemTotalCost_"+id;var cost="shopItemCost_"+id;var form=document.forms['shopSelectedItemForm_'+id];GupShup.util.setInnerHTML(total,(form.cost.value*form.qty.value).toFixed(2));GupShup.util.setInnerHTML(cost,(form.cost.value*1).toFixed(2));};GupShup.html.shop.changeAttribute=function(attrName,attrValId){if(typeof GupShup.html.shop.vars.productAttrs[attrName]=='undefined')
return;var values=GupShup.html.shop.vars.productAttrs[attrName];var selectedValue=null;for(var i=0;i<values.length;i++)
{if(values[i].id==attrValId)
{selectedValue=values[i];break;}}
if(selectedValue!=null)
{var oldProd=GupShup.html.shop.vars.product;var newUrl=(GupShup.util.trim(selectedValue.imageUrl)=="")?oldProd.imageUrl:selectedValue.imageUrl;var newCost=(GupShup.util.trim(selectedValue.cost)=="0.00")?oldProd.cost:selectedValue.cost;var actualCost=(GupShup.util.trim(selectedValue.actualCost)=="0.00")?oldProd.actualCost:selectedValue.actualCost;var newProd={cost:newCost,name:oldProd.name,id:oldProd.id,shortDescr:oldProd.shortDescr,actualCost:actualCost,displayName:oldProd.displayName,longDescr:oldProd.longDescr,imageUrl:newUrl};GupShup.util.expandTemplateInDiv('selectedShopItem_'+GupShup.html.shop.vars.product.id,'shopItemTemplate',GupShup.html.shop.map.shopItemTemplate,[newProd]);GupShup.html.shop.vars.costCtrl.set(newProd.cost);GupShup.html.shop.vars.attrValIdCtrl.set(selectedValue.id);GupShup.html.shop.changeAmountDetails();}};GupShup.html.shop.buyShopItemStep2=function(details){if(GupShup.html.shop.validateShopForm())
{var id=GupShup.html.shop.vars.product.id;var formName='shopSelectedItemForm_'+id;var callBack={success:GupShup.html.shop.postOrderResponseHandler,failure:GupShup.html.shop.postOrderResponseHandler};GupShup.html.util.submitFormUsingAjax('POST',GupShup.conf.writeUrl,callBack,formName);}};GupShup.html.shop.postOrderResponseHandler=function(xhr){var status=GupShup.util.getJsonFromResponse(xhr.responseText);var msg=status.message;var msgDetails={type:GupShup.html.shop.vars.product.type,itemType:GupShup.html.shop.vars.product.displayName};switch(status.status)
{case'SUCCESS':GupShup.forms.hideNotification();GupShup.html.paidItems.methods.showPaidItemSentPopUp(status.params.accountDetails,msgDetails,status.params.type);break;case'FAILURE':GupShup.forms.showNotification(msg,{failure:true});break;}};GupShup.html.shop.buyShopItemRedirect=function(details){if(details.cost<GupShup.conf.minimumPay)
details.cost=GupShup.conf.minimumPay
GupShup.html.actions.forwardToPaymentSystem(details.cost,GupShup.conf.phoneNumber,GupShup.conf.fromUrl+"/buy?itemId="+GupShup.html.shop.vars.product.id);};GupShup.html.shop.getBigImageUrlFrom=function(url){var urrparts=GupShup.util.getFileAndExtension(url);return urrparts.name+"Big."+urrparts.ext;};GupShup.html.shop.validateShopForm=function(){GupShup.forms.controls.hideNotification();var delDetails=GupShup.html.shop.vars.product.showDeliveryDetails;var custDetails=GupShup.html.shop.vars.product.isCustomizable;var vars=GupShup.html.shop.vars;if(custDetails)
{var quantity=vars.qtyCtrl.getValue();if(quantity<1||isNaN(quantity))
{vars.qtyCtrl.showNotification(GupShup.html.errorMessages.invalidQuantity,{failure:true,position:'right'});return false;;}}
if(delDetails)
{var fName=vars.fNameCtrl.getValue();var lName=vars.lNameCtrl.getValue();var address=vars.addressCtrl.getValue();var city=vars.cityCtrl.getValue();var state=vars.stateCtrl.getValue();var pinCode=vars.pinCodeCtrl.getValue();if(lName.length<1)
{vars.lNameCtrl.showNotification(GupShup.html.errorMessages.blankLastName,{failure:true,position:'right'});return false;}
if(fName.length<1)
{vars.fNameCtrl.showNotification(GupShup.html.errorMessages.blankFirstName,{failure:true,position:'right'});return false;}
if(address.length<1)
{vars.addressCtrl.showNotification(GupShup.html.errorMessages.blankAddress,{failure:true,position:'right'});return false;}
if(city.length<1)
{vars.cityCtrl.showNotification(GupShup.html.errorMessages.blankCity,{failure:true,position:'right'});return false;}
if(state.length<1)
{vars.stateCtrl.showNotification(GupShup.html.errorMessages.blankState,{failure:true,position:'right'});return false;}
if(pinCode.length<1)
{vars.pinCodeCtrl.showNotification(GupShup.html.errorMessages.blankPinCode,{failure:true,position:'right'});return false;}
if(isNaN(pinCode))
{vars.pinCodeCtrl.showNotification(GupShup.html.errorMessages.invalidPinCode,{failure:true,position:'right'});return false;}}
return true;}})();(function(){GupShup.html.shop.map={};GupShup.html.shop.map.methods={getSuperCatExpansion:function(catDetails){return GupShup.util.expandTemplate(GupShup.util.getInnerHTML('shopCatItemContentTemplate'),GupShup.html.shop.map.shopCatItemTemplate,[catDetails]);},getSubCatExpansion:function(subCatList,data){if(subCatList.length<1)
return"";else
{var op="";for(var i=0;i<subCatList.length;i++)
{subCatList[i].catDetails.parentId=data.catDetails.id;if(subCatList[i].childCategories.length>0)
{op+=GupShup.util.expandTemplate(GupShup.util.getInnerHTML('shopCatTemplate'),GupShup.html.shop.map.shopCatTemplate,[subCatList[i]]);}
else
{op+=GupShup.util.expandTemplate(GupShup.util.getInnerHTML('shopCatItemTemplate'),GupShup.html.shop.map.shopCatItemTemplate,[subCatList[i].catDetails]);}}
return op;}},getSavedCost:function(actual,data){var actualCost=GupShup.html.shop.map.methods.getDefaultActualCost(actual,data);var cost=GupShup.html.shop.map.methods.getDefaultCost(data.cost,data);return(actualCost-cost);},getSelectedItem:function(id,data){GupShup.html.shop.vars.product=data;for(var i=0;i<data.attributes.length;i++)
{if(data.attributes[i].name=="bigImageUrl")
GupShup.html.shop.vars.bigImageUrl=true;}
var html=GupShup.util.expandTemplate(GupShup.util.getInnerHTML('shopItemTemplate'),GupShup.html.shop.map.shopItemTemplate,[data]);return html;},getOtherAttrs:function(attrs,data){var html="";for(var i=0;i<attrs.length;i++)
{if(typeof GupShup.html.shop.vars.productAttrs[attrs[i].name]=='undefined')
GupShup.html.shop.vars.productAttrs[attrs[i].name]=attrs[i].values;if(attrs[i].hidden==true)
continue;html+=GupShup.util.expandTemplate(GupShup.util.removeHTMLComments(GupShup.util.getInnerHTML('shopItemAttrNameTemplate')),GupShup.html.shop.map.shopItemAttrNameTemplate,[attrs[i]]);}
return html;},getAttrsValues:function(values,data){var html=GupShup.util.expandTemplate(GupShup.util.removeHTMLComments(GupShup.util.getInnerHTML('shopItemAttrValTemplate')),GupShup.html.shop.map.shopItemAttrValTemplate,values);return html;},getCustomisationDetails:function(isCustomizable,data){var html=isCustomizable?GupShup.util.expandTemplate(GupShup.util.removeHTMLComments(GupShup.util.getInnerHTML('shopSelectedItemCustomizeTemplate')),GupShup.html.shop.map.shopSelectedItemCustomizeTemplate,[data]):"";return html;},getDelvDetails:function(showDelvDetails,data){var html=showDelvDetails?GupShup.util.expandTemplate(GupShup.util.removeHTMLComments(GupShup.util.getInnerHTML('shopSelectedItemDeliveryTemplate')),GupShup.html.shop.map.shopSelectedItemDeliveryTemplate,[data]):"";return html;},selectCostTemplate:function(data){return(data.actualCost==data.cost)?1:0;},isDefaultAttr:function(isDefault){return(isDefault==true)?'selected="true"':'';},getQtyClass:function(showQty){return(showQty==true)?'':'template';},getDefaultActualCost:function(cost,data){if(typeof data.defaultActualCost!="undefined")
return data.defaultActualCost;else
return cost;},getDefaultCost:function(cost,data){if(typeof data.defaultCost!="undefined")
return data.defaultCost;else
return cost;},getDefaultImage:function(imageUrl,data){if(typeof data.defaultImageUrl!="undefined")
return data.defaultImageUrl;else
return imageUrl;},getBigImageClass:function(id,data){if(GupShup.html.shop.vars.bigImageUrl)
return"shopItemPreviewLink"
else
return"template";},getBigImage:function(imageUrl,data){if(GupShup.html.shop.vars.bigImageUrl)
return GupShup.html.shop.getBigImageUrlFrom(imageUrl);else
return imageUrl;},getClearBothDiv:function(id,data,pos){if(pos%3==2)
return'<div style="clear:both"></div>';else
return"";},isPremiumGroup:function(type){if(type=="PREMIUM_GROUP")
return true;return false;},getPageName:function(type){if(type=="PREMIUM_GROUP")
return'groups/';return'buy';},getItemUIdHolder:function(type){if(type=="PREMIUM_GROUP")
return'entityName';return'itemId';},getItemUName:function(type,data){if(type=="PREMIUM_GROUP")
return data.name;return data.id;},getFeaturedShopCatHeaderExpansion:function(cat){return GupShup.util.expandTemplate(GupShup.util.getInnerHTML('shopFeaturedContentHeaderTemplate'),GupShup.html.shop.map.shopCatItemTemplate,[cat.catDetails]);},getFeaturedShopContentExpansion:function(products){return GupShup.util.expandTemplate(GupShup.util.getInnerHTML('shopItemTemplate'),GupShup.html.shop.map.shopItemTemplate,products);}};GupShup.html.shop.map.shopCatItemTemplate=[{key:'$ID$',dataMember:'id'},{key:'$PID$',dataMember:'parentId'},{key:'$CAT_TITLE$',dataMember:'displayName'}];GupShup.html.shop.map.shopCatTemplate=[{key:'$ID$',dataMember:'catDetails.id'},{key:'$SUPER_CAT_EXPANSION$',dataMember:'catDetails',dataProcessor:GupShup.html.shop.map.methods.getSuperCatExpansion},{key:'$SUBCATLIST$',dataMember:'childCategories',dataProcessor:GupShup.html.shop.map.methods.getSubCatExpansion}];GupShup.html.shop.map.shopItemCostTemplate=[{key:'$ORIG_COST$',dataMember:'actualCost',dataProcessor:GupShup.html.shop.map.methods.getDefaultActualCost},{key:'$OUR_COST$',dataMember:'cost',dataProcessor:GupShup.html.shop.map.methods.getDefaultCost}];GupShup.html.shop.map.shopItemTemplate=[{key:'$ID$',dataMember:'id'},{key:'$TITLE$',dataMember:'displayName'},{key:'$COST_INFO$',templateSelector:GupShup.html.shop.map.methods.selectCostTemplate,templateOptions:[{tmplDivId:'shopItemSavedCostTemplate',tmplMap:GupShup.html.shop.map.shopItemCostTemplate},{tmplDivId:'shopItemDefaultCostTemplate',tmplMap:GupShup.html.shop.map.shopItemCostTemplate}]},{key:GupShup.util.getPlaceHolderUrl('$PIC_SRC$'),dataMember:'imageUrl',dataProcessor:GupShup.html.shop.map.methods.getDefaultImage},{key:'$SAVED$',dataMember:'actualCost',dataProcessor:GupShup.html.shop.map.methods.getSavedCost},{key:'$BIG_IMAGE_URL$',dataMember:'imageUrl',dataProcessor:GupShup.html.shop.map.methods.getBigImage},{key:'$BIG_IMAGE_CLASS$',dataMember:'id',dataProcessor:GupShup.html.shop.map.methods.getBigImageClass},{key:'$CLEAR_BOTH$',dataMember:'id',dataProcessor:GupShup.html.shop.map.methods.getClearBothDiv},{key:'$NAME$',dataMember:'name'},{key:'$IS_PREMIUM$',dataMember:'type',dataProcessor:GupShup.html.shop.map.methods.isPremiumGroup},{key:'$ITEM_UID_HOLDER$',dataMember:'type',dataProcessor:GupShup.html.shop.map.methods.getItemUIdHolder},{key:'$ITEM_UNAME$',dataMember:'type',dataProcessor:GupShup.html.shop.map.methods.getItemUName},{key:'$PAGE_NAME$',dataMember:'type',dataProcessor:GupShup.html.shop.map.methods.getPageName}];GupShup.html.shop.map.shopSelectedItemDeliveryTemplate=[{key:'$ID$',dataMember:'id'}];GupShup.html.shop.map.shopSelectedItemCustomizeTemplate=[{key:'$ID$',dataMember:'id'},{key:'$OUR_COST$',dataMember:'cost',dataProcessor:GupShup.html.shop.map.methods.getDefaultCost},{key:'$SHOW_QTY$',dataMember:'showQty',dataProcessor:GupShup.html.shop.map.methods.getQtyClass},{key:'$OTHER_ATTRS$',dataMember:'attributes',dataProcessor:GupShup.html.shop.map.methods.getOtherAttrs}];GupShup.html.shop.map.shopSelectedItemTemplate=[{key:'$ID$',dataMember:'id'},{key:'$CUSTOM_DETAILS$',dataMember:'isCustomizable',dataProcessor:GupShup.html.shop.map.methods.getCustomisationDetails},{key:'$DELV_DETAILS$',dataMember:'showDeliveryDetails',dataProcessor:GupShup.html.shop.map.methods.getDelvDetails},{key:'$SELECTED_ITEM$',dataMember:'id',dataProcessor:GupShup.html.shop.map.methods.getSelectedItem},{key:'$TITLE$',dataMember:'displayName'},{key:'$DESCR$',dataMember:'longDescr',dataProcessor:GupShup.util.htmlDecode},{key:'$OUR_COST$',dataMember:'cost'},{key:'$DEFAULT_ATTR_VAL_ID$',dataMember:'defaultAttrValId'}];GupShup.html.shop.map.shopItemAttrNameTemplate=[{key:'$NAME$',dataMember:'name'},{key:'$DISPLAY_NAME$',dataMember:'displayName'},{key:'$OPTIONS$',dataMember:'values',dataProcessor:GupShup.html.shop.map.methods.getAttrsValues}];GupShup.html.shop.map.shopItemAttrValTemplate=[{key:'$VAL$',dataMember:'value'},{key:'$VAL_ID$',dataMember:'id'},{key:'$SELECTED$',dataMember:'isDefault',dataProcessor:GupShup.html.shop.map.methods.isDefaultAttr}];GupShup.html.shop.map.featuredShopContent=[{key:'$SHOP_CONTENT_SUB_HEADER$',dataMember:'category',dataProcessor:GupShup.html.shop.map.methods.getFeaturedShopCatHeaderExpansion},{key:'$SHOP_CONTENT_UNITS$',dataMember:'products',dataProcessor:GupShup.html.shop.map.methods.getFeaturedShopContentExpansion},];})();GupShup.html.mySubscriptions={};GupShup.html.mySubscriptions.controls={};GupShup.html.mySubscriptions.vars={};GupShup.html.mySubscriptions.templateMaps={};GupShup.html.mySubscriptions.vars.pageName="";GupShup.html.mySubscriptions.vars.mySubscriptionsAjaxReqType="";GupShup.html.mySubscriptions.vars.mySubscriptionsStreamAjaxReqType="";GupShup.html.mySubscriptions.vars.SORT_BY_NAME="";GupShup.html.mySubscriptions.vars.SORT_BY_RECENCY="";GupShup.html.mySubscriptions.vars.isSortingByName=true;GupShup.html.mySubscriptions.vars.userId='';GupShup.html.mySubscriptions.methods=GupShup.html.mySubscriptions.methods||{updatePage:function(subscriptionsInfo){if(subscriptionsInfo.status=='SUCCESS')
{GupShup.html.mySubscriptions.methods.setupTabs(subscriptionsInfo.params.sortBy);GupShup.html.mySubscriptions.vars.isSortingByName=(subscriptionsInfo.params.sortBy==GupShup.html.mySubscriptions.vars.SORT_BY_NAME);GupShup.html.mySubscriptions.methods.renderPage(subscriptionsInfo);}
else
GupShup.html.mySubscriptions.methods.handleError(subscriptionsInfo);},updatePageOnAjaxSucsess:function(request){var subscriptionsInfo=GupShup.util.getJsonFromResponse(request.responseText);GupShup.html.mySubscriptions.methods.updatePage(subscriptionsInfo);},handleActiveTabChange:function(e){var oldTab=e.prevValue;var newTab=e.newValue;GupShup.connectionManager.addTransaction({obj:newTab.dataConnection,type:'TABSWITCH',onAbort:function(){newTab._loading=false;}});if(oldTab==newTab)
return;else
{oldTab.set('content',"");GupShup.html.dynamicBar.update(oldTab.gupshupConf.tabType,newTab.gupshupConf.tabType,'right');}
GupShup.html.indexPage.changeTabHeader(newTab.get('label'));},getMsgStreamFromInfo:function(subscriptionsInfo){var stream=null;if(typeof subscriptionsInfo.subscriptions=="object")
stream=subscriptionsInfo.subscriptions;else if(typeof subscriptionsInfo.messages=="object")
stream=subscriptionsInfo.messages;else
stream=[];return stream;},renderPage:function(subscriptionsInfo){subscriptionsInfo.stream=GupShup.html.mySubscriptions.methods.getMsgStreamFromInfo(subscriptionsInfo);if(subscriptionsInfo.stream.length>0)
{var innerHTML=GupShup.html.mySubscriptions.methods.expandSubscriptions(subscriptionsInfo);innerHTML+=GupShup.html.mySubscriptions.methods.expandPagination(subscriptionsInfo);var activeTab=GupShup.html.mySubscriptions.controls.tabView.yahooTabView.get('activeTab');activeTab.set('content',innerHTML);GupShup.html.util.showElement('subscriptionsMasterContainer');GupShup.html.util.hideElement('noElementSubsContWrapper');}
else
{GupShup.html.util.hideElement('subscriptionsMasterContainer');GupShup.util.copyContent('noUserSubscriptionTemplate','noElementSubsContWrapper');GupShup.html.util.showElement('noElementSubsContWrapper');}},setupTabs:function(sortByName){if(GupShup.util.isInitialized(GupShup.html.mySubscriptions.controls.tabView))
return;GupShup.html.mySubscriptions.vars.tabsConfig[0].yahooConf.isActive=sortByName;GupShup.html.mySubscriptions.vars.tabsConfig[0].gupshupConf.url=GupShup.html.mySubscriptions.methods.getQueryURLForTab(GupShup.html.mySubscriptions.vars.SORT_BY_NAME);GupShup.html.mySubscriptions.vars.tabsConfig[1].yahooConf.isActive=!sortByName;GupShup.html.mySubscriptions.vars.tabsConfig[1].gupshupConf.url=GupShup.html.mySubscriptions.methods.getQueryURLForTab(GupShup.html.mySubscriptions.vars.SORT_BY_RECENCY);GupShup.html.mySubscriptions.controls.tabView=GupShup.util.createTabView(GupShup.html.mySubscriptions.vars.tabsConfig,'subscriptionsContainer');GupShup.html.mySubscriptions.controls.tabView.yahooTabView.addListener('activeTabChange',GupShup.html.mySubscriptions.methods.handleActiveTabChange)},expandSubscriptions:function(subscriptionsInfo){var tmplHTML=GupShup.util.getInnerHTML('entityMsgTemplate');var tmplMap=GupShup.msgTemplates.entityMsgMap;var subs=GupShup.html.mySubscriptions.methods.updateStreamForMsgActions(subscriptionsInfo.stream);return GupShup.util.expandTemplate(tmplHTML,tmplMap,subs);},updateStreamForMsgActions:function(stream){for(var i=0;i<stream.length;i++)
{stream[i].dontShowJoinBtn=true;stream[i].latestMessage.isPrivate=stream[i].isPrivate;stream[i].latestMessage.showTrueTime=true;}
return stream;},expandPagination:function(subscriptionsInfo){var reqObj={url:GupShup.conf.readUrl,queryStr:'type='+subscriptionsInfo.params.type
+'&sortBy='+subscriptionsInfo.params.sortBy
+"&userId="+GupShup.html.mySubscriptions.vars.userId,callBack:{success:GupShup.html.mySubscriptions.methods.updatePageOnAjaxSucsess,failure:GupShup.html.mySubscriptions.methods.updatePageOnAjaxFailure}};var paginationObj={start:subscriptionsInfo.params.start,total:subscriptionsInfo.totalForPg,returned:subscriptionsInfo.stream.length,windowSize:GupShup.conf.windowSize};return GupShup.util.expandPaginationTemplate(reqObj,paginationObj,GupShup.html.mySubscriptions.vars.pageName);},getQueryURLForTab:function(sortBy){var query=GupShup.conf.readUrl;if(sortBy==GupShup.html.mySubscriptions.vars.SORT_BY_NAME)
{query+='&type='+GupShup.html.mySubscriptions.vars.mySubscriptionsAjaxReqType;query+='&sortBy='+sortBy+"&userId="+GupShup.html.mySubscriptions.vars.userId;}
else
{query+='&type='+GupShup.html.mySubscriptions.vars.mySubscriptionsStreamAjaxReqType;}
query+='&start=0'+'&limit='+GupShup.conf.ITEMS_PER_PAGE;return query;},updatePageOnAjaxFailure:function(){},handleError:function(subscriptionInfo){switch(subscriptionInfo.errorCode)
{case'INVALID_REQUEST':var customMsgTmplMap=[{key:'$CUSTOM_MESSAGE$',fixedMember:subscriptionInfo.message}];GupShup.util.expandTemplateInDiv('subscriptionsMasterContainer','customMessageTemplate',customMsgTmplMap);break;case'INVALID_PAGE':GupShup.util.expandTemplateInDiv('subscriptionsMasterContainer','invalidPageTemplate',{});break;case'INVALID_PARAM':case'INTERNAL_ERROR':default:GupShup.util.expandTemplateInDiv('subscriptionsMasterContainer','defaultErrorPageTemplate',{});break;}}};GupShup.html.mySubscriptions.vars.tabsConfig=new Array();GupShup.html.mySubscriptions.vars.tabsConfig[0]={yahooConf:{label:'Name',isActive:true},gupshupConf:{url:'',reqType:'AJAX',success:{callBack:GupShup.html.mySubscriptions.methods.updatePageOnAjaxSucsess},failure:{callBack:GupShup.html.mySubscriptions.methods.updatePageOnAjaxFailure}}};GupShup.html.mySubscriptions.vars.tabsConfig[1]={yahooConf:{label:'Recency',isActive:false},gupshupConf:{url:'',reqType:'AJAX',success:{callBack:GupShup.html.mySubscriptions.methods.updatePageOnAjaxSucsess},failure:{callBack:GupShup.html.mySubscriptions.methods.updatePageOnAjaxFailure}}};(function(){GupShup.html.resetPasswordPage=GupShup.html.resetPasswordPage||{newPasswordControl:new GupShup.forms.controls({name:'resetPasswordForm.newPassword',toolTip:'',limit:50}),verifyPasswordControl:new GupShup.forms.controls({name:'resetPasswordForm.verifiedPassword',toolTip:'',limit:50}),resetPasswordInFailure:function(o,obj){GupShup.forms.showNotification(GupShup.html.errorMessages.internalError,{failure:true});obj.newPasswordControl.set("");obj.verifyPasswordControl.set("");GupShup.html.util.enableBtn('resetPasswordBtnId');},resetPasswordInSuccess:function(o,obj){var response=GupShup.util.getJsonFromResponse(o.responseText);obj.newPasswordControl.set("");obj.verifyPasswordControl.set("");GupShup.html.util.enableBtn('resetPasswordBtnId');if(response.status=="SUCCESS")
{GupShup.util.postData(GupShup.conf.contextPath+'/gupshupspace','status',response.status,'message',response.message);}
else
{GupShup.forms.showNotification(response.message,{failure:true});}},validateResetPasswordForm:function()
{var newPass=this.newPasswordControl.get('value');var vrfyPass=this.verifyPasswordControl.get('value');if((newPass!="")&&(vrfyPass!=""))
{if(newPass!=vrfyPass)
{this.newPasswordControl.showNotification(GupShup.html.errorMessages.verifyPassMismatch,{failure:true,position:'right'});return false;}
if(newPass.length<5)
{this.newPasswordControl.showNotification(GupShup.html.errorMessages.currentPassLength,{failure:true,position:'right'});return false;}
return true;}
else
{if(newPass=="")
{this.newPasswordControl.showNotification(GupShup.html.errorMessages.blankNewPass,{failure:true,position:'right'});return false;}
else if(vrfyPass=="")
{this.verifyPasswordControl.showNotification(GupShup.html.errorMessages.verifyPassMismatch,{failure:true,position:'right'});return false;}}
return false;},resetPassword:function(){GupShup.html.util.disableBtn('resetPasswordBtnId');if(this.validateResetPasswordForm())
{var password=this.newPasswordControl.get('value');document.resetPasswordForm.changedPass.value=b64_md5(password+GupShup.conf.systemSalt);GupShup.util.putDummyPassword(this.newPasswordControl.get('object'));GupShup.util.putDummyPassword(this.verifyPasswordControl.get('object'));var obj=this;var callback={success:function(o){obj.resetPasswordInSuccess(o,obj)},failure:function(o){obj.resetPasswordInFailure(o,obj)},argument:{}};GupShup.html.util.submitFormUsingAjax('POST',GupShup.conf.writeUrl+"&type=CHANGE_PASSWORD",callback,'resetPasswordForm');}
else
{GupShup.html.util.enableBtn('resetPasswordBtnId');return false;}}}})();(function(){GupShup.html.loginPage={countryCodeControl:new GupShup.forms.controls({name:'loginForm.countryCode',toolTip:''}),phoneControl:new GupShup.forms.controls({name:'loginForm.phone',toolTip:''}),passwordControl:new GupShup.forms.controls({name:'loginForm.password',toolTip:'',limit:50}),loginInSuccess:function(o,obj){var response=GupShup.util.getJsonFromResponse(o.responseText);if(response.status=="SUCCESS")
{if(typeof GupShup.html.loginPage.redirectUrl=='undefined')
window.location=GupShup.conf.contextPath+"/"+response.nextServlet;else
{var ccPhone=response.countryCode+((response.countryCode=='91')?'':'-')+response.phone;window.location=GupShup.html.loginPage.redirectUrl+"token="+response.token+"&phone="+ccPhone;}}
else
{GupShup.forms.showNotification(response.message,{failure:true});document.loginForm.password.value="";GupShup.html.util.enableBtn('loginBtnId');if(GupShup.conf.useTokenAuth)
{GupShup.conf.systemChallenge=response.challenge;document.loginForm.challenge.value=response.challenge;}}},loginInFailure:function(o,obj){GupShup.html.util.enableBtn('loginBtnId');GupShup.forms.showNotification(GupShup.html.errorMessages.internalError,{failure:true});document.loginForm.password.value="";},validateLoginForm:function(){phone=this.phoneControl.get('value');pass=this.passwordControl.get('value');cCode=this.countryCodeControl.get('value');if(phone.length==0)
{this.phoneControl.showNotification(GupShup.html.errorMessages.blankPhone,{failure:true,position:'right'});return false;}
if(GupShup.util.isValidPhone(cCode,phone))
{if(pass.length>0)
return true;else
{this.passwordControl.showNotification(GupShup.html.errorMessages.blankPassword,{failure:true,position:'right'});return false;}}
else
{this.phoneControl.showNotification(GupShup.html.errorMessages.invalidPhone,{failure:true,position:'right'});return false;}},loginUser:function(){GupShup.html.util.disableBtn('loginBtnId');if(this.validateLoginForm())
{var password=this.passwordControl.get('value');var rand=b64_md5(password+GupShup.conf.systemSalt);rand=b64_md5(GupShup.util.trim(rand)+document.loginForm.challenge.value);document.loginForm.rand.value=rand;GupShup.util.putDummyPassword(document.loginForm.password);var obj=this;var callback={success:function(o){obj.loginInSuccess(o,obj)},failure:function(o){obj.loginInFailure(o,obj)},argument:{}};GupShup.html.util.submitFormUsingAjax('POST',GupShup.conf.writeUrl+"&type=LOGIN_USER",callback,'loginForm');}
else
{GupShup.html.util.enableBtn('loginBtnId');}
return false;},initPage:function(){var loginControls=[GupShup.html.loginPage.countryCodeControl,GupShup.html.loginPage.phoneControl,GupShup.html.loginPage.passwordControl];GupShup.forms.controls.initControls(loginControls);}}})();(function(){GupShup.html.signupPage=GupShup.html.signupPage||{emailControl:null,pwdControl:null,pwdVerifyControl:null,phoneControl:null,captchaControl:null,countryCodeControl:null,randControl:null,grpNameControl:null,register:function(newUserFlow){GupShup.html.util.disableBtn('cancelBtnId');GupShup.html.util.disableBtn('signupId');if(!newUserFlow)
{var grpName=this.grpNameControl.get('value');var status=GupShup.util.isValidGroupName(grpName);if(status.code!='VALID')
{this.grpNameControl.showNotification(GupShup.html.errorMessages.invalidGroupName,{failure:true,position:'right'});GupShup.html.util.enableBtn('cancelBtnId');GupShup.html.util.enableBtn('signupId');return;}}
if(this.validateSignupForm())
{var obj=this;var callback={success:function(o){obj.signupSuccess(o,obj)},failure:function(o){obj.signupFailure(o,obj)},argument:{}};this.randControl.set(b64_md5(this.pwdControl.get('value')+GupShup.conf.systemSalt));GupShup.util.putDummyPassword(this.pwdControl.get('object'));GupShup.util.putDummyPassword(this.pwdVerifyControl.get('object'));GupShup.html.util.submitFormUsingAjax('POST',GupShup.conf.writeUrl+"&type=REGISTER_USER",callback,'signupForm');}
else
{GupShup.html.util.enableBtn('cancelBtnId');GupShup.html.util.enableBtn('signupId');}},signupSuccess:function(o,obj){var response=GupShup.util.getJsonFromResponse(o.responseText);if(response.status=="SUCCESS")
{window.location=GupShup.conf.contextPath+"/"+response.nextServlet;}
else
{obj.reloadCapcha();obj.pwdControl.set("");obj.pwdVerifyControl.set("");obj.captchaControl.set("");GupShup.html.util.enableBtn('cancelBtnId');GupShup.html.util.enableBtn('signupId');errorCode=response.errorCode;var i=errorCode.lastIndexOf(".");errorCode=errorCode.substr(i+1);var message=response.message;if(errorCode=='GROUPNAMEREJECTED')
this.grpNameControl.showNotification(message,{failure:true,position:'right'});else if(errorCode=='PHONEREJECTED'||errorCode=='DUPLICATEPHONE'||errorCode=='PHONEMISSMATCH'||errorCode=='DND')
this.phoneControl.showNotification(message,{failure:true,position:'right'});else if(errorCode=='DUPLICATEEMAIL')
this.emailControl.showNotification(message,{failure:true,position:'right'});else if(errorCode=='INVALIDCAPTCHA')
this.captchaControl.showNotification(message,{failure:true,position:'right'});else
GupShup.forms.showNotification(message,{failure:true});if(GupShup.conf.useTokenAuth)
{GupShup.conf.systemChallenge=response.challenge;document.loginForm.challenge.value=response.challenge;}}},signupFailure:function(o,obj){obj.reloadCapcha();obj.pwdControl.set("");obj.pwdVerifyControl.set("");obj.captchaControl.set("");GupShup.html.util.enableBtn('cancelBtnId');GupShup.html.util.enableBtn('signupId');GupShup.forms.showNotification(GupShup.html.errorMessages.internalError,{failure:true});},validateSignupForm:function(){var email=this.emailControl.get('value');var pass=this.pwdControl.get('value');var passV=this.pwdVerifyControl.get('value');var phn=this.phoneControl.get('value');var cap=this.captchaControl.get('value');var code=this.countryCodeControl.get('value');if(phn.length<1)
{this.phoneControl.showNotification(GupShup.html.errorMessages.blankPhone,{failure:true,position:'right'});return false;}
var err=false;if(code!="91")
{if(!GupShup.util.validatePhoneNumber(phn,true))
err=true;}
else
{if(!GupShup.util.validatePhoneNumber(phn,false))
err=true;}
if(err)
{this.phoneControl.showNotification(GupShup.html.errorMessages.invalidPhone,{failure:true,position:'right'});return false;}
if(!GupShup.util.isValidEmail(email))
{GupShup.html.util.clearTextBox('emailId');this.emailControl.showNotification(GupShup.html.errorMessages.invalidEmail,{failure:true,position:'right'});return false;}
if(pass.length<5)
{GupShup.html.util.clearTextBox('pwdId');this.pwdControl.showNotification(GupShup.html.errorMessages.currentPassLength,{failure:true,position:'right'});return false;}
if(passV!=pass)
{this.pwdVerifyControl.showNotification(GupShup.html.errorMessages.verifyPassMismatch,{failure:true,position:'right'});return false;}
if(cap=="")
{GupShup.html.util.clearTextBox('captchaId');this.captchaControl.showNotification(GupShup.html.errorMessages.blankCaptcha,{failure:true,position:'right'});return false;}
return true;},enableSignup:function(){if(document.signupForm.terms.checked)
GupShup.html.util.enableBtn("signupId");else
GupShup.html.util.disableBtn("signupId");},checkAvalibility:function(newGroupNameId){var newGroupName=document.getElementById(newGroupNameId).value;var status=GupShup.util.isValidGroupName(newGroupName);if(status.code!='VALID')
{this.grpNameControl.showNotification(status.err,{failure:true,position:'right'});return false;}
var obj=this;var callback={success:function(o){obj.checkAvalibilitySuccess(o,obj)},failure:function(o){obj.checkAvalibilityError(o,obj)},argument:{}};GupShup.ajax.send('POST',GupShup.conf.contextPath+"/GroupNameStatus?groupName="+newGroupName,callback,'WRITE');},checkAvalibilitySuccess:function(o,obj){var response=GupShup.util.trim(o.responseText);if(response=="PHONEMISSMATCH"||response=="INVALID"||response=="DUPLICATENICK"||response=="ALREADYACTIVATED")
{obj.grpNameControl.showNotification(GupShup.html.errorMessages.groupNameInUse,{failure:true,position:'right'});}
else if(response=="BLOCKED")
{obj.grpNameControl.showNotification(GupShup.html.errorMessages.userBlocked,{failure:true,position:'right'});}
else if(response=="AUTHDBERR"||response=="SMSDBERR"||response=="ERROR")
{obj.grpNameControl.showNotification(GupShup.html.errorMessages.internalError,{failure:true,position:'right'});}
else if(response=="GROUPNAMEREJECTED")
{obj.grpNameControl.showNotification(GupShup.html.errorMessages.blockedGroupName,{failure:true,position:'right'});}
else if(response=="NEW")
{obj.grpNameControl.showNotification(GupShup.html.errorMessages.groupAvailible,{success:true,position:'right'});}
else
{obj.grpNameControl.showNotification(GupShup.html.errorMessages.internalError,{failure:true,position:'right'});}},checkAvalibilityError:function(o,obj){GupShup.forms.showNotification(GupShup.html.errorMessages.internalError,{failure:true});},initPage:function(isNewUser){this.emailControl=new GupShup.forms.controls({name:'signupForm.email',toolTip:'',limit:50});this.emailControl.init();this.pwdControl=new GupShup.forms.controls({name:'signupForm.pwd',toolTip:'',limit:50});this.pwdControl.init();this.pwdVerifyControl=new GupShup.forms.controls({name:'signupForm.pwdVerify',toolTip:'',limit:50});this.pwdVerifyControl.init();this.phoneControl=new GupShup.forms.controls({name:'signupForm.phone',toolTip:'',limit:18});this.phoneControl.init();this.captchaControl=new GupShup.forms.controls({name:'signupForm.captcha',limit:6});this.captchaControl.init();this.countryCodeControl=new GupShup.forms.controls({name:'signupForm.countryCode'});this.countryCodeControl.init();this.randControl=new GupShup.forms.controls({name:'signupForm.rand'});this.randControl.init();if(!isNewUser)
{this.grpNameControl=new GupShup.forms.controls({name:'signupForm.grpName',toolTip:'',limit:15});this.grpNameControl.init();}},reloadCapcha:function()
{var dt=new Date();var tableCell=document.getElementById('capchaImageId');var captchaImgElementsArr=tableCell.getElementsByTagName('img');captchaImgElementsArr[0].src=GupShup.conf.contextPath+"/captcha?capReqType=0&sId="+dt.getMilliseconds();}}})();(function(){GupShup.html.forgotPasswordPage=GupShup.html.forgotPasswordPage||{countryCodeControl:new GupShup.forms.controls({name:'forgotPasswordForm.countryCode',toolTip:''}),phoneControl:new GupShup.forms.controls({name:'forgotPasswordForm.phone',toolTip:''}),emailControl:new GupShup.forms.controls({name:'forgotPasswordForm.email',toolTip:'',limit:50}),forgotPasswordSuccess:function(o,obj){var response=GupShup.util.getJsonFromResponse(o.responseText);if(response.status=="SUCCESS")
{GupShup.forms.showNotification(response.message,{success:true});GupShup.html.util.showHideElement('loginDiv','forgotPasswordDiv');}
else
{if(response.errorCode=="EMAIL_MISMATCH")
{obj.emailControl.showNotification(response.message,{failure:true,position:'right'});}
else
{GupShup.forms.showNotification(response.message,{failure:true});}}
GupShup.html.util.enableBtn('forgotSubmitBtnId');GupShup.html.util.enableBtn('forgotCancelBtnId');},forgotPasswordFailure:function(o,obj){GupShup.forms.showNotification(GupShup.html.errorMessages.internalError,{failure:true});GupShup.html.util.enableBtn('forgotSubmitBtnId');GupShup.html.util.enableBtn('forgotCancelBtnId');},validateForgotPasswordForm:function(){phone=this.phoneControl.get('value');email=this.emailControl.get('value');cCode=this.countryCodeControl.get('value');if(phone.length==0)
{this.phoneControl.showNotification(GupShup.html.errorMessages.blankPhone,{failure:true,position:'right'});return false;}
if(!GupShup.util.isValidPhone(cCode,phone))
{this.phoneControl.showNotification(GupShup.html.errorMessages.invalidPhone,{failure:true,position:'right'});return false;}
if(email.length==0)
{this.emailControl.showNotification(GupShup.html.errorMessages.blankEmail,{failure:true,position:'right'});return false;}
if(!GupShup.util.isValidEmail(email))
{this.emailControl.showNotification(GupShup.html.errorMessages.invalidEmail,{failure:true,position:'right'});return false;}
return true;},sendRequest:function(){GupShup.html.util.disableBtn('forgotSubmitBtnId');GupShup.html.util.disableBtn('forgotCancelBtnId');if(this.validateForgotPasswordForm())
{var obj=this;var callback={success:function(o){obj.forgotPasswordSuccess(o,obj)},failure:function(o){obj.forgotPasswordFailure(o,obj)},argument:{}};GupShup.html.util.submitFormUsingAjax('POST',GupShup.conf.writeUrl+"&type=RESET_PASSWORD",callback,'forgotPasswordForm');}
else
{GupShup.html.util.enableBtn('forgotSubmitBtnId');GupShup.html.util.enableBtn('forgotCancelBtnId');}
return false;},initPage:function(){var forgotPasswordControls=[GupShup.html.forgotPasswordPage.countryCodeControl,GupShup.html.forgotPasswordPage.phoneControl,GupShup.html.forgotPasswordPage.emailControl];GupShup.forms.controls.initControls(forgotPasswordControls);},showForgotPwdDiv:function(){GupShup.html.forgotPasswordPage.toggleForgotPwdInput();GupShup.html.util.showElement('forgotPasswordDiv');GupShup.html.util.hideElement('loginDiv');},toggleForgotPwdInput:function(){var cCode=this.countryCodeControl.get('value');var tableRows=document.getElementById('forgotPasswordFormTable').getElementsByTagName("TR");var isIndian=true;if(cCode.length>0&&cCode!="91")
isIndian=false;if(isIndian)
for(var i=1;i<tableRows.length;i++)
if(i!=1)
tableRows[i].style.display="none";else
tableRows[i].style.display=GupShup.html.util.isIE()?"block":"table-row";else
for(var i=1;i<tableRows.length;i++)
if(i==1)
tableRows[i].style.display="none";else
tableRows[i].style.display=GupShup.html.util.isIE()?"block":"table-row";}}})();(function(){GupShup.html.profileSettingsPage=GupShup.html.profileSettingsPage||{redirect:false,isCopied:false,formSubmitted:false,nickControl:new GupShup.forms.controls({name:'profileSettingsForm.nick',toolTip:'',limit:10}),imageControl:new GupShup.forms.controls({name:'profileSettingsForm.image',toolTip:''}),profileNameControl:new GupShup.forms.controls({name:'profileSettingsForm.profileName',toolTip:'',limit:15}),genderControl:new GupShup.forms.controls({name:'profileSettingsForm.gender',toolTip:''}),locationControl:new GupShup.forms.controls({name:'profileSettingsForm.location',toolTip:'',limit:30}),descriptionControl:new GupShup.forms.controls({name:'profileSettingsForm.description',toolTip:''}),dobControl:new GupShup.forms.controls({id:'yearId',toolTip:''}),profileSettingsFailure:function(o,obj){GupShup.forms.showNotification(GupShup.html.errorMessages.internalError,{failure:true});GupShup.html.util.enableBtn('saveBtnId');},isNickValid:function(str)
{return/^[\w-]+$/.test(str);},copyName:function()
{if(!this.isCopied)
{this.isCopied=true;var name=this.profileNameControl.get('value');this.nickControl.set(name.substr(0,10));}},profileSettingsProcess:function(o,obj){var response=GupShup.util.getJsonFromResponse(o.responseText);document.profileSettingsForm.image.value="";GupShup.html.util.showHideElement('linkId','imageUploadId');if(obj.redirect&&(response.errorCode!='AUTH_ERROR'))
{GupShup.util.postData(GupShup.conf.contextPath+'/createFirstGroup','status',response.status,'message',response.message);}
else
{if(response.status=="SUCCESS")
{GupShup.forms.showNotification(response.message,{success:true});}
else
{if((response.errorCode=="IMAGE_ERROR")||(response.errorCode=="IMAGE_OVERSIZE_ERROR"))
{obj.imageControl.showNotification(response.message,{failure:true,position:'right'});}
else
{GupShup.forms.showNotification(response.message,{failure:true});}}
if(typeof response.imageUrl!='undefined')
{document.getElementById('profileImageId').innerHTML="<img src=\""+response.imageUrl+"\" height=\"45px\" width=\"45px\">";var eventArgs={name:'PROFILE_IMAGE_UPDATED',params:{imageSrc:response.imageUrl},source:'PROFILE_SETTINGS'};var updateImageEvent=new GupShup.html.event(eventArgs);updateImageEvent.publish();}
if(typeof response.profileName!='undefined')
{document.getElementById('heading').innerHTML=response.profileName+"'s Profile";var eventArgs={name:'PROFILE_NAME_UPDATED',params:{name:response.profileName},source:'PROFILE_SETTINGS'};var updateNameEvent=new GupShup.html.event(eventArgs);updateNameEvent.publish();}}
obj.formSubmitted=false;var btn=document.getElementById("saveBtnId");btn.style.backgroundColor="#FF9933";btn.style.cursor="pointer";},validateChangeSettingsForm:function(){var profileName=this.profileNameControl.get('value');var location=this.locationControl.get('value');var description=this.descriptionControl.get('value');var image=this.imageControl.get('value');var nick=this.nickControl.get('value');if(GupShup.util.isValidImage(image))
{document.profileSettingsForm.imgType.value=GupShup.util.getFileExtension(image);}
else
{this.imageControl.showNotification(GupShup.html.errorMessages.invalidImage,{failure:true,position:'right'});return false;}
if(profileName.length<1)
{this.profileNameControl.showNotification(GupShup.html.errorMessages.blankName,{failure:true,position:'right'});return false;}
else if(!GupShup.util.isAscii(profileName))
{this.profileNameControl.showNotification(GupShup.html.errorMessages.nonAsciiChar,{failure:true,position:'right'});return false;}
if(nick.length<1)
{this.nickControl.showNotification(GupShup.html.errorMessages.blankNick,{failure:true,position:'right'});return false;}
else if(nick.length>10)
{this.nickControl.showNotification(GupShup.html.errorMessages.invalidNick,{failure:true,position:'right'});return false;}
else if(!this.isNickValid(nick))
{this.nickControl.showNotification(GupShup.html.errorMessages.invalidNick,{failure:true,position:'right'});return false;}
if(!GupShup.util.isValidContent(nick,restrictedNames)||!GupShup.util.isValidContent(nick,stopWords))
{this.nickControl.showNotification(GupShup.html.errorMessages.blockedNick,{failure:true,position:'right'});return false;}
if(document.getElementById('dayId').value=="DD"&&document.getElementById('monthId').value=="MM"&&document.getElementById('yearId').value=="YYYY")
{this.dobControl.showNotification(GupShup.html.errorMessages.blankDOB,{failure:true,position:'right'});return false;}
else
{if(GupShup.util.checkDate('dayId','monthId','yearId'))
{document.getElementById('dobId').value=GupShup.util.getDateFrom('dayId','monthId','yearId').getTime();}
else
{this.dobControl.showNotification(GupShup.html.errorMessages.invalidDOB,{failure:true,position:'right'});return false;}}
if(GupShup.util.trim(document.getElementById('genderId').options[document.getElementById('genderId').selectedIndex].value)=="NOTSPECIFIED")
{this.genderControl.showNotification(GupShup.html.errorMessages.selectGender,{failure:true,position:'right'});return false;}
if(location.length<1)
{this.locationControl.showNotification(GupShup.html.errorMessages.blankLocation,{failure:true,position:'right'});return false;}
else if(!GupShup.util.isAscii(location))
{this.locationControl.showNotification(GupShup.html.errorMessages.nonAsciiChar,{failure:true,position:'right'});return false;}
else if(!GupShup.util.isValidContent(location,stopWords))
{this.locationControl.showNotification(GupShup.html.errorMessages.blankLocation,{failure:true,position:'right'});return false;}
if(description.length>500)
{this.descriptionControl.showNotification(GupShup.html.errorMessages.PinvalidDescription,{failure:true,position:'right'});return false;}
if((description.length>0)&&(!GupShup.util.isAscii(description)))
{this.descriptionControl.showNotification(GupShup.html.errorMessages.nonAsciiChar,{failure:true,position:'right'});return false;}
return true;},changeProfileSettings:function(redirect){if(this.formSubmitted)
return;this.formSubmitted=true;var btn=document.getElementById("saveBtnId");btn.style.backgroundColor="#F3f2f2";btn.style.cursor="wait";this.redirect=redirect;if(this.validateChangeSettingsForm())
{var obj=this;var callback={upload:function(o){obj.profileSettingsProcess(o,obj)},success:function(o){obj.profileSettingsProcess(o,obj)},failure:function(o){obj.profileSettingsFailure(o,obj)},argument:{}};if(obj.imageControl.get('value').length>0)
{GupShup.html.util.submitFormUsingAjax('POST',GupShup.conf.writeUrl+"&type=PROFILE_SETTINGS",callback,'profileSettingsForm',true);}
else
{GupShup.html.util.submitFormUsingAjax('POST',GupShup.conf.writeUrl+"&type=PROFILE_SETTINGS",callback,'profileSettingsForm');}}
else
{btn.style.backgroundColor="#FF9933";btn.style.cursor="pointer";this.formSubmitted=false;return false;}},initPage:function(){var profileSettingsControls=[GupShup.html.profileSettingsPage.imageControl,GupShup.html.profileSettingsPage.profileNameControl,GupShup.html.profileSettingsPage.nickControl,GupShup.html.profileSettingsPage.genderControl,GupShup.html.profileSettingsPage.dobControl,GupShup.html.profileSettingsPage.locationControl,GupShup.html.profileSettingsPage.descriptionControl];GupShup.forms.controls.initControls(profileSettingsControls);}}})();GupShup.html.managePrepaidAccount={};GupShup.html.managePrepaidAccount.vars={};GupShup.html.managePrepaidAccount.vars.pageName='';GupShup.html.managePrepaidAccount.vars.ajaxReqType='';GupShup.html.managePrepaidAccount.vars.paymentSysPromotionsURL='';GupShup.html.managePrepaidAccount.methods=GupShup.html.managePrepaidAccount.methods||{updatePage:function(paymentTransLog,userBalance){if(paymentTransLog.status=='SUCCESS')
GupShup.html.managePrepaidAccount.methods.renderPage(paymentTransLog,userBalance);else
GupShup.html.managePrepaidAccount.methods.handleError(paymentTransLog,userBalance);},updatePageOnAjaxSucsess:function(request){var paymentTransLog=GupShup.util.getJsonFromResponse(request.responseText);GupShup.html.managePrepaidAccount.methods.updatePage(paymentTransLog);},renderPage:function(paymentTransLog,userBalance){var tmplMap=GupShup.templates.managePrepaidAccount.transactionLogHeaderTemplateMap;if(!GupShup.util.isInitialized(userBalance))
{userBalance=paymentTransLog.params.accountDetails;}
userBalance.loggedInUsersPhone=GupShup.conf.phoneNumber;GupShup.util.expandTemplateInDiv('prepaidAccountSummaryContainer','managePrepaidAccountHeadTemplate',tmplMap,[userBalance]);if(paymentTransLog.transactionLog.length>0)
{innerHTML=GupShup.html.managePrepaidAccount.methods.getExpandedTransactions(paymentTransLog);innerHTML+=GupShup.html.managePrepaidAccount.methods.getExpandedPagination(paymentTransLog);}
else
{innerHTML=GupShup.util.getInnerHTML('noTransactionsTemplate');}
GupShup.util.setInnerHTML('prepaidAccountTransLogContainer',innerHTML);},getExpandedTransactions:function(paymentTransLog){var tmplHTML=GupShup.util.getInnerHTML('transactionLogTableTemplate');var tmplMap=GupShup.templates.managePrepaidAccount.transactionLogTableTemplateMap;GupShup.templates.managePrepaidAccount.vars.isOdd=true;var tableBody=GupShup.util.expandTemplate(tmplHTML,tmplMap,[paymentTransLog]);var tableHead=GupShup.templates.managePrepaidAccount.methods.getFirstRowHTML('transactionLogTableHeadTemplate');tableHead='<tr class="transactionLogTableHead">'+tableHead+'</tr>';return'<table class="transactionLogTable">'+tableHead+tableBody+'</table>';},getExpandedPagination:function(paymentTransLog){var reqObj={url:GupShup.conf.readUrl,queryStr:'type='+GupShup.html.managePrepaidAccount.vars.ajaxReqType,callBack:{success:GupShup.html.managePrepaidAccount.methods.updatePageOnAjaxSucsess,failure:GupShup.html.managePrepaidAccount.methods.updatePageOnAjaxFailure}};var paginationObj={start:paymentTransLog.params.start,total:paymentTransLog.totalForPg,returned:paymentTransLog.transactionLog.length,windowSize:GupShup.conf.windowSize};return GupShup.util.expandPaginationTemplate(reqObj,paginationObj,GupShup.html.managePrepaidAccount.vars.pageName);},updatePageOnAjaxFailure:function(){},handleError:function(paymentTransLog){switch(paymentTransLog.errorCode)
{case'INVALID_PAGE':GupShup.util.expandTemplateInDiv('prepaidAccountTransLogContainer','noTransactionsTemplate',{});break;case'SESSION_TIMEOUT':case'INVALID_REQUEST':case'INVALID_PARAMS':GupShup.forms.showNotification(paymentTransLog.message,{failure:true});break;case'INTERNAL_ERROR':default:GupShup.util.expandTemplateInDiv('prepaidAccountTransLogContainer','internalErrorTemplate',{});break;}},redirectToPaymentFundRU:function(userPhone){var params='phone='+userPhone;var returnURL=GupShup.html.managePrepaidAccount.vars.pageName;var promotionsURL=GupShup.html.managePrepaidAccount.vars.paymentSysPromotionsURL;GupShup.html.actions.redirectToPaymentFundRU(params,returnURL,promotionsURL);}};GupShup.html.poll={};GupShup.html.poll.vars={calender:[null,null],dateContainers:['cal1Container','cal2Container'],dateFormNames:['pollStartForm','pollStopForm'],pollStepContainers:['','poll_step1','poll_step2','poll_step3','poll_step4'],pollStepLI:['poll_step_li','poll_step_li1','poll_step_li2','poll_step_li3'],pollStepRhsContainers:['','poll_right_step1','poll_right_step2','poll_right_step3','poll_right_step1'],pollStepForms:['','pollCreateForm','pollStartForm','pollStopForm','pollAccessForm'],pollForm:'pollForm',pollWidgets:['sampleWidget1','sampleWidget2','pollSMSPreivew'],pollWidgetsTemplate:['sampleWidgetTemplate','sampleWidgetTemplate','pollSMSPreviewTemplate'],pollNameStatusServlet:GupShup.conf.contextPath+"/PollNameStatus",pollQuestion:null,pollNick:null,pollOptions:[null,null,null],accessTabs:null,startNow:true,inviteLimit:25,maxEndInterval:30*24*60*60*1000,pollNameLimit:15,pollQLimit:120,pollId:-1};GupShup.html.poll.methods={init:function(){var date=new Date();var timestamp=date.getTime();GupShup.html.poll.methods.setUpCalender(timestamp,0);GupShup.html.poll.methods.setUpCalender(timestamp,1);GupShup.html.poll.vars.pollQuestion=new GupShup.forms.controls({name:GupShup.html.poll.vars.pollStepForms[1]+".question",dimText:'Enter your question',limit:GupShup.html.poll.vars.pollQLimit});GupShup.html.poll.vars.pollQuestion.init();GupShup.html.poll.vars.pollNick=new GupShup.forms.controls({name:GupShup.html.poll.vars.pollStepForms[2]+".pollNick",dimText:'Nickname'});GupShup.html.poll.vars.pollNick.init();GupShup.html.poll.vars.pollQuestion.addListner('counter',{holder:'pollCount'});for(var i=0;i<GupShup.html.poll.vars.pollOptions.length;i++)
{GupShup.html.poll.vars.pollOptions[i]=new GupShup.forms.controls({name:GupShup.html.poll.vars.pollStepForms[1]+".pollOption"+(i+1),dimText:''});}
GupShup.html.poll.vars.accessTabs=new GupShup.widget.TabView("pollAccessSettings");GupShup.html.poll.vars.accessTabs.yahooTabView.addListener('activeTabChange',GupShup.html.poll.methods.changePollAccessType);GupShup.html.poll.methods.setCurrTime();},setCurrTime:function(){var startFormName=GupShup.html.poll.vars.pollStepForms[2];var endFormName=GupShup.html.poll.vars.pollStepForms[3];var startForm=document.forms[startFormName];var endForm=document.forms[endFormName];var date=new Date();var hours=date.getHours();var mins=date.getMinutes();if(hours>=12)
{hours-=12;endForm.meridiem.options[1].selected='true';startForm.meridiem.options[1].selected='true';}
startForm.hours.options[hours].selected='true';startForm.mins.options[mins].selected='true';endForm.hours.options[hours].selected='true';endForm.mins.options[mins].selected='true';var timestamp=date.getTime();GupShup.html.poll.methods.setSelectedDate(0,timestamp);},setMaxDate:function(index,timeStamp){var calObj=GupShup.html.poll.vars.calender[index];var nextDate=new Date();nextDate.setTime(timeStamp);calObj.cfg.setProperty('maxdate',nextDate);calObj.render();},setMinDate:function(index,timeStamp){var calObj=GupShup.html.poll.vars.calender[index];var nextDate=new Date();nextDate.setTime(timeStamp);calObj.cfg.setProperty('mindate',nextDate);calObj.render();},setSelectedDate:function(index,timeStamp){var calObj=GupShup.html.poll.vars.calender[index];var nextDate=new Date();nextDate.setTime(timeStamp);calObj.select(nextDate);calObj.render();},setUpCalender:function(timeStamp,index){var container=GupShup.html.poll.vars.dateContainers[index];var currDate=new Date();currDate.setTime(timeStamp);var calObj=new YAHOO.widget.Calendar(container);calObj.cfg.setProperty('close',true);GupShup.html.poll.vars.calender[index]=calObj;GupShup.html.poll.methods.setMinDate(index,currDate.getTime());if(index==1)
GupShup.html.poll.methods.setMaxDate(index,(timeStamp+GupShup.html.poll.vars.maxEndInterval));calObj.selectEvent.subscribe(GupShup.html.poll.methods.dateChange,index);},showCalender:function(containerIndex){GupShup.html.poll.methods.hideCalenders();GupShup.html.util.showElement(GupShup.html.poll.vars.dateContainers[containerIndex]);},hideCalenders:function(){for(var i=0;i<GupShup.html.poll.vars.dateContainers.length;i++)
GupShup.html.util.hideElement(GupShup.html.poll.vars.dateContainers[i]);},dateChange:function(eName,eParam,index){var selCal1Date=GupShup.html.poll.vars.calender[index].getSelectedDates()[0];GupShup.html.poll.methods.setDateFieldInputBox(selCal1Date,index);if(index==0)
{var maxTime=selCal1Date.getTime()+GupShup.html.poll.vars.maxEndInterval;GupShup.html.poll.methods.setMaxDate(1,maxTime);GupShup.html.poll.methods.setMinDate(1,selCal1Date.getTime());var selCal2Date=GupShup.html.poll.vars.calender[1].getSelectedDates()[0];if(typeof selCal2Date=="object")
{if((selCal2Date.getTime()<selCal1Date.getTime())||(selCal2Date.getTime()>maxTime))
GupShup.html.poll.methods.setSelectedDate(1,maxTime);}
else
GupShup.html.poll.methods.setSelectedDate(1,selCal1Date.getTime()+GupShup.html.poll.vars.maxEndInterval);}
else
{GupShup.html.poll.vars.endDateSet=true;}
GupShup.html.poll.methods.hideCalenders();},setDateFieldInputBox:function(selDate,index){var dateStr=(selDate.getMonth()+1)+"/"+selDate.getDate()+"/"+selDate.getFullYear();var formName=GupShup.html.poll.vars.dateFormNames[index];document.forms[formName].date.value=dateStr;},setPollFormValues:function(key,value){var form=document.forms[GupShup.html.poll.vars.pollForm];form[key].value=GupShup.util.trim(value);},getPollFormValues:function(key){var form=document.forms[GupShup.html.poll.vars.pollForm];return form[key].value;},changePollAccessType:function(e){var newTab=e.newValue;var vlabel=newTab.get('label');setTimeout("GupShup.html.poll.methods.switchPollAccessType('"+vlabel+"')",100);},switchPollAccessType:function(type){var formName=GupShup.html.poll.vars.pollStepForms[4];switch(type)
{case'Public':document.forms[formName].accessTypePub.checked='checked';document.forms[formName].accessTypePri.checked=false;document.forms[formName].phonesPublic.value=document.forms[formName].phonesPrivate.value;GupShup.html.poll.methods.setPollFormValues('pollType',true);break;case'Private':document.forms[formName].accessTypePri.checked='checked';document.forms[formName].accessTypePub.checked=false;document.forms[formName].phonesPrivate.value=document.forms[formName].phonesPublic.value;GupShup.html.poll.methods.setPollFormValues('pollType',false);break;}},isPollNameValid:function(checkAvailability){var form=GupShup.html.poll.vars.pollStepForms[1];var pollName=GupShup.util.trim(document.forms[form].pollName.value);var status=GupShup.html.util.isNickValid(pollName,15);var filterUnderScore=/[_]+/;if(filterUnderScore.test(pollName))
status={status:false,code:'INVALID_CHAR'};if(pollName.toLowerCase()=="poll")
status={status:false,code:'NOT_ALLOWED'};if(pollName.toLowerCase()=="status")
status={status:false,code:'NOT_ALLOWED'};if(status.status==false)
{switch(status.code)
{case'LENGTH':GupShup.forms.showNotification(GupShup.html.errorMessages.invalidPollName(GupShup.html.poll.vars.pollNameLimit),{failure:true});break;case'INVALID_CHAR':GupShup.forms.showNotification(GupShup.html.errorMessages.invalidPollName(GupShup.html.poll.vars.pollNameLimit),{failure:true});break;case'NOT_ALLOWED':GupShup.forms.showNotification(GupShup.html.errorMessages.blockedPollName,{failure:true});break;}
return false;}
else
{if(checkAvailability)
{var reqUrl=GupShup.html.poll.vars.pollNameStatusServlet+"?pollName="+pollName;var callBack={success:GupShup.html.poll.methods.isPollNameValidSuccess,failure:GupShup.html.poll.methods.isPollNameValidFailure}
GupShup.ajax.send('GET',reqUrl,callBack,'PAGINATION');return true;}
else
{GupShup.html.poll.methods.setPollFormValues('pollName',pollName);return true;}}},isPollNameValidSuccess:function(xhr){var status=xhr.responseText;switch(status)
{case'INVALID':GupShup.forms.showNotification(GupShup.html.errorMessages.invalidPollName(GupShup.html.poll.vars.pollNameLimit),{failure:true});return;case'VALID':GupShup.forms.showNotification(GupShup.html.errorMessages.validPollName,{success:true});return;case'DUPLICATE':GupShup.forms.showNotification(GupShup.html.errorMessages.duplicatePollName,{failure:true});return;}},isPollNameValidFailure:function(xhr){GupShup.forms.showNotification(GupShup.html.errorMessages.internalError,{failure:true});return;},switchQuestionType:function(){var formName=GupShup.html.poll.vars.pollStepForms[1];var qType=document.forms[formName].yesNoPoll;for(var i=0;i<qType.length;i++)
{if(qType[i].checked==true)
{if(qType[i].value=="true")
{GupShup.html.util.showElement('yesNoPollEg');GupShup.html.util.hideElement('customPollEg');GupShup.html.util.hideElement('pollOptions');GupShup.html.poll.methods.setPollFormValues('yesNoPoll',true);}
else
{GupShup.html.util.showElement('customPollEg');GupShup.html.util.hideElement('yesNoPollEg');GupShup.html.util.showElement('pollOptions');GupShup.html.poll.methods.setPollFormValues('yesNoPoll',false);}}}},validatePollOptions:function(){var val=GupShup.html.poll.methods.getPollFormValues('yesNoPoll');if(val=="true")
return true;else
{var count=0;var optnStr='';var filterUnderScore=/^[_]+$/;var filterSingleQuotes=/^[']+$/;var optArray=new Array();for(var i=0;i<GupShup.html.poll.vars.pollOptions.length;i++)
{var val=GupShup.html.poll.vars.pollOptions[i].getValue();if(val.length>0)
{for(var j=0;j<optArray.length;j++)
{if(optArray[j]==val.toLowerCase())
{GupShup.forms.showNotification(GupShup.html.errorMessages.duplicatePollOptions,{failure:true});return false;}}
if(GupShup.util.isValidContent(val,stopWords)&&(/^[\w ']+$/.test(val))&&!filterSingleQuotes.test(val)&&!filterUnderScore.test(val))
{count++;GupShup.html.poll.methods.setPollFormValues('option'+(count),val);optArray.push(val.toLowerCase());}
else
{GupShup.forms.showNotification(GupShup.html.errorMessages.invalidPollOptions,{failure:true});return false;}}}
if(count<2)
{GupShup.forms.showNotification(GupShup.html.errorMessages.invalidPollOptions,{failure:true});return false;}
else
{GupShup.html.poll.methods.setPollFormValues('optionCount',count);return true;}}},validateFirstStep:function(){if(GupShup.html.poll.methods.isPollNameValid(false))
{var que=GupShup.html.poll.vars.pollQuestion.getValue();if(que.length>0&&!GupShup.html.poll.vars.pollQuestion.isDefaultText()&&que.length<=GupShup.html.poll.vars.pollQLimit)
{if(!GupShup.util.isValidContent(que,stopWords))
{GupShup.forms.showNotification(GupShup.html.errorMessages.objectionablePoll,{failure:true});return false;}
if(GupShup.util.isAscii(que))
{GupShup.html.poll.methods.setPollFormValues('question',que);if(GupShup.html.poll.methods.validatePollOptions())
{GupShup.html.poll.methods.createPollWidgetInDiv(0);GupShup.html.poll.methods.createPollWidgetInDiv(2);GupShup.html.poll.methods.switchPollSteps(2);return;}}
else
{GupShup.forms.showNotification(GupShup.html.errorMessages.invalidPollQ,{failure:true});return false;}}
else
{GupShup.forms.showNotification(GupShup.html.errorMessages.invalidPollQ,{failure:true});return false;}}},createPollWidgetInDiv:function(index){var pollData=GupShup.html.poll.methods.getPollDataObject();pollData.pollQ=GupShup.util.escapeCharsForHTML(pollData.pollQ);var tmpl=GupShup.util.getInnerHTML(GupShup.html.poll.vars.pollWidgetsTemplate[index]);var html=GupShup.util.expandTemplate(tmpl,GupShup.html.poll.templates.pollDemoTemplate,[pollData]);html=html.replace('<!--','').replace('-->','');GupShup.util.setInnerHTML(GupShup.html.poll.vars.pollWidgets[index],html);document.getElementById("pollEmbedCode").value=GupShup.util.trim(html);},switchPollSteps:function(stepNo)
{GupShup.forms.hideNotification();for(var i=1;i<GupShup.html.poll.vars.pollStepContainers.length;i++)
{GupShup.html.util.hideElement(GupShup.html.poll.vars.pollStepContainers[i]);GupShup.html.util.hideElement(GupShup.html.poll.vars.pollStepRhsContainers[i]);if(i<GupShup.html.poll.vars.pollStepLI.length)
GupShup.html.util.setClass(GupShup.html.poll.vars.pollStepLI[i],'');}
GupShup.html.util.showElement(GupShup.html.poll.vars.pollStepContainers[stepNo]);GupShup.html.util.showElement(GupShup.html.poll.vars.pollStepRhsContainers[stepNo]);GupShup.html.util.showElement(GupShup.html.poll.vars.pollStepLI[0]);if(stepNo<GupShup.html.poll.vars.pollStepLI.length)
GupShup.html.util.setClass(GupShup.html.poll.vars.pollStepLI[stepNo],'active');else
GupShup.html.util.hideElement(GupShup.html.poll.vars.pollStepLI[0]);},editUserNick:function(){GupShup.html.poll.vars.pollNick.get('object').removeAttribute('readonly','readonly');GupShup.html.poll.vars.pollNick.get('object').focus();},isValidDateSet:function(){var startFormName=GupShup.html.poll.vars.pollStepForms[2];var endFormName=GupShup.html.poll.vars.pollStepForms[3];var startForm=document.forms[startFormName];var endForm=document.forms[endFormName];var selCal2Date=GupShup.html.poll.vars.calender[1].getSelectedDates()[0];var selCal1Date=GupShup.html.poll.vars.calender[0].getSelectedDates()[0];if(typeof selCal2Date=='object')
{var hrs=parseInt(endForm.hours.options[endForm.hours.selectedIndex].value)+parseInt(endForm.meridiem.options[endForm.meridiem.selectedIndex].value);selCal2Date.setHours(hrs);selCal2Date.setMinutes(endForm.mins.options[endForm.mins.selectedIndex].value);}
else
return false;if(typeof selCal1Date=='object')
{var hrs=parseInt(startForm.hours.options[startForm.hours.selectedIndex].value)+parseInt(startForm.meridiem.options[startForm.meridiem.selectedIndex].value);selCal1Date.setHours(hrs);selCal1Date.setMinutes(startForm.mins.options[startForm.mins.selectedIndex].value);}
else
return false;if(selCal2Date.getTime()<=selCal1Date.getTime())
return false;GupShup.html.poll.methods.setPollFormValues('startDate',selCal1Date.getTime());GupShup.html.poll.methods.setPollFormValues('endDate',selCal2Date.getTime());return true;},validateSecondStep:function()
{if(GupShup.html.poll.vars.pollNick.isDefaultText())
{GupShup.forms.showNotification(GupShup.html.errorMessages.blankNick,{failure:true});return;}
var status=GupShup.html.util.isNickValid(GupShup.html.poll.vars.pollNick.getValue());if(status.status==false)
{GupShup.forms.showNotification(status.err,{failure:true});return;}
else
GupShup.html.poll.methods.setPollFormValues('nick',GupShup.html.poll.vars.pollNick.getValue());if(!GupShup.html.poll.methods.isValidDateSet())
{GupShup.forms.showNotification(GupShup.html.errorMessages.invalidPollDates,{failure:true});return;}
var accessType=GupShup.html.poll.methods.getPollFormValues('pollType');var formName=GupShup.html.poll.vars.pollStepForms[4];var val='';if(accessType=="false")
{val=document.forms[formName].phonesPrivate.value;}
else
{val=document.forms[formName].phonesPublic.value;}
status=GupShup.html.util.validatePhoneList(val,false);switch(status.status)
{case'INVALID':GupShup.forms.showNotification(GupShup.html.errorMessages.invalidInvitePhone,{failure:true});return;case'DUPLICATE':GupShup.forms.showNotification(GupShup.html.errorMessages.invitePhoneDuplicates,{failure:true});return;}
if(status.total==0&&accessType=="false")
{GupShup.forms.showNotification(GupShup.html.errorMessages.pollInvitePhone,{failure:true});return;}
if(status.total>GupShup.html.poll.vars.inviteLimit)
{GupShup.forms.showNotification(GupShup.html.errorMessages.getPollLimitReachedMsg(GupShup.html.poll.vars.inviteLimit),{failure:true});return;}
GupShup.html.poll.methods.setPollFormValues('phones',val);GupShup.html.poll.methods.expandPollStepsThree();GupShup.html.poll.methods.switchPollSteps(3);return;},getPollDataObject:function(){var pollData={};pollData.pollName=GupShup.html.poll.methods.getPollFormValues('pollName');pollData.pollId=GupShup.html.poll.vars.pollId;pollData.pollQ=GupShup.util.replaceNewLine(GupShup.html.poll.methods.getPollFormValues('question'),' ');pollData.pollOptions=new Array();pollData.yesNoPoll=GupShup.html.poll.methods.getPollFormValues('yesNoPoll')=="true"?true:false;if(!pollData.yesNoPoll)
{var len=parseInt(GupShup.html.poll.methods.getPollFormValues('optionCount'));for(var i=1;i<=len;i++)
pollData.pollOptions.push({pollOption:GupShup.html.poll.methods.getPollFormValues('option'+i),pollKey:String.fromCharCode(64+i)});}
else
pollData.pollOptions=[{pollOption:'Yes',pollKey:'Y'},{pollOption:'No',pollKey:'N'}];pollData.accessType=GupShup.html.poll.methods.getPollFormValues('pollType')=="true"?"Public":"Private";pollData.pollAuthor=GupShup.html.poll.methods.getPollFormValues('nick');pollData.pollStart=GupShup.html.poll.methods.getPollFormValues('startDate');pollData.pollEnd=GupShup.html.poll.methods.getPollFormValues('endDate');return pollData;},expandPollStepsThree:function(){var pollData=GupShup.html.poll.methods.getPollDataObject();pollData.pollQ=GupShup.util.escapeCharsForHTML(pollData.pollQ);GupShup.util.expandTemplateInDiv('poll_step3','pollDemoTemplate',GupShup.html.poll.templates.pollDemoTemplate,[pollData]);},getPollOptString:function(options,data){var str='';for(var i=0;i<options.length;i++)
str+=options[i].pollKey+") "+options[i].pollOption+' ';return str;},getPollOptEgString:function(options,data){for(var i=0;i<options.length;i++)
{options[i].pollName=data.pollName;options[i].sep='';if(i<(options.length-1))
options[i].sep='OR';}
return GupShup.util.expandTemplate(GupShup.util.getInnerHTML('pollOptionTemplate'),GupShup.html.poll.templates.pollOptionEgTemplate,options);},getPollDateString:function(dateTime){var date=new Date();date.setTime(dateTime);var hrs=date.getHours();return(date.toDateString()+" "+((hrs>=12)?(hrs-12):hrs)+":"+date.getMinutes()+" "+((hrs>=12)?"PM":"AM"));},getPollOptWidgetString:function(options,data){var str='';for(var i=0;i<options.length;i++)
str=str+options[i].pollOption+(i<(options.length-1)?',':'');return str;},submitPoll:function(){var callback={success:GupShup.html.poll.methods.pollSuccess,failure:GupShup.html.poll.methods.pollFailed,argument:{}};GupShup.html.util.submitFormUsingAjax('POST',GupShup.conf.webWriteUrl,callback,GupShup.html.poll.vars.pollForm);},cancelPoll:function(cancelUrl){if(confirm("You are just a one click away from creating poll. Are you sure you want to cancel poll creation process?"))
{window.location=cancelUrl;}},pollFailed:function(xhr){},pollSuccess:function(xhr){var pollResp=GupShup.util.getJsonFromResponse(xhr.responseText);switch(pollResp.status)
{case"SUCCESS":{GupShup.html.poll.vars.pollId=pollResp.pollId;GupShup.html.poll.methods.createPollWidgetInDiv(1);GupShup.html.poll.methods.switchPollSteps(4);GupShup.forms.hideNotification();break;}
case"FAILURE":{switch(pollResp.errorCode)
{case"DUPLICATE":{GupShup.html.poll.methods.switchPollSteps(1);GupShup.forms.showNotification(GupShup.html.errorMessages.duplicatePollName,{failure:true});break;}
case"NICK_FAIL":{GupShup.html.poll.methods.switchPollSteps(2);GupShup.forms.showNotification(pollResp.message,{failure:true});break;}
case"LIMIT_REACHED":{GupShup.html.poll.methods.switchPollSteps(1);GupShup.forms.showNotification(pollResp.message,{failure:true});break;}
case"SESSION_TIMEOUT":{GupShup.forms.showNotification(pollResp.message,{failure:true});break;}
case"INVALID_PARAM":{GupShup.html.poll.methods.switchPollSteps(1);GupShup.forms.showNotification('Details you have entered are invalid. Please make sure that you have filled all information correctly.',{failure:true});break;}
default:{GupShup.forms.showNotification(GupShup.html.errorMessages.internalError,{failure:true});break;}}
break;}}}}
GupShup.html.poll.templates={pollDemoTemplate:[{key:'$POLL_NAME$',dataMember:'pollName'},{key:'$POLL_ID$',dataMember:'pollId'},{key:'$POLL_Q$',dataMember:'pollQ'},{key:'$POLL_OPTION_WIDGET_STR$',dataMember:'pollOptions',dataProcessor:GupShup.html.poll.methods.getPollOptWidgetString},{key:'$POLL_OPTION_STR$',dataMember:'pollOptions',dataProcessor:GupShup.html.poll.methods.getPollOptString},{key:'$POLL_OPTION_EXAMPLE$',dataMember:'pollOptions',dataProcessor:GupShup.html.poll.methods.getPollOptEgString},{key:'$POLL_AUTHOR$',dataMember:'pollAuthor'},{key:'$POLL_START$',dataMember:'pollStart',dataProcessor:GupShup.html.poll.methods.getPollDateString},{key:'$POLL_END$',dataMember:'pollEnd',dataProcessor:GupShup.html.poll.methods.getPollDateString},{key:'$POLL_ACCESS$',dataMember:'accessType'}],pollOptionEgTemplate:[{key:'$POLL_NAME$',dataMember:'pollName'},{key:'$POLL_KEY$',dataMember:'pollKey'},{key:'$POLL_OPTION$',dataMember:'pollOption'},{key:'$SEPERATOR$',dataMember:'sep'}]};GupShup.callback.processSubscribeResp=function(xhr){var status=GupShup.util.getJsonFromResponse(xhr.responseText);switch(status.status)
{case'SUCCESS':{switch(status.errorCode)
{case'SUCCESS':case'NO_ERROR':case'TRIAL':case'JOIN':GupShup.util.postData(GupShup.conf.contextPath+'/subscribedGroupMessages?entityName='+status.entityDetails.orgName,'status','joined','message',status.message);break;}}
break;case'FAILURE':{GupShup.forms.showNotification(status.message,{failure:true});}}};GupShup.callback.processComSubscribeResp=function(xhr){var status=GupShup.util.getJsonFromResponse(xhr.responseText);var comName=status.params.comName;var id=status.params.entityId;switch(status.status)
{case'SUCCESS':{switch(status.errorCode)
{case'SUCCESS':case'NO_ERROR':case'JOIN':GupShup.forms.showNotification('You joined the community '+comName+'.',{success:true});GupShup.html.util.hideElement('communityJoinBtn_'+id);break;}}
break;case'FAILURE':{GupShup.forms.showNotification('There was internal error while joining community '+comName+', please try again later.',{failure:true});}}};(function(){GupShup.html.activatePage=GupShup.html.activatePage||{isReactivatePage:false,isIndianPhone:true,codeControl:null,phoneControl:null,countryCodeControl:null,actCode:null,isSelfActivationInProgress:false,activationFormSubmitSuccess:function(o,obj){var response=GupShup.util.getJsonFromResponse(o.responseText);if(response.status=="SUCCESS")
{if(!obj.isReactivatePage)
window.location=GupShup.conf.contextPath+"/"+response.nextServlet;else
GupShup.util.postData(GupShup.conf.contextPath+'/gupshupspace','status',response.status,'message',response.message);}
else if(response.status=="WARNING"&&obj.isReactivatePage)
{var merge=confirm(GupShup.html.errorMessages.mergeSubscriber);if(merge)
{document.activationForm.force.value="true";var callback={success:function(o){obj.activationFormSubmitSuccess(o,obj)},failure:function(o){obj.activationFormSubmitFailure(o,obj)},argument:{}};GupShup.html.util.submitFormUsingAjax('POST',GupShup.conf.writeUrl+"&type=MOBILE_COMPARE_CODE",callback,'activationForm');}
else
{window.location=GupShup.conf.contextPath+"/gupshupspace";}}
else if(response.errorCode=="MAXLIMITREACHED")
{if(!obj.isReactivatePage)
{GupShup.forms.showNotification(response.message,{failure:true});GupShup.html.util.hideElement('allowVerify');GupShup.html.util.showElement('limitReached');}
else
{GupShup.util.postData(GupShup.conf.contextPath+'/gupshupspace','status',response.status,'message',response.message);}}
else
{GupShup.html.util.enableBtn('verifyId');GupShup.forms.showNotification(response.message,{failure:true});if(typeof response.alert!='undefined')
{obj.codeControl.showNotification(response.alert,{failure:true,position:'right'});}}},activationFormSubmitFailure:function(o,obj){GupShup.html.util.enableBtn('verifyId');GupShup.forms.showNotification(GupShup.html.errorMessages.internalError,{failure:true});},sendActivationCodeFormSubmitSuccess:function(o,obj){GupShup.html.util.enableBtn('sendCodeId');var response=GupShup.util.getJsonFromResponse(o.responseText);if(response.status=="SUCCESS")
{if(obj.isReactivatePage&&(response.errorCode=="PHONECHANGE_REVERTED"))
{GupShup.util.postData(GupShup.conf.contextPath+'/gupshupspace','status',response.status,'message',response.message);return;}
else
{var refreshPage=obj.isReactivatePage?"reactivate":"activate";var message=response.message;if(obj.countryCodeControl.get('value')=="91")
message="Phone number changed.";GupShup.util.postData(GupShup.conf.contextPath+'/'+refreshPage,'status','SUCCESS','message',message);}}
else
{GupShup.forms.showNotification(response.message,{failure:true});}},sendActivationCodeFormSubmitFailure:function(o,obj){GupShup.html.util.enableBtn('sendCodeId');GupShup.forms.showNotification(GupShup.html.errorMessages.internalError,{failure:true});},validateActivationForm:function(activationCode){if(activationCode.length!=4)
{this.codeControl.showNotification(GupShup.html.errorMessages.invalidVerifyCode,{failure:true,position:'right'});return false;}
return true;},checkVerificationStatus:function(){GupShup.html.util.disableBtn('chkStatusId');var obj=this;var callback={success:function(o){obj.checkStatusHandler(o,obj)},failure:function(o){obj.checkStatusHandler(o,obj)}};GupShup.ajax.send('GET',GupShup.conf.contextPath+"/checkVerificationStatus",callback,'READ');},checkStatusHandler:function(o,obj){GupShup.html.util.enableBtn('chkStatusId');var response=GupShup.util.trim(o.responseText);if(response=="VERIFIED")
{if(!obj.isReactivatePage)
window.location=GupShup.conf.contextPath+"/createProfile";else
GupShup.util.postData(GupShup.conf.contextPath+'/gupshupspace','status',"SUCCESS",'message',"Phone number changed.");}
else if(response=="NOTVERIFIED")
GupShup.forms.showNotification(GupShup.html.errorMessages.getActivateMobileErr(GupShup.html.activatePage.actCode),{warning:true});else
GupShup.forms.showNotification(GupShup.html.errorMessages.internalError,{failure:true});},verify:function(){var activationCode=this.codeControl.get('value');GupShup.html.util.disableBtn('verifyId');if(this.validateActivationForm(activationCode))
{var obj=this;var callback={success:function(o){obj.activationFormSubmitSuccess(o,obj)},failure:function(o){obj.activationFormSubmitFailure(o,obj)},argument:{}};GupShup.html.util.submitFormUsingAjax('POST',GupShup.conf.writeUrl+"&type=MOBILE_COMPARE_CODE",callback,'activationForm');}
else
{GupShup.html.util.enableBtn('verifyId');}},sendActivationCode:function(){var phone=this.phoneControl.get('value');var cCode=this.countryCodeControl.get('value');GupShup.html.util.disableBtn('sendCodeId');if(this.validateResendActivationCodeForm(phone,cCode))
{var obj=this;var callback={success:function(o){obj.sendActivationCodeFormSubmitSuccess(o,obj)},failure:function(o){obj.sendActivationCodeFormSubmitFailure(o,obj)},argument:{phone:phone,cCode:cCode}};GupShup.html.util.submitFormUsingAjax('POST',GupShup.conf.writeUrl+"&type=MOBILE_SET_CODE&phone="+phone+"&countryCode="+cCode,callback,'sendActivationCodeForm');}
else
{GupShup.html.util.enableBtn('sendCodeId');}},validateResendActivationCodeForm:function(phone,cCode){if(phone.length<1)
{this.phoneControl.showNotification(GupShup.html.errorMessages.blankPhone,{failure:true,position:'right'});return false;}
var status=GupShup.util.isValidPhone(cCode,phone);if(!status)
this.phoneControl.showNotification(GupShup.html.errorMessages.invalidPhone,{failure:true,position:'right'});return status;},initPage:function(isReactivatePage,isIndianPhone,isSelfActivationInProgress){this.isReactivatePage=isReactivatePage;this.isIndianPhone=isIndianPhone;this.isSelfActivationInProgress=isSelfActivationInProgress;if(!isIndianPhone||!isSelfActivationInProgress)
{this.codeControl=new GupShup.forms.controls({name:'activationForm.code',dimText:'',limit:-1,toolTip:''}),this.codeControl.init();}
this.phoneControl=new GupShup.forms.controls({name:'sendActivationCodeForm.phone',dimText:'',limit:18,toolTip:''}),this.phoneControl.init();this.countryCodeControl=new GupShup.forms.controls({name:'sendActivationCodeForm.countryCode'}),this.countryCodeControl.init();}}})();(function(){GupShup.html.accountSettingsPage=GupShup.html.accountSettingsPage||{currentPasswordControl:new GupShup.forms.controls({name:'changePasswordForm.curPassword',toolTip:'',limit:50}),newPasswordControl:new GupShup.forms.controls({name:'changePasswordForm.newPassword',toolTip:'',limit:50}),verifyPasswordControl:new GupShup.forms.controls({name:'changePasswordForm.verifiedPassword',toolTip:'',limit:50}),countryCodeControl:new GupShup.forms.controls({name:'changePhoneForm.countryCode',toolTip:''}),phoneControl:new GupShup.forms.controls({name:'changePhoneForm.newPhone',toolTip:''}),changePasswordInFailure:function(o,obj){GupShup.forms.showNotification(GupShup.html.errorMessages.internalError,{failure:true});obj.currentPasswordControl.set("");obj.newPasswordControl.set("");obj.verifyPasswordControl.set("");GupShup.html.util.enableBtn('changePasswordBtnId');},changePasswordInSuccess:function(o,obj){var response=GupShup.util.getJsonFromResponse(o.responseText);obj.currentPasswordControl.set("");obj.newPasswordControl.set("");obj.verifyPasswordControl.set("");GupShup.html.util.enableBtn('changePasswordBtnId');if(response.status=="SUCCESS")
{GupShup.forms.showNotification(response.message,{success:true});}
else
{GupShup.forms.showNotification(response.message,{failure:true});}},validateChangePasswordForm:function(){var currPass=this.currentPasswordControl.get('value');var newPass=this.newPasswordControl.get('value');var vrfyPass=this.verifyPasswordControl.get('value');if((currPass!="")&&(newPass!="")&&(vrfyPass!=""))
{var pwdValue=b64_md5(currPass+GupShup.conf.systemSalt);if(pwdValue!=userPassword)
{this.currentPasswordControl.showNotification(GupShup.html.errorMessages.passwordMismatch,{failure:true,position:'right'});return false;}
if(newPass!=vrfyPass)
{this.newPasswordControl.showNotification(GupShup.html.errorMessages.verifyPassMismatch,{failure:true,position:'right'});return false;}
if(newPass.length<5)
{this.newPasswordControl.showNotification(GupShup.html.errorMessages.currentPassLength,{failure:true,position:'right'});return false;}
return true;}
else
{if(currPass=="")
{this.currentPasswordControl.showNotification(GupShup.html.errorMessages.blankCurrentPass,{failure:true,position:'right'});return false;}
else if(newPass=="")
{this.newPasswordControl.showNotification(GupShup.html.errorMessages.blankNewPass,{failure:true,position:'right'});return false;}
else if(vrfyPass=="")
{this.verifyPasswordControl.showNotification(GupShup.html.errorMessages.verifyPassMismatch,{failure:true,position:'right'});return false;}}
return false;},changePassword:function(){GupShup.html.util.disableBtn('changePasswordBtnId');if(this.validateChangePasswordForm())
{var password=this.newPasswordControl.get('value');document.changePasswordForm.changedPass.value=b64_md5(password+GupShup.conf.systemSalt);GupShup.util.putDummyPassword(this.newPasswordControl.get('object'));GupShup.util.putDummyPassword(this.currentPasswordControl.get('object'));GupShup.util.putDummyPassword(this.verifyPasswordControl.get('object'));var obj=this;var callback={success:function(o){obj.changePasswordInSuccess(o,obj)},failure:function(o){obj.changePasswordInFailure(o,obj)},argument:{}};GupShup.html.util.submitFormUsingAjax('POST',GupShup.conf.writeUrl+"&type=CHANGE_PASSWORD",callback,'changePasswordForm');}
else
{GupShup.html.util.enableBtn('changePasswordBtnId');return false;}},changeAlertSettings:function(){GupShup.html.util.disableBtn('changeAlertSettingsSubBtnId');var obj=this;var callback={success:function(o){obj.alertSettingsInSuccess(o,obj)},failure:function(o){obj.alertSettingsInFailure(o,obj)},argument:{}};GupShup.html.util.submitFormUsingAjax('POST',GupShup.conf.writeUrl+"&type=ALERT_SETTINGS",callback,'changeAlertSettingsForm');},alertSettingsInFailure:function(o){GupShup.forms.showNotification(GupShup.html.errorMessages.internalError,{failure:true});GupShup.html.util.enableBtn('changeAlertSettingsSubBtnId');},alertSettingsInSuccess:function(o){var response=GupShup.util.getJsonFromResponse(o.responseText);GupShup.html.util.enableBtn('changeAlertSettingsSubBtnId');if(response.status=="SUCCESS")
{GupShup.forms.showNotification(response.message,{success:true});}
else
{GupShup.forms.showNotification(response.message,{failure:true});}},validateChangePhone:function(){phone=this.phoneControl.get('value');cCode=this.countryCodeControl.get('value');if(phone.length==0)
{this.phoneControl.showNotification(GupShup.html.errorMessages.blankPhone,{failure:true,position:'right'});return false;}
if(!GupShup.util.isValidPhone(cCode,phone))
{this.phoneControl.showNotification(GupShup.html.errorMessages.invalidPhone,{failure:true,position:'right'});return false;}
return true;},changePhone:function(){GupShup.html.util.disableBtn('changePhoneBtnId');if(this.validateChangePhone())
{var obj=this;var callback={success:function(o){obj.changePhoneInSuccess(o,obj)},failure:function(o){obj.changePhoneInFailure(o,obj)},argument:{}};GupShup.html.util.submitFormUsingAjax('POST',GupShup.conf.writeUrl+"&type=CHANGE_PHONE",callback,'changePhoneForm');}
else
{GupShup.html.util.enableBtn('changePhoneBtnId');}
return false;},changePhoneInFailure:function(o){GupShup.forms.showNotification(GupShup.html.errorMessages.internalError,{failure:true});GupShup.html.util.enableBtn('changePhoneBtnId');},changePhoneInSuccess:function(o){var response=GupShup.util.getJsonFromResponse(o.responseText);GupShup.html.util.enableBtn('changePhoneBtnId');if(response.status=="SUCCESS")
{if(response.errorCode=="NO_ERROR")
{GupShup.util.postData(GupShup.conf.contextPath+'/reactivate','status',response.status,'message',response.message);}
else
{GupShup.forms.showNotification(response.message,{success:true});}}
else
{GupShup.forms.showNotification(response.message,{failure:true});}},initPage:function(){var accountSettingsControls=[GupShup.html.accountSettingsPage.currentPasswordControl,GupShup.html.accountSettingsPage.newPasswordControl,GupShup.html.accountSettingsPage.verifyPasswordControl,GupShup.html.accountSettingsPage.phoneControl,GupShup.html.accountSettingsPage.countryCodeControl];GupShup.forms.controls.initControls(accountSettingsControls);}}})();
