 var reqid2,reqid3,reqid4,reqid5,reqid6,reqid7,reqid8;
  
 function getItem(id)
{
    var itm = false;
    if(document.getElementById)
                itm = document.getElementById(id);
    else if(document.all)
                itm = document.all[id];
    else if(document.layers)
                itm = document.layers[id];
    return itm;
}
 function HideContent(d)
{
     if(d.length < 1) { return; }
     document.getElementById(d).style.display = 'none';
}
    function ShowContent(d)
{
//alert(d.length)
     if(d.length < 1) { return; }
     document.getElementById(d).style.display = 'inline';
}

function ShowShippingDiv(d,id1,id2,id3,id4,id5,id6,id7,id8,id9,id10)
{
 
    if(document.getElementById(id1).checked)
    {
//alert(document.getElementById("divShippingaddress"))
   document.getElementById("divShippingaddress").style.display ='inline'; 
   // alert(document.getElementById(id1.id))
   ValidatorEnable(document.getElementById(id2),true);  
    reqid2=document.getElementById(id2);
   ValidatorEnable(document.getElementById(id3),true);
   reqid3=document.getElementById(id3);
   ValidatorEnable(document.getElementById(id4),true);
     reqid4=document.getElementById(id4);
   ValidatorEnable(document.getElementById(id5),true);
   reqid5=document.getElementById(id5);
   ValidatorEnable(document.getElementById(id6),true);
    reqid6=document.getElementById(id6);
   ValidatorEnable(document.getElementById(id7),true);
   reqid7=document.getElementById(id7);
   ValidatorEnable(document.getElementById(id8),true);
   reqid8=document.getElementById(id8);
   document.getElementById(id9).style.display ='none';
   document.getElementById(id10).style.display ='none';
   }
   else
   {
     document.getElementById("divShippingaddress").style.display ='none'; 
   // alert(document.getElementById(id1.id))
   ValidatorEnable(document.getElementById(id2),false);  
   ValidatorEnable(document.getElementById(id3),false);
   ValidatorEnable(document.getElementById(id4),false);
   ValidatorEnable(document.getElementById(id5),false);
   ValidatorEnable(document.getElementById(id6),false);
   ValidatorEnable(document.getElementById(id7),false);
   ValidatorEnable(document.getElementById(id8),false);
    document.getElementById(id9).style.display ='inline';
   document.getElementById(id10).style.display ='inline';
   }
}

function ShowDiv(obj)
{

    if(document.getElementById(obj).checked)  
    {  
     document.getElementById("divShippingaddress").style.display ='inline';
     }
   else
   {   
    document.getElementById("divShippingaddress").style.display ='none';
    }
}



function HideDiv(id1,id2,id3,id4,id5,id6,id7,id8,id9,id10)
{
 document.getElementById(id1).checked =false;
 ValidatorEnable(reqid2,false); 
   ValidatorEnable(reqid3,false);
   ValidatorEnable(reqid4,false);
   ValidatorEnable(reqid5,false);   
   ValidatorEnable(reqid6,false);
   ValidatorEnable(reqid7,false);
   ValidatorEnable(reqid8,false);
 document.getElementById(id2).style.display ='inline';
 document.getElementById(id3).style.display ='inline';
  document.getElementById("divShippingaddress").style.display ='none';
 return false;
}

//function CreatePopUp()
//{
//              
//               //jsFunction += "var content = \"<html><head><title>" + title + "</title></head><body>" + sBody + "</body></html>";
//            
//                var popup = window.open("/","Invoicewindow","resizeable,width=920,height=550"); 
//                         
//               popup.document.write("<html><title>Invoice</title><link href='/Style%20Library/CSS/My%20Account/Basket.css' type='text/css' rel='stylesheet' />");
//             
//               popup.document.write("<body onload='window.print();'>");  
//          
//               popup.document.write("<div id='phc_confirmaddress' class='hcorderprint' >");
//              
//               popup.document.write(document.getElementById('phc_confirmaddress').innerHTML);
//            
//               popup.document.write('</div></body></html>');               
//              popup.document.getElementById('divButtons').style.display = 'none';
//              popup.document.getElementById('phc_confirmaddress').style.width = '450'
//              popup.document.close();
//              return false;
//              
//              
// }

