var HFSF = {} ;
HFSF.Overlays = {
    showLoginModule : function(targetUrl)//creating login Layer
    {
     trackLoginRegPageName(true , false);
     if(!document.getElementById("loginDiv"))//Create it only if it the div is not already present
     {
      var loginDiv = document.createElement("div");
      loginDiv.id="loginDiv";
	  loginDiv.name="loginDiv";
	  loginDiv.style.display ="none";
	  document.body.appendChild(loginDiv);
	  
	  var tempInnerHtml = new Array();
	  tempInnerHtml.push("<div class='containerDiv'>");
	  tempInnerHtml.push("<div class='subcontainer'>");
	  tempInnerHtml.push("<div class='h4'>Log in to "+websiteName+"</div>");
	  tempInnerHtml.push("<div></div>");
	  tempInnerHtml.push("<div id='loginSaveText' style='display:none'>Please log in to your account to save your "+product+"</div>");
	  tempInnerHtml.push("<div id='loginCartText' style='display:none'>Please log in to add your "+product+" to your cart</div>");
      loginDiv.name="loginDiv";
      loginDiv.style.display ="none";
      document.body.appendChild(loginDiv);
      tempInnerHtml.push("<div id='loginShareText' style='display:none'>Please log in to your account to share your "+product+"</div>");
      tempInnerHtml.push('<span id="loginErrorMessage" name="loginErrorMessage" style="padding:8px 0;"><b></b></span>');
      tempInnerHtml.push("<div></div>");
	  tempInnerHtml.push("<div></div>");
	  tempInnerHtml.push('<form name="loginForm" id="loginForm" action='+loginPostURL+' onsubmit="return submitForm('+'\'loginForm\''+','+'\''+targetUrl+'\''+');" method="post">');
      if( typeof(emailAddr) != "undefined" &&
             (cobrand == "albertsons" || cobrand == "shaws" ||
                cobrand == "jewel" || cobrand == "savonosco" ||
                    cobrand == "acme") ) {
         tempInnerHtml.push("<div>Thank you for visiting the "+cobrand+" Photo Center. We noticed that you already have a photo center account and instead of creating a second account, we are redirecting you to your existing account.<br/><br/></div>");
       }
      if(isMobileCobrand)
      {
        tempInnerHtml.push("<div class='formFields'>mobile number or &nbsp; email address&nbsp;</div>");
      }
      else
      {
        tempInnerHtml.push("<div class='formFields'>email address&nbsp;</div>");
      }
      if(typeof(CBrowserMgr)!="undefined" && CBrowserMgr.isIE()){
        tempInnerHtml.push('<div><input type="text" id='+loginEmail+' name='+'"'+loginEmail+'"'+' value='+'"'+emailAddr+'"'+' class="loginforminput" maxlength="255" onkeypress="onEnterClick(event,\'loginsubmit\')" ></div>');      
      }else{
        tempInnerHtml.push('<div><input type="text" id='+loginEmail+' name='+'"'+loginEmail+'"'+' value='+'"'+emailAddr+'"'+' class="loginforminput" maxlength="255"  ></div>');
      }
      

      tempInnerHtml.push("<div class='formFields'>password&nbsp;</div>");
      if(typeof(CBrowserMgr)!="undefined" && CBrowserMgr.isIE()){
        tempInnerHtml.push("<div><input type='password'id="+loginPwd+" name="+loginPwd+" class='loginforminput' maxlength='255' onkeypress='onEnterClick(event,\"loginsubmit\")' ></div>");
      }else{
        tempInnerHtml.push("<div><input type='password'id="+loginPwd+" name="+loginPwd+" class='loginforminput' maxlength='255' ></div>");
      }
      

      tempInnerHtml.push("<div style='margin-left:118px;'>");
      if(cobrand != 'undefined' && cobrand == "comcast")
      {
        tempInnerHtml.push("<a href='javascript:gotoComcast()'>Forgot your password?</a>");
      }
      else
      {
       tempInnerHtml.push('<a href="javascript:showForGotPassword('+'\''+targetUrl+'\''+');" onClick ="javascript:trackLoginRegClickMap(this,'+'\'link_forgot password\''+');">Forgot your password?</a>');
      }
      tempInnerHtml.push("</div>");
      if(campaignName != 'undefined')
      {
        if(campaignName == "hpphotonewmigrate" || campaignName == "hpphotoexistingmigrate" )
         {
             if(typeof(CBrowserMgr)!="undefined" && CBrowserMgr.isIE()){
                tempInnerHtml.push("<div style='margin-left:115px;'><input type='checkbox' onkeypress='onEnterClick(event,\"loginsubmit\")' name="+savePassword+" value='ON'>Sign me in automatically </div>");             
             }else{
                tempInnerHtml.push("<div style='margin-left:115px;'><input type='checkbox' name="+savePassword+" value='ON'>Sign me in automatically </div>");
             }
             

             tempInnerHtml.push("<div><font color='#EE0000'>If your password is less than 5 characters please click the 'Forgot password?' link and we will email your new password to you.</font></div>");
         }
         else
         {
             if(typeof(CBrowserMgr)!="undefined" && CBrowserMgr.isIE()){
                tempInnerHtml.push("<div style='margin-left:115px;'><input type='checkbox' onkeypress='onEnterClick(event,\"loginsubmit\")' name="+savePassword+" value='ON' onClick ='trackLoginRegClickMap(this,"+"\"checkbox_auto sign in\""+");'>Sign me in automatically</div>");             
             }else{
                tempInnerHtml.push("<div style='margin-left:115px;'><input type='checkbox' name="+savePassword+" value='ON' onClick ='trackLoginRegClickMap(this,"+"\"checkbox_auto sign in\""+");'>Sign me in automatically</div>");
             }
             
         }
      }
      else
      {
        if(typeof(CBrowserMgr)!="undefined" && CBrowserMgr.isIE()){
            tempInnerHtml.push("<div style='margin-left:115px;'><input type='checkbox' onkeypress='onEnterClick(event,\"loginsubmit\")' name="+savePassword+" value='ON' onClick ='trackLoginRegClickMap(this,"+"\"checkbox_auto sign in\""+");'>Sign me in automatically</div>");        
        }else{
            tempInnerHtml.push("<div style='margin-left:115px;'><input type='checkbox' name="+savePassword+" value='ON' onClick ='trackLoginRegClickMap(this,"+"\"checkbox_auto sign in\""+");'>Sign me in automatically</div>");
        }
        
      }
      if(typeof(CBrowserMgr)!="undefined" && CBrowserMgr.isIE()){
        tempInnerHtml.push("<div style='margin-left:118px; margin-top:10px;'><a onClick='javascript:submitForm("+"\"loginForm\""+","+"\""+targetUrl+"\""+");trackLoginRegClickMap(this,"+"\"button_login\""+")'><img id='loginsubmit'  src="+loginImgPath+" name='log in' title='log in' width='78' height='23' border='0'></a></div>");      
      }else{
        tempInnerHtml.push("<div style='margin-left:118px; margin-top:10px;'><a onClick='javascript:trackLoginRegClickMap(this,"+"\"button_login\""+")'><input id='loginsubmit' type='image' src="+loginImgPath+" name='log in' title='log in' width='78' height='23' border='0'></a></div>");
      }
	  
	  if( isASPSnapfish || isSnapfishUKWebsite ){
	  	tempInnerHtml.push('<div style="margin-left:115px;"><iframe marginwidth="0" marginheight="0" style="width:95px;height:28px;" frameborder="0" vspace="0" hspace="0" align="middle"  src="/livechat/fromloginlayer=true"  frameborder="0"></iframe></div>');
	  }
      tempInnerHtml.push("<div class='greydashlined'></div>");
      tempInnerHtml.push('<span class="h4">New to '+websiteName+'?</b></span>&nbsp;&nbsp;<a href="javascript:showReg('+'\''+targetUrl+'\''+');" onClick ="javascript:trackLoginRegClickMap(this,'+'\'link_registration\''+');">sign up</a>');
      tempInnerHtml.push("</form>");
      tempInnerHtml.push("</div>");
      tempInnerHtml.push("</div>");
      document.getElementById("loginDiv").innerHTML = tempInnerHtml.join('');
      }
      if(typeof(userAction) != "undefined")
	  {
	    if(userAction == "save")
	    {
	      document.getElementById("loginSaveText").style.display = "";
	      document.getElementById("loginCartText").style.display = "none";
	      document.getElementById("loginShareText").style.display = "none";
	    }
	    else if(userAction == "addtocart")
	    {
	      document.getElementById("loginCartText").style.display = "";
	      document.getElementById("loginSaveText").style.display = "none";
	      document.getElementById("loginShareText").style.display = "none";	
	    }
	    else if(userAction.indexOf("share") != -1)
	    {
	      document.getElementById("loginShareText").style.display = "";
	      document.getElementById("loginSaveText").style.display = "none";
	      document.getElementById("loginCartText").style.display = "none";
	    } 
	  }
      if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)	
      {
      	if(tempInnerHtml != undefined)
    	  document.getElementById("moveregbackhack").innerHTML = tempInnerHtml.join('');
    	else
    	  document.getElementById("moveregbackhack").innerHTML = document.getElementById("loginDiv").innerHTML;
      }
      else
    	  CLayer.openLayer("login",{type:'div', src:'loginDiv',width:'376',height:'285',isMovable:'false',closeText:'Close',closeCallBack:'closeModule()'});
      
	  if(document.getElementById("loginEmail")!=null){
	  	document.getElementById("loginEmail").focus();
	  }
	},
    
    showGuestLoginModule : function(targetUrl)//creating Guest login Layer
    {

     if(document.getElementById("guestLoginErrorMessage"))
     {
      document.getElementById("guestLoginErrorMessage").style.display = "none";
     }
     if(document.getElementById("guestLoginPwd"))
     {
      document.getElementById("guestLoginPwd").value = "";
     }
     trackMRBPageName("Guest:Login:Layer");
     if(!document.getElementById("guestLoginDiv"))
     {
      var guestLoginDiv = document.createElement("div");
      guestLoginDiv.id="guestLoginDiv";
      guestLoginDiv.name="guestLoginDiv";
      guestLoginDiv.style.display="none";
      document.body.appendChild(guestLoginDiv);
      var tempDiv = document.createElement("div");
      tempDiv.id="tempDiv";
      tempDiv.name="tempDiv";

      var tempInnerHtml = new Array();
      tempInnerHtml.push('<div class=containerDiv>');
      tempInnerHtml.push('<div class=subcontainer>');
      tempInnerHtml.push('<div class=h4>Log in to '+websiteName+' </div>');
      tempInnerHtml.push('<div>Please log in to use all the photos already in your account.</div>');
      tempInnerHtml.push('<span id="guestLoginErrorMessage" name="guestLoginErrorMessage" style="padding:8px 0;"></span>');
      tempInnerHtml.push('<div></div>')
      tempInnerHtml.push('<form name="guestLoginForm" id="guestLoginForm" action='+guestLoginPostURL+' onsubmit="return submitForm('+'\'guestLoginForm\''+','+'\''+targetUrl+'\''+');" method="post">');
  	  tempInnerHtml.push('<div class=formFields><span id="email">email address&nbsp;</span></div>');
	  if(typeof(CBrowserMgr)!="undefined" && CBrowserMgr.isIE()){
        tempInnerHtml.push('<div><input type="text" class   =loginforminput maxLength=255 name="guestLoginEmail" id="guestLoginEmail" onkeypress="onEnterClick(event,\'guestloginsubmit\')" value='+emailAddr+'  ></div>');	  
	  }else{
	    tempInnerHtml.push('<div><input type="text" class   =loginforminput maxLength=255 name="guestLoginEmail" id="guestLoginEmail" value='+emailAddr+'  ></div>');
	  }
      tempInnerHtml.push('<div class=formFields>password&nbsp;</div>');
      if(typeof(CBrowserMgr)!="undefined" && CBrowserMgr.isIE()){
        tempInnerHtml.push('<div><input class=loginforminput type=password maxLength=255 name="guestLoginPwd" onkeypress="onEnterClick(event,\'guestloginsubmit\')" id="guestLoginPwd"></div>');      
      }else{
        tempInnerHtml.push('<div><input class=loginforminput type=password maxLength=255 name="guestLoginPwd" id="guestLoginPwd"></div>');
      }
      
      tempInnerHtml.push('<div class="left115px"><a href="javascript:showForGotPassword('+'\''+targetUrl+'\''+');" onClick ="javascript:trackMRBClickMap(this,'+'\'link_forgot password\''+');">Forgot your password?</a></div>');
      if(typeof(CBrowserMgr)!="undefined" && CBrowserMgr.isIE()){
        tempInnerHtml.push('<div style="margin-left:111px"><input type="checkbox" onkeypress="onEnterClick(event,\'guestloginsubmit\')" value=ON name=savepassword>Sign me in automatically</div>');      
      }else{    
        tempInnerHtml.push('<div style="margin-left:111px"><input type="checkbox" value=ON name=savepassword>Sign me in automatically</div>');
      }
      if(typeof(CBrowserMgr)!="undefined" && CBrowserMgr.isIE()){
        tempInnerHtml.push('<div class="left115px"><a onClick="javascript:submitForm('+'\'guestLoginForm\''+','+'\''+targetUrl+'\''+');trackMRBClickMap(this,'+'\'button_login\''+');"><img id="guestloginsubmit" title="log in" height=23 width=82 src='+loginImgPath+' border=0 name="log in"></a></div>');      
      }else{
        tempInnerHtml.push('<div class="left115px"><a onClick="javascript:trackMRBClickMap(this,'+'\'button_login\''+');"><input type="image" id="guestloginsubmit" title="log in" height=23 width=82 src='+loginImgPath+' border=0 name="log in"></a></div>');
      }      
      
	  if( isASPSnapfish || isSnapfishUKWebsite ){
	  	tempInnerHtml.push('<div style="margin-left:115px;"><iframe marginwidth="0" marginheight="0" style="width:95px;height:28px;" frameborder="0" vspace="0" hspace="0" align="middle" src="/livechat/fromloginlayer=true" ></iframe></div>');
	  }
      tempInnerHtml.push('<div class=greydashlined></div>');
      tempInnerHtml.push('<span class=h4>new to '+websiteName+'?</span>');
      tempInnerHtml.push('<div class="unorderedlist">');
      tempInnerHtml.push('<ul>');
      if(isASPSnapfish)
      {
          tempInnerHtml.push('<li>Create an account and get free 4x6 prints with your <br />first photo upload</li>');
      }
      else if(isSnapfishUKWebsite)
      {
          tempInnerHtml.push('<li>Create an account and get free 6x4 prints with your <br />first photo upload</li>');
      }
      else
      {
          tempInnerHtml.push('<li>Create an account and get free 4x6 prints</li>');
      }
      tempInnerHtml.push('<li>Turn your photos into a memorable custom '+product+'</li>');
      tempInnerHtml.push('<li>Share and store your photos for free</li>');
      tempInnerHtml.push('</ul>');
      tempInnerHtml.push('<span><a href="javascript:showReg('+'\''+targetUrl+'\''+');"  onClick ="javascript:trackMRBClickMap(this,'+'\'link_register\''+');">create an account</a> or <a href="javascript:createGuestAcct('+'\''+targetUrl+'\''+')"  onClick ="javascript:trackMRBClickMap(this,'+'\'link_guest\''+');">enter as a guest</a></span></div>');
      tempInnerHtml.push('</form>');
      tempInnerHtml.push('</div>');
      tempInnerHtml.push('</div>');
      tempDiv.innerHTML = tempInnerHtml.join('');
      document.getElementById("guestLoginDiv").appendChild(tempDiv);
     }
     if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)	
     {
   	  document.getElementById("moveregbackhack").innerHTML = tempInnerHtml.join('');
     }
     else     
	  CLayer.openLayer("guestLoginLayer",{type:'div', src:'guestLoginDiv',width:'364',isMovable:'false',closeText:'Close',closeCallBack:'closeModule()'});
	  if(document.getElementById("guestLoginEmail")!=null){
	  	document.getElementById("guestLoginEmail").focus();
	  }
	},

    showGuestRegModule : function(targetUrl)//creating Guest Reg Layer
    {
     trackMRBPageName("Guest:Registration:Layer");
     if(!document.getElementById("guestRegDiv"))
     {
      var guestRegDiv = document.createElement("div");
      guestRegDiv.id="guestRegDiv";
      guestRegDiv.name="guestRegDiv";
      guestRegDiv.style.display="none";
      document.body.appendChild(guestRegDiv);
      var tempInnerHtml = new Array();
      tempInnerHtml.push('<div class="containerDiv">');
      tempInnerHtml.push('<div class="subcontainer">');
      tempInnerHtml.push('<span class=h4>New to '+websiteName+'?</span>');
      tempInnerHtml.push('<div class="unorderedlist">');
      tempInnerHtml.push('<ul>');
      if(isASPSnapfish)
      {
          tempInnerHtml.push('<li>Create an account and get free 4x6 prints with your <br />first photo upload</li>');
      }
      else if(isSnapfishUKWebsite)
      {
          tempInnerHtml.push('<li>Create an account and get free 6x4 prints with your <br />first photo upload</li>');
      }
      else
      {
          tempInnerHtml.push('<li>Create an account and get free 4x6 prints</li>');
      }
      tempInnerHtml.push('<li>Turn your photos into a memorable custom '+product+'</li>');
      tempInnerHtml.push('<li>Share and store your photos for free</li>');
      tempInnerHtml.push('</ul></div>');
      tempInnerHtml.push('<div><a href="javascript:showReg('+'\''+targetUrl+'\''+');" onClick ="javascript:trackMRBClickMap(this,'+'\'button_register\''+');"><img title="create account" vspace="3" align="absmiddle" height=23 width=134 src='+createAcctImagePath+' border=0 name="create account"></a></div>');
      tempInnerHtml.push('<div></div>');
	  tempInnerHtml.push('<div> or <a href="javascript:createGuestAcct('+'\''+targetUrl+'\''+');"  onClick ="javascript:trackMRBClickMap(this,'+'\'link_guest\''+');">enter as a guest</a></div>');
	  tempInnerHtml.push('<div></div>');
      tempInnerHtml.push('<div class=greydashlined></div>');
      tempInnerHtml.push('<div class=h4>Already have an account?</div>');
      tempInnerHtml.push('<div style="PADDING:2px 0 10px 0;"><a href="javascript:showGuestLogin('+'\''+targetUrl+'\''+');" onClick ="javascript:trackMRBClickMap(this,'+'\'link_login\''+');">Log in</a> to use all the photos already in your account.</div>');
      tempInnerHtml.push('</div>');
      tempInnerHtml.push('</div>');
      document.getElementById("guestRegDiv").innerHTML = tempInnerHtml.join('');
     }
     if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)	
     {
   	  document.getElementById("moveregbackhack").innerHTML = tempInnerHtml.join('');
     }
     else
      CLayer.openLayer("guestRegLayer",{type:'div', src:'guestRegDiv',width:'380',height:'430',isMovable:'false',closeText:'Close',closeCallBack:'closeModule()'});
    },

    showRegModule : function(targetUrl)//creating Registration Layer
    {
      trackLoginRegPageName(false , false);
      if(!document.getElementById("regDiv"))
      {
      var regDiv = document.createElement("div");
      regDiv.id="regDiv";
      regDiv.name="regDiv";
      regDiv.style.display="none";
      document.body.appendChild(regDiv);
      var tempInnerHtml = new Array();
      tempInnerHtml.push('<div class="containerDiv2" >');
      tempInnerHtml.push('<div class="subcontainer">');
      tempInnerHtml.push('<div class="h4">Create a free '+websiteName+' account</div>');
      tempInnerHtml.push("<div id='regSaveText' style='display:none'>Please create an account to save your "+product+"</div>");
      tempInnerHtml.push("<div id='regCartText' style='display:none'>Please create an account to add your "+product+" to your cart</div>");
      tempInnerHtml.push("<div id='regShareText' style='display:none'>Please create an account to share your "+product+"</div>");	
      tempInnerHtml.push('<div style="color:#c2c0c0;">All fields are required</div>');
      tempInnerHtml.push('<span id="regErrorMessage" name="regErrorMessage" style="padding:8px 0;"><b></b></span>');
      tempInnerHtml.push('<form name="regForm" id="regForm" action='+regPostURL+' onSubmit="return submitForm('+'\'regForm\''+','+'\''+targetUrl+'\''+');" method=post>');
      tempInnerHtml.push('<div id="regFname">');
      tempInnerHtml.push('<div class="formFields">first name&nbsp;</div>');
      tempInnerHtml.push('</div>');
      tempInnerHtml.push('<div id="regFnameError" style="display:none">');
      tempInnerHtml.push('<div class="formFields error">first name*&nbsp;</div>');
      tempInnerHtml.push('</div>');
      if(typeof(CBrowserMgr)!="undefined" && CBrowserMgr.isIE()){
        tempInnerHtml.push('<div><input name="firstname" id="firstname" type=text maxlength="12"  onkeypress="onEnterClick(event,\'regsubmit\')"  value="" class="loginforminput"/></div>');      
      }else{
        tempInnerHtml.push('<div><input name="firstname" id="firstname" type=text maxlength="12"  value="" class="loginforminput"/></div>');
      }
                
	  tempInnerHtml.push('<div id="regLname">');
	  tempInnerHtml.push('<div class="formFields">last name&nbsp;</div>');
	  tempInnerHtml.push('</div>');
	  tempInnerHtml.push('<div id="regLnameError" style="display:none">');
      tempInnerHtml.push('<div class="formFields error">last name*&nbsp;</div>');
      tempInnerHtml.push('</div>');
      if(typeof(CBrowserMgr)!="undefined" && CBrowserMgr.isIE()){
        tempInnerHtml.push('<div><input type=text name="lastname" id="lastname" maxlength="14"  onkeypress="onEnterClick(event,\'regsubmit\')"  value="" class="loginforminput"/></div>');      
      }else{
        tempInnerHtml.push('<div><input type=text name="lastname" id="lastname" maxlength="14"  value="" class="loginforminput"/></div>');
      }
      
      tempInnerHtml.push('<div id="regEmail">');
      tempInnerHtml.push('<div class="formFields">email address&nbsp;</div>');
      tempInnerHtml.push('</div>');
      tempInnerHtml.push('<div id="regEmailError" style="display:none">');
      tempInnerHtml.push('<div class="formFields error">email address*&nbsp;</div>');
      tempInnerHtml.push('</div>');
      if(typeof(CBrowserMgr)!="undefined" && CBrowserMgr.isIE()){
        tempInnerHtml.push('<div><input type=text name='+emailAddress+' id='+emailAddress+' value=""  onkeypress="onEnterClick(event,\'regsubmit\')"  class="loginforminput"/></div>');      
      }else{
        tempInnerHtml.push('<div><input type=text name='+emailAddress+' id='+emailAddress+' value=""  class="loginforminput"/></div>');
      }
      
      tempInnerHtml.push('<div id="regPwd">');
      tempInnerHtml.push('<div class="formFields">password&nbsp;</div>');
      tempInnerHtml.push('</div>');
      tempInnerHtml.push('<div id="regPwdError" style="display:none">');
      tempInnerHtml.push('<div class="formFields error">password*&nbsp;</div>');
      tempInnerHtml.push('</div>');
      if(typeof(CBrowserMgr)!="undefined" && CBrowserMgr.isIE()){
        tempInnerHtml.push('<div style="height:25px;"><input type=password name='+password+' id='+password+' value=""  onkeypress="onEnterClick(event,\'regsubmit\')"  class="loginforminput"/></div>');      
      }else{
        tempInnerHtml.push('<div style="height:25px;"><input type=password name='+password+' id='+password+' value=""  class="loginforminput"/></div>');
      }
      
      tempInnerHtml.push('<div style="margin-left:120px;color:#c2c0c0;">(at least 5 characters)</div>');
      tempInnerHtml.push('<div id="regPwd2">');
      tempInnerHtml.push('<div class="formFields">re-type password&nbsp;</div>');
      tempInnerHtml.push('</div>');
      tempInnerHtml.push('<div id="regPwd2Error" style="display:none">');
      tempInnerHtml.push('<div class="formFields error">re-type password*&nbsp;</div>');
      tempInnerHtml.push('</div>');
      if(typeof(CBrowserMgr)!="undefined" && CBrowserMgr.isIE()){
        tempInnerHtml.push('<div ><input type=password  name="password2" id="password2" value=""  onkeypress="onEnterClick(event,\'regsubmit\')"  class="loginforminput"/></div>');      
      }else{
        tempInnerHtml.push('<div ><input type=password  name="password2" id="password2" value=""  class="loginforminput"/></div>');
      }
      
      if(isFullCobrand  && (cobrand == "SKY" || cobrand == "Skyphoto"))
      {
          tempInnerHtml.push('<table cellsapcing="0" border="0" cellpadding="0">');
          tempInnerHtml.push('<tr>');
          tempInnerHtml.push('<td width="12"><img src='+spacerImagePath+' width="1" height="1" border="0" /></td>');
          tempInnerHtml.push('<td nowrap="nowrap">Are you a Sky Subscriber?&nbsp;&nbsp;<input name="skyuser" type="radio" value="yes"> Yes  <input name="skyuser" type="radio" value="no"> No</td>');
          tempInnerHtml.push('</tr>');
          tempInnerHtml.push('</table>');
      }
      if(!hidecheckbox && isASPSnapfish)
      {
           tempInnerHtml.push('<table cellpadding="0" cellspacing="0" border="0">');
           tempInnerHtml.push('<tr>');
           tempInnerHtml.push('<td width="112"><img src='+spacerImagePath+' width="1" height="1" border="0" /></td>');
           if(typeof(CBrowserMgr)!="undefined" && CBrowserMgr.isIE()){
            tempInnerHtml.push('<td valign="top"><input type="checkbox" onkeypress="onEnterClick(event,\'regsubmit\')" name='+regPromoOption+'value='+optionChecked+'>');           
           }else{
            tempInnerHtml.push('<td valign="top"><input type="checkbox" name='+regPromoOption+'value='+optionChecked+'>');
           }
           
           tempInnerHtml.push('<input type="hidden" name='+regOptFlag+' value='+regOptFlag+ '');
           tempInnerHtml.push('</td>');
           tempInnerHtml.push('<td width="5"><img src='+spacerImagePath+'width="1" height="1" border="0" /></td>');
           tempInnerHtml.push('<td>Please send me periodic deals and announcements by email<br /><img src='+spacerImagePath+' width="105" height="1" border="0" alt="" /><br /></td>');
           tempInnerHtml.push('</tr>');
           tempInnerHtml.push('</table>');
      }
      if(isSnapfishUKWebsite)
      {
         tempInnerHtml.push('<table cellpadding="0" cellspacing="0" border="0">');
         tempInnerHtml.push('<tr>');
         tempInnerHtml.push('<td width="112"><img src='+spacerImagePath+' width="1" height="1" border="0" /></td>');
         tempInnerHtml.push('<td nowrap="nowrap" valign="top">');
         if(typeof(CBrowserMgr)!="undefined" && CBrowserMgr.isIE()){
            tempInnerHtml.push('<input type="checkbox" onkeypress="onEnterClick(event,\'regsubmit\')" id='+'"'+accept+'"name='+'"'+accept+'"'+'value='+optionChecked+' onClick ="javascript:trackLoginRegClickMap(this,'+'\'checkbox_accept terms\''+');">');         
         }else{
            tempInnerHtml.push('<input type="checkbox" id='+'"'+accept+'"name='+'"'+accept+'"'+'value='+optionChecked+' onClick ="javascript:trackLoginRegClickMap(this,'+'\'checkbox_accept terms\''+');">');
         }
         
         //tempInnerHtml.push('<%= dm.getCBStatus(new Boolean(dm.getInputValue(IParameterConstants.ACCEPT )).booleanValue()) %> ></td>');
         tempInnerHtml.push('<td width="5"><img src='+spacerImagePath+' width="1" height="1" border="0" /></td>');
         tempInnerHtml.push('<td><span id="regAccept">');
         if(isMobileCobrand)
         {
           tempInnerHtml.push('I accept the '+websiteName+'<br/><a href="javascript:openTermsnConditionsWindow('+'\''+tncPopupPath+'\''+')" onClick ="javascript:trackLoginRegClickMap(this,'+'\'link_terms and conditions\''+');">terms and conditions</a>');
         }
         else
         {
           tempInnerHtml.push('I accept the '+websiteName+'<br/><a href="javascript:openTermsnConditionsWindow('+'\''+tncPopupPath+'\''+')" onClick ="javascript:trackLoginRegClickMap(this,'+'\'link_terms and conditions\''+');">terms and conditions</a>');
         }
         tempInnerHtml.push('</span>');
         tempInnerHtml.push('<span id="regAcceptError" style="display:none">');
         if(isMobileCobrand)
         {
           tempInnerHtml.push('<font color=\"#d00031\">I accept the '+websiteName+'<br/><a href="javascript:openTermsnConditionsWindow('+'\''+tncPopupPath+'\''+')" onClick ="javascript:trackLoginRegClickMap(this,'+'\'link_terms and conditions\''+');">terms and conditions</a>*</font>');
         }
         else
         {
           tempInnerHtml.push('<font color=\"#d00031\">I accept the '+websiteName+'<br/><a href="javascript:openTermsnConditionsWindow('+'\''+tncPopupPath+'\''+')" onClick ="javascript:trackLoginRegClickMap(this,'+'\'link_terms and conditions\''+');">terms and conditions</a>*</font>');
         }
         tempInnerHtml.push('</span></td>');
         tempInnerHtml.push('</div>');
         tempInnerHtml.push('</tr>');
         tempInnerHtml.push('<tr><td colspan="4" height="10"><img src='+spacerImagePath+' width="1" height="1" border="0" /></td></tr>');
         tempInnerHtml.push('<tr>');
         tempInnerHtml.push('<td width="112"><img src='+spacerImagePath+' width="1" height="1" border="0" /></td>');
         if(!errorinpage)
         {
          tempInnerHtml.push('<td nowrap="nowrap" valign="top">');
          if(typeof(CBrowserMgr)!="undefined" && CBrowserMgr.isIE()){
            tempInnerHtml.push('<input type="checkbox" onkeypress="onEnterClick(event,\'regsubmit\')" name='+regPromoOption+' checked value='+optionChecked+'>');          
          }else{
            tempInnerHtml.push('<input type="checkbox" name='+regPromoOption+' checked value='+optionChecked+'>');
          }
          
          //tempInnerHtml.push('<%= dm.getCBStatus(new Boolean(dm.getInputValue(IParameterConstants.REG_PROMO_OPTION )).booleanValue()) %>   >');
          tempInnerHtml.push('</td>');
          tempInnerHtml.push('<td width="5"><img src='+spacerImagePath+' width="1" height="1" border="0" /></td>');
          tempInnerHtml.push('<td>');
          tempInnerHtml.push('Yes, please send me special offers and updates on ');
		  if(cobrand=="bestbuyuk")
		  {
			tempInnerHtml.push(partnerName+' Buy Photo Service and The Carphone Warehouse Ltd products and services</strong>');
		  }
		  else
		  {
			tempInnerHtml.push(partnerName+' products and services</strong>');
		  }
          tempInnerHtml.push('</td>');
      }
      else
      {
          tempInnerHtml.push('<td valign="top">');
          if(typeof(CBrowserMgr)!="undefined" && CBrowserMgr.isIE()){
            tempInnerHtml.push('<input type="checkbox" onkeypress="onEnterClick(event,\'regsubmit\')" name='+regPromoOption+' value='+optionChecked+'>');          
          }else{
            tempInnerHtml.push('<input type="checkbox" name='+regPromoOption+' value='+optionChecked+'>');
          }
          
          tempInnerHtml.push('</td>');
          tempInnerHtml.push('<td width="5"><img src='+spacerImagePath+' width="1" height="1" border="0" /></td>');
          tempInnerHtml.push('<td>Yes, please send me special offers and updates on ');
		  if(cobrand=="bestbuyuk")
		  {
			tempInnerHtml.push(partnerName+' Buy Photo Service and The Carphone Warehouse Ltd products and services</strong>');
		  }
		  else
		  {
			tempInnerHtml.push(partnerName+' products and services</strong>');
		  }
          tempInnerHtml.push('</td>');
      }
      tempInnerHtml.push('<input type="hidden" name="emailpromo" value='+optionChecked+'>');
      tempInnerHtml.push('</tr>');
      tempInnerHtml.push('</table>');
    }
    if(isASPSnapfish || isASPYork || isASPClark)
    {
       if(regVersion == "null" || regVersion == "regver1"){
       tempInnerHtml.push('<table cellsapcing="0" cellpadding="0" border="0">');
       tempInnerHtml.push('<tr>');
       tempInnerHtml.push('<td width="112"><img src='+spacerImagePath+' width="1" height="1" border="0" alt="" /></td>');
       tempInnerHtml.push('<td nowrap="nowrap" valign="top">');
       if(typeof(CBrowserMgr)!="undefined" && CBrowserMgr.isIE()){
        tempInnerHtml.push('<input type="checkbox" onkeypress="onEnterClick(event,\'regsubmit\')" id='+'"'+accept+'"name='+'"'+accept+'"'+'value='+optionChecked+' onClick ="javascript:trackLoginRegClickMap(this,'+'\'checkbox_accept terms\''+');">');       
       }else{
        tempInnerHtml.push('<input type="checkbox" id='+'"'+accept+'"name='+'"'+accept+'"'+'value='+optionChecked+' onClick ="javascript:trackLoginRegClickMap(this,'+'\'checkbox_accept terms\''+');">');
       }
       
       //tempInnerHtml.push('<%= dm.getCBStatus(new Boolean(dm.getInputValue(IParameterConstants.ACCEPT )).booleanValue()) %> ></td>');
       tempInnerHtml.push('<td width="5"><img src='+spacerImagePath+' width="1" height="1" border="0" alt="" /></td>');
       tempInnerHtml.push('<td><span id="regAccept">');
       if(isMobileCobrand)
       {
         tempInnerHtml.push('I accept the '+websiteName+'<br/><a href="javascript:openTermsnConditionsWindow('+'\''+tncPopupPath+'\''+')" onClick ="javascript:trackLoginRegClickMap(this,'+'\'link_terms and conditions\''+');">terms and conditions</a>');
       }
       else
       {
         tempInnerHtml.push('I accept the '+websiteName+'<br/><a href="javascript:openTermsnConditionsWindow('+'\''+tncPopupPath+'\''+')" onClick ="javascript:trackLoginRegClickMap(this,'+'\'link_terms and conditions\''+');">terms and conditions</a>');
       }
       tempInnerHtml.push('</span></td>');
       tempInnerHtml.push('<td class="error"><span id="regAcceptError" style="display:none">');
       if(isMobileCobrand)
       {
         tempInnerHtml.push('<font color=\"#d00031\">I accept the '+websiteName+'<br/><a href="javascript:openTermsnConditionsWindow('+'\''+tncPopupPath+'\''+')" onClick ="javascript:trackLoginRegClickMap(this,'+'\'link_terms and conditions\''+');">terms and conditions</a>*</font>');
       }
       else
       {
         tempInnerHtml.push('<font color=\"#d00031\">I accept the '+websiteName+'<br/><a href="javascript:openTermsnConditionsWindow('+'\''+tncPopupPath+'\''+')" onClick ="javascript:trackLoginRegClickMap(this,'+'\'link_terms and conditions\''+');">terms and conditions</a>*</font>');
       }
		tempInnerHtml.push('</span></td>');
				tempInnerHtml.push('</tr>');
				tempInnerHtml.push('<tr><td colspan="4" height="10"><img src='+spacerImagePath+' width="1" height="1" border="0" /></td></tr>');
				tempInnerHtml.push('<tr>');
				tempInnerHtml.push('<td width="112"><img src='+spacerImagePath+' width="1" height="1" border="0" /></td>');
				if(!errorinpage)
				{
				tempInnerHtml.push('<td nowrap="nowrap" valign="top">');
				if(typeof(CBrowserMgr)!="undefined" && CBrowserMgr.isIE()){
					tempInnerHtml.push('<input type="checkbox" onkeypress="onEnterClick(event,\'regsubmit\')" name='+regPromoOption+' checked value='+optionChecked+'>');          
				}else{
					tempInnerHtml.push('<input type="checkbox" name='+regPromoOption+' checked value='+optionChecked+'>');
				}
          
				//tempInnerHtml.push('<%= dm.getCBStatus(new Boolean(dm.getInputValue(IParameterConstants.REG_PROMO_OPTION )).booleanValue()) %>   >');
				tempInnerHtml.push('</td>');
				tempInnerHtml.push('<td>');
				 if(isFullCobrand && ( !cobrand == "snapfish" && !isSnapfishUKWebsite && !isASPYork && !isASPClark))
				{
					tempInnerHtml.push('<td>Yes,I would like to receive periodic discounts and special offers from Snapfish and '+cobrandName+'');
				}
				else {
					tempInnerHtml.push('<td>Yes,I would like to receive periodic discounts and  special offers from Snapfish by HP ');
				}
				tempInnerHtml.push('</td>');
				}
				else
				{
					tempInnerHtml.push('<td valign="top">');
					if(typeof(CBrowserMgr)!="undefined" && CBrowserMgr.isIE()){
					tempInnerHtml.push('<input type="checkbox" onkeypress="onEnterClick(event,\'regsubmit\')" name='+regPromoOption+' value='+optionChecked+'>');          
					}else{
					tempInnerHtml.push('<input type="checkbox" name='+regPromoOption+' value='+optionChecked+'>');
					}
				tempInnerHtml.push('</td>');
				
				 if(isFullCobrand && ( !cobrand == "snapfish" && !isSnapfishUKWebsite && !isASPYork && !isASPClark))
				{
					tempInnerHtml.push('<td>Yes,I would like to receive periodic discounts and special offers from Snapfish and '+cobrandName+'');
				}
				else {
					tempInnerHtml.push('<td>Yes,I would like to receive periodic discounts and special offers from Snapfish by HP ');
				}tempInnerHtml.push('</td>');
				}
				tempInnerHtml.push('<input type="hidden" name="emailpromo" value='+optionChecked+'>');
				tempInnerHtml.push('</tr>');
				tempInnerHtml.push('</table>');
		
    }
    else if(regVersion == "regver2")
    {
        tempInnerHtml.push('<table cellsapcing="0" cellpadding="0" border="0">');
        tempInnerHtml.push('<tr>');
        tempInnerHtml.push('<td width="112"><img src='+spacerImagePath+' width="1" height="1" border="0" alt=""></td>');
        tempInnerHtml.push('<td nowrap="nowrap">');
        if(typeof(CBrowserMgr)!="undefined" && CBrowserMgr.isIE()){
            tempInnerHtml.push(' <input type="checkbox" onkeypress="onEnterClick(event,\'regsubmit\')" name='+accept+' value='+optionChecked+'>');
        }else{
            tempInnerHtml.push(' <input type="checkbox" name='+accept+' value='+optionChecked+'>');
        }
        
        tempInnerHtml.push(' <td width="5"><img src='+spacerImagePath+' width="1" height="1" border="0" alt="" /></td>');
        if(error)
        {
           if(isMobileCobrand)
           {
               tempInnerHtml.push('<td>I accept the '+websiteName+'<br/><a href="javascript:openTermsnConditionsWindow('+'\''+tncPopupPath+'\''+')">terms and conditions</a></td>');
           }
           else
           {
               tempInnerHtml.push('<td>I accept the '+websiteName+'<br/><a href="javascript:openTermsnConditionsWindow('+'\''+tncPopupPath+'\''+')">terms and conditions</a></td>');
           }
        }
        else
        {
           if(isMobileCobrand)
           {
               tempInnerHtml.push('<td class="error">I accept the'+websiteName+'<br/><a href="javascript:openTermsnConditionsWindow('+'\''+tncPopupPath+'\''+')">terms and conditions</a>*</td>');
           }
           else
           {
               tempInnerHtml.push('<td class="error">I accept the '+websiteName+'<br/><a href="javascript:openTermsnConditionsWindow('+'\''+tncPopupPath+'\''+')">terms and conditions</a>*</td>');
           }
        tempInnerHtml.push('</tr>');
        tempInnerHtml.push(' </table>');
        }
        if(errorinpage)
        {
            tempInnerHtml.push('<table cellsapcing="0" cellpadding="0" border="0">');
            tempInnerHtml.push('<tr>');
            tempInnerHtml.push('<td width="112"><img src='+spacerImagePath+' width="1" height="1" border="0" alt="" /></td>');
            tempInnerHtml.push('<td nowrap="nowrap" valign="top">');
            if(typeof(CBrowserMgr)!="undefined" && CBrowserMgr.isIE()){
                tempInnerHtml.push('<input type="checkbox" onkeypress="onEnterClick(event,\'regsubmit\')" name='+specialOffersAccept+' value='+optionCheked+'>');
            }else{
                tempInnerHtml.push('<input type="checkbox" name='+specialOffersAccept+' value='+optionCheked+'>');
            }
            
            //tempInnerHtml.push('<%= dm.getCBStatus(new Boolean(dm.getInputValue(IParameterConstants.SPECIAL_OFFERS_ACCEPT )).booleanValue()) %> checked>');
            tempInnerHtml.push('<input type="hidden" name='+regFlagFt1+'value='+regFlagFt1+'></td>');
            tempInnerHtml.push('<td width="5"><img src='+spacerImagePath+' width="1" height="1" border="0" alt="" /></td>');
            tempInnerHtml.push('<td>Send me special offers, and great money saving deals on Snapfish products and services. </td>');
            tempInnerHtml.push('</tr>');
        }
        else
        {
            tempInnerHtml.push('<tr class="checkbox">');
            tempInnerHtml.push('<td width="112"><img src='+spacerImagePath+' width="1" height="1" border="0" alt="" /></td>');
            tempInnerHtml.push('<td nowrap="nowrap">');
            if(typeof(CBrowserMgr)!="undefined" && CBrowserMgr.isIE()){
                tempInnerHtml.push(' <input type="checkbox" onkeypress="onEnterClick(event,\'regsubmit\')" name='+specialOffersAccept+' value='+optionCheked+'>');            
            }else{
                tempInnerHtml.push(' <input type="checkbox" name='+specialOffersAccept+' value='+optionCheked+'>');
            }
            
            //tempInnerHtml.push('<%= dm.getCBStatus(new Boolean(dm.getInputValue(IParameterConstants.SPECIAL_OFFERS_ACCEPT )).booleanValue()) %>>');
            tempInnerHtml.push('<input type="hidden" name='+regFlagFt1+'value='+regFlagFt1+'></td>');
            tempInnerHtml.push('<td width="5"><img src='+spacerImagePath+' width="1" height="1" border="0" alt="" /></td>');
            tempInnerHtml.push('<td>Send me special offers, and great money saving deals on Snapfish products and services. </td>');
            tempInnerHtml.push('</tr>');
        }

    }
    else if(regVersion == "regver3")
    {
        tempInnerHtml.push('<tr class="checkbox">');
        tempInnerHtml.push('<td width="112"><img src='+spacerImagePath+' width="1" height="1" border="0" alt="" /></td>');
        tempInnerHtml.push('<td nowrap="nowrap">');
        if(typeof(CBrowserMgr)!="undefined" && CBrowserMgr.isIE()){
            tempInnerHtml.push('<input type="checkbox" onkeypress="onEnterClick(event,\'regsubmit\')" name='+accept+'value='+optionChecked+'>');        
        }else{
            tempInnerHtml.push('<input type="checkbox" name='+accept+'value='+optionChecked+'>');
        }
        
        //tempInnerHtml.push('<%= dm.getCBStatus(new Boolean(dm.getInputValue(IParameterConstants.ACCEPT )).booleanValue()) %> ></td>');
        tempInnerHtml.push(' <td width="5"><img src='+spacerImagePath+' width="1" height="1" border="0" alt="" /></td>');
        if(error)
        {
           if(isMobileCobrand)
           {
               tempInnerHtml.push('<td>I accept the '+websiteName+'<br/><a href="javascript:openTermsnConditionsWindow('+'\''+tncPopupPath+'\''+')">terms and conditions</a></td>');
           }
           else
           {
               tempInnerHtml.push('<td>I accept the '+websiteName+'<br/><a href="javascript:openTermsnConditionsWindow('+'\''+tncPopupPath+'\''+')">terms and conditions</a></td>');
           }
        }
        else
        {
           if(isMobileCobrand)
           {
               tempInnerHtml.push('<td class="error">I accept the '+websiteName+'<br/><a href="javascript:openTermsnConditionsWindow('+'\''+tncPopupPath+'\''+')">terms and conditions</a>*</td>');
           }
           else
           {
               tempInnerHtml.push('<td class="error">I accept the '+websiteName+'<br/><a href="javascript:openTermsnConditionsWindow('+'\''+tncPopupPath+'\''+')">terms and conditions</a>*</td>');
           }
        tempInnerHtml.push('</tr>');
        tempInnerHtml.push(' </table>');
        }

        if(errorinpage)
        {
          tempInnerHtml.push('<table cellsapcing="0" cellpadding="0" border="0">');
          tempInnerHtml.push('<tr class="checkbox">');
          tempInnerHtml.push('<td width="112"><img src='+spacerImagePath+' width="1" height="1" border="0" alt="" /></td>');
          tempInnerHtml.push('<td nowrap="nowrap">');
          if(typeof(CBrowserMgr)!="undefined" && CBrowserMgr.isIE()){
            tempInnerHtml.push('<input type="checkbox" onkeypress="onEnterClick(event,\'regsubmit\')" name='+newsLetterAccept+' value='+optionChecked+'>');          
          }else{
            tempInnerHtml.push('<input type="checkbox" name='+newsLetterAccept+' value='+optionChecked+'>');
          }
          
          tempInnerHtml.push('<input type="hidden" name='+regFlagFt2+' value='+regFlagFt2+'></td>');
          tempInnerHtml.push('<td width="5"><img src='+spacerImagePath+' width="1" height="1" border="0" alt="" /></td>');
          tempInnerHtml.push('<td>Send me the Snapfish monthly newsletter with great photo ideas,  exclusive offers and special savings. </td>');
          tempInnerHtml.push('</tr>');
        }
        else
        {
          tempInnerHtml.push('<tr class="checkbox">');
          tempInnerHtml.push('<td width="112"><img src='+spacerImagePath+' width="1" height="1" border="0" alt="" /></td>');
          tempInnerHtml.push('<td nowrap="nowrap">');
          if(typeof(CBrowserMgr)!="undefined" && CBrowserMgr.isIE()){
            tempInnerHtml.push('<input type="checkbox" onkeypress="onEnterClick(event,\'regsubmit\')" name='+newsLetterAccept+' value='+optionChecked+'>');
          }else{
            tempInnerHtml.push('<input type="checkbox" name='+newsLetterAccept+' value='+optionChecked+'>');
          }
          
          //tempInnerHtml.push('<%= dm.getCBStatus(new Boolean(dm.getInputValue(IParameterConstants.NEWS_LETTER_ACCEPT )).booleanValue()) %>>');
          tempInnerHtml.push('<input type="hidden" name='+regFlagFt2+' value='+regFlagFt2+'>');
          tempInnerHtml.push('<td width="5"><img src='+spacerImagePath+' width="1" height="1" border="0" alt="" /></td>');
          tempInnerHtml.push('<td>Send me the Snapfish monthly newsletter with great photo ideas,exclusive offers and special savings. &nbsp;</td>');
          tempInnerHtml.push('</tr>');
        }
         tempInnerHtml.push('</table>');

    }//end of regVer3
    }//end of isASPSNAPFISH
    if(isFullCobrand && ( !cobrand == "snapfish" && !isSnapfishUKWebsite && !isASPYork && !isASPClark))
    {
       tempInnerHtml.push('<table cellsapcing="0" cellpadding="0" border="0">');
       tempInnerHtml.push('<tr><td height="5"><img src='+spacerImagePath+' width="1" height="1" border="0" alt="" /></td></tr>');
       tempInnerHtml.push('<tr>');
       tempInnerHtml.push('<td width="112"><img src='+spacerImagePath+' width="1" height="1" border="0" alt="" /></td>');
       tempInnerHtml.push('<td>By signing up, you are providing your registration information to both '+cobrandName+' and Snapfish.</td>');
       tempInnerHtml.push('</tr>');
       tempInnerHtml.push(' </table>');
    }
    if( (campaignOid != null)  )
    {
        if( campaignOid == "1003622") //bellsports gets special text
        {
           tempInnerHtml.push('<table cellsapcing="0" cellpadding="0" border="0">');
           tempInnerHtml.push('<tr><td height="5"><img src='+spacerImagePath+' width="1" height="1" border="0" alt="" /></td></tr>');
           tempInnerHtml.push('<tr>');
           tempInnerHtml.push('<td width="112"><img src='+spacerImagePath+' width="1" height="1" border="0" alt="" /></td>');
           tempInnerHtml.push('<td>');
           tempInnerHtml.push('By signing up, you are providing your registration information to both Bell Sports and Snapfish.<br><a href="http://www.bellbikestuff.com/privacy.html" target="view_window">Bell Sports Privacy Policy</a>');
           tempInnerHtml.push('</td></tr>');
           tempInnerHtml.push('</table>');
        }
    }
    if(cobrand == "PHONES4U" || cobrand == "GMTV" || cobrand == "Sky" || cobrand == "iVillage"
         || cobrand == "dabs" || cobrand == "Bounty" || cobrand == "Jessops" || cobrand == "buddies")
    {
       tempInnerHtml.push('<table cellsapcing="0" cellpadding="0" border="0">');
       tempInnerHtml.push('<tr><td height="5"><img src='+spacerImagePath+' width="1" height="1" border="0" alt="" /></td></tr>');
       tempInnerHtml.push(' <td>By signing up, you are providing your registration<br> information to both '+cobrandName+' and <% if(isASPHarrier || isTruprint){%>Truprint<% } else if(isSnapfishUKWebsite) {%>Snapfish UK<%}%>.</td>');
       tempInnerHtml.push(' </tr>');
       tempInnerHtml.push('</table>');
    }


      tempInnerHtml.push("<div style='height:15px;'><img src="+spacerImagePath+" width='1' height='1' border='0' /></div>");
      if(typeof(CBrowserMgr)!="undefined" && CBrowserMgr.isIE()){
        tempInnerHtml.push('<div style="margin-left:110px;"><a onClick ="javascript:submitForm('+'\'regForm\''+','+'\''+targetUrl+'\''+');trackLoginRegClickMap(this,'+'\'button_register\''+');"><img id="regsubmit" src='+createAcctImagePath+' width="134" height="23" border="0" title=" create an account "></a></div>');
      }else{
        tempInnerHtml.push('<div style="margin-left:110px;"><a onClick ="javascript:trackLoginRegClickMap(this,'+'\'button_register\''+');"><input type="image" id="regsubmit" src='+createAcctImagePath+' width="134" height="23" border="0" title=" create an account "></a></div>');
      }
      tempInnerHtml.push('<div style="height:10px;"><img src='+spacerImagePath+' width="1" height="1" border="0" /></div>');
      if( isASPSnapfish || isSnapfishUKWebsite ){
      	tempInnerHtml.push('<div style="margin-left:70px;"><a href ="javascript:openHelpWindow('+'\''+helpIDAsString+'\''+')" onClick ="javascript:trackLoginRegClickMap(this,'+'\'link_help\''+');">Need help?</a>  |  <a href="javascript:openPrivacyWindow('+'\''+privacyPopupPath+'\''+')" onClick ="javascript:trackLoginRegClickMap(this,'+'\'link_privacy\''+');">privacy policy</a> <iframe marginwidth="0" marginheight="0" style="width:100px;height:28px;" frameborder="0" align="middle" vspace="0" hspace="0"  src="/livechat/fromreglayer=true"></iframe></div>');
      }else{
      	tempInnerHtml.push('<div style="margin-left:110px;"><a href ="javascript:openHelpWindow('+'\''+helpIDAsString+'\''+')" onClick ="javascript:trackLoginRegClickMap(this,'+'\'link_help\''+');">Need help?</a>  |  <a href="javascript:openPrivacyWindow('+'\''+privacyPopupPath+'\''+')" onClick ="javascript:trackLoginRegClickMap(this,'+'\'link_privacy\''+');">privacy policy</a></div>');
      }
      tempInnerHtml.push('<div class="greydashlined" style="margin:20px 0px 10px 0px;"><img src='+spacerImagePath+' width="12" height="2" border="0" /></div>');
      tempInnerHtml.push('<span class="h4">Already have an account?</b></span>&nbsp;&nbsp;<a href="javascript:showLogin('+'\''+targetUrl+'\''+');" onClick ="javascript:trackLoginRegClickMap(this,'+'\'link_login\''+');">log in</a>');
      tempInnerHtml.push('</form>');
      tempInnerHtml.push('</div>');
      tempInnerHtml.push('</div>');
      document.getElementById("regDiv").innerHTML = tempInnerHtml.join('');
      }
      if(typeof(userAction) != "undefined")
	  {
	    if(userAction == "save")
	    {
	      document.getElementById("regSaveText").style.display = "";
	      document.getElementById("regCartText").style.display = "none";
	      document.getElementById("regShareText").style.display = "none";
	    }
	    else if(userAction == "addtocart")
	    {
	      document.getElementById("regCartText").style.display = "";
	      document.getElementById("regSaveText").style.display = "none";
	      document.getElementById("regShareText").style.display = "none";	
	    }
	    else if(userAction.indexOf("share") != -1)
	    {
	      document.getElementById("regShareText").style.display = "";
	      document.getElementById("regSaveText").style.display = "none";
	      document.getElementById("regCartText").style.display = "none";
	    }
	  }
      if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)	
      {
      	if(tempInnerHtml != undefined)
    	  document.getElementById("moveregbackhack").innerHTML = tempInnerHtml.join('');
    	else
    	  document.getElementById("moveregbackhack").innerHTML = document.getElementById("regDiv").innerHTML;
      }
      else      
    	  CLayer.openLayer("reg",{type:'div', src:'regDiv',width:'380',height:'430',isMovable:'false',closeText:'Close',closeCallBack:'closeModule()'});
      if(document.getElementById("firstname")!=null)
      {
	  	 document.getElementById("firstname").focus();
	  }
      
    },

    showForgotPwdModule : function(targetUrl)//creating Forgot Password Layer
    {
     trackMRBPageName("Forgot Your Password:Layer");
     if(!document.getElementById("forgotPwdDiv"))
     {
      var forgotPwdDiv = document.createElement("div");
      forgotPwdDiv.id="forgotPwdDiv";
	  forgotPwdDiv.name="forgotPwdDiv";
	  forgotPwdDiv.style.display="none";
	  document.body.appendChild(forgotPwdDiv);
	  var tempInnerHtml = new Array();
	   var tempInnerHtml = new Array();
	  tempInnerHtml.push('<div class="containerDiv">');
	  tempInnerHtml.push('<div class="subcontainer">');
	  tempInnerHtml.push('<FORM action='+forgotPwdPostURL+' name="forgotPwdForm" id="forgotPwdForm" onSubmit="return submitForm('+'\'forgotPwdForm\''+');" method="post">');
	  tempInnerHtml.push('<div class="h4">Forgot your password?</div>');
	  tempInnerHtml.push('<div class="content">');
	  tempInnerHtml.push('<div class="error" id="invalidUserOrEmail" style="display:none">');
	  tempInnerHtml.push('<b>Oops, the address you have entered is incorrect. Please enter a valid email address</b>');
	  tempInnerHtml.push('</div></div>');
	  tempInnerHtml.push('<div class="content">Please enter the email address you use to log in below. We'+'\''+'ll email you a temporary');
	  tempInnerHtml.push('&nbsp password to that address so that you can log in. Once you'+'\''+'ve logged in, follow the steps');
	  tempInnerHtml.push('in the email to create a new password for your account.</div>');
	  tempInnerHtml.push('<div></div>');
	  tempInnerHtml.push('<div class="email">email address <input type="text" name="forgotPwdEmail" id="forgotPwdEmail" value="" class="loginforminput" maxlength="64"></div>');
	  tempInnerHtml.push('<div style="clear:both;"></div>');
	  tempInnerHtml.push('<div class="grey-dotted-line">&nbsp;</div>');
	  tempInnerHtml.push('<div class="text-right"><input type="image" src='+submitImagePath+' width="71" height="23" border="0" alt=" submit "></div>');
	  tempInnerHtml.push('</FORM>');
	  if(isASPSnapfish  && !(cobrand == "ATTWIRELESS"))
	  {
	    if(!isMobileCobrand)
	    {
	      tempInnerHtml.push('<div class="content">');
	      tempInnerHtml.push('<div><img class="text-left" src='+mobileIconImgPath+' width="13" height="21" border="0">');
	      tempInnerHtml.push('<a class="mobile" href="javascript:showMobileForGotPassword('+'\''+targetUrl+'\''+');">Snapfish mobile users</a></div>');
	      tempInnerHtml.push('</div>');
	    }
	  }
	  tempInnerHtml.push('</div>');
	  tempInnerHtml.push('</div>');
	  document.getElementById("forgotPwdDiv").innerHTML = tempInnerHtml.join('');
	 }
     if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)	
     {
   	  document.getElementById("moveregbackhack").innerHTML = tempInnerHtml.join('');
     }
     else
	  CLayer.openLayer("forgotpassword",{type:'div', src:'forgotPwdDiv',width:'377',height:'280',isMovable:'false',closeText:'Close',closeCallBack:'closeModule()'});
	  if(document.getElementById("forgotPwdEmail")!=null){
	  	document.getElementById("forgotPwdEmail").focus();
	  }
   },
   showMobileForgotPwdModule : function(targetUrl)//creating Mobile Forgot Password Layer
   {
     trackMRBPageName("Help Forgot Password Mobile:Layer");
     if(!document.getElementById("forgotMobilePwdDiv"))
     {
      var forgotMobilePwdDiv = document.createElement("div");
      forgotMobilePwdDiv.id="forgotMobilePwdDiv";
      forgotMobilePwdDiv.name="forgotMobilePwdDiv";
      forgotMobilePwdDiv.style.display="none";
      document.body.appendChild(forgotMobilePwdDiv);
      var tempInnerHtml = new Array();
      tempInnerHtml.push('<div class="containerDiv">');
      tempInnerHtml.push('<div class="subcontainer">');
      tempInnerHtml.push('<div class="h4">Forgot your password?</div>');
      tempInnerHtml.push('<div></div>');
      tempInnerHtml.push('<div class="content">If you'+'\''+'ve registered a mobile number with your Snapfish account but don'+'\''+'t have an email on file, ');
      tempInnerHtml.push('please send an email to <a href="mailto:'+mailLink+'?subject=mobilepassword">'+mailLink+'</a>. ');
      tempInnerHtml.push('<div></div>');
      tempInnerHtml.push('<div></div>');
      tempInnerHtml.push('Please include your first and last name, your mobile number, and the name of your wireless provider. ');
      tempInnerHtml.push('A customer support representative will be in touch with you shortly.');
      tempInnerHtml.push('</div>');
      tempInnerHtml.push('<div></div>');
      tempInnerHtml.push('<div class="content">If you have an email associated with your account and need to retrieve your password, ');
      tempInnerHtml.push('<a href="javascript:showForGotPassword('+'\''+targetUrl+'\''+');">please follow this link</a>.</div>');
      tempInnerHtml.push('<div style="clear:both;"></div>');
      tempInnerHtml.push('</div>');
      tempInnerHtml.push('</div>');
      tempInnerHtml.push('</div>');
      document.getElementById("forgotMobilePwdDiv").innerHTML = tempInnerHtml.join('');
     }
     if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)	
     {
   	  document.getElementById("moveregbackhack").innerHTML = tempInnerHtml.join('');
     }
     else     
      CLayer.openLayer("forgotmobilepassword",{type:'div', src:'forgotMobilePwdDiv',width:'380',height:'430',isMovable:'false',closeText:'Close',closeCallBack:'closeModule()'});
    },

    showForgotPwdConfirmModule : function(targetUrl)//creating  Forgot Password  Confirm Layer
    {
     if(!document.getElementById("forgotPwdConfirmDiv"))
     {
      var forgotPwdConfirmDiv = document.createElement("div");
      forgotPwdConfirmDiv.id="forgotPwdConfirmDiv";
      forgotPwdConfirmDiv.name="forgotPwdConfirmDiv";
      forgotPwdConfirmDiv.style.display="none";
      document.body.appendChild(forgotPwdConfirmDiv);
      var tempInnerHtml = new Array();
      tempInnerHtml.push('<div class="containerDiv">');
      tempInnerHtml.push('<div class="subcontainer">');
      tempInnerHtml.push('<div class="h4">Password Sent</div>');
      tempInnerHtml.push('<div></div>');
      tempInnerHtml.push('<div />');
      tempInnerHtml.push('<div class="content">We have sent you an email with your temporary password.</div>');
      tempInnerHtml.push('<div class="content">');
      tempInnerHtml.push('</div>');
      tempInnerHtml.push('</div>');
      tempInnerHtml.push('</div>');
      document.getElementById("forgotPwdConfirmDiv").innerHTML = tempInnerHtml.join('');
     }
     if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)	
     {
   	  document.getElementById("moveregbackhack").innerHTML = tempInnerHtml.join('');
     }
     else
      CLayer.openLayer("forgotpasswordconfirm",{type:'div', src:'forgotPwdConfirmDiv',width:'377',height:'280',isMovable:'false',closeText:'Close',closeCallBack:'closeModule()'});
   },

    showPwdMatchModule : function(targetUrl)//creating  Password Match Layer
    {
     trackMRBPageName("Existing Account:Password Match:Layer");
     if(!document.getElementById("PwdMatchDiv"))
     {
      var PwdMatchDiv = document.createElement("div");
      PwdMatchDiv.id="PwdMatchDiv";
      PwdMatchDiv.name="PwdMatchDiv";
      PwdMatchDiv.style.display="none";
      document.body.appendChild(PwdMatchDiv);
      var tempInnerHtml = new Array();
      tempInnerHtml.push('<FORM name="pwdMatchForm" id="pwdMatchForm" action='+pwdMatchPostURL+' onSubmit="return submitForm('+'\'pwdMatchForm\''+','+'\''+targetUrl+'\''+');"  method=post>');
      tempInnerHtml.push('<div class="containerDiv">');
      tempInnerHtml.push('<div class="subcontainer">');
      tempInnerHtml.push('<div class="h4">You already have an account</div>');
      tempInnerHtml.push('<div class="content">A ' + websiteName +' account with the email address ' + emailAddr +' already exists. Click the \"log in\" button below to go to your account.</div>');
      tempInnerHtml.push('<div class="content">If youd like to create another account, please <a href="javascript:showReg('+'\''+targetUrl+'\''+')">sign up again</a>');
      tempInnerHtml.push('<div class="content error" id="PwdMatcherrorMessage" style="display:none;"></div>');
      if(isPwdMatch)
      {
       tempInnerHtml.push('<div style="padding-top: 10px; padding-left: 18px;">email address:'+emailAddr+'</div>');
       tempInnerHtml.push('<div style="padding-top: 10px; padding-left: 50px;">password <input type="password" name="pwd" id="pwd" class="loginforminput" size="17" maxlength="255"/></div>');
       tempInnerHtml.push('<div style="padding-top: 3px; padding-left: 105px;"><a href="javascript:showForGotPassword('+'\''+targetUrl+'\''+');">Forgot your password?</a></div>');

      }
      else
      {
      tempInnerHtml.push('<input type="hidden" name='+password+' value="">');
      }
      tempInnerHtml.push('<input type="hidden" name='+emailAddress+' value='+'"'+emailAddr+'">');
      tempInnerHtml.push('<input type="hidden" name="passwordmatch" value="passwordmatch">');
      tempInnerHtml.push('<div style="clear:both;"></div>');
      tempInnerHtml.push('<div class="content"></div>');
      tempInnerHtml.push('<div class="grey-dotted-line">&nbsp;</div>');
      tempInnerHtml.push('<div class="text-right"><input type="image" src='+loginImgPath+' width="82" height="23" border="0" alt=" log in "></a></div>');
      tempInnerHtml.push('</div>');
      tempInnerHtml.push('</div>');
      tempInnerHtml.push('</FORM>');
      document.getElementById("PwdMatchDiv").innerHTML = tempInnerHtml.join('');
     }
     if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)	
     {
   	  document.getElementById("moveregbackhack").innerHTML = tempInnerHtml.join('');
     }
     else     
      CLayer.openLayer("passwordmatch",{type:'div', src:'PwdMatchDiv',width:'377',height:'280',isMovable:'false',closeText:'Close',closeCallBack:'closeModule()'});

    },

    showInterstitialModule: function(targetUrl)
    {
     if(!document.getElementById("interstitialDiv"))
     {
      var interstitialDiv = document.createElement("div");
      interstitialDiv.id="interstitialDiv";
      interstitialDiv.name="interstitialDiv";
      interstitialDiv.style.display="none";
      document.body.appendChild(interstitialDiv);
      var tempInnerHtml = new Array();
      tempInnerHtml.push('<table width= "377" cellpadding="0" cellspacing="0" border="0">');
      tempInnerHtml.push('<tr><td><img src='+spacerImagePath+' width="1" height="80" alt="" /></td></tr>');
      tempInnerHtml.push('<tr>');
      tempInnerHtml.push('<td width="80"></td>');
      tempInnerHtml.push('<td>We apologize, but this site is not available <br> in the country you selected.<br></td>');
      tempInnerHtml.push('<tr><td><img src='+spacerImagePath+' width="1" height="20" alt="" /></td></tr>');
      tempInnerHtml.push('<tr>');
      tempInnerHtml.push('<td width="80"></td>');
      tempInnerHtml.push('<td valign="top">');
      tempInnerHtml.push('Please go to &nbsp;<a href='+targetUrl+'>'+targetUrl+'</a>');
      tempInnerHtml.push('</td>');
      tempInnerHtml.push('</tr>');
      tempInnerHtml.push('<tr><td><img src='+spacerImagePath+' width="1" height="80" alt="" /></td></tr>');
      tempInnerHtml.push('</table>');
      document.getElementById("interstitialDiv").innerHTML = tempInnerHtml.join('');
     }
     if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)	
     {
   	  document.getElementById("moveregbackhack").innerHTML = tempInnerHtml.join('');
     }
     else     
      CLayer.openLayer("interstitial",{type:'div', src:'interstitialDiv',width:'377',height:'280',isMovable:'false',closeText:'Close',closeCallBack:'closeModule()'});

    },
    showChangePwdModule: function(targetUrl)
    {
     if(!document.getElementById("changePwdDiv"))
     {
      var changePwdDiv = document.createElement("div");
      changePwdDiv.id="changePwdDiv";
      changePwdDiv.name="changePwdDiv";
      changePwdDiv.style.display="none";
      document.body.appendChild(changePwdDiv);
      var tempInnerHtml = new Array();
      tempInnerHtml.push('<div class="containerDiv">');
      tempInnerHtml.push('<div class="subcontainer">');
      tempInnerHtml.push('<div><img src='+createPwgImgPath+' width=254 height=20 border=0></div>');
      tempInnerHtml.push('<div></div>');
      tempInnerHtml.push('<div>You can start using'+websiteName+' as soon as you create your new password.</div>');
      tempInnerHtml.push('<div></div>');
      tempInnerHtml.push('<div class="content error" id="changePwderrorMessage" style="display:none;"></div>');
      tempInnerHtml.push('<div></div>');
      tempInnerHtml.push('<form name="changePwdForm" id="changePwdForm" action='+changePwdPostURL+' onSubmit="return submitForm('+'\'changePwdForm\''+','+'\''+targetUrl+'\''+');" method="post">');
      tempInnerHtml.push('<div style="width:320px; background:#dddddd;"><!--Table Main box-->');
      tempInnerHtml.push('<div style="float:left; height=6"><img src='+topLeftImgPath+' width=5 height=6 border=0></div>');
      tempInnerHtml.push('<div style="float:right; height=6"><img src='+topRightImgPath+' width=5 height=6 border=0></div>');
      tempInnerHtml.push('<div style:"clear:both;"></div>');
      tempInnerHtml.push('<div style="padding-left:10px;"><!--login box-->');
      tempInnerHtml.push('<div><b>Create your own password.</b></div>');
      tempInnerHtml.push('<div style="float:left; width:150px;"><!--column1-->');
      tempInnerHtml.push('<div>new password<input type="password" name="changepwd" id="changepwd" value="" size="17" maxlength="255"></div>');
      tempInnerHtml.push('<div>re-type new password<input type="password" name="changepwd2" id="changepwd2" value="" size="17" maxlength="255"></div>');
      tempInnerHtml.push('</div><!--column1-->');
      tempInnerHtml.push('<div style="float:left; padding-top:12px; width:160px;">Choose something that'+'\''+'s easy for you to remember, but difficult for others to guess.</div>');
      tempInnerHtml.push('</div><!--login box-->');
      tempInnerHtml.push('<div style="clear:both; padding-left:7px;"><input type="checkbox" name="savepassword" value="ON">Remember me every time I visit '+websiteName+'.</div>');
      tempInnerHtml.push('<div style="clear:both;"></div>');
      tempInnerHtml.push('<div style="padding-left:25px; margin-top:3px;"><input type="image" name="log in" src='+changePwdImgPath+' width=114 height=20 border=0 alt= "change password"></div>');
      tempInnerHtml.push('<div style="float:left; height=6"><img src='+bottomLeftImgPath+' width=5 height=6 border=0></div>');
      tempInnerHtml.push('<div style="float:right; height=6"><img src='+bottomRightImgPath+' width=5 height=6 border=0></div>');
      tempInnerHtml.push('</div><!--Table Main box-->');
      tempInnerHtml.push('</form>');
      tempInnerHtml.push('</div>');
      tempInnerHtml.push('</div>');

      document.getElementById("changePwdDiv").innerHTML = tempInnerHtml.join('');
     }
     if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)	
     {
   	  document.getElementById("moveregbackhack").innerHTML = tempInnerHtml.join('');
     }
     else
      CLayer.openLayer("changePwd",{type:'div', src:'changePwdDiv',width:'377',height:'280',isMovable:'false',closeText:'Close',closeCallBack:'closeModule()'});

    },
    showAlertOverlay: function(targetUrl)
    {
      trackMRBPageName("Guest:Alert:Layer");
      if(typeof(disableExitWarning) == "function")
      {
       disableExitWarning("exitWarning");
      }
      if(!document.getElementById("alertDiv"))
      {
        var alertDiv = document.createElement("div");
        alertDiv.id="alertDiv";
	    alertDiv.name="alertDiv";
	    alertDiv.style.display="none";
	    document.body.appendChild(alertDiv);
	    var tempInnerHtml = new Array();
	    tempInnerHtml.push('<div class="containerDiv">');
	    tempInnerHtml.push('<div class="subcontainer">');
	    tempInnerHtml.push('<div class=h4>Save before leaving?</div>');
	    tempInnerHtml.push('<div>Would you like to save your '+product+' before leaving this page?</div>');
	    tempInnerHtml.push('<div style="clear:both;"></div>');
	    tempInnerHtml.push('<div class="btnimg">');
	    tempInnerHtml.push('<a name="dontSave" id ="dontSave" href="javascript:dontSaveCalendar('+'\''+targetUrl+'\''+');" onClick="javascript:trackMRBClickMap(this,'+'\'button_no save\''+');"><img src='+dontSaveImgPath+' border=0 alt="no, don'+'\''+'t save" ></a>');
	    tempInnerHtml.push('<span id="saveMyWork"><a href="javascript:saveProject();" onClick="javascript:trackMRBClickMap(this,'+'\'button_yes save\''+');"><img src='+saveWorkImgPath+' border=0 alt="yes, save my work"></a></span>');
	    tempInnerHtml.push('<span id="saveMyWorkDim" style="display:none;"><img src='+saveWorkDimImgPath+' border=0 alt="yes, save my work"></span>');
	    tempInnerHtml.push('</div>');
	    tempInnerHtml.push('</div>');
	    tempInnerHtml.push('</div>');
	    document.getElementById("alertDiv").innerHTML = tempInnerHtml.join('');
	   }
	   else
	   {
	      document.getElementById("dontSave").href = "javascript:dontSaveCalendar("+"\""+targetUrl+"\""+");";
	   }
      if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)	
      {
    	  document.getElementById("moveregbackhack").innerHTML = tempInnerHtml.join('');
      }
      else
	   CLayer.openLayer("alertOverLay",{type:'div', src:'alertDiv',width:'377',height:'280',isMovable:'false',closeText:'Close',closeCallBack:'closeModule()'});
	
	}
} ;


