//create namespace
if( typeof(SNI)=='undefined' ) {
SNI = {};
}
// instantiate object namespaces
if( typeof(SNI.Community)=='undefined' ) {
SNI.Community = {};
}
// instantiate object namespaces
if( typeof(SNI.Community.UR)=='undefined' ) {
SNI.Community.UR = {};
}
//use this function to get querystring parameters
SNI.Community.UR.gup = function (name)
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else
return results[1];
}
SNI.Community.UR.isLoggedIn = function ()
{
if(SNI.Community.UR.logged_in)
{
return true;
}
else
{
return false;
}
}
SNI.Community.UR.getLoginDomains = function (sso_id)
{
//get the list of domains for the sso_id...sso_id (is currently) corresponding to site_id but doesn't have to
if(window.location.href.substring(0,12).indexOf("test1")!=-1)
{
if(sso_id==2)
{
//return ["http://test1-my.hgtv.com", "http://test1-www.athomewith.com", "http://test1-www.roomzaar.com", "http://www.dev-diynetwork.com/communitytools", "http://test1-my.diynetwork.com", "http://test1-my.fineliving.com", "http://test1-my.foodnetwork.com", "http://test1-my.gactv.com", "http://test1-share.frontdoor.com", "http://test1-my.upmystreet.com", "http://test1-hgtv.athomewith.com", "http://test1-my.foodtv.co.uk", "http://test1-share.recipezaar.com"];
//return "{\"logindomains\": [\"http://test1-my.hgtv.com\", \"http://test1-www.athomewith.com\", \"http://test1-www.roomzaar.com\", \"http://www.dev-diynetwork.com/communitytools\", \"http://test1-my.diynetwork.com\", \"http://test1-my.fineliving.com\", \"http://test1-my.foodnetwork.com\", \"http://test1-my.gactv.com\", \"http://test1-share.frontdoor.com\", \"http://test1-my.upmystreet.com\", \"http://test1-hgtv.athomewith.com\", \"http://test1-my.foodtv.co.uk\", \"http://test1-share.recipezaar.com\"]}";
return '{"GlossSeeAlso": ["GML", "XML"]}';
}
}
}
function recordKeys(e)
{
//var theTarget = e.target ? e.target : e. srcElement
if (!e) var e = window.event;
if (e.target) theTarget = e.target;
else if (e.srcElement) theTarget = e.srcElement;
if (theTarget.nodeType == 3) // defeat Safari bug
theTarget = theTarget.parentNode;
var unicode=e.keyCode? e.keyCode : e.charCode
if((theTarget.name=="com_signin_email" || theTarget.name == "com_signin_password") && unicode==13)
//signin();
callPostFullFormLogin();
else if(theTarget.name=="com_forgot_email" && unicode==13)
sendpassword();
}
document.body.onkeyup = recordKeys;
function updateLoginAuditing(redirecturl, lip, app_name, site_id, let, user_id)
{
if(window.XMLHttpRequest){ // For Mozilla, Safari, ...
var xmlHttp = new XMLHttpRequest();
}
else if(window.ActiveXObject){ // For Internet Explorer
var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHttp.open('POST', SNI.Community.Toolbox.subPath+"/loginauditing/update_login_auditing.jsp", true);
xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.onreadystatechange = function()
{
if (xmlHttp.readyState == 4)
{
//after you've updated the login_auditing redirect them
document.location = redirecturl;
}
}
var params = "lip="+lip+"&APP_NAME="+app_name+"&site_id="+site_id+"&let="+let+"&user_id="+user_id
xmlHttp.send(params);
}
function disabledUserRedirect()
{
var lip=document.getElementById("com-signin-lip").value;
//var app_name = document.getElementById("gApplicationName").value;
var app_name = SNI.Community.Toolbox.cWidgetProjectName;
var site_id = SNI.Community.Toolbox.siteId;
var user_id = readCookie('DISABLED_UID');
eraseCookie('DISABLED_UID');
updateLoginAuditing(SNI.Community.Toolbox.baseDomainOfLoginProject+"/redirectors/logout_redirector.jsp?DEST_URL="+escape(SNI.Community.Toolbox.registUrl+"disableduser.esi"),lip,app_name,site_id,3,user_id);
}
var nextExe = "";
function displayOn(obj){
document.getElementById(obj).style.display = "block";
}
function displayOff(obj){
document.getElementById(obj).style.display = "none";
}
function layerOn(obj){
document.getElementById(obj).style.visibility = "visible";
}
function layerOff(obj){
document.getElementById(obj).style.visibility = "hidden";
}
var lastObject;
function secureComponent(exe_val,message,obj,lip)
{
lastObject = obj;
var existValue = "";
var idTextChange = false;
curId = "";
if(obj!="" && obj!=undefined){
idTextChange = true;
existValue = obj.innerHTML;
}
var favId = "";
try{
favId = obj.id;
}catch(e){favId = obj}
if(idTextChange){
obj.innerHTML = "
"; //"loading";
}
document.getElementById('header_text').innerHTML = message;
var test = document.location+"";
if(SNI.Community.Toolbox.notLocal)
{
if(SNI.Community.Toolbox.isLoggedIn)
{
//SM on and user logged in
if(obj!="" && obj!=undefined){obj.innerHTML = existValue;}
eval(exe_val);
return "found";
}else{
//alert("lip is " + lip);
document.getElementById("com-signin-lip").value=lip;
//alert("lip in form is " + document.getElementById("com-signin-lip").value);
showLoginPopupForm(exe_val,message,obj,idTextChange,test,favId,existValue);
}
}else{
if(readCookie('picklecookie') !=null && trim(readCookie('picklecookie')).length>0 && trim(readCookie('picklecookie'))!= "null")
{
if(obj!="" && obj!=undefined){obj.innerHTML = existValue;}
eval(exe_val);
return "found";
}
else{
document.getElementById("com-signin-lip").value=lip;
showLoginPopupForm(exe_val,message,obj,idTextChange,test,favId,existValue);
}
}
return "notfound";
}
function showLoginPopupForm(exe_val,message,obj,idTextChange,test,favId,existValue)
{
if(idTextChange)
{
obj.innerHTML = existValue;
}
GV("com_signin_email").value = "";
GV("com_signin_password").value = "";
document.getElementById('e-m').innerHTML = "E-mail Address";
document.getElementById('Fe-m').innerHTML = "E-mail Address";
document.getElementById('p-w').innerHTML = "Password";
document.getElementById('up-ur-signup-error').innerHTML = "";
var wide = false;
if(obj == "cgp-id-page-title-area" && !document.getElementById(obj))
{
obj = "p2-d2cwide";
wide = true;
}
var top_temp;
var left_temp;
var real_obj;
if(obj.id){
real_obj = $('#'+obj.id)
}else if(obj != undefined){
real_obj = $('#'+obj)
}
top_temp = real_obj.offset().top;
left_temp = real_obj.offset().left;
var left_min = 0;
var top_min = 0;
if(document.getElementById('fullwidth-wrapper'))
{
left_min = $('#fullwidth-wrapper').offset().left;
if(document.getElementById('cgp-id-page-title-area'))
left_min = (left_min*2)+35;
top_min = $('#fullwidth-wrapper').offset().top;
}else if(document.getElementById('diy-w'))
{
left_min = $('#diy-w').offset().left;
if(document.getElementById('cgp-id-page-title-area'))
left_min = (left_min*2)+35;
top_min = $('#diy-w').offset().top;
}
if(!obj.id){
if(obj=="cgp-id-comment-ad")
{
top_temp = top_temp - parseInt($('#com-signin').height());
}else if(obj.indexOf("cmt_usr_img_")!=-1){
top_temp = top_temp - 100;
}
}else{
if(document.getElementById('site-wrapper'))
{
top_min = $('#site-wrapper').offset().top;
}
}
$('#com-signin').css({position:"absolute" , top: (top_temp-top_min), left: (left_temp-left_min)}).show();
GV("com_signin_email").focus();
nextExe = exe_val;
}//end showLoginPopupForm
function createCookie(name,value) {
var date = new Date();
date.setTime(date.getTime()+(1*60*60*1000));
var expires = "; expires="+date.toGMTString();
if(SNI.Community.Toolbox.domainName)
document.cookie = name+"="+value+expires+"; path=/; domain="+SNI.Community.Toolbox.domainName;
else
document.cookie = name+"="+value+expires+"; path=/";
}
function findPosX(obj)
{
var curleft = 0
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curleft += obj.offsetLeft
obj = obj.offsetParent
}
}
else if (obj.x)
curleft += obj.x
return curleft
}
function findPosY(obj)
{
var curtop = 0
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curtop += obj.offsetTop
obj = obj.offsetParent
}
}
else if (obj.y)
curtop += obj.y
return curtop
}
function readCookie(name) {
var valreturn = null;
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0)
valreturn = c.substring(nameEQ.length,c.length);
if(valreturn!=null && trim(valreturn).length>0)
{
//if the cookie value is a string and browser has wrapped it in double quotes, remove these
var lastchar = valreturn.charAt(valreturn.length-1);
var firstchar = valreturn.charAt(0);
if(firstchar=='"' && lastchar=='"')
{
return valreturn.substring(1,valreturn.length-2);
}
else
{
return valreturn;
}
}
}
return valreturn;
}
function eraseCookie(name) {
createCookie(name,"");
}
var userId_Global ;
var userEmail_Global ;
function isIE6() {
var appVer = navigator.appVersion;
appVer = appVer.split(';');
if(appVer[1] == ' MSIE 6.0') {
return true;
}
}
function DA(url,callBack)
{
var request=document.all?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();
request.onreadystatechange=function()
{
if(request.readyState==4)
{
if(request.status==200)
{
try{eval(callBack);}catch(e){}
}
}
}
request.open("POST",url,true);
request.setRequestHeader("content-type","text/plain;charset=UTF-8");
request.send('');
}
var counter=0;
var interval_id=0;
function checkForSMCookies()
{
//alert("inside checkForSMCookies");
counter++;
if(counter<40)
{
//the presence of any of these cookies indicates that login has completed (specifically the OnAZAccept or OnAZReject from SM has completed)
if( (readCookie('AJAXLOGINSUCCESS')=='TRUE') || (readCookie('HANDSHAKE')=='TRUE') || (readCookie('SM_EM')=='TRUE') || (readCookie('MIGRATED')=='TRUE') || (readCookie('UNCONFIRMED')=='TRUE') || (readCookie('DISABLED')=='TRUE'))
{
//erase the AJAXLOGINSUCCESS cookie if present
if(readCookie('AJAXLOGINSUCCESS')=='TRUE')
{
eraseCookie('AJAXLOGINSUCCESS');
}
//alert('AJAXLOGINSUCCESS is ' + readCookie('AJAXLOGINSUCCESS'));
//alert('DISABLED is ' + readCookie('DISABLED'));
//alert("one of the SM cookies was found that means a response came back, clearing interval and continuing");
//stop processing function checkForSMCookies and call postLogin
window.clearInterval(interval_id);
postLogin(null);
}
}
else
{
//the OnAZAccept or OnAZReject from SM took more than 10 seconds, continue processing (failure). Safari appears to timeout, never gets the above cookies
//if the response is more than 10 seconds
window.clearInterval(interval_id);
postLogin(null);
}
}
function signin()
{
var agt=navigator.userAgent.toLowerCase();
var emailID = GV("com_signin_email");
//alert("email-id : "+emailID);
var pass = GV("com_signin_password");
//alert("pass : "+pass);
document.getElementById('e-m').innerHTML = "E-mail Address";
document.getElementById('p-w').innerHTML = "Password";
if ((emailID.value==null)||(emailID.value=="")){
document.getElementById('e-m').innerHTML = "";
document.getElementById('up-ur-signup-error').innerHTML = "
Whoops. Please enter your e-mail address.
"; document.getElementById('up-ur-signup-error').style.display = "block"; if (isIE6()){ie_heightfix('ieDiv','235');} emailID.focus() return; } if (echeck(emailID.value)==false){ emailID.value="" document.getElementById('e-m').innerHTML = ""; document.getElementById('up-ur-signup-error').innerHTML = "Whoops. Please enter a valid e-mail address.
"; document.getElementById('up-ur-signup-error').style.display = "block"; if (isIE6()){ie_heightfix('ieDiv','235');} emailID.focus() return; } if ((pass.value==null)||(pass.value=="")){ document.getElementById('p-w').innerHTML = ""; document.getElementById('up-ur-signup-error').innerHTML = "Whoops. Please enter your password.
"; document.getElementById('up-ur-signup-error').style.display = "block"; if (isIE6()){ie_heightfix('ieDiv','219');} pass.focus() return; } if(SNI.Community.Toolbox.notLocal){ var smAgentNameFromAjax = ''; var smTargetFromAjax=''; var currentUrl = document.location.href; var indexOfDotCom = currentUrl.indexOf('.com'); smAgentNameFromAjax=currentUrl.substring(0, (indexOfDotCom+4)); //check if you are on https, if so, strip the https, if not strip the http if(currentUrl.substring(0,5)=='https') { smAgentNameFromAjax=smAgentNameFromAjax.substring(8); } else { smAgentNameFromAjax=smAgentNameFromAjax.substring(7); } var indexOfDotComPlusFour = indexOfDotCom+4; smTargetFromAjax=currentUrl.substring(0, indexOfDotComPlusFour); //smTargetFromAjax=smTargetFromAjax+'/authajax'; //JEE ADDING 20090412 smTargetFromAjax=smTargetFromAjax+SNI.Community.Toolbox.subPath+'/authajax'; var url = "siteminderagent/forms/login.fcc?USER="+escape(emailID.value.toLowerCase())+"&PASSWORD="+escape(pass.value)+"&target="+smTargetFromAjax+"&smagentname="+smAgentNameFromAjax; var xmlHttp; document.getElementById('up-ur-signup-error').innerHTML = ""; if(window.XMLHttpRequest){ // For Mozilla, Safari, ... var xmlHttp = new XMLHttpRequest(); } else if(window.ActiveXObject){ // For Internet Explorer var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } /* Safari ajax does not work well with SM. If you submit asynchronously, onreadystatechange is never called. If you submit synchronously, processing is not blocked. This manifests itself to the user where if HANDSHAKE or MIGRATED cookie is returned as a result of the OnAZReject from SM, the postLogin may have already completed by that point and user would get sent toWhoops. The e-mail address you entered is not in our system.
"; document.getElementById('up-ur-signup-error').style.display = "block"; if (isIE6()) { ie_heightfix('ieDiv','235'); } } else if (readCookie('SM_EM')=="PWI") { displayOn('com-signin-content'); displayOff('com-signin-content02'); eraseCookie('SM_EM'); GV("com_signin_password").focus(); document.getElementById('p-w').innerHTML = ""; document.getElementById('up-ur-signup-error').innerHTML = "Whoops. The password you entered is incorrect.
"; document.getElementById('up-ur-signup-error').style.display = "block"; if (isIE6()){ie_heightfix('ieDiv','235');} } if(readCookie('MIGRATED')=='TRUE') { eraseCookie('MIGRATED'); var userId; if(readCookie('AJAX_LOGIN_RESPONSE')) { userId = readCookie('AJAX_LOGIN_RESPONSE').split("||")[0]; } try { registrationIntercept(userId); } catch(e){} } else if(readCookie('UNCONFIRMED')=='TRUE') { eraseCookie('UNCONFIRMED'); var userId; if(readCookie('AJAX_LOGIN_RESPONSE')) { userId = readCookie('AJAX_LOGIN_RESPONSE').split("||")[0]; } try{ unConfirmed(userId); } catch(e){} } else if(readCookie('HANDSHAKE')=='TRUE') { eraseCookie('HANDSHAKE'); try { handshakeUser(); }catch(e) {} } else if(readCookie('DISABLED')=='TRUE') { eraseCookie('DISABLED'); disabledUserRedirect(); } }else{ var result = resultvalue.responseText; if(trim(result)=="success") { /*displayOff('com-signin'); displayOff('com-signin-content'); displayOff('com-signin-content02'); displayOff('com-signin-content03'); displayOff('com-signin-content04'); eval(nextExe);*/ document.location = document.location+""; }else { displayOn('com-signin-content'); displayOff('com-signin-content02'); if(resultvalue.responseText.indexOf("Password")!=-1) { document.getElementById('p-w').innerHTML = ""; document.getElementById('up-ur-signup-error').innerHTML = "Whoops. The password you entered is incorrect.
"; document.getElementById('up-ur-signup-error').style.display = "block"; if (isIE6()){ie_heightfix('ieDiv','235');} }else if(resultvalue.responseText.indexOf("user")!=-1) { document.getElementById('e-m').innerHTML = ""; document.getElementById('up-ur-signup-error').innerHTML = "Whoops. The e-mail address you entered is not in our system.
"; document.getElementById('up-ur-signup-error').style.display = "block"; if (isIE6()){ie_heightfix('ieDiv','235');} }else if(resultvalue.responseText.indexOf("activate")!=-1) { document.getElementById('e-m').innerHTML = ""; document.getElementById('up-ur-signup-error').innerHTML = "Whoops. Please Activate your account.
"; document.getElementById('up-ur-signup-error').style.display = "block"; if (isIE6()){ie_heightfix('ieDiv','235');} } } } var userId; if(readCookie('AJAX_LOGIN_RESPONSE')) { userId = readCookie('AJAX_LOGIN_RESPONSE').split("||")[0]; eraseCookie('AJAX_LOGIN_RESPONSE'); }else if(readCookie('picklecookie')){ userId = readCookie('picklecookie').split(",")[0]; } try{ if(parseInt(collectionUserID)== parseInt(userId)) document.getElementById('tool-bar-edit').style.display = "block"; }catch(e){} } function sendpassword() { document.getElementById('Fe-m').innerHTML = "E-mail Address"; document.getElementById('up-ur-signup-error').style.display = "none"; var emailID = GV('com_forgot_email'); if ((emailID.value==null)||(emailID.value=="")){ document.getElementById('Fe-m').innerHTML = ""; document.getElementById('up-ur-signup-error').innerHTML = "Whoops. Please enter your e-mail address.
"; document.getElementById('up-ur-signup-error').style.display = "block"; displayOff('com-signin-message'); emailID.focus() return; } if (echeck(emailID.value)==false){ emailID.value="" document.getElementById('Fe-m').innerHTML = ""; document.getElementById('up-ur-signup-error').innerHTML = "Whoops. Please enter a valid e-mail address.
"; document.getElementById('up-ur-signup-error').style.display = "block"; displayOff('com-signin-message'); emailID.focus() return; } displayOn('com-signin-content05'); displayOff('com-signin-content03'); displayOff('com-signin-content04'); var url = SNI.Community.Toolbox.subPath+"/pass.do?show=pwdrequest&email="+escape(emailID.value.toLowerCase())+"&returl="+SNI.Community.Toolbox.returl+"&homeurl="+SNI.Community.Toolbox.homeProjectUrl+"&siteId="+SNI.Community.Toolbox.siteId; DA(url,"forgotPwd(request)"); } function forgotPwd(resultText){ if(resultText.responseText.indexOf("E-mail Not Exist")!=-1) { displayOff('com-signin-content05'); displayOn('com-signin-content03'); displayOff('com-signin-content04'); document.getElementById('Fe-m').innerHTML = ""; document.getElementById('up-ur-signup-error').innerHTML = "Whoops. The e-mail address you entered is not in our system.
"; document.getElementById('up-ur-signup-error').style.display = "block"; displayOff('com-signin-message'); }else{ displayOff('com-signin-content03'); displayOn('com-signin-content04'); displayOff('fogot_button'); // hide Sign in displayOff('com-signin-content05'); } } function GV(n) { return document.getElementsByName(n)[0]; } function echeck(str) { var at="@" var dot="." var a = true; var lat=str.indexOf(at) var lstr=str.length var ldot=str.indexOf(dot) if (str.indexOf(at)==-1) a = false; else if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) a = false; else if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) a = false; else if (str.indexOf(at,(lat+1))!=-1) a = false; else if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) a = false; else if (str.indexOf(dot,(lat+2))==-1) a = false; else if (str.indexOf(" ")!=-1) a = false; if(!a) { document.getElementById('e-m').innerHTML = ""; document.getElementById('up-ur-signup-error').innerHTML = "Whoops. Please enter a valid e-mail address.
"; document.getElementById('up-ur-signup-error').style.display = "block"; } return a } var mouse_PosX; var mouse_PosY; function get_mouse_pointer_coordinates(e) { var posx = 0; var posy = 0; if (!e) var e = window.event; if (e.pageX || e.pageY) { posx = e.pageX; posy = e.pageY; } else if (e.clientX || e.clientY) { posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; } mouse_PosX = posx; mouse_PosY = posy; //You have the coordinates in the posx and posY variables //You can do whatever you want with them after this point } function ie_heightfix(inDiv, inState){document.getElementById(inDiv).style.height = inState+"px";} document.onmousemove = get_mouse_pointer_coordinates; function postFullFormLogin(target, agent, action) { var emailField = GV("com_signin_email"); var passwordField = GV("com_signin_password"); var email = emailField.value.toLowerCase(); var password = passwordField.value; var form = document.createElement("form"); form.setAttribute("method", "POST"); form.setAttribute("action", action); var hiddenFieldEmail = document.createElement("input"); hiddenFieldEmail.setAttribute("type", "hidden"); hiddenFieldEmail.setAttribute("name", "USER"); hiddenFieldEmail.setAttribute("value", email); form.appendChild(hiddenFieldEmail); var hiddenFieldPassword = document.createElement("input"); hiddenFieldPassword.setAttribute("type", "hidden"); hiddenFieldPassword.setAttribute("name", "PASSWORD"); hiddenFieldPassword.setAttribute("value", password); form.appendChild(hiddenFieldPassword); var hiddenFieldTarget = document.createElement("input"); hiddenFieldTarget.setAttribute("type", "hidden"); hiddenFieldTarget.setAttribute("name", "TARGET"); hiddenFieldTarget.setAttribute("value", target); form.appendChild(hiddenFieldTarget); var hiddenFieldAgent = document.createElement("input"); hiddenFieldAgent.setAttribute("type", "hidden"); hiddenFieldAgent.setAttribute("name", "SMAGENTNAME"); hiddenFieldAgent.setAttribute("value", agent); form.appendChild(hiddenFieldAgent); document.body.appendChild(form); form.submit(); }