function CreatePopUp()
{
              
               //jsFunction += "var content = \"<html><head><title>" + title + "</title></head><body>" + sBody + "</body></html>";
            
                var popup = window.open("/","Invoicewindow","resizeable,width=800,height=550"); 
                         
               popup.document.write("<html><head><title>Invoice</title><link href='http://nnstaging.hcp-uk.co.uk/Style%20Library/CSS/My%20Account/Basket.css' type='text/css' rel='stylesheet' /><link href='http://nnstaging.hcp-uk.co.uk/Style%20Library/styles_level1.css' type='text/css' rel='stylesheet' /><link href='http://nnstaging.hcp-uk.co.uk/Style%20Library/CSS/My%20Account/Basket_config.css' type='text/css' rel='stylesheet' /></head>");
               
                        
               popup.document.write("<body onload='window.print();'>");  
          
               popup.document.write("<div id='phc_confirmaddress' class='hcbasket' style='width:auto;' >");   
               popup.document.write("<h2 class='pageheader' style='width:auto;'>");
               popup.document.write("Order Summary");
               popup.document.write("</h2>"); 
               popup.document.write("<br/><div id='maindiv' style='width:auto;'>");                           
              
               popup.document.write(document.getElementById('maindivprint').innerHTML);
            
               popup.document.write('</div></div></body></html>');               
              popup.document.getElementById('divButtons').style.display = 'none';
              
              popup.document.close();
              return false;
              
              
 }
 
 
 
 
 //---------------------------Instant Forums Scripts -------------------------------------//
 
 
 function getNewSubmitForm(){
 var submitForm = document.createElement("FORM");
 document.body.appendChild(submitForm);
 submitForm.method = "POST";
 return submitForm;
 
}



function  createMyformAndRegister(userEmail,password,userName,url,siteUrl)
{


 var registerForm = getNewSubmitForm(); 
 createNewFormElement(registerForm,'ForumUserEmail',userEmail);
 createNewFormElement(registerForm,'ForumUserPassword',password);
 createNewFormElement(registerForm,'ForumUserName',userName);
 createNewFormElement(registerForm,'SiteUrl',siteUrl);
 registerForm.action =url;
 //alert(userEmail);
 //alert(password); 
 //alert(url);
 //alert(siteUrl);
 registerForm.submit();
 
 
}

function  createMyformAndLogin(userEmail,password,url,siteUrl)
{


 var registerForm = getNewSubmitForm(); 
 createNewFormElement(registerForm,'ForumUserEmail',userEmail);
 createNewFormElement(registerForm,'ForumUserPassword',password);
createNewFormElement(registerForm,'SiteUrl',siteUrl);
  registerForm.action =url;
//alert(userEmail);
//alert(password); 
//alert(url);
//alert(siteUrl);
registerForm.submit(); 
}





function createNewFormElement(registerForm, elementName, elementValue){
 var newElement = document.createElement("<input name='"+elementName+"' type='hidden'>");
 registerForm.appendChild(newElement);
 newElement.value = elementValue;
 return newElement;
}

 
 
  
function showHideDiv(id)
{      
   alert('In Function');
	if(document.getElementById(id).style.display =='inline' || document.getElementById(id).style.display== '')        
    {
    alert(id);
      document.getElementById(id).style.display = 'none';
    } 
    else        
    {       
    alert('in else');     
        document.getElementById(id).style.display = 'inline';        
     }
     
 }
 
 
  function show_visibility(divId,imgId,lblhiddenId)
  {
      
      var divshow = document.getElementById(divId);
	  var img=document.getElementById(imgId);
      var hiddenVariable = document.getElementById(lblhiddenId);
        
	  divshow.style.display ='block';
	  img.src="/Style%20Library/Images/cssimages/side_arrow.gif";
	  hiddenVariable.value = "1";
	         
    }
    
 
 
 
 function hide_visibility(divId,imgId,lblhiddenId) 
 {
       
       var divhide = document.getElementById(divId);
       var img=document.getElementById(imgId);
       
         var hiddenVariable = document.getElementById(lblhiddenId);
       
       
       divhide.style.display ='none';
	   img.src='/Style%20Library/Images/cssimages/down_arrow.gif';
	   hiddenVariable.value = "0";
	         
    }
    
    function imageclick(imgId,divId,lblhiddenId)
    {
        
             
    var img=document.getElementById(imgId);
    
    if(img.src.match('Style%20Library/Images/cssimages/side_arrow.gif'))
    {
    hide_visibility(divId,imgId,lblhiddenId);
    }
    else{

    show_visibility(divId,imgId,lblhiddenId);
    
    }
    
    return false;
}

 var divUserDetailsFlag = false;
 var divContactDetailsFlag = false;
 var divPreferencesFlag = false;
 
 function browserclose(even)
 {


 
 if(divUserDetailsFlag==true || divContactDetailsFlag==true || divPreferencesFlag==true)
 { 
     if(window.event)
     {
      window.event.returnValue='Any unsaved changes will be lost.';
      return event.returnValue;
     }
     else
     {
     return('Any unsaved changes will be lost.'); 
     }
  }
 }
 
 

 
 
 
 