HFSF.Overlays.showModalPanel = function ( moduleInfo )
{
     if(moduleInfo.component == "account/login/Login")
        HFSF.Overlays.showLoginModule(moduleInfo.targetUrl) ;
     else if (moduleInfo.component == "account/login/GuestLogin")
        HFSF.Overlays.showGuestLoginModule(moduleInfo.targetUrl) ;
     else if (moduleInfo.component == "account/reg/Registration")
        HFSF.Overlays.showRegModule(moduleInfo.targetUrl) ;
     else if (moduleInfo.component == "account/reg/GuestReg")
        HFSF.Overlays.showGuestRegModule(moduleInfo.targetUrl) ;
     else if (moduleInfo.component == "account/login/ForgotPassword")
        HFSF.Overlays.showForgotPwdModule(moduleInfo.targetUrl) ;
     else if (moduleInfo.component == "account/login/MobileForgotPassword")
        HFSF.Overlays.showMobileForgotPwdModule(moduleInfo.targetUrl) ;
     else if (moduleInfo.component == "account/login/ForgotPassWordConfirm")
        HFSF.Overlays.showForgotPwdConfirmModule(moduleInfo.targetUrl) ;
     else if (moduleInfo.component == "account/login/InterstitialPage")
        HFSF.Overlays.showInterstitialModule(moduleInfo.targetUrl) ;
     else if (moduleInfo.component == "account/reg/PasswordMatch")
        HFSF.Overlays.showPwdMatchModule(moduleInfo.targetUrl) ;
     else if (moduleInfo.component == "account/login/changePassword")
        HFSF.Overlays.showChangePwdModule(moduleInfo.targetUrl) ;
     else if (moduleInfo.component == "account/calendar/alertOverlay")
        HFSF.Overlays.showAlertOverlay(moduleInfo.targetUrl) ;
}
function createGuestAcct(targetUrl)
{
    var xmlhttp1 = null;
     if (navigator.appName == "Netscape")
        xmlhttp1 = new XMLHttpRequest();
     else
        xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP");

        xmlhttp1.onreadystatechange = function() { getGuestUserInfo(xmlhttp1,targetUrl); }
        xmlhttp1.open("GET",  createGuestAcctURL , true);
        xmlhttp1.setRequestHeader('If-Modified-Since','Wed, 15 Nov 1995 04:58:08 GMT');
        xmlhttp1.send(null);

}
function getGuestUserInfo(xmlhttp ,targetUrl)
{

  if(xmlhttp.readyState == 4)
  {
   if(xmlhttp.status == 200)
   {
      var ajxResponse = xmlhttp.responseText;
      if (ajxResponse == null || ajxResponse == "")
      {

      }
      else
      {
        var data = eval('(' + ajxResponse + ')');
        if(typeof(data.gauth) != "undefined" && typeof(data.gacctoid) != "undefined" && typeof(data.podifiedhost) != "undefined" )
        {
            var lm = CLinkManager.getInstance(targetUrl);
            lm.setURLParameter(guestAuthCode,data.gauth);
            lm.setURLParameter(guestAcctOid,data.gacctoid);
            lm.setURLParameter("COBRAND_NAME",data.COBRAND_NAME);
            if(data.podifiedhost.indexOf("http") != -1)
            {
            	if(targetUrl.indexOf("isPopup=true") > 0)
                {
            		/*
              	  CBuilderPopup.open(data.podifiedhost + lm.getURL(), 'resizable=1,toolbar=no,location=no,menubar=no,scrollbars=yes', 'FlexBuilderApp');
              	  CLayer.closeAllLayers();
              	  document.location.href = data.podifiedhost + inputRefreshURL;  
              	  */
            	  if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)
            		  window.parent.flexInvokeWidgetMethod(widgetId,'swiftLoadWindow', data.podifiedhost + lm.getURL() );
            	  else
            		  document.location.href = data.podifiedhost + lm.getURL();
                }
                else
                {
              	  if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)
            		  window.parent.flexInvokeWidgetMethod(widgetId,'swiftLoadWindow', data.podifiedhost + lm.getURL() );
            	  else
                	  document.location.href = data.podifiedhost + lm.getURL();
                }
            }
            else
            {
            	if(targetUrl.indexOf("isPopup=true") > 0)
                {
            		/*
                  CBuilderPopup.open(scheme + data.podifiedhost + lm.getURL(), 'resizable=1,toolbar=no,location=no,menubar=no,scrollbars=yes', 'FlexBuilderApp');
              	  CLayer.closeAllLayers();
              	  document.location.href = scheme + data.podifiedhost + inputRefreshURL; 
              	  */
              	  if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)
            		  window.parent.flexInvokeWidgetMethod(widgetId,'swiftLoadWindow', scheme + data.podifiedhost + lm.getURL() );
            	  else
            		  document.location.href = scheme + data.podifiedhost + lm.getURL();
                }
                else
                {      
              	  if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)
            		  window.parent.flexInvokeWidgetMethod(widgetId ,'swiftLoadWindow', scheme + data.podifiedhost + lm.getURL() );
            	  else
                	  document.location.href = scheme + data.podifiedhost + lm.getURL();
                }
            }
        }
        else
        {
          alert('Please Try Again');
        }
      }
   }
 }
}


