var Invite={contacts:null,webmail:""};
var AjaxInvite={SendRequest:function(_1,_2,_3,_4){
var _5=null;
if(window.XMLHttpRequest){
_5=new XMLHttpRequest();
}else{
if(window.ActiveXObject){
try{
_5=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e){
try{
_5=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
alert("Your browser doesn't support AJaX");
return false;
}
}
}else{
alert("Your browser doesn't support AJaX");
return false;
}
}
_5.onreadystatechange=function(){
switch(_5.readyState){
case 0:
break;
case 1:
window.status="Loading...";
break;
case 2:
window.status="Loaded...";
break;
case 3:
window.status="Interactive...";
break;
case 4:
window.status="Complete...";
try{
if(_5.status==200){
window.status="Done";
_4(_5);
}else{
window.status="Done";
alert("AJaX request failed. Try refreshing/reloading the page.");
return false;
}
}
catch(e){
}
default:
break;
}
};
var _6=false;
if(_1.toLowerCase()=="strictpost"){
_6=true;
_1="POST";
}
_5.open(_1,_2,true);
if(_6){
_5.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
}
_5.send(_3);
}};
function FieldFocus(id){
document.getElementById(id).focus();
}
function GnUser(){
var _8="";
var _9="";
var _a="";
var _b="";
var _c="";
var _d="";
var _e="";
var _f="";
var _10="";
var _11="";
}
String.prototype.trim=function(){
return this.replace(/^\s+|\s+$/g,"");
};
function GetAbstractAge(age){
var _13=new Array(1,13,16,20,25,30,35,40,45,50,55,60);
var _14=new Array("very young","early teens","late teens","early 20's","late 20's","early 30's","late 30's","early 40's","late 40's","early 50's","late 50's","too old");
for(var i=0;i<_13.length;i++){
if(i!=(_13.length-1)){
if(age>=_13[i]&&age<_13[i+1]){
return _14[i];
}
}
}
return _14[_13.length-1];
}
function ShowGrabError(){
ShowLayer("InviteForm4",false);
var msg=document.getElementById("InviteForm3Msg");
msg.className="status01";
msg.innerHTML="Address book import failed.  Please check your e-mail address and password. ";
ShowLayer("InviteForm3",true);
}
function ShowGrabForm(_17,_18){
Invite.contacts=null;
var _19=document.forms["frmInvite"];
_19.Email.value="";
_19.Pass.value="";
if(_18){
_19.Email.value=_18;
}
ShowLayer("SendInviteForm",false);
ShowLayer("InviteForm2",false);
ShowLayer("InviteForm3",true);
document.getElementById("Webmail Logo").innerHTML="<img src='/images/Grab"+_17+".gif' alt='"+_17+"' width='150' height='70' />";
document.getElementById("CheckWebmail").innerHTML="&nbsp;"+_17+"&nbsp;";
document.getElementById("WebDomain").innerHTML="@"+_17.toLowerCase()+".com";
Invite.webmail=_17;
FieldFocus("Email");
}
function GrabContacts(){
Invite.contacts=null;
ShowLayer("InviteForm4",true);
ShowLayer("InviteForm3",false);
ShowLayer("InviteForm4Status",true);
ShowLayer("InviteForm4List",false);
var _1a=document.getElementById("frmInvite");
var _1b=_1a.Email.value;
var _1c=_1a.Pass.value;
var _1d="lib="+Invite.webmail.toLowerCase()+"lib.php&update=1&EmailAddress="+_1b+"&Passwd="+_1c;
var url="/grabber/AjaxGrabber.php";
AjaxInvite.SendRequest("STRICTPOST",url,_1d,GrabContactsReply);
}
function GrabContactsReply(_1f){
var _20=_1f.responseText;
if(_20==""){
ShowGrabError();
}else{
var _21=_20.split("&");
var _22=new Array();
var _23="";
for(var i=0;i<(_21.length-1);i++){
var _25=_21[i].split(">");
if(_25[0].trim()==""){
var _26=_25[1].split("@");
_25[0]=_26[0];
}
var _27=Cookie.GetValue("email");
if(_27!=_25[1]){
_22.push([_25[0],_25[1]]);
_23+=_25[1]+",";
}
}
Invite.contacts=_22;
_23=_23.substring(0,(_23.length-1));
var _28=Cookie.GetValue("cid");
FindGnUsers(_28,_23);
}
}
function FindGnUsers(_29,_2a){
var _2b=new Array("UserID","EmailList");
var _2c=new Array(_29,_2a);
var _2d=XmlObj.Create("FindGnUsers",_2b,_2c);
AjaxInvite.SendRequest("POST",AjaxUrl.ApiV2,_2d,FindGnUsersComplete);
}
function FindGnUsersComplete(_2e){
var xml=_2e.responseXML.documentElement;
var _30=xml.getElementsByTagName("status")[0].childNodes[0].nodeValue;
var _31=new Array();
if(_30=="true"){
var _32=xml.getElementsByTagName("DisplayName");
var _33=xml.getElementsByTagName("EmailAddress");
var age=xml.getElementsByTagName("Age");
var _35=xml.getElementsByTagName("ProvinceName");
var _36=xml.getElementsByTagName("CountryName");
var _37=xml.getElementsByTagName("ProfilePhoto");
var _38=xml.getElementsByTagName("RelationStatus");
for(var i=0;i<_32.length;i++){
_31[i]=new GnUser();
_31[i].displayName=_32[i].childNodes[0].nodeValue;
_31[i].emailAddress=_33[i].childNodes[0].nodeValue;
_31[i].age=age[i].childNodes[0].nodeValue;
_31[i].abstractAge=GetAbstractAge(_31[i].age);
_31[i].provinceName=_35[i].childNodes[0].nodeValue;
_31[i].countryName=_36[i].childNodes[0].nodeValue;
_31[i].profilePhoto=_37[i].childNodes[0].nodeValue;
_31[i].relationStatus=_38[i].childNodes[0].nodeValue;
}
}
ShowContactList(_31);
}
function ShowContactList(_3a){
var _3b=new Array();
_3b.push("<form name='frmContactList'>");
_3b.push("<div class='text3 gnMaroon'>Add your friends now!</div><br/>");
_3b.push("<div>");
_3b.push("<input type='button' class='btn01' onclick='AddAndInvite();' value='Send Invite'>&nbsp;&nbsp;");
_3b.push("</div>");
_3b.push("<div id='InviteForm4Msg1'>&nbsp;</div>");
_3b.push("<div class='text21' style='width:610px; height:30px; background-color:#c0c0c0; border:1px solid #c0c0c0;'>");
_3b.push("\t<input type='checkbox' name='allContacts' onclick='CheckAllContacts(this.checked)' checked>&nbsp;Select / Unselect All");
_3b.push("</div>");
if(_3a.length<1){
_3b.push("<div class='text42'>You have "+Invite.contacts.length+" friends who may join you on GrooveNet</div>");
for(var i=0;i<Invite.contacts.length;i++){
_3b.push("<div style='width:610px; height:30px; padding-top:5px; border:1px dotted #c0c0c0;'>");
_3b.push("\t<div style='float:left; width:50px;'><input type='checkbox' name='nonUsers' value='"+Invite.contacts[i][1]+"'checked></div>");
_3b.push("\t<div style='float:left; width:550px;'><span class='text34'>"+Invite.contacts[i][0]+"</span><span class='text21'>&nbsp;&nbsp;&lt;"+Invite.contacts[i][1]+"&gt;</span></div>");
_3b.push("</div>");
}
}else{
var _3d;
var _3e=new Array();
for(var i=0;i<Invite.contacts.length;i++){
_3d=false;
for(var j=0;j<_3a.length;j++){
if(Invite.contacts[i][1]==_3a[j].emailAddress){
_3a[j].bookName=Invite.contacts[i][0];
_3a[j].bookEmail=Invite.contacts[i][1];
_3d=true;
break;
}
}
if(!_3d){
_3e.push(Invite.contacts[i]);
}
}
_3b.push("<br/>");
_3b.push("<div class='text42'>You already have "+_3a.length+" friends on GrooveNet</div>");
for(var i=0;i<_3a.length;i++){
_3b.push("<div style='width:610px; height:100px; border:1px dotted #c0c0c0;'>");
if(_3a[i].relationStatus!=1){
_3b.push("<div style='float:left; width:50px; border:1px none #ff3300'><br/><br/><input type='checkbox' name='gnUsers' value='"+_3a[i].bookEmail+"'checked></div>");
}else{
_3b.push("<div style='float:left; width:50px; border:1px none #ff3300'><br/><br/>&nbsp;</div>");
}
_3b.push("<div style='float:left; width:300px; border:1px none #00cc00;'><br/><br/><span class='text34'>"+_3a[i].bookName+"</span><span class='text21'>&nbsp;&nbsp;&lt;"+_3a[i].bookEmail+"&gt;</span>");
if(_3a[i].relationStatus==1){
_3b.push("<br/><span class='text9 gnItalic'>On Your Friend List</span>");
}
_3b.push("</div>");
_3b.push("<div style='float:left; width:250px; border:1px none #cc3300'><br/><span class='text34'>");
_3b.push("\t<img style='border:1px solid #c0c0c0' width='70' height='70' align='left' src='"+_3a[i].profilePhoto+"'/><br/>&nbsp;&nbsp;");
_3b.push(_3a[i].displayName+"</span>, <span class='text21'>"+_3a[i].abstractAge+"<br/>&nbsp;&nbsp;"+_3a[i].provinceName+", "+_3a[i].countryName);
_3b.push("\t</span>");
_3b.push("</div>");
_3b.push("</div>");
}
_3b.push("<br/><br/>");
_3b.push("<div class='text42'>You have "+_3e.length+" friends who may join you on GrooveNet</div>");
for(var i=0;i<_3e.length;i++){
_3b.push("<div style='width:610px; height:30px; padding-top:5px; border:1px dotted #c0c0c0;'>");
_3b.push("\t<div style='float:left; width:50px; border:1px none #00ff00;'><input type='checkbox' name='nonUsers' value='"+_3e[i][1]+"'checked></div>");
_3b.push("\t<div style='float:left; width:550px; border:1px none #ffff00; padding-top:1px;'><span class='text34'>"+_3e[i][0]+"</span><span class='text21'>&nbsp;&nbsp;&lt;"+_3e[i][1]+"&gt;</span></div>");
_3b.push("</div>");
}
}
_3b.push("<br/>");
_3b.push("<div class='text21' style='width:610px; height:30px; background-color:#c0c0c0; border:1px solid #c0c0c0'>");
_3b.push("\t<input type='checkbox' name='allContacts' onclick='CheckAllContacts(this.checked)' checked>&nbsp;Select / Unselect All");
_3b.push("</div>");
_3b.push("<div id='InviteForm4Msg2' style='width:550px;'>&nbsp;</div>");
_3b.push("<div>");
_3b.push("<input type='button' class='btn01' onclick='AddAndInvite();' value='Send Invite'>&nbsp;&nbsp;");
_3b.push("</div>");
_3b.push("</form>");
ShowLayer("InviteForm4Status",false);
ShowLayer("InviteForm4List",true);
document.getElementById("InviteForm4List").innerHTML=_3b.join("");
document.getElementById("InviteForm4List").paddingLeft="20px";
}
function CheckAllContacts(_40){
var _41=document.forms["frmContactList"].elements["gnUsers"];
var _42=document.forms["frmContactList"].elements["nonUsers"];
var _43=document.forms["frmContactList"].elements["allContacts"];
for(var i=0;i<_41.length;i++){
_41[i].checked=_40;
}
for(var i=0;i<_42.length;i++){
_42[i].checked=_40;
}
_43[0].checked=_40;
_43[1].checked=_40;
}
function SendInvite(){
var _45="";
var _46=document.forms["frmContactList"].elements["contacts"];
for(var i=0;i<_46.length;i++){
if(_46[i].checked){
_45+=_46[i].value+",";
}
}
if(_45==""){
var _48=document.getElementById("InviteForm4Msg1");
var _49=document.getElementById("InviteForm4Msg2");
_48.className="status01";
_48.innerHTML="You need to select at least 1 contact.";
_49.className="status01";
_49.innerHTML="You need to select at least 1 contact.";
}else{
_45=_45.substring(0,(_45.length-1));
SendInviteToApi(_45);
}
}
function SendInviteToApi(_4a){
document.getElementById("InviteForm4Status").innerHTML="<br/><br/><br/><br/><img src='/images/ajaxLoader2.gif' align='absmiddle' />&nbsp;&nbsp;Sending invite...";
ShowLayer("InviteForm4List",false);
ShowLayer("InviteForm4Status",true);
var _4b=Cookie.GetValue("photoUrl");
var _4c=Cookie.GetValue("fName");
var _4d=Cookie.GetValue("lName");
var _4e=Cookie.GetValue("email");
var _4f="";
var _50=new Array("UserID","UserEmail","InviteMessage","PhotoUrl","EmailList","FirstName","LastName");
var _51=new Array(User.CustomerID,_4e,_4f,_4b,_4a,_4c,_4d);
var _52=XmlObj.Create("SendInvites",_50,_51);
AjaxInvite.SendRequest("POST",AjaxUrl.ApiV2,_52,SendInviteToApiComplete);
}
function SendInviteToApiComplete(_53){
var xml=_53.responseXML.documentElement;
var _55=xml.getElementsByTagName("status")[0].childNodes[0].nodeValue;
var msg=xml.getElementsByTagName("message")[0].childNodes[0].nodeValue;
document.getElementById("InviteForm5").innerHTML="<br/><br/><br/><br/>"+msg;
ShowLayer("InviteForm4",false);
ShowLayer("InviteForm5",true);
}
function AddAndInvite(){
var _57="";
var _58="";
var _59=new Array();
var _5a=new Array();
var _5b=document.forms["frmContactList"].elements["gnUsers"];
var _5c=document.forms["frmContactList"].elements["nonUsers"];
if(_5b){
for(var i=0;i<_5b.length;i++){
if(_5b[i].checked){
_59.push(_5b[i].value);
}
}
_57=_59.join(",");
}
if(_5c){
for(var i=0;i<_5c.length;i++){
if(_5c[i].checked){
_5a.push(_5c[i].value);
}
}
_58=_5a.join(",");
}
if(_57==""&&_58==""){
var _5e=document.getElementById("InviteForm4Msg1");
var _5f=document.getElementById("InviteForm4Msg2");
_5e.className="status01";
_5e.innerHTML="You need to select at least 1 contact.";
_5f.className="status01";
_5f.innerHTML="You need to select at least 1 contact.";
}else{
RequestAddAndInvite(_57,_58);
}
}
function RequestAddAndInvite(_60,_61){
document.getElementById("InviteForm4Status").innerHTML="<br/><br/><br/><br/><img src='/images/ajaxLoader2.gif' align='absmiddle' />&nbsp;&nbsp;Sending invite...";
ShowLayer("InviteForm4List",false);
ShowLayer("InviteForm4Status",true);
var _62=Cookie.GetValue("photoUrl");
var _63=Cookie.GetValue("fName");
var _64=Cookie.GetValue("lName");
var _65=Cookie.GetValue("email");
var _66=Cookie.GetValue("dispName");
var _67="";
var _68=new Array("UserID","DisplayName","FirstName","LastName","UserEmail","InviteMessage","PhotoUrl","GnContacts","NonGnContacts");
var _69=new Array(User.CustomerID,_66,_63,_64,_65,_67,_62,_60,_61);
var _6a=XmlObj.Create("AddAndInvite",_68,_69);
AjaxInvite.SendRequest("POST",AjaxUrl.ApiV2,_6a,SendInviteToApiComplete);
}
function RequestAddAndInviteComplete(_6b){
var xml=_6b.responseXML.documentElement;
var _6d=xml.getElementsByTagName("status")[0].childNodes[0].nodeValue;
var msg=xml.getElementsByTagName("message")[0].childNodes[0].nodeValue;
document.getElementById("InviteForm5").innerHTML="<br/><br/><br/><br/>"+msg;
ShowLayer("InviteForm4",false);
ShowLayer("InviteForm5",true);
}
function AutoInvite(){
var _6f=Cookie.GetValue("cid");
var _70=new Array("UserID");
var _71=new Array(_6f);
var _72=XmlObj.Create("AutoPrompt",_70,_71);
AjaxInvite.SendRequest("POST",AjaxUrl.ApiV2,_72,AutoInviteComplete);
}
function AutoInviteComplete(_73){
var xml=_73.responseXML.documentElement;
var _75=xml.getElementsByTagName("status")[0].childNodes[0].nodeValue;
if(_75=="true"){
var _76=Cookie.GetValue("email");
var _77=_76.split(new RegExp("[@.]{1}"));
var _78=true;
switch(_77[1].toLowerCase()){
case "yahoo":
Invite.webmail="Yahoo";
break;
case "gmail":
Invite.webmail="Gmail";
break;
case "hotmail":
Invite.webmail="Hotmail";
break;
case "msn":
Invite.webmail="Hotmail";
break;
case "aol":
Invite.webmail="Aol";
break;
default:
_78=false;
break;
}
if(_78){
ActionBox.Open("../invite/InviteForm.html",ShowPredictiveInvite,null,true);
}else{
ActionBox.Open("../invite/InviteForm.html",ShowGenericInvite,null,true);
}
}
}
function ShowGenericInvite(){
ShowLayer("SendInviteForm",false);
ShowLayer("InviteForm2",true);
}
function ShowPredictiveInvite(){
var _79=Cookie.GetValue("email");
var _7a=_79.split(new RegExp("[@.]{1}"));
ShowGrabForm(Invite.webmail,_7a[0]);
}