function setFlag(divId)
{

   
   if(divId == 'divMyUserDetails')
   {
    divUserDetailsFlag = true;
   }
   else if(divId == 'divMyContactDetails')
   {
      divContactDetailsFlag = true;
    
   }
   else if(divId == 'divMyPreferences')
   {
    divPreferencesFlag = true;
   }
    
}




function clearFlags()
{
 
  divPreferencesFlag = false;
  divUserDetailsFlag = false;
  divContactDetailsFlag = false;
   
}

//function browserEvent(e)
//{
//  alert('in browserEvent');
//  debugger;
// window.onbeforeunload = onBodyUnload(e);
//  alert("out browser event");
//}

//function onBodyUnload(e)
//{
//  
//  var e = e || window.event;
//  alert(e);
//  e.returnValue = "Are you sure you want to log off?";
//  return e.returnValue; 
//} 


function init()
{
alert('init')
if(window.addEventListener)
{
alert(windows);
window.addEventListener("beforeunload", unloadMess, false);
}
else if(window.onbeforeunload)
{
window.onbeforeunload = unloadMess;
};
}

function unloadMess()
{
var User_Message = "[Your user message here]"
return User_Message;
}

function callCheckMessages()
{
    var arr=document.getElementsByTagName('*');
    for(c=0;c<arr.length;c++) 
    {
    
    arr[c].onclick=function() 
    {
    
    CheckMessages(this);
    
    }
    arr[c].onfocus=function() 
    {
    CheckMessages(this);
    }
    }

}
function CheckMessages(currentNode)
{

 

if(divUserDetailsFlag == true || divPreferencesFlag == true || divContactDetailsFlag == true)
{


  var node=currentNode;
   
   
    for(;node.tagName!='body';)
    {
    
    if(node.id=='divMyUserDetails' || node.id == 'divMyContactDetails' || node.id == 'divMyPreferences' || node.id == 'divChangePassword')
    {    
    break;
    }
    
    if(node.parentElement)
    {
    node=node.parentElement;
    }
    else
    {
    node=node.parentNode;
    }
    }
    
     
    if(divUserDetailsFlag == true && node.id != 'divMyUserDetails')
    {      
       ShowMessage('lbldivMyUserDetails','divMyUserDetails')
    }
    if(divContactDetailsFlag == true && node.id != 'divMyContactDetails')
    {
      
       ShowMessage('lbldivMyContactDetails','divMyContactDetails')
    }
    if(divPreferencesFlag == true && node.id != 'divMyPreferences')
    {
       ShowMessage('lbldivMyPreferences','divMyPreferences')
    }
   
     
   
}
   
}



  function divSection(lblhiddenUserDetailsId,lblhiddenContactDetailsId,lblhiddenPreferencesId,lblhiddenChangePasswordId,image_first,image_second,image_third,image_fourth)
   {
     
     var lbhiddenUserDetails = document.getElementById(lblhiddenUserDetailsId);
     var lblhiddenContactDetails = document.getElementById(lblhiddenContactDetailsId);
     var lblhiddenPreferences = document.getElementById(lblhiddenPreferencesId);
     var lblhiddenChangePassword = document.getElementById(lblhiddenChangePasswordId);
     
     
     
     if(lbhiddenUserDetails.value == "1")
     {
         show_visibility('divMyUserDetails',image_first,lblhiddenUserDetailsId);
     }
     else
     {
        hide_visibility('divMyUserDetails',image_first,lblhiddenUserDetailsId);
     }
     
     if(lblhiddenContactDetails.value == "1")
     {
      show_visibility('divMyContactDetails',image_second,lblhiddenContactDetailsId);
     }
     else
     {
     hide_visibility('divMyContactDetails',image_second,lblhiddenContactDetailsId);
     }
     
     if(lblhiddenPreferences.value == "1")
     {
     show_visibility('divMyPreferences',image_third,lblhiddenPreferencesId);
     }
     else
     {
        hide_visibility('divMyPreferences',image_third,lblhiddenPreferencesId);     
     }
     
     if(lblhiddenChangePassword.value == "1")
     {
     show_visibility('divChangePassword',image_fourth,lblhiddenChangePasswordId);
     }
     else
     {
     hide_visibility('divChangePassword',image_fourth,lblhiddenChangePasswordId);     
     }
     
     
   }
   