function showLogin(targetUrl)
{
  CLayer.closeLayer("reg");
  CLayer.closeLayer("guestLoginLayer");
  CLayer.closeLayer("guestRegLayer");
  if(document.getElementById("loginErrorMessage"))
  {
    document.getElementById("loginErrorMessage").style.display = "none";
  }
  if(document.getElementById("loginpwd"))
  {
    document.getElementById("loginpwd").value = "";
  }
  var lm = CLinkManager.getInstance(targetUrl);
  lm.removeURLParameter("isFromReg");
  targetUrl = lm.getURL();
  HFSF.Overlays.showModalPanel({
     component : "account/login/Login",
     title : "Login",
     targetUrl : targetUrl
      });
}
function showReg(targetUrl)
{
  var lm = CLinkManager.getInstance(targetUrl);
  lm.setURLParameter("isFromReg" , "true");
  targetUrl = lm.getURL();
  if(document.getElementById("regErrorMessage"))
  {
    document.getElementById("regErrorMessage").style.display = "none";
  }
  if(document.getElementById("regFnameError"))
  {
    document.getElementById("regFnameError").style.display = "none";
  }
  if(document.getElementById("regFname"))
  {
    document.getElementById("regFname").style.display = "block";
  }
  if(document.getElementById("regLnameError"))
  {
    document.getElementById("regLnameError").style.display = "none";
  }
  if(document.getElementById("regLname"))
  {
    document.getElementById("regLname").style.display = "block";
  }
  if(document.getElementById("regEmailError"))
  {
    document.getElementById("regEmailError").style.display = "none";
  }
  if(document.getElementById("regEmail"))
  {
    document.getElementById("regEmail").style.display = "block";
  }
  if(document.getElementById("regPwdError"))
  {
    document.getElementById("regPwdError").style.display = "none";
  }
  if(document.getElementById("regPwd"))
  {
    document.getElementById("regPwd").style.display = "block";
  }
  if(document.getElementById("regPwd2Error"))
  {
    document.getElementById("regPwd2Error").style.display = "none";
  }
  if(document.getElementById("regPwd2"))
  {
    document.getElementById("regPwd2").style.display = "block";
  }
  if(document.getElementById("regAcceptError"))
  {
    document.getElementById("regAcceptError").style.display = "none";
  }
  if(document.getElementById("regAccept"))
  {
    document.getElementById("regAccept").style.display = "block";
  }
  if(document.getElementById("firstname"))
  {
    document.getElementById("firstname").value = "";
  }
  if(document.getElementById("lastname"))
  {
    document.getElementById("lastname").value = "";
  }
  if(document.getElementById(emailAddress))
  {
    document.getElementById(emailAddress).value = "";
  }
  if(document.getElementById(password))
  {
    document.getElementById(password).value = "";
  }
  if(document.getElementById("password2"))
  {
    document.getElementById("password2").value = "";
  }
  if(document.getElementById("accept"))
  {
    document.getElementById("accept").checked = false;
  }
 CLayer.closeAllLayers();
  HFSF.Overlays.showModalPanel({
     component : "account/reg/Registration",
     title : "Registration",
     targetUrl : targetUrl
      });
}

function showMobileForGotPassword(targetUrl)
{
  CLayer.closeAllLayers();
  HFSF.Overlays.showModalPanel({
     component : "account/login/MobileForgotPassword",
     title : "Forgot Password",
     targetUrl : targetUrl
      });

}

function showForGotPassword(targetUrl)
{
  if(document.getElementById("invalidUserOrEmail"))
  {
    document.getElementById("invalidUserOrEmail").style.display = "none";
  }
  if(document.getElementById("forgotPwdEmail"))
  {
    document.getElementById("forgotPwdEmail").value = "";
  }
  CLayer.closeAllLayers();
  HFSF.Overlays.showModalPanel({
     component : "account/login/ForgotPassword",
     title : "Mobile Forgot Password",
     targetUrl : targetUrl
      });

}

function showPwdMatch(targetUrl)
{
  CLayer.closeAllLayers();
  if(document.getElementById("PwdMatcherrorMessage"))
  {
    document.getElementById("PwdMatcherrorMessage").style.display = "none";
  }
  if(document.getElementById("pwd"))
  {
    document.getElementById("pwd").value = "";
  }
  HFSF.Overlays.showModalPanel({
     component : "account/reg/PasswordMatch",
     title : "Password Match",
     targetUrl : targetUrl
      });

}

function moveGuestAccount(eventName , eventObj)
{
	var lm = CLinkManager.getInstance(moveGuestAccountURL);
	userAction = "save";
	if(eventName == "events.SharedEvents.onAddToCartClick")
	{
	  userAction = "addtocart";
	}
	else if(eventName == "events.SharedEvents.onShareEmailClick")
	{
	  userAction = "shareemail";
	}
	else if(eventName == "events.SharedEvents.onShareLinkClick")
	{
	  userAction = "sharelink";
	}
	else if(eventName == "events.SharedEvents.onShareFBClick")
	{
	  userAction = "sharefb";
	}

	lm.setURLParameter("useraction" , userAction);
	if(eventObj.orderId != null)
	{
	  lm.setURLParameter("orderId" , eventObj.orderId);
	}
	if(eventObj.leadingOliOid != null)
	{
	  lm.setURLParameter("leadingolioid" , eventObj.leadingOliOid);
	}
	if(eventObj.orderType != null)
	{
	  lm.setURLParameter("ordertype" , eventObj.orderType);
	}
	lm.setURLParameter("orderstatus" , eventObj.orderStatus);
	lm.setURLParameter("albumIds" , eventObj.albumIds );
	var lm1 = CLinkManager.getInstance(regPostURL);
	lm1.setURLParameter("useraction" , userAction);
	lm1.setURLParameter("albumIds" , eventObj.albumIds );
	regPostURL = lm1.getURL();
	gTargetURL = lm.getURL();
	if(isRetUser)
	{
	  showLogin(lm.getURL());
	}
	else
	{
	  showReg(lm.getURL());
	}	
}

