/* dynodes.js Kent Brewster, 2005 http://www.mindsack.com/uxe/dynodes/ feel free to use or distribute this code but please retain this notice Gotcha: onLoad takes a camelCase L, or IE wont work Gotcha: need init(), not init, or Opera wont work Gotcha: do not use // style comments in the file modified by Christos Dritsas, 2006, christos@prefpass.com to meet some specific needs. */ /*dyn replace*/var prefpass_unique_id='0';var prefpass_user_prefs='0';var prefpass_user_state_logged_in='0'; var prefpass_user_state_current_member='1'; var prefpass_user_state_pass_granted='0'; var prefpass_user_state_prev_cancelled_pass='0'; var prefpass_user_state_grant_request='0'; var prefpass_user_state_login_type='prefpass'; /* Prefpass callback function (if user passed in callback=true in badge api call) *//* no callback specified *//* code to add functions to onLoad event */function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } }}/* capture onmouseup */ function init() { document.onmouseup = k; } /* addLoadEvent(prefpassHidePasswordOptions); */addLoadEvent(init);/* window.onLoad=init(); *//* klick: execute remote function, remove the remote script */ function k(v) { el = getEl(v); if (el.className == 'runScript_badgeNotGranted') { /* switch visibilities */ document.getElementById('prefpass_badge_not_processing').style.display = "none"; document.getElementById('prefpass_badge_processing').style.display = "block"; var remoteScript=document.createElement('script'); remoteScript.id = 'rs'; remoteScript.setAttribute('type','text/javascript'); remoteScript.setAttribute('src','http://prefpass.com/api/grant_pass/2aa611d46e93e69091b90451b872cc93.js?site=b02b1ccf65194bc5a03c420bc4912de8'); var hd=document.getElementsByTagName('head')[0]; /* Gotcha: set attribute and src BEFORE appending, or Safari wont work */ hd.appendChild(remoteScript); } }/* manually hit */function grantBadge(){/* switch visibilities */ document.getElementById('prefpass_badge_not_processing').style.display = "none";document.getElementById('prefpass_badge_processing').style.display = "block";var remoteScript=document.createElement('script');remoteScript.id = 'rs';remoteScript.setAttribute('type','text/javascript'); remoteScript.setAttribute('src','http://prefpass.com/api/grant_pass/2aa611d46e93e69091b90451b872cc93.js?site=b02b1ccf65194bc5a03c420bc4912de8'); var hd=document.getElementsByTagName('head')[0];/* Gotcha: set attribute and src BEFORE appending, or Safari wont work */ hd.appendChild(remoteScript);}/* mimic klick */function manualRun(){ var remoteScript=document.createElement('script');remoteScript.id = 'rs';remoteScript.setAttribute('type','text/javascript'); remoteScript.setAttribute('src','http://prefpass.com/api/badge/2aa611d46e93e69091b90451b872cc93.js?site=b02b1ccf65194bc5a03c420bc4912de8');var hd=document.getElementsByTagName('head')[0];/* Gotcha: set attribute and src BEFORE appending, or Safari wont work */ hd.appendChild(remoteScript);}/* called by the remote script upon successful execution */ function taskCompleted(my_output) {removeScript('rs');document.getElementById('prefpassBadgeDisplay').innerHTML = my_output;}/* called on page load */ function taskInitialized(my_output) {document.getElementById('prefpassBadgeDisplay').innerHTML = my_output;}/* remove script node */ function removeScript(id) { var hd=document.getElementsByTagName('head')[0]; hd.removeChild(document.getElementById(id)); }/* figure out which element the event is pointing to */ function getEl(v) { var tg = (v) ? v : event; if (tg.target) { var el = (tg.target.nodeType == 3) ? tg.target.parentNode : tg.target; } else { var el = tg.srcElement; } return el; }/* monitor when child has been closed then perform some task(s) */ function clockChildWindow() { if (prefpassWindow.closed) { /*document.location = document.location;*/manualRun()} else { setTimeout('clockChildWindow()', 500); }}/* Start PrefPass SSO Globals */var prefpass_X = 0;var prefpass_Y = 0;var prefpass_auth_X = 0;var prefpass_auth_Y = 0;var prefpass_reset_X = 0;var prefpass_reset_Y = 0;var prefpass_W = 330;var prefpass_H = 255;var prefpass_enabled = true;var prefpass_ns6 = document.getElementById && !document.all;prefpass_IE = document.all?true:false;if (!prefpass_IE) document.captureEvents(Event.MOUSEMOVE);document.onmousemove = prefpass_getMouseXY; /* End PrefPass SSO Globals *//*Start SSO functions */function prefpassSSORouterReg(my_form_email) { if (true == prefpass_enabled) { prefpassAuthGetUserState(my_form_email,"reg"); } else { prefpassAuthGetUserState(my_form_email,"directreg"); }}function prefpassSSORouterLogin(my_form_email){prefpassAuthGetUserState(my_form_email,"login");}function prefpassSSORouterPasswordReset(my_form_email){prefpassAuthGetUserState(my_form_email,"passwordreset");}function prefpassSubmitOriginalForm(){document.getElementById("prefpassFormSubmissionReg").action="";document.getElementById("prefpassFormSubmissionReg").method="post";document.getElementById("prefpassFormSubmissionReg").submit();}function prefpass_ietruebody() {return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;}function prefpass_getMouseXY(e) { /* first set the absolute mouse location */prefpass_X=(prefpass_ns6)?e.pageX : event.clientX+prefpass_ietruebody().scrollLeft; prefpass_Y=(prefpass_ns6)?e.pageY : event.clientY+prefpass_ietruebody().scrollTop; /* now set the popup coords */var offsetxpoint = 10; var offsetypoint = (prefpass_H / 2) * (-1); /* Find out how close the mouse is to the corner of the window */var rightedge = (prefpass_IE && !window.opera) ? prefpass_ietruebody().clientWidth - event.clientX - offsetxpoint : window.innerWidth - e.clientX - offsetxpoint - 20;var bottomedge = (prefpass_IE && !window.opera) ? prefpass_ietruebody().clientHeight - event.clientY - offsetypoint : window.innerHeight - e.clientY - offsetypoint - 20;var leftedge = (offsetxpoint < 0) ? offsetxpoint * (-1) : -1000;/* If the horizontal distance isn't enough to accomodate the width of the popup */if (rightedge < prefpass_W) {/* move the horizontal position of the popup to the left by it's width */prefpass_auth_X = prefpass_IE ? prefpass_ietruebody().scrollLeft + event.clientX - prefpass_W : window.pageXOffset + e.clientX - prefpass_W;} else if (prefpass_X < leftedge) {prefpass_auth_X = 5;} else {/* put the horizontal position of the popup where the mouse is */prefpass_auth_X = prefpass_X + offsetxpoint;} /* same concept with the vertical position */if (bottomedge < prefpass_H) {prefpass_auth_Y = prefpass_IE ? prefpass_ietruebody().scrollTop + event.clientY - prefpass_H - offsetypoint : window.pageYOffset + e.clientY - prefpass_H - offsetypoint;} else {prefpass_auth_Y = prefpass_Y + offsetypoint;} /* make sure it is not too far to the upper left */ if (prefpass_auth_X < 0){prefpass_auth_X = 0} if (prefpass_auth_Y < 0){prefpass_auth_Y = 0} prefpass_reset_X = prefpass_auth_X; prefpass_reset_Y = prefpass_auth_Y; return true;}/* no longer used */function prefpass_getPopupXY() { /* get the size of the visible window */ var max_x, max_y; if (prefpass_IE) { max_x = prefpass_ietruebody().clientWidth; max_y = prefpass_ietruebody().clientHeight; } else { max_x = window.innerWidth; max_y = window.innerHeight; } /* set max and min coords */ max_x = max_x-(prefpass_W+35); /* 5 for border + bunch of slop */ max_y = max_y-(prefpass_H+15); var min_x = min_y = 5; /* fix max and min for IE */ if (prefpass_IE) { max_x = max_x + document.body.scrollLeft; max_y = max_y + document.body.scrollTop; min_x = min_x + document.body.scrollLeft; min_y = min_y + document.body.scrollTop; } /* put the corner where we would ideally like it */ prefpass_Y = prefpass_Y - (prefpass_H/2); prefpass_X = prefpass_X + 10; /* make sure it is not too far to the lower right */ if (prefpass_X > max_x){prefpass_X = max_x} if (prefpass_Y > max_y){prefpass_Y = max_y} /* make sure it is not too far to the upper left */ if (prefpass_X < min_x){prefpass_X = min_x} if (prefpass_Y < min_y){prefpass_Y = min_y} return true;}function prefpassAuthCallBackReg() { if (false == prefpass_enabled) { prefpassSubmitOriginalForm(); } else if (("0" == prefpass_user_state_current_member) & ( "0" == prefpass_user_state_logged_in)) { prefpassAuthSelectionCloseWindow();prefpassAuthSelectionScreen(); } else if (("0" == prefpass_user_state_logged_in) & ("1" == prefpass_user_state_current_member)) { prefpassAuthSelectedReg(prefpass_user_state_login_type) } else if ("1" == prefpass_user_state_logged_in) { prefpassAuthSelectedReg(prefpass_user_state_login_type) } else { prefpassAuthSelectionCloseWindow();prefpassAuthSelectionScreen();}}function prefpassAuthCallBackLogin(){if (prefpass_user_state_current_member == "1") {prefpassAuthSelectedLogin("login");} else {document.getElementById("prefpassFormSubmissionLogin").action="";document.getElementById("prefpassFormSubmissionLogin").method="post";document.getElementById("prefpassFormSubmissionLogin").submit();}}function prefpassAuthCallBackPasswordReset(){if (("1" == prefpass_user_state_current_member) & ("1" == prefpass_user_state_pass_granted)){prefpassPasswordResetCloseWindow();prefpassPasswordResetScreen();} else {document.getElementById("prefpassFormSubmissionPasswordReset").submit();}}function prefpassPasswordResetScreen(my_top, my_left) {obj = document.getElementById("prefpassPasswordResetWindow");/* move to child of body if not already there, so our offsets are correct */if (obj.parentNode != document.body) {document.body.appendChild(obj); }obj.style.width=prefpass_W+'px';/* obj.style.height=prefpass_H+'px'; */obj.style.background="#ffffff";obj.style.position="absolute";obj.style.border="2px solid #808080";/* gotcha (no longer used): get position of popup after setting attributes, otherwise offsetParent is null prefpass_getPopupXY();*/obj.style.top=prefpass_reset_Y+'px';obj.style.left=prefpass_reset_X+'px';obj.style.display='';}function prefpassPasswordResetCloseWindow(){document.getElementById("prefpassPasswordResetWindow").style.display='none';}function prefpassAuthSelectionScreen(my_top, my_left){obj = document.getElementById("prefpassAuthSelectionWindow");/* move to child of body if not already there, so our offsets are correct */if (obj.parentNode != document.body) {document.body.appendChild(obj); } obj.style.width=prefpass_W+'px';/* obj.style.height=prefpass_H+'px'; */obj.style.background="#ffffff";obj.style.position="absolute"; obj.style.border="2px solid #808080";/* gotcha (no longer used): get position of popup after setting attributes, otherwise offsetParent is null prefpass_getPopupXY(); */obj.style.top=prefpass_auth_Y+'px';obj.style.left=prefpass_auth_X+'px';obj.style.display='';}function prefpassAuthSelectionCloseWindow(){document.getElementById("prefpassAuthSelectionWindow").style.display='none';}function prefpassUsePasswordCloseWindow(){prefpassAuthSelectionCloseWindow();prefpassDisplayPasswordOptions();}function prefpassHidePasswordOptions(){if (document.getElementById("prefpass-enabled-password-field")) {document.getElementById("prefpass-enabled-password-field").style.display='none';}arrElements = document.getElementsByTagName('span');oRegExp = new RegExp("prefpass-enabled-password-field-(.)");for (i = 0; i < arrElements.length; i++) {oElement = arrElements[i];if (oRegExp.test(oElement.id)) {document.getElementById(oElement.id).style.display='none';}}prefpass_enabled = true;}function prefpassDisplayPasswordOptions(){if (document.getElementById("prefpass-enabled-password-field")) {document.getElementById("prefpass-enabled-password-field").style.display='block';}arrElements = document.getElementsByTagName('span');oRegExp = new RegExp("prefpass-enabled-password-field-(.)");for (i = 0; i < arrElements.length; i++) {oElement = arrElements[i];if (oRegExp.test(oElement.id)) {document.getElementById(oElement.id).style.display='block';}}prefpass_enabled = false;}function prefpassAuthSelectedReg(my_selection){document.getElementById("prefpassFormSubmissionReg").action="http://prefpass.com/api/sso_remote_registration/2aa611d46e93e69091b90451b872cc93.js?site=b02b1ccf65194bc5a03c420bc4912de8&my_selection=" + my_selection + "";document.getElementById("prefpassFormSubmissionReg").method="post";document.getElementById("prefpassFormSubmissionReg").submit();}function prefpassAuthSelectedLogin(my_selection){document.getElementById("prefpassFormSubmissionLogin").action="http://prefpass.com/api/sso_remote_login/2aa611d46e93e69091b90451b872cc93.js?site=b02b1ccf65194bc5a03c420bc4912de8&my_selection=" + my_selection + "";document.getElementById("prefpassFormSubmissionLogin").method="post";document.getElementById("prefpassFormSubmissionLogin").submit();}function prefpassAuthGetUserState(current_email_address, routing_type){var remoteScript=document.createElement('script');remoteScript.id = 'rs';remoteScript.setAttribute('type','text/javascript'); remoteScript.setAttribute('src','http://prefpass.com/api/sso_get_state/2aa611d46e93e69091b90451b872cc93.js?site=b02b1ccf65194bc5a03c420bc4912de8&email=' + current_email_address + '&router=' + routing_type + '');var hd=document.getElementsByTagName('head')[0];/* Gotcha: set attribute and src BEFORE appending, or Safari wont work */ hd.appendChild(remoteScript);}/*End SSO*//* openChild */ function openChild(myfile){ prefpassWindow=open(myfile,'prefpassWindow','resizable=1,scrollbars=1,toolbar=1,menubar=0,location=1,status=1,directories=0,width=800,height=490'); if (prefpassWindow.opener == null) prefpassWindow.opener = self; return 1} /* openChildExternal */ function openChildExternal(myfile){ prefpassWindow=open(myfile,'prefpassWindow','resizable=1,scrollbars=1,toolbar=1,menubar=0,location=1,status=1,directories=0,width=800,height=600'); if (prefpassWindow.opener == null) prefpassWindow.opener = self; return 1} function spawnWindowAuthSelection(){opened = openChild('http://prefpass.com/external/Const::ACTION_AUTH_SELECTION/2aa611d46e93e69091b90451b872cc93.js?site=b02b1ccf65194bc5a03c420bc4912de8');}function spawnWindowNoCookie(){ opened = openChild('http://prefpass.com/external/signup/2aa611d46e93e69091b90451b872cc93.js?site=b02b1ccf65194bc5a03c420bc4912de8');if (opened == 1){clockChildWindow();}}function spawnWindowPasses(){ opened = openChildExternal('http://prefpass.com/account/member/overview/2aa611d46e93e69091b90451b872cc93.js?site=b02b1ccf65194bc5a03c420bc4912de8');if (opened == 1){clockChildWindow();}} taskInitialized('Prefpass Login Join');