Type.registerNamespace("GG");
Type.registerNamespace("GG.M");
GG.M.S=function(options){GG.M.S.initializeBase(this,[options]);
};
GG.M.S.OK=function(control){var instance=GG.Modal.Instance;
instance.okClick();
return false;
};
GG.M.S.PreviousEmailedClick=function(control){var instance=GG.Modal.Instance;
instance.emailForm.style.display="none";
instance.previousShareList.style.display="block";
instance.importerForm.style.display="none";
instance.currentWrapper="previous";
instance.previousEmailLink.style.color="#fff";
instance.importEmailLink.style.color="#737272";
return false;
};
GG.M.S.ImportEmails=function(control){var instance=GG.Modal.Instance;
instance.emailForm.style.display="none";
instance.previousShareList.style.display="none";
instance.importerForm.style.display="block";
instance.currentWrapper="import";
instance.previousEmailLink.style.color="#737272";
instance.importEmailLink.style.color="#fff";
return false;
};
GG.M.S.CheckAll=function(control){var instance=GG.Modal.Instance;
var scroller=(instance.currentWrapper=='previous')? instance.previousScroller: instance.importScroller;
var checked=control.checked;
var list=scroller.getElementsByTagName("input");
for(var i=0;i<list.length;i++){if(list[i]==control)continue;
GG.M.S.DoCheck(list[i],checked);
}};
GG.M.S.Cancel=function(control){var instance=GG.Modal.Instance;
instance.resetToDefault();
instance.previousEmailLink.style.color="#737272";
instance.importEmailLink.style.color="#737272";
return false;
};
GG.M.S.SelectEmails=function(control){var instance=GG.Modal.Instance;
var scroller=(instance.currentWrapper=='previous')? instance.previousScroller: instance.importScroller;
switch(	instance.currentWrapper){case "previous":case "import":var controlList=document.getElementsByClassName(scroller,"row checkbox selected");
var emailList=[];
if(instance.txtEmails.value!=""){emailList= instance.txtEmails.value.split(",");
}for(var i=0;i<controlList.length;i++){var exists=false;
for(var a=0;a<emailList.length;a++){if(emailList[a]==controlList[i].childNodes[1].nodeValue){exists=true;
break;
}}if(false==exists)emailList.push(controlList[i].childNodes[1].nodeValue);
}instance.txtEmails.value=emailList.join(',');
instance.resetToDefault();
break;
default:alert('unknown type');
}return false;
};
GG.M.S.RetreiveEmails=function(control){var instance=GG.Modal.Instance;
if(instance.txtYourEmail.value==""|| instance.txtYourPassword.value==""){alert('The email or password cannot be blank.');
return false;
}instance.lblYourError.innerHTML=GG.getLoadingHtml()+" Loading...";
var callback=function(names){instance.lblYourError.innerHTML="";
if(names==null)instance.lblYourError.innerHTML="Invalid username or password.";
else {instance.injectNames(names,"You don't have any friends yet. Make some! :)");
instance.importerContainer.style.display="block";
}};
GG.WS.ImportEmails( instance.txtYourEmail.value, instance.txtYourPassword.value, instance.ddlYourMailType.value,callback);
return false;
};
GG.M.S.DoCheck=function(checkbox,newState){checkbox.checked=newState;
checkbox.parentNode.className=newState?"row checkbox selected":"row checkbox";
};
GG.M.S.prototype={load:function(contentItemID){var instance=this;
instance.contentItemID=contentItemID;
GG.renderControl("SHARE",contentItemID,function(html){instance.body.innerHTML=html;
instance.txtEmails=$get("Share_txtEmails");
instance.txtMessageArea=$get("Share_txtMessageArea");
instance.previousShareList=$get("Share_PreviousEmailed");
instance.wireWrapper();
});
},resetToDefault:function(){this.emailForm.style.display="block";
this.previousShareList.style.display="none";
this.importerForm.style.display="none";
},wireWrapper:function(){this.emailForm=this.getChild("friendEmailOptions","div");
this.importerForm=this.getChild("friendEmailWrap","div");
this.emailEntry=this.getChild("emailLogin","div");
this.txtYourEmail=this.getChild("small-medium email","input");
this.txtYourPassword=this.getChild("small-medium password","input");
this.ddlYourMailType=this.getChild("small-medium","select");
this.lblYourError=this.getChild("yourEmailError","label");
this.previousEmailsContainer=this.getChild("previousEmailsContainer","div");
this.importerContainer=this.getChild("importerContainer","div");
this.previousScroller=this.getChild("previousScroller scroller","div");
this.importScroller=this.getChild("importScroller scroller","div");
this.previousEmailLink=this.getChild("previousEmailLink","a");
this.importEmailLink=this.getChild("importEmailLink","a");
this.wrapLabel=this.getChild("expandedOptions","a");
},injectNames:function(list,emptyMessage){if(list.length==0){this.importScroller.style.display="none";
return;
}var html=[];
for(var i=0;i<list.length;i++){if(list[i].trim().length==0)continue;
html.push("<div class='row checkbox' onclick='GG.M.S.DoCheck(this.childNodes[0],!this.childNodes[0].checked);'><input type='checkbox' class='checkbox' onclick='this.checked=!this.checked;' />");
html.push(list[i].trim());
html.push("</div>");
}this.importScroller.style.display="";
this.importScroller.innerHTML=html.join('');
},okClick:function(){var instance=this;
if(instance.txtEmails.value==""){alert('nothing to send. enter some emails.');
return;
}var emailList=[];
if(instance.txtEmails.value!=""){var strEmails= instance.txtEmails.value.replace(/\n|\s/g,'');
var callback=function(){instance.txtYourEmail.value="";
instance.close();
alert('Emails sent');
};
GG.DPWS.SendEmail(strEmails, instance.txtMessageArea.value, instance.contentItemID,callback);
}}};
GG.M.S.registerClass("GG.M.S",GG.Modal);
Type.registerNamespace("GG");
GG.EV=function(contentItemID){GG.EV.initializeBase(this,[document.body]);
this.contentItemID=contentItemID;
this.headerWrapper=this.getChild("evHeaderWrapper","div");
this.iframe=this.getChild("evFrame","iframe");
this.mainBody=this.getChild("evBody","div");
this.voteGrindContainer=this.getChild("grinds","a");
this.voteTrashContainer=this.getChild("trashes","a");
GG.EV.Instance=this;
$addHandler(window,"resize",GG.EV.window_resize);
GG.EV.Instance.resize();
};
GG.EV.window_resize=function(){GG.EV.Instance.resize();
};
GG.EV.prototype={resize:function(){var size=GG.getPageSize();
var bounds=Sys.UI.DomElement.getBounds(this.headerWrapper);
var body=Sys.UI.DomElement.getBounds(this.mainBody);
var height=size.windowHeight-bounds.height;
var width=parseInt(this.mainBody.clientWidth);
width=width-25;
this.iframe.style.height=height-20+"px";
this.iframe.style.width=width+"px";
this.mainBody.style.height=height+"px";
},vote:function(no){if(!GG.CurrentUser.IsRegistered){GG.sendToLogin();return false;
}if(!GG.CurrentUser.IsVerified){GG.sendToUserVerification();return false;
}GG.WS.Vote("I",this.contentItemID,no,false);
var yesVotes=parseInt(this.getChild("iconGrinds","span").innerHTML);
var noVotes=parseInt(this.getChild("iconTrashes","span").innerHTML);
if(!no){yesVotes++;
}else {noVotes++;
}this.voteGrindContainer.innerHTML=String.format("<span>Grinds</span> <span class=\"iconGrinds\">{0}</span>",yesVotes.toString());
this.voteTrashContainer.innerHTML=String.format("<span>Trashes</span> <span class=\"iconTrashes\">{0}</span>",noVotes.toString());
this.voteTrashContainer.onclick=GG.returnFalseFunction;
this.voteGrindContainer.onclick=GG.returnFalseFunction;
return false;
},dispose:function(){$removeHandler(window,"resize",GG.EV.window_resize);
}};
GG.EV.registerClass("GG.EV",GG.BaseControl);
Sys.Application.notifyScriptLoaded();