if(typeof SF != 'undefined'){
	SF.client = {
		publish: function(eventName , eventObj)
		{
			var lm = CLinkManager.getInstance(moveGuestAccountURL);
			userAction = "save";
			if(eventName == "events.SharedEvents.onAddToCartClick")
			{
			  userAction = "addtocart";
			}
			else if(eventName == "events.SharedEvents.onShareEmailClick")
			{
			  userAction = "shareemail";
			}
			else if(eventName == "events.SharedEvents.onShareLinkClick")
			{
			  userAction = "sharelink";
			}
			else if(eventName == "events.SharedEvents.onShareFBClick")
			{
			  userAction = "sharefb";
			}

			lm.setURLParameter("useraction" , userAction);
			if(eventObj.orderId != null)
			{
			  lm.setURLParameter("orderId" , eventObj.orderId);
			}
			if(eventObj.leadingOliOid != null)
			{
			  lm.setURLParameter("leadingolioid" , eventObj.leadingOliOid);
			}
			if(eventObj.orderType != null)
			{
			  lm.setURLParameter("ordertype" , eventObj.orderType);
			}
			lm.setURLParameter("orderstatus" , eventObj.orderStatus);
			lm.setURLParameter("albumIds" , eventObj.albumIds );
			var lm1 = CLinkManager.getInstance(regPostURL);
			lm1.setURLParameter("useraction" , userAction);
			lm1.setURLParameter("albumIds" , eventObj.albumIds );
			regPostURL = lm1.getURL();
			gTargetURL = lm.getURL();
			if(isRetUser)
			{
			  showLogin(lm.getURL());
			}
			else
			{
			  showReg(lm.getURL());
			}
		}
	};
}

function getFormResponse(formName , targetURL)
{
  var xmlhttp1 = null;
  if(navigator.appName == "Netscape"){
    xmlhttp1 = new XMLHttpRequest();
  }
  else{
    xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP");
  }
  xmlhttp1.onreadystatechange = function() {getRegLoginStatus(xmlhttp1,formName ,targetURL); }
  xmlhttp1.open("GET", regLoginStatusURL , true);
  xmlhttp1.setRequestHeader('If-Modified-Since','Wed, 15 Nov 1995 04:58:08 GMT');
  xmlhttp1.send(null);
}

function getRegLoginStatus(xmlhttp,formName,targetURL)
{
  if(xmlhttp.readyState == 4)
  {
    if(xmlhttp.status == 200)
    {
      var ajxResponse = xmlhttp.responseText;
      if (ajxResponse == null || ajxResponse == "")
      {
          //getGuestLoginResponse();
      }
      else
      {
        var data = eval('(' + ajxResponse + ')');
        if(formName == "loginForm" || formName == "guestLoginForm")
        {
          if(typeof(data.loginerror) != "undefined")//Checking the error cases for Login
          {
            var message = "";
            if ((isSnapfishUKWebsite || isASPSnapfish))
            {
              message = "<font color=\"#d00031\">Oops&#151;we were unable to log you in with the information you provided. "
                + "Please try again.</font>" ;
            }
            else
            {
              message = "<font color=\"#d00031\">Oops&#151;either your password or email address was incorrect. "
                + "Please try again.</font>" ;
            }
            if(typeof(data.loginstatus) != "undefined" && data.loginstatus == "user_not_found")
            {
                if(typeof(data.invalidemail) !="undefied" && data.invalidemail == "true")
                {
                   message = "<font color=\"#d00031\">Oops! There is no "+  websiteName + " account with this email address. Please try again.</font> " ;
                }
                else
                {
                    message = "<font color=\"#d00031\">Oops! There is no "+  websiteName + " account with this mobile phone number. Please try again. "
                    + "If you have never signed up with your mobile phone number, you will need to log in using your email address. "
                    + "You can add your mobile phone number to your account information to be able to log in with your phone number next time.</font>"   ;
                }
            }
            else if(typeof(data.invalidemail) !="undefied" && data.invalidemail == "true")
            {
              if (isSnapfishUKWebsite || isASPSnapfish)
              {
                message = '<font color=\"#d00031\">We'+'\''+'re sorry, but your login failed. Please check your email address and password and try again! If you forgot your password, </font>'
                         +  '<a href="javascript:showForGotPassword('+'\''+targetURL+'\''+');">click here</a>.';
              }
              else
              {
                message = "<font color=\"#d00031\">Oops! This email address is not a valid email address. Please try again.</font>" ;
              }
            }
            else if ( (isSnapfishUKWebsite || isASPSnapfish) && typeof(data.invalidemail) !="undefied" && data.invalidemail == "false" )
            {
              message = "<font color=\"#d00031\">Oops! The mobile phone number you entered is not a valid mobile phone number. Please enter your 10-digit number (no dashes required, e.g. 4155551234)." ;
            }
            else if(typeof(data.loginstatus) != "undefined" && data.loginstatus == "badpassword")
            {
              if(formName == "loginForm")
              {
                if(document.getElementById(loginEmail))
                {
                  var enteredPhoneNumber = document.getElementById(loginEmail).value.indexOf("@") == -1;
                }
              }
              else if(formName == "guestLoginForm")
              {
                if(document.getElementById("guestLoginEmail"))
                {
                  var enteredPhoneNumber = document.getElementById("guestLoginEmail").value.indexOf("@") == -1;
                }
              }

              if((isSnapfishUKWebsite || isASPSnapfish) && enteredPhoneNumber)
              {
                 message = '<font color=\"#d00031\">We'+'\''+'re sorry, but your login failed. Please check your mobile phone number and password and try again! If you forgot your password, </font>' + '<a href="javascript:showMobileForGotPassword('+'\''+targetURL+'\''+');">click here</a>.';
              }
              else
              {
                if(isSnapfishUKWebsite)
                {
                   message = '<font color=\"#d00031\">We'+'\''+'re sorry, but your login failed. Please check your email address and password and try again! If you forgot your password, </font>'+ '<a href="javascript:showForGotPassword('+'\''+targetURL+'\''+');">click here</a>.';
                }
                else
                {
                   message = '<font color=\"#d00031\">Oops! Your password and email address do not match. Please try again. If you '+ 'forgot your password, </font>'+ '<a href="javascript:showForGotPassword('+'\''+targetURL+'\''+');">click here</a>.';
                }
              }
            }
            else if(data.loginstatus == "notallowedtologin")
            {
                if(typeof(data.HOST_NAME) != "undefied")
                {
                  showInterstitialPage(data.HOST_NAME);
                }
            }
            if(formName == "loginForm")
            {
                if(typeof(data.errorstr) != "undefined")
                {
                  setsProp14Value(true ,data.errorstr )
                }
                trackLoginRegPageName(true , true);
                if(document.getElementById("loginpwd"))
                {
                  document.getElementById("loginpwd").value = "";
                }
                document.getElementById("loginErrorMessage").innerHTML = message;
                document.getElementById("loginErrorMessage").style.display = "block";
                document.getElementById(loginEmail).focus();
            }
            else
            {
                if(typeof(data.errorstr) != "undefined")
                {
                  setsProp14Value(true ,data.errorstr )
                }
                trackMRBPageName("Guest:Login:Error:Layer");
                if(document.getElementById("guestLoginPwd"))
                {
                  document.getElementById("guestLoginPwd").value = "";
                }
                document.getElementById("guestLoginErrorMessage").innerHTML = message;
                document.getElementById("guestLoginErrorMessage").style.display = "block";
                document.getElementById('guestLoginEmail').focus();
            }
           }
          else if(typeof(data.loginsuccess) != "undefined")//for Login Success
          {
            if(typeof(data.autogenpwd) != "undefined")//Checking for Autogen password case in Login
            {
              showChangePwd(targetURL);
            }
            else if(typeof(data.podifiedhost) != "undefined" && typeof(data.authcode) != "undefined")//redirecting to the targetUrl on Successful Login
            {
              var lm = CLinkManager.getInstance(targetURL);                           
              if(lm.getInputParameter("useraction") != 'null' && typeof(data.gacctoid) != "undefined")
              {
                lm.setURLParameter("gacctoid",data.gacctoid);
              }
              lm.setURLParameter("u_",data.authcode);             
              
              if(data.podifiedhost.indexOf("http") != -1)
              {
              		if(typeof(data.isNewPolicy) != "undefined" && data.isNewPolicy == false)
	              	{
	              		var temp = lm.getURL();
              			var s = temp.substring(temp.indexOf("/")+1,temp.length);
              			var urlWithoutCobrand = s.substring(s.indexOf("/"),s.length);
              			 if(temp.indexOf("isPopup=true") > 0)
                         {
              				 /*
                           CBuilderPopup.open(data.podifiedhost + "/" + data.targetCobrand + urlWithoutCobrand, 'resizable=1,toolbar=no,location=no,menubar=no,scrollbars=yes', 'FlexBuilderApp');
                       	   CLayer.closeAllLayers();
 	                      	var temp1 = inputRefreshURL;
 	              			var s1 = temp.substring(temp1.indexOf("/")+1,temp1.length);
 	              			var urlWithoutCobrand1 = s1.substring(s1.indexOf("/"),s1.length);                      	  
                       	    document.location.href = data.podifiedhost + "/" + data.targetCobrand + urlWithoutCobrand1;
                       	    */
              				if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)
                      		  window.parent.flexInvokeWidgetMethod(widgetId ,'swiftLoadWindow', data.podifiedhost + "/" + data.targetCobrand + urlWithoutCobrand );
                      	    else
              				  document.location.href = data.podifiedhost + "/" + data.targetCobrand + urlWithoutCobrand;
                         }
                         else
                         {   
                        	 if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)
                       		  window.parent.flexInvokeWidgetMethod(widgetId ,'swiftLoadWindow', data.podifiedhost + "/" + data.targetCobrand + urlWithoutCobrand );
                       	     else
                        	  document.location.href = data.podifiedhost + "/" + data.targetCobrand + urlWithoutCobrand;	  
                         }
	              	}
	              	else
	              	{
	              		if(lm.getURL().indexOf("isPopup=true") > 0)
                        {
	              			/*
                          CBuilderPopup.open(data.podifiedhost + lm.getURL(), 'resizable=1,toolbar=no,location=no,menubar=no,scrollbars=yes', 'FlexBuilderApp');
                      	  CLayer.closeAllLayers();
                      	  document.location.href = data.podifiedhost + inputRefreshURL;
                      	  */
	              			if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)
	                  		  window.parent.flexInvokeWidgetMethod(widgetId ,'swiftLoadWindow', data.podifiedhost + lm.getURL() );
	                  	    else	              			
	              			  document.location.href = data.podifiedhost + lm.getURL();
                        }
                        else
                        { 	 
                        	if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)
                      		  window.parent.flexInvokeWidgetMethod(widgetId ,'swiftLoadWindow', data.podifiedhost + lm.getURL() );
                      	    else
                        	  document.location.href = data.podifiedhost + lm.getURL();
                        }
	              	}
              	
              }
              else
              {
              	 	if(typeof(data.isNewPolicy) != "undefined" && data.isNewPolicy == false)
	              	{
	              		var temp = lm.getURL();
              			var s = temp.substring(temp.indexOf("/")+1,temp.length);
              			var urlWithoutCobrand = s.substring(s.indexOf("/"),s.length);
              			
              			if(temp.indexOf("isPopup=true") > 0)
                        {
              				/*
                            CBuilderPopup.open(scheme + data.podifiedhost + "/" + data.targetCobrand, 'resizable=1,toolbar=no,location=no,menubar=no,scrollbars=yes', 'FlexBuilderApp');
                      	    CLayer.closeAllLayers();
	  	              		var temp1 = inputRefreshURL;
	              			var s1 = temp1.substring(temp1.indexOf("/")+1,temp1.length);
	              			var urlWithoutCobrand1 = s1.substring(s1.indexOf("/"),s1.length);                      	  
                      	    document.location.href = data.podifiedhost +  "/" + data.targetCobrand + urlWithoutCobrand1;
                      	    */
              				if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)
                      		  window.parent.flexInvokeWidgetMethod(widgetId ,'swiftLoadWindow', data.podifiedhost + "/" + data.targetCobrand + urlWithoutCobrand );
                      	    else              				
              				  document.location.href = scheme + data.podifiedhost + "/" + data.targetCobrand + urlWithoutCobrand;
                        }
                        else
                        {   
                        	if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)
                      		  window.parent.flexInvokeWidgetMethod(widgetId ,'swiftLoadWindow', scheme + data.podifiedhost + "/" + data.targetCobrand + urlWithoutCobrand );
                      	    else
                        	  document.location.href = scheme + data.podifiedhost + "/" + data.targetCobrand + urlWithoutCobrand;
                        }
	              	}
	              	else
	              	{
	              		if(lm.getURL().indexOf("isPopup=true") > 0)
                        {
	              			/*
                          CBuilderPopup.open(scheme + data.podifiedhost + lm.getURL() + "/" + data.targetCobrand, 'resizable=1,toolbar=no,location=no,menubar=no,scrollbars=yes', 'FlexBuilderApp');
                      	  CLayer.closeAllLayers();
                      	  document.location.href = scheme + data.podifiedhost + inputRefreshURL;
                      	  */   
	              			if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)
	                  		  window.parent.flexInvokeWidgetMethod(widgetId ,'swiftLoadWindow', scheme + data.podifiedhost + lm.getURL() );
	                  	    else
	              			  document.location.href = scheme + data.podifiedhost + lm.getURL();
                        }
                        else
                        {  	
                        	if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)
                      		  window.parent.flexInvokeWidgetMethod(widgetId ,'swiftLoadWindow', scheme + data.podifiedhost + lm.getURL() );
                      	    else                        	
                        	  document.location.href = scheme + data.podifiedhost + lm.getURL();
                        }
	              	}
              	           
              }
            }
          }
          else//repeating the loop for getting response
          {
            counter++;
            if(counter < 3)
            {
              setTimeout(function(){getFormResponse(formName , targetURL)} , 2000);
            }
            else
            {
              removeSessionValues();
              var message = "<font color=\"#d00031\">Oops&#151;we were unable to log you in with the information you provided. "
                + "Please try again.</font>" ;
              if(formName == "guestLoginForm")
              {
                document.getElementById("guestLoginErrorMessage").innerHTML = message;
                document.getElementById("guestLoginErrorMessage").style.display = "block";
                document.getElementById('guestLoginEmail').focus();
              }
              else
              {
                document.getElementById("loginErrorMessage").innerHTML = message;
                document.getElementById("loginErrorMessage").style.display = "block";
                document.getElementById(loginEmail).focus();
              }
            }
          }
        }//end of Login Form
        else if(formName == "regForm")//reg Form
        {
          if(typeof(data.regerror) != "undefined")//Checking for error cases in Registartion Form
          {
            if(typeof(data.firstName) != "undefined" && data.firstName == "invalidFname")
            {
              document.getElementById("regFnameError").style.display = "block";
              document.getElementById("regFname").style.display = "none";
            }
            else
            {
              document.getElementById("regFnameError").style.display = "none";
              document.getElementById("regFname").style.display = "block";
            }
            if(typeof(data.lastname) != "undefined" && data.lastname == "invalidLname")
            {
              document.getElementById("regLnameError").style.display = "block";
              document.getElementById("regLname").style.display = "none";
            }
            else
            {
              document.getElementById("regLnameError").style.display = "none";
              document.getElementById("regLname").style.display = "block";
            }
            if(typeof(data.emailaddress) != "undefined" && data.emailaddress == "invalidEmail")
            {
              document.getElementById("regEmailError").style.display = "block";
              document.getElementById("regEmail").style.display = "none";
            }
            else
            {
              document.getElementById("regEmailError").style.display = "none";
              document.getElementById("regEmail").style.display = "block";
            }
            if(typeof(data.password) != "undefined" && data.password == "invalidPwd")
            {
              document.getElementById("regPwdError").style.display = "block";
              document.getElementById("regPwd").style.display = "none";
            }
            else
            {
              document.getElementById("regPwdError").style.display = "none";
              document.getElementById("regPwd").style.display = "block";
            }
            if(typeof(data.password2) != "undefined" && data.password2 == "invalidPwd2")
            {
              document.getElementById("regPwd2Error").style.display = "block";
              document.getElementById("regPwd2").style.display = "none";
            }
            else
            {
              document.getElementById("regPwd2Error").style.display = "none";
              document.getElementById("regPwd2").style.display = "block";
            }
            if(typeof(data.accept) != "undefined" && data.accept == "invalidaccept")
            {
              document.getElementById("regAcceptError").style.display = "block";
              document.getElementById("regAccept").style.display = "none";
            }
            else
            {
              document.getElementById("regAcceptError").style.display = "none";
              document.getElementById("regAccept").style.display = "block";
            }
            if(typeof(data.badpassword) != "undefined")
            {
              document.getElementById("regPwdError").style.display = "block";
              document.getElementById("regPwd").style.display = "none";
              document.getElementById("regPwd2Error").style.display = "block";
              document.getElementById("regPwd2").style.display = "none";
            }
            else
            {
              document.getElementById("regPwdError").style.display = "none";
              document.getElementById("regPwd").style.display = "block";
              document.getElementById("regPwd2Error").style.display = "none";
              document.getElementById("regPwd2").style.display = "block";
            }
            if(typeof(data.errormessage) != "undefined")
            {
              if(typeof(data.errorstr) != "undefined")
              {
                setsProp14Value(true ,data.errorstr )
              }
              trackLoginRegPageName(false , true);
              document.getElementById("regErrorMessage").innerHTML = data.errormessage;
              document.getElementById("regErrorMessage").style.display = "block";
            }
            if(data.loginstatus == "passwordmismatch")//Checking if an acct already exists with this email
            {
              isPwdMatch = true;
              if(typeof(data.emailaddress) != "undefined")
              {
                emailAddr = data.emailaddress;
              }
              showPwdMatch(targetURL);
            }
          }
          else if(data.loginstatus == "notallowedtologin")//If user is not allowed to login in this website
          {
            if(typeof(data.HOST_NAME) != "undefied")
            {
              showInterstitialPage(data.HOST_NAME);
            }
          }
          else if(typeof(data.regsuccess) != "undefined")
          {
            if(typeof(data.podifiedhost) != "undefined" && typeof(data.authcode) != "undefined")
            {
              var lm = CLinkManager.getInstance(targetURL);
              if(lm.getInputParameter("userAction") != 'null')
              {
                lm.setURLParameter("gacctoid",data.gacctoid);
              }
              lm.setURLParameter("u_",data.authcode);
              if(data.podifiedhost.indexOf("http") != -1)
              {
            	  if(lm.getURL().indexOf("isPopup=true") > 0)
                  {
            		  /*
                	  CBuilderPopup.open(data.podifiedhost + lm.getURL(), 'resizable=1,toolbar=no,location=no,menubar=no,scrollbars=yes', 'FlexBuilderApp');
                	  CLayer.closeAllLayers();
                	  document.location.href = data.podifiedhost + inputRefreshURL;
                	  */
            		  if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)
                		  window.parent.flexInvokeWidgetMethod(widgetId ,'swiftLoadWindow', data.podifiedhost + lm.getURL() );
                	  else            		  
                		  document.location.href = data.podifiedhost + lm.getURL();
                  }
                  else
                  {      
                	  if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)
                		  window.parent.flexInvokeWidgetMethod(widgetId ,'swiftLoadWindow', data.podifiedhost + lm.getURL() );
                	  else                	  
                		  document.location.href = data.podifiedhost + lm.getURL();
                  }
              }
              else
              {
            	  if(lm.getURL().indexOf("isPopup=true") > 0)
                  {
            		  /*
                	  CBuilderPopup.open(scheme + data.podifiedhost + lm.getURL(), 'resizable=1,toolbar=no,location=no,menubar=no,scrollbars=yes', 'FlexBuilderApp');
                	  CLayer.closeAllLayers();
                	  document.location.href = scheme + data.podifiedhost + inputRefreshURL;
                	  */
            		  if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)
                		  window.parent.flexInvokeWidgetMethod(widgetId ,'swiftLoadWindow', scheme + data.podifiedhost + lm.getURL() );
                	  else            		  
                		  document.location.href = scheme + data.podifiedhost + lm.getURL();
                  }
                  else
                  {   
                	  if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)
                		  window.parent.flexInvokeWidgetMethod(widgetId ,'swiftLoadWindow', scheme + data.podifiedhost + lm.getURL() );
                	  else                	  
                		  document.location.href = scheme + data.podifiedhost + lm.getURL();
                  }
              }
            }
          }
          else
          {
            counter++;
            if(counter < 3)
            {
              setTimeout(function(){getFormResponse(formName , targetURL)} , 2000);
            }
            else
            {
              removeSessionValues();
              var message = "<font color=\"#d00031\">Oops&#151;we were unable to register you in with the information you provided. "
                + "Please try again.</font>" ;
              document.getElementById("regErrorMessage").innerHTML = message;
              document.getElementById("regErrorMessage").style.display = "block";
            }
          }
        }//end of regForm
        else if(formName == "forgotPwdForm")//for forgotpwd Flow
        {
          if(typeof(data.forgotpwderror) != "undefined")
          {
             trackMRBPageName("Forgot Your Password Error:Layer");
            document.getElementById("invalidUserOrEmail").style.display = "block";
          }
          else if(typeof(data.forgotpwdsuccess) != "undefined")//Redirecting to the targetURL on success
          {
            showForgotPassWordConfirm();
          }
          else
          {
            counter++;
            if(counter < 3)
            {
              setTimeout(function(){getFormResponse(formName , targetURL)} , 2000);
            }
            else
            {
              removeSessionValues();
              document.getElementById("invalidUserOrEmail").style.display = "block";
            }
          }
        }
        else if(formName == "pwdMatchForm")//for forgotpwd Flow
        {
          if(typeof(data.pwdmatcherror) != "undefined")
          {
            if(typeof(data.loginstatus) != "undefined")
            {
                if(data.loginstatus == "notallowedtologin")
                {
                  if(typeof(data.HOST_NAME) != "undefied")
                  {
                    showInterstitialPage(data.HOST_NAME);
                  }
                }
                else
                {
                  var message = "Oops&#151; the password you entered doesn't match this email address. Please try again.";
                  document.getElementById("PwdMatcherrorMessage").innerHTML = message;
                  document.getElementById("PwdMatcherrorMessage").style.display = "block";
                }
            }
          }
          else if(typeof(data.pwdmatchsuccess) != "undefined")
          {
            if(typeof(data.autogenpwd) != "undefined")//Checking for Autogen password case in Login
            {
              showChangePwd(targetURL);
            }
            else if(typeof(data.podifiedhost) != "undefined" && typeof(data.authcode) != "undefined")
            {
              var destURL = targetURL;
              
              if(typeof(data.acctCobrand) != "undefined")
              {
              	destURL = updateUrlWithCobrand(targetURL,data.acctCobrand);
              }
              
              var lm = CLinkManager.getInstance(destURL);
              lm.setURLParameter("u_",data.authcode);
              lm.removeURLParameter("isFromReg");
              if(lm.getInputParameter("useraction") != 'null' && typeof(data.gacctoid) != "undefined")
              {
                lm.setURLParameter("gacctoid",data.gacctoid);
              }
              if(data.podifiedhost.indexOf("http") != -1)
              {
            	  if(lm.getURL().indexOf("isPopup=true") > 0)
                  {
            		  /*
                	  CBuilderPopup.open(data.podifiedhost + lm.getURL(), 'resizable=1,toolbar=no,location=no,menubar=no,scrollbars=yes', 'FlexBuilderApp');
                	  CLayer.closeAllLayers();
                	  document.location.href = data.podifiedhost + inputRefreshURL;
                	  */
            		  if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)
                		  window.parent.flexInvokeWidgetMethod(widgetId ,'swiftLoadWindow', data.podifiedhost + lm.getURL() );
                	  else            		  
                		  document.location.href = data.podifiedhost + lm.getURL();
                  }
                  else
                  {           
                	  if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)
                		  window.parent.flexInvokeWidgetMethod(widgetId ,'swiftLoadWindow', data.podifiedhost + lm.getURL() );
                	  else                	  
                		  document.location.href = data.podifiedhost + lm.getURL();
                  }
              }
              else
              {
            	  if(lm.getURL().indexOf("isPopup=true") > 0)
                  {
            		  /*
                	  CBuilderPopup.open(scheme + data.podifiedhost + lm.getURL(), 'resizable=1,toolbar=no,location=no,menubar=no,scrollbars=yes', 'FlexBuilderApp');
                	  CLayer.closeAllLayers();                	  
                	  document.location.href = scheme + data.podifiedhost + inputRefreshURL;
                	  */      
            		  if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)
                		  window.parent.flexInvokeWidgetMethod(widgetId,'swiftLoadWindow', scheme + data.podifiedhost + lm.getURL() );
                	  else            		  
                		  document.location.href = scheme + data.podifiedhost + lm.getURL();
                  }
                  else
                  {   
                	  if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)
                		  window.parent.flexInvokeWidgetMethod(widgetId,'swiftLoadWindow', scheme + data.podifiedhost + lm.getURL() );
                	  else                	  
                		  document.location.href = scheme + data.podifiedhost + lm.getURL();
                  }
              }
            }
          }
          else
          {
            counter++;
            if(counter < 3)
            {
              setTimeout(function(){getFormResponse(formName , targetURL)} , 2000);
            }
            else
            {
              removeSessionValues();
              var message = "Oops&#151; We are unable to process your request now. Please try again.";
              document.getElementById("PwdMatcherrorMessage").innerHTML = message;
              document.getElementById("PwdMatcherrorMessage").style.display = "block";
            }
          }
        }//end of PwdMatch
        else if(formName == "changePwdForm")
        {
          if(typeof(data.changepwderror) != "undefined")
          {
            if(typeof(data.loginstatus) != "undefined")
            {
              var message = "";
              if(data.loginstatus == "passwordmismatch")
              {
                message = "Your passwords don't match. Please re-type both passwords.";
              }
              else
              {
                message = "Your password must have 5 or more characters, and must be only letters and numbers &#151; no spaces. Please try again.";
              }
              document.getElementById("changePwderrorMessage").innerHTML = message;
              document.getElementById("changePwderrorMessage").style.display = "block";
            }

          }
          else if(typeof(data.changepwdsuccess) != "undefined")
          {
            if(typeof(data.podifiedhost) != "undefined" && typeof(data.authcode) != "undefined")
            {
              var lm = CLinkManager.getInstance(targetURL);
              lm.setURLParameter("u_",data.authcode);
              lm.removeURLParameter("isFromReg");
              if(lm.getInputParameter("useraction") != 'null' && typeof(data.gacctoid) != "undefined")
              {
                lm.setURLParameter("gacctoid",data.gacctoid);
              }
              if(data.podifiedhost.indexOf("http") != -1)
              {
            	  if(lm.getURL().indexOf("isPopup=true") > 0)
                  {
            		  /*
                	  CBuilderPopup.open(data.podifiedhost + lm.getURL(), 'resizable=1,toolbar=no,location=no,menubar=no,scrollbars=yes', 'FlexBuilderApp');
                	  CLayer.closeAllLayers();
                	  document.location.href = data.podifiedhost + inputRefreshURL;
                	  */  
            		  if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)
                		  window.parent.flexInvokeWidgetMethod(widgetId,'swiftLoadWindow', data.podifiedhost + lm.getURL() );
                	  else            		  
                		  document.location.href = data.podifiedhost + lm.getURL();
                  }
                  else
                  {             
                	  if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)
                		  window.parent.flexInvokeWidgetMethod(widgetId,'swiftLoadWindow', data.podifiedhost + lm.getURL() );
                	  else                	  
                		  document.location.href = data.podifiedhost + lm.getURL();
                  }
              }
              else
              {
            	  if(lm.getURL().indexOf("isPopup=true") > 0)
                  {
            		  /*
                	  CBuilderPopup.open(scheme + data.podifiedhost + lm.getURL(), 'resizable=1,toolbar=no,location=no,menubar=no,scrollbars=yes', 'FlexBuilderApp');
                	  CLayer.closeAllLayers();                	  
                	  document.location.href = scheme + data.podifiedhost + inputRefreshURL;
                	  */         
            		  if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)
                		  window.parent.flexInvokeWidgetMethod(widgetId,'swiftLoadWindow', scheme + data.podifiedhost + lm.getURL() );
                	  else            		  
                		  document.location.href = scheme + data.podifiedhost + lm.getURL();
                  }
                  else
                  {  
                	  if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)
                		  window.parent.flexInvokeWidgetMethod(widgetId,'swiftLoadWindow', scheme + data.podifiedhost + lm.getURL() );
                	  else                	  
                		  document.location.href = scheme + data.podifiedhost + lm.getURL();
                  }
              }
            }
          }
          else
          {
            counter++;
            if(counter < 3)
            {
              setTimeout(function(){getFormResponse(formName , targetURL)} , 2000);
            }
            else
            {
              removeSessionValues();
              var message = "Oops&#151; We are unable to process your request now. Please try again.";
              document.getElementById("changePwderrorMessage").innerHTML = message;
              document.getElementById("changePwderrorMessage").style.display = "block";
            }
          }
        }//end of changePwd
      }
    }
  }
}

function submitForm(formName , targetURL)
{
  counter = 0;
  if(formName == "loginForm")//Checking if any of the fields are empty for Login
  {
    var message = "";
    if(document.getElementById(loginEmail).value.length == 0 || document.getElementById(loginPwd).value.length == 0)
    {
      trackLoginRegPageName(true , true);
      if(document.getElementById(loginEmail).value.length == 0 && document.getElementById(loginPwd).value.length == 0)
      {
        if ((isSnapfishUKWebsite || isASPSnapfish))
        {
          message = "<font color=\"#d00031\">Oops&#151;please enter your email address and password to log in.</font> " ;
        }
        else
        {
          message = "<font color=\"#d00031\">Oops&#151;please enter both your email address and password to log in.</font> " ;
        }
      }
      else
      {
        message = "<font color=\"#d00031\">Oops&#151;we were unable to log you in with the information you provided. "
                + "Please try again.</font>" ;
      }

      document.getElementById("loginErrorMessage").innerHTML = message;
      document.getElementById("loginErrorMessage").style.display = "block";
      document.getElementById(loginEmail).focus();
      return false;
    }
  }
  else if(formName == "guestLoginForm")//Checking if any of the fields are empty for Login
  {
    var message = "";
    if(document.getElementById("guestLoginEmail").value.length == 0 || document.getElementById("guestLoginPwd").value.length == 0)
    {
      trackMRBPageName("Guest:Login:Error:Layer");
      if(document.getElementById("guestLoginEmail").value.length == 0 && document.getElementById("guestLoginPwd").value.length == 0)
      {
        if ((isSnapfishUKWebsite || isASPSnapfish))
        {
          message = "<font color=\"#d00031\">Oops&#151;please enter your email address and password to log in.</font> " ;
        }
        else
        {
          message = "<font color=\"#d00031\">Oops&#151;please enter both your email address and password to log in.</font> " ;
        }
      }
      else
      {
        message = "<font color=\"#d00031\">Oops&#151;we were unable to log you in with the information you provided. "
                + "Please try again.</font>" ;
      }

      document.getElementById("guestLoginErrorMessage").innerHTML = message;
      document.getElementById("guestLoginErrorMessage").style.display = "block";
      document.getElementById('guestLoginEmail').focus();
      return false;
    }
  }
  else if(formName == "regForm")//Checking if any of the fields are empty for Registration
  {
   if(document.getElementById("firstname").value.length == 0
        ||document.getElementById("lastname").value.length == 0
        ||document.getElementById(emailAddress).value.length == 0
        ||document.getElementById(password).value.length == 0
        ||document.getElementById("password2").value.length == 0
        ||document.getElementById("accept").checked == false)
    {
      trackLoginRegPageName(false , true);
      message = "<font color=\"#d00031\">Oops-there's invalid or missing info.Please review the information below and re-enter the fields marked in red</font>" ;
      if(document.getElementById("firstname").value.length == 0)
      {
        document.getElementById("regFnameError").style.display = "block";
        document.getElementById("regFname").style.display = "none";
      }
      else
      {
        document.getElementById("regFnameError").style.display = "none";
        document.getElementById("regFname").style.display = "block";
      }
      if(document.getElementById("lastname").value.length == 0)
      {
        document.getElementById("regLnameError").style.display = "block";
        document.getElementById("regLname").style.display = "none";
      }
      else
      {
        document.getElementById("regLnameError").style.display = "none";
        document.getElementById("regLname").style.display = "block";
      }
      if(document.getElementById(emailAddress).value.length == 0 || document.getElementById(emailAddress).value.indexOf("@") == -1)
      {
        document.getElementById("regEmailError").style.display = "block";
        document.getElementById("regEmail").style.display = "none";
      }
      else
      {
        document.getElementById("regEmailError").style.display = "none";
        document.getElementById("regEmail").style.display = "block";
      }
      if(document.getElementById(password).value.length == 0)
      {
        document.getElementById("regPwdError").style.display = "block";
        document.getElementById("regPwd").style.display = "none";
        message+="</br><font color=\"#d00031\">Please choose another password that is at least five characters long.</font>";
      }
      else
      {
        document.getElementById("regPwdError").style.display = "none";
        document.getElementById("regPwd").style.display = "block";
      }
      if(document.getElementById("password2").value.length == 0)
      {
        document.getElementById("regPwd2Error").style.display = "block";
        document.getElementById("regPwd2").style.display = "none";
      }
      else
      {
        document.getElementById("regPwd2Error").style.display = "none";
        document.getElementById("regPwd2").style.display = "block";
      }
      if(document.getElementById("accept").checked == false)
      {
        document.getElementById("regAcceptError").style.display = "block";
        document.getElementById("regAccept").style.display = "none";
      }
      else
      {
        document.getElementById("regAcceptError").style.display = "none";
        document.getElementById("regAccept").style.display = "block";
      }
      document.getElementById("regErrorMessage").innerHTML = message;
      document.getElementById("regErrorMessage").style.display = "block";
	  if(document.getElementById("firstname").value.length == 0){
      	document.getElementById("firstname").focus();
      }else if(document.getElementById("lastname").value.length == 0){
      	document.getElementById("lastname").focus();
      }else if(document.getElementById(emailAddress).value.length == 0 || document.getElementById(emailAddress).value.indexOf("@") == -1){
      	document.getElementById(emailAddress).focus();
      }else if(document.getElementById(password).value.length == 0){
      	document.getElementById(password).focus();
      }else if(document.getElementById("password2").value.length == 0){
      	document.getElementById("password2").focus();
      }else if(document.getElementById("accept").checked == false){
      	document.getElementById("accept").focus();
      }
      return false;
    }
  }
  else if(formName == "forgotPwdForm")//Checking if any of the fields are empty for Forgot Password
  {
    if(document.getElementById("forgotPwdEmail").value.length == 0)
    {
      trackMRBPageName("Forgot Your Password Error:Layer");
      document.getElementById("invalidUserOrEmail").style.display = "block";
      return false;
    }
  }
  else if(formName == "pwdMatchForm")//Checking if any of the fields are empty for Password Match
  {
    if(document.getElementById("pwd").value.length == 0)
    {
      message = "Oops&#151; the password you entered doesn't match this email address. Please try again.";
      document.getElementById("PwdMatcherrorMessage").innerHTML = message;
      document.getElementById("PwdMatcherrorMessage").style.display = "block";
      return false;
    }
  }
  else if(formName == "changePwdForm")
  {
    if(document.getElementById("changepwd").value.length == 0 || document.getElementById("changepwd2").value.length == 0 )
    {
      message = "<font color=\"#d00031\">Your password must have 5 or more characters, and must be only letters and numbers &#151; no spaces. Please try again.</font>";
      document.getElementById("changePwderrorMessage").innerHTML = message;
      document.getElementById("changePwderrorMessage").style.display = "block";
      return false;
    }
  }
  if(formName != "guestLoginForm" && gTargetURL != "")
  {
    var lm = CLinkManager.getInstance(gTargetURL);
    if(typeof(targetURL) != "undefined" && targetURL.indexOf("isFromReg") != -1)
    {
      lm.setURLParameter("isFromReg" , true);
    }
    else
    {
      lm.removeURLParameter("isFromReg");
    }
    gTargetURL = lm.getURL();
    targetURL = gTargetURL;
  }
  var tempDiv = document.createElement('div');
  document.body.appendChild(tempDiv);
  tempDiv.innerHTML = '<iframe id="tempIframe" name="tempIframe" width="0" height="0"></iframe>';
  var tempIframe = document.getElementById("tempIframe");
  var tempForm = document.getElementById(formName);
  tempForm.target = tempIframe.id;
  tempForm.submit();
  //Calling the AJAX Call for getting the reglogin status after 2 sec.
  setTimeout(function(){getFormResponse(formName , targetURL)} , 1250);
  return true;
}

function showForgotPassWordConfirm()
{
  CLayer.closeAllLayers();
  HFSF.Overlays.showModalPanel({
     component : "account/login/ForgotPassWordConfirm",
     title : "Forgot Password"
      });

}

function showInterstitialPage(targetURL)
{
  CLayer.closeAllLayers();
  HFSF.Overlays.showModalPanel({
     component : "account/login/InterstitialPage",
     title : "Forgot Password",
     targetUrl :targetURL
      });

}
function showChangePwd(targetURL)
{
  CLayer.closeAllLayers();
  if(document.getElementById("changePwderrorMessage"))
  {
    document.getElementById("changePwderrorMessage").style.display = "none";
  }
  if(document.getElementById("changepwd"))
  {
    document.getElementById("changepwd").value = "";
  }
  HFSF.Overlays.showModalPanel({
     component : "account/login/changePassword",
     title : "Change Password",
     targetUrl :targetURL
      });

}

function getFlexApp(appName)
{
  if (navigator.appName.indexOf ("Microsoft") !=-1)
  {
    return window[appName];
  }
  else
  {
    return document[appName];
  }
}
function saveProject()
{
  CLayer.closeLayer('alertOverLay',closeModule());
  if(product == "calendar")
  {
    getFlexApp('PhotoBooks').saveCalendarProject();
  }
  else
  {
    getFlexApp('PhotoBooks').saveBookProject();
  }
}
function showGuestLogin(targetURL)
{
  CLayer.closeAllLayers();
  HFSF.Overlays.showModalPanel({
     component : "account/login/GuestLogin",
     title : "GuestLogin",
     targetUrl : targetURL
     });

}

var counter = 0;
var gTargetURL = "";

function removeSessionValues()
{
  var xmlhttp1 = null;
  if(navigator.appName == "Netscape")
    xmlhttp1 = new XMLHttpRequest();
  else
    xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP");

    xmlhttp1.onreadystatechange = function() { getRemoveSessionResponse(xmlhttp1); }
    xmlhttp1.open("GET",  removeSessionURL , true);
    xmlhttp1.setRequestHeader('If-Modified-Since','Wed, 15 Nov 1995 04:58:08 GMT');
    xmlhttp1.send(null);
}

function dontSaveCalendar(targetUrl)
{
  deletePhotos(targetUrl);
}

function deletePhotos(targetUrl)
{
  var xmlhttp1 = null;
  if(navigator.appName == "Netscape")
    xmlhttp1 = new XMLHttpRequest();
  else
    xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP");

    xmlhttp1.onreadystatechange = function() { getDeletePhotosResponse(xmlhttp1,targetUrl); }
    xmlhttp1.open("GET",  deletePhotosURL , true);
    xmlhttp1.setRequestHeader('If-Modified-Since','Wed, 15 Nov 1995 04:58:08 GMT');
    xmlhttp1.send(null);
}

function getDeletePhotosResponse(xmlhttp,targetUrl)
{
  if(xmlhttp.readyState == 4)
  {
   if(xmlhttp.status == 200)
   {
      var ajxResponse = xmlhttp.responseText;
      if (ajxResponse == null || ajxResponse == "")
      {

      }
      else
      {
        var data = eval('(' + ajxResponse + ')');
        if(typeof(data.deletephotossuccess) != "undefined")
        {
        	if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)
        	{
      		  window.parent.flexInvokeWidgetMethod(widgetId,'swiftLoadWindow', targetUrl  );
        	}
      	    else        	
      		  document.location.href = targetUrl;
        }
        else
        {
          if( isMoveRegFromSWIFT != "undefined" && isMoveRegFromSWIFT != null && isMoveRegFromSWIFT == true)
      		  window.parent.flexInvokeWidgetMethod(widgetId,'swiftLoadWindow', targetUrl  );
      	  else        	
      		  document.location.href = targetUrl;
        }
      }
    }
  }
}

function getRemoveSessionResponse(xmlhttp)
{

}

function onEnterClick(e,id){
	var key;
	if (!e){ 
		e = window.event;
	}
	// e gives access to the event in all browsers  
	if(!e.which){
	 key = e.keyCode; // This is used store the keycode(IE Only)  
	}  
	else{
	 key = e.which; // This is used store the keycode(Netscape Only)  
	}
	if(key==13){
		if(document.getElementById(id)!=null){
			document.getElementById(id).click();
		}
	}
}
function disableSaveMyWork()
{
  if(document.getElementById("deletephotos").checked == true)
  {
    document.getElementById("saveMyWork").style.display = "none";
    document.getElementById("saveMyWorkDim").style.display = "";
  }
  else
  {
    document.getElementById("saveMyWorkDim").style.display = "none";
    document.getElementById("saveMyWork").style.display = "";
  }
}