function ShowMessage(lblId,divId)
{


   var lbl = document.getElementById(lblId);
  
   
   if(divId=='divMyUserDetails')
   {
     
       if(divUserDetailsFlag == true)
       {    
            //lbl.innerHTML = "To save details of the this section please click on update.";
           
            lbl.style.visibility = "visible";
          
       }
       else
       {
           //lbl.innerHTML = " ";
           lbl.style.visibility = "hidden";
       }
   }
   
   if(divId=='divMyContactDetails')
   {
        
        if(divContactDetailsFlag == true)
        {
       // lbl.innerHTML = "To save details of the this section please click on update.";
        lbl.style.visibility = "visible";
        }
        else
        {
          //lbl.innerHTML = " ";
          lbl.style.visibility = "hidden";
        }
    }
    
    
    if(divId == 'divMyPreferences')
    {
           if(divPreferencesFlag == true)
           {
             // lbl.innerHTML = "To save details of the this section please click on update.";
             lbl.style.visibility = "visible";
           }
           else
           {
              //  lbl.innerHTML = " ";
              lbl.style.visibility = "hidden";
              
           }
    }
    
    
  
 
   

}
 

 function ChangePasswordValidation(txtOld,txtNew,txtConfirm,lblError,lblErr)
 {
    
      
      var txtOldPwd =  document.getElementById(txtOld);
      var txtNewPwd =  document.getElementById(txtNew);
      var txtConfirmPwd =  document.getElementById(txtConfirm);
      var lblErrMsg =  document.getElementById(lblError);
      var lblErr = document.getElementById(lblErr);
      
       var regex = /^[A-Za-z0-9_*#%&!-]{6,20}$/;
      
      lblErr.value = "";
      lblErr.innerHTML = "";
      lblErr.innerText = "";
      
     if(txtOldPwd != null && txtOldPwd.value == "")
     {
         lblErrMsg.innerHTML = "Please enter your old password";
         lblErrMsg.focus();
         return false;
     }
     else if(!(txtOldPwd.value.match(regex)))
     {
         lblErrMsg.innerHTML = "Your password must be between 6 and 20 characters in length with at least one number. Allowed special characters are:_-#*&!";
         txtOldPwd.focus();
         return false;
     }   
     else if(!(CheckForNumeric(txtOldPwd.value)))
     {
         lblErrMsg.innerHTML = "Your password must be between 6 and 20 characters in length with at least one number. Allowed special characters are:_-#*&!";
         lblErrMsg.focus();
         return false;
     }     
     else if(txtNewPwd != null && txtNewPwd.value == "")
     { 
        lblErrMsg.innerHTML = "Please enter a new password";
        lblErrMsg.focus();
        return false;
     }
     else if(txtOldPwd.value == txtNewPwd.value)
     { 
        lblErrMsg.innerHTML = "The new password entered is the same as the old password, therefore no change has been made";
         lblErrMsg.focus();
         return false;
        
     }
      else if(!(txtNewPwd.value.match(regex)))
     {
         lblErrMsg.innerHTML = "Your password must be between 6 and 20 characters in length with at least one number. Allowed special characters are:_-#*&!";
         txtNewPwd.focus();
         return false;
     }
      else if(!(CheckForNumeric(txtNewPwd.value)))
     {
         lblErrMsg.innerHTML = "Your password must be between 6 and 20 characters in length with at least one number. Allowed special characters are:_-#*&!";
         lblErrMsg.focus();
         return false;
     }
     else if(txtConfirmPwd != null && txtConfirmPwd.value == "")
     { 
        lblErrMsg.innerHTML = "Please confirm your new password";
        lblErrMsg.focus();
        return false;
     }
     else if(!txtConfirmPwd.value.match(txtNewPwd.value))
     { 
        lblErrMsg.innerHTML = "Entered passwords don't match";
         lblErrMsg.focus();
         return false;
     }
     else
     { 
       return true;
     }
     
     
     
        
    } 
 
 
 
  
  function CheckForNumeric(strValue)
 {
       var IsNumber = false;
        var Char;
        for (i = 0; i < strValue.length ; i++) 
        { 
                Char = strValue.charAt(i); 
                             
                if(Char>=0 && Char <=9)
                {
                  
                  IsNumber = true;
                  break;
                }
        }
        
       
       return IsNumber;
   
 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 //---------------------------End Instant Forums Scripts -------------------------------------//