﻿    // JScript File
    
    var selected;
    
    function selectProduct(param)
    {       
    
            TabStrip1.set_visible(false); 
            TabStrip1.render();

      selected = param;
      Dialog1.set_result(param);
      
      CallBack1.callback(param);
    }
    
       

    function dialogshow(dialog)
    {
        Dialog1.set_result(selected);
            TabStrip1.set_visible(true); 
            TabStrip1.render();
//        document.getElementById("status").innerHTML = dialog.get_id()+" shown";
//        document.getElementById("result").innerHTML = dialog.get_result();
    }
    function dialogclose(dialog)
    {
            TabStrip1.set_visible(false); 
            TabStrip1.render();
    }
    function dialogdrag(dialog)
    {
//        document.getElementById("status").innerHTML = dialog.get_id()+" drag started";
//        document.getElementById("position").innerHTML = "x: "+dialog.get_x()+" y: "+dialog.get_y();
    }
    function dialogdrop(dialog)
    {
//        document.getElementById("status").innerHTML = dialog.get_id()+" dropped";
//        document.getElementById("position").innerHTML = "x: "+dialog.get_x()+" y: "+dialog.get_y();
    }
    function dialogfocus(dialog)
    {
//        document.getElementById("status").innerHTML = dialog.get_id()+" focused";
    }
    
    function toggle_setup()
    {
      if(Dialog1.get_isShowing())
      {
        Dialog1.Close();
//        document.getElementById('showclose').value = 'Show Dialog';
      }
      else
      {
        Dialog1.Show();
     //  document.getElementById('showclose').value = 'Close Dialog';
      }
    }

    function CallBack1_Load(sender, eventArgs)
    {
      setTimeout("selectProduct('Template')", 0);
    }


var form1 = document.getElementById('form1');

function getCurrent(){

        fillInCurrent();
   //     alert("getCurrent");
        if(Dialog1.get_isShowing()){
            TabStrip1.set_visible(true); 
            TabStrip1.render();
           }

}


        function send_privacy(myType, myVar, myZone){
        
              
            switch (myType) { 
          
            case "1": case "11": case "2": case "12": 
            
                    var zoneCurrent = document.getElementById('community_zone_current').value;
                    
                // alert(myType + "_" + myVar + "_" + myZone + "_" + zoneCurrent);  

                        
                            if(Dialog1.get_isShowing()){
                                TabStrip1.set_visible(false); 
                                TabStrip1.render();
                               }               
                                         
                     
                    CallBack1.callback(myType + "|" +  myVar + "|" +  myZone + "|" +  zoneCurrent);
                    break;         
                    
              case "20":             
                 
                      var myCode = ""
                      
                        if (document.getElementById('authentic_box1').value != '----'){
                                myCode = document.getElementById('authentic_box1').value + document.getElementById('authentic_box2').value + "-"  + document.getElementById('authentic_box3').value + "-" + document.getElementById('authentic_box4').value + "-" + document.getElementById('authentic_box5').value + "-" + document.getElementById('authentic_box6').value + document.getElementById('authentic_box7').value + document.getElementById('authentic_box8').value ;
                        }
                            else
                        {
                                 myCode = document.getElementById('authentic_box').value
                        }          
                              var myRole = document.getElementById('authentic_role').value;
                                                   
                        
                            if(Dialog1.get_isShowing()){
                                TabStrip1.set_visible(false); 
                                TabStrip1.render();
                               }               
                                         
                     
                              CallBack1.callback(myType + "|" +  myCode + "|" +  myRole);
                              break;         
                                        
              case "22":     
              
                    document.getElementById('auth_initial').style.display = "inline";    

                    document.getElementById('authentic_box').style.display = "inline";    
                    document.getElementById('auth_step1').style.display = "none";       
            
                    document.getElementById('authentic_box1').value = "----";
                    document.getElementById('authentic_box2').value = "----";
                    document.getElementById('authentic_box3').value = "----";
                    document.getElementById('authentic_box4').value = "----";
                    document.getElementById('authentic_box5').value = "----";
                    document.getElementById('authentic_box6').value = "----";
                    document.getElementById('authentic_box7').value = "----";
                    document.getElementById('authentic_box8').value = "----";
              
                    document.getElementById('authentic_box').value = "validation code"  
                    document.getElementById('authentic_role').value = "role or position in organisation"  
                    
                    break;        
                    

            case "25":             // handles validation 'Current Verification' change to radio buttons - True
                          
                        
                            if(Dialog1.get_isShowing()){
                                TabStrip1.set_visible(false); 
                                TabStrip1.render();
                               }               
                                         
                     
                    CallBack1.callback(myType + "|" +  myVar );
                    
                    break;       
                                   
            case "26":               // handles validation 'Current Verification' change to radio buttons - False

                        
                            if(Dialog1.get_isShowing()){
                                TabStrip1.set_visible(false); 
                                TabStrip1.render();
                               }               
                                         
                     
                    CallBack1.callback(myType + "|" +  myVar );
                    
                    break;            
                             
            case "60": 
           
           
                    var myFamNum = document.getElementById('numberFam').value
                    myFamNum = myFamNum*1 + 1
                    //alert(myFamNum + "|" +  myFamNum);
            
                    for (x = 1; x < myFamNum; x++)
                    {
                   // alert(x);
                   // alert(document.getElementById("member_" + x).value );
                    
                        myVar = myVar + document.getElementById("member_" + x).value + "~```~" + document.getElementById("relationship_" + x).value + "~```~" + document.getElementById("monitor_" + x).checked + "`~~`";

                    }                  

                        
                            if(Dialog1.get_isShowing()){
                                TabStrip1.set_visible(false); 
                                TabStrip1.render();
                               }               
                                         
                     
                    CallBack1.callback(myType + "|" +  myVar);
                    break;         
                    
                                   
            case "90": 
                               
                     input_box=confirm("Do you want to remove this relationship?");
                        if (input_box==true){
                       
                        
                            if(Dialog1.get_isShowing()){
                                TabStrip1.set_visible(false); 
                                TabStrip1.render();
                               }               
                                         
                     
                                CallBack1.callback(myType + "|" +  myVar);
                                
                        }
                    break;         
                    
            case "120":             //create new family profile
           
                    var myOne = document.getElementById('name_one_text').value;
                    var myTwo = document.getElementById('name_two_text').value;
                               
                     input_box=confirm("Do you want to create a new family profile with the url - " + myOne + "." + myTwo + ".Cathspace.com?");
                        if (input_box==true){
                        
                        
                            if(Dialog1.get_isShowing()){
                                TabStrip1.set_visible(false); 
                                TabStrip1.render();
                               }               
                                         
                     
                                CallBack1.callback(myType + "|" +  myOne + "|" + myTwo);
                                
                        }
                    break;         
                    
            case "130":             //exit family profile
           
                     input_box=confirm("Do you want to leave this family profile?");
                        if (input_box==true){
                        
                            if(Dialog1.get_isShowing()){
                                TabStrip1.set_visible(false); 
                                TabStrip1.render();
                               }               
                                         
                                CallBack1.callback(myType + "|" +  myVar);
                                
                        }
                    break; 
                    
            case "140":             //join family profile
           
                     input_box=confirm("Do you want to join this family profile?");
                        if (input_box==true){
                         
                            if(Dialog1.get_isShowing()){
                                TabStrip1.set_visible(false); 
                                TabStrip1.render();
                               } 
                                                      
                                CallBack1.callback(myType + "|" +  myVar);
                                
                        }
                    break;   
                    
                 case "640": case "650": case "660":           //submit comments and reports
           
                    var bug_url = document.getElementById('bug_url_text');
                    var username = document.getElementById('username_text');
                    var comment = document.getElementById('comment_text');
                               
                     input_box=confirm("Do you want send this information?");
                        if (input_box==true){
                        
                    if(Dialog1.get_isShowing()){
                        TabStrip1.set_visible(false); 
                        TabStrip1.render();
                       } 
                       
                       bug_url_text = ""
                        username_text = ""
                        
                            if (username) {  
                                username_text = username.value
                                }
                        
                            if (bug_url) {  
                                bug_url_text = bug_url.value
                                }
                                
                            if (comment) {  
                                comment_text = comment.value
                                }
                                //alert(myType + "|" +  username_text + "|" + bug_url_text + "|" + comment_text+ "|" +  myVar);
                                CallBack1.callback(myType + "|" +  username_text + "|" + bug_url_text + "|" + comment_text + "|" +  myVar);
                                
                        }
                    break;     
                    
            case "sa": case "pa": case "le": case "ym": case "ca": case "mo": case "yo": case "ch": case "te":  case "pr": case "st": case "oa": case "ad": case "ps": case "ba": case "bl": case "bs": case "bc": case "pl": case "pi":
           
            
                    if(Dialog1.get_isShowing()){
                        TabStrip1.set_visible(false); 
                        TabStrip1.render();
                       }
           
                    myVar2 =  document.getElementById("valid_var2")
                    CallBack1.callback(myType + "|" +  myVar + "|" + myVar2.value + "|" +  myZone);
                    break;    
                    
            case "setup_temp": 
            
            
                    if(Dialog1.get_isShowing()){
                        TabStrip1.set_visible(false); 
                        TabStrip1.render();
                       }
                       //  alert("3");           
                        CallBack1.callback(myType + "|" +  myVar);

                    break;    
            }  
        }
       
       function fillInCurrent(){
       
                   var myhiddenObject = document.getElementById('currentHidden')
                   
                   if (myhiddenObject) {
                        var myhidden = myhiddenObject.value;
                      //  alert(myhidden);
                        var myRegExp2 = new RegExp(/\~/);
                        myArray = myhidden.split(myRegExp2);    
                           
                        for (j=0;j<myArray.length;j++){
                            var myCheck = document.getElementById(myArray[j]);
                            if(myCheck) myCheck.checked = "true";
                        }
                  }
       } 
        
        function GetPrivacyFromServer(TotalStr){
        
    //    alert(TotalStr);
                                     
           var myRegExp = new RegExp(/\|/)
           item_array = TotalStr.split(myRegExp);   
          
           switch (item_array[0]){ 
              
                case "1": case "11":
                
                
                        var myWait = document.getElementById(item_array[1] + '_wait');
                        myWait.innerHTML = "";  

                        for (j = 0; j < form1.length; j++)
                        {
                            if((form1.elements[j].type == 'checkbox'))
                            {
                                  form1.elements[j].disabled=false;
                            }
                        }
                        break;
 
                case "20":      //authentication code is valid
               
         //     alert(TotalStr)  
                    //document.getElementById('authenticate_div').style.display = 'none';
                    var myWait = document.getElementById('authentic_list_wait');
                    myWait.innerHTML = "<p class='body_text_7' style='color:white'>" + item_array[1] + "</p>";
                   for (j = 0; j < form1.length; j++)
                    {
                              form1.elements[j].disabled=false;
                    } 
                    
                    var myList = document.getElementById('valid_var1_div');;
                    myList.innerHTML =  item_array[2];
                    var myNew= document.getElementById('valid_var2_div');
                    myNew.innerHTML = item_array[3];
                    
                    break;
                        
                case "21":      //authentication code is incorrect
               
              //alert(TotalStr)  
                    var myWait = document.getElementById('authentic_list_wait');
                    myWait.innerHTML = item_array[1];
                   for (j = 0; j < form1.length; j++)
                    {
                              form1.elements[j].disabled=false; 
                    } 
                        break;

                case "25": case "26":     //make validation code private or public
               
              //alert(TotalStr)  
              
              
                    var myWait = document.getElementById('authentic_list_wait');
                    myWait.innerHTML = "";
                   for (j = 0; j < form1.length; j++)
                    {
                              form1.elements[j].disabled=false; 
                    } 
                        break;
                        
                case "60":  case "90":
               
                    //alert(TotalStr);  
                    var myWait = document.getElementById('family_member_wait');
                    myWait.innerHTML = "";
                   for (j = 0; j < form1.length; j++)
                    {
                              form1.elements[j].disabled=false;
                    } 

                    document.getElementById('family_list').innerHTML = item_array[1];
                    break;
                                     
                                   
                case "120": //create family profile

                    var myWait = document.getElementById('family_new_wait');
                    myWait.innerHTML = "";
                   for (j = 0; j < form1.length; j++)
                    {
                              form1.elements[j].disabled=false;
                    } 

                    document.getElementById('family_new_profile_div').innerHTML = item_array[1];
                    document.getElementById('family_list_profile_div').innerHTML = item_array[2];
                    break; 
                    
                    
                case "130": case "140":         // exit or join family profile
               
                   var myWait = document.getElementById('family_list_wait');
                   myWait.innerHTML = "";
                   for (j = 0; j < form1.length; j++)
                    {
                              form1.elements[j].disabled=false;
                    }

                    document.getElementById('family_list_profile_div').innerHTML = item_array[1];
                    break; 
                                     
            case "sa": case "pa": case "le": case "ym": case "ca": case "mo": case "yo": case "ch": case "te":  case "pr": case "st": case "oa": case "ad": case "ps": case "ba": case "bl": case "bs": case "bc": case "pl": case "pi":
  
                        var myWait = document.getElementById(item_array[0] + "_" + item_array[1]+ "_wait");
                        myWait.innerHTML = "";     
                                   
                        input_box=confirm(item_array[3]);
                        if (input_box==true){
                             var myResult = document.getElementById(item_array[0] + "_" + item_array[1]);
                             myResult.innerHTML = item_array[2];  
                        }
                        else
                        {
                             var myResult = document.getElementById(item_array[0] + "_" + item_array[1]);
                             myResult.innerHTML = "<p class='body_text_7' style='margin-left:50pt;color:red'>action cancelled.</p>";     
                        }
                        
                     break;
                     
                 }

        }

//          function ShowPrivacy()
//          {
//               var Popup = document.getElementById('subnet_privacy');
//               if (Popup) {
//                   Popup.style.display = (Popup.style.display == "none")?"inline":"none";
//                   Popup.style.visibility = (Popup.style.visibility == "hidden")?"visible":"hidden";
//                   Popup.style.left = 100;
//                   Popup.style.top = 100;
//               }
//          }
//          
//          function ShowPrivacy2()
//          {
//                ShowPrivacy();
//                ShowPrivacyTop("family_div");
//          }
          
          function change_val2(myVal)
          {
                  if(myVal == 1)
                  {
                     // alert(1) 
                      document.getElementById("valid_var2_box_div").innerHTML = "<input id='valid_var2' type='password' style='width: 60pt' class='box_one' value='' onblur='if (this.value==&quot;&quot;) change_val2(2); ;' />"
                  }
                  else
                  {
                     // alert(2) 
                       document.getElementById("valid_var2_box_div").innerHTML = "<input id='valid_var2' type='type' style='width: 60pt' class='box_one' value='password'   onfocus='if (this.value==&quot;password&quot;) change_val2(1);;'  onblur='if (this.value==&quot;&quot;) change_val2(2); ;' />"
                  }
          }
          
          function ShowPrivacyInfo(myArg)
          {
               var PrivacyInfo = document.getElementById(myArg);
               PrivacyInfo.style.display = (PrivacyInfo.style.display == "none")?"inline":"none";
          }
          
          function ShowPrivacyTop(myArg)
          {
              var PrivacyInfo = document.getElementById(myArg);
              var privacy_div = document.getElementById("privacy_div");
              var authenticate_div = document.getElementById("authenticate_div");
              var family_div = document.getElementById("family_div");
               
              if  (PrivacyInfo.style.display == "inline") {
              
                    PrivacyInfo.style.display = "none"
                    
              }
                    else
              {
                
                    privacy_div.style.display = "none";
                    authenticate_div.style.display = "none";
                    family_div.style.display = "none";
          
                    PrivacyInfo.style.display = (PrivacyInfo.style.display == "none")?"inline":"none";
                    
              }
          }
          
          function addRelationships(myVal){
              
                  var add_family_div = document.getElementById("add_relationships");
                  var plus_family_div = document.getElementById("add_relationships_plus");
                  var add_family_value = add_family_div.innerHTML
                  
                  myVal = myVal + 1
                   
                  add_family_value = add_family_value + "<table border='0' cellpadding='0' cellspacing='0' width='100%'> <tr valign='top'><td align='right' width='40pt'><input id='member_" + myVal + "' type='text' size='20' class='box_one' value='username' onfocus='if (this.value==&quot;username&quot;) this.value=&quot;&quot;;' onblur='if (this.value==&quot;&quot;) this.value=&quot;username&quot;;' /></td><td>&nbsp;<input id='relationship_" + myVal + "' type='text' size='15' class='box_one' value='relationship' onfocus='if (this.value==&quot;relationship&quot;) this.value=&quot;&quot;;' onblur='if (this.value==&quot;&quot;) this.value=&quot;relationship&quot;;' /></td><td>&nbsp;<input id='monitor_" + myVal + "' type='checkbox' title='this person can monitor my online activity' onfocus='(confirm(&quot;Ticking this will give this person the capacity to view your online activity?&quot;))?this.checked=&quot;checked&quot;:this.checked=&quot;&quot;;' /></td></tr></table>"  
                   
                  add_family_div.innerHTML =  add_family_value
                  
                  
                  plus_family_div.innerHTML =  "<p class='body_text_11' style='color:black' align='right'><a href='javascript:addRelationships(" + myVal +");' title='add addtional family members'>+</a><input id='numberFam' type='hidden' value='" + myVal +"' /></p>"

          }


function toggle_community_zone(myArg){

               var zoneCount = document.getElementById('community_zone_count').value;

               for (var i=0;i<zoneCount+1 ;i++ ){
                       var zone = document.getElementById('community_zone_' + i);
                       if (zone) {
                           zone.style.display = "none";
                       }        
                        zoneNum = document.getElementById('community_zone_number_' + i);
                        if (zoneNum) {
                            zoneNum.innerHTML = i
                        }
               }

               zoneNum = document.getElementById('community_zone_number_' + myArg);
              if (zoneNum) {
                   zoneNum.innerHTML = "<u>" + myArg + "</u>"
               }

               var zoneCurrent = document.getElementById('community_zone_current');
               if (zoneCurrent) {
                //   alert("zoneCurrent.innerHTML: " + myArg);
                   zoneCurrent.value = myArg;
               }

               zone = document.getElementById('community_zone_' + myArg);
               if (zone) {
                   zone.style.display = "inline";
               }

}


function toggle_validation_zone(myArg){

               var zoneCount = document.getElementById('validation_zone_count').value;

               for (var i=0;i<zoneCount+1 ;i++ ){
                       var zone = document.getElementById('validation_zone_' + i);
                       if (zone) {
                           zone.style.display = "none";
                       }        
                        zoneNum = document.getElementById('validation_zone_number_' + i);
                        if (zoneNum) {
                            zoneNum.innerHTML = i
                        }
               }

               zoneNum = document.getElementById('validation_zone_number_' + myArg);
              if (zoneNum) {
                   zoneNum.innerHTML = "<u>" + myArg + "</u>"
               }

               var zoneCurrent = document.getElementById('validation_zone_current');
               if (zoneCurrent) {
                //   alert("zoneCurrent.innerHTML: " + myArg);
                   zoneCurrent.value = myArg;
               }

               zone = document.getElementById('validation_zone_' + myArg);
               if (zone) {
                   zone.style.display = "inline";
               }

}

function toggle_new_validation_Code_zone(){

               valid_code_intro = document.getElementById('new_valid_code_intro');
               valid_code = document.getElementById('new_valid_code');
               if (valid_code) {
                     valid_code_intro.style.display = (valid_code_intro.style.display == "none")?"inline":"none";
                     valid_code.style.display = (valid_code.style.display == "none")?"inline":"none";
               }

}

function toggle_template_zone(myArg){

               var zoneCount = document.getElementById('template_zone_count').value;

               for (var i=0;i<zoneCount+1 ;i++ ){
                       var zone = document.getElementById('template_zone_' + i);
                       if (zone) {
                           zone.style.display = "none";
                       }        
                        zoneNum = document.getElementById('template_zone_number_' + i);
                        if (zoneNum) {
                            zoneNum.innerHTML = i
                        }
               }

               zoneNum = document.getElementById('template_zone_number_' + myArg);
              if (zoneNum) {
                   zoneNum.innerHTML = "<u>" + myArg + "</u>"
               }

               var zoneCurrent = document.getElementById('template_zone_current');
               if (zoneCurrent) {
                //   alert("zoneCurrent.innerHTML: " + myArg);
                   zoneCurrent.value = myArg;
               }

               zone = document.getElementById('template_zone_' + myArg);
               if (zone) {
                   zone.style.display = "inline";
               }

}


       function openDiv(myDiv)
          {
          
                    document.getElementById(myDiv).style.display = (document.getElementById(myDiv).style.display == "none") ? "inline" : "none";

          } 
          
          
//    var winColor = null; // make global
//    var tId = "";
//    var myCount = 0;

       function openColor(subnetid, type, role)
          {
          
               winColor = window.open("../../community/popup/color_header.aspx?subnetid=" + subnetid + "&type=" + type + "&role=" + role,"colorPicker","status=no,scrollbars=yes,toolbar=no,location=no,menu=no,maximum=no,resizable=yes,width=600,height=600");
                winColor.focus()
          } 
          

       function openHeader(subnetid, id, type, j, year)
          {
          
               winColor = window.open("../../community/popup/image_header.aspx?subnetid=" + subnetid + "&" + j + "=" + id + "&type=" + type + "&j=" + j + "&year=" + year,"colorPicker","status=no,scrollbars=yes,toolbar=no,location=no,menu=no,maximum=no,resizable=yes,width=600,height=600");
                winColor.focus()
          
          } 
          

       function openBackground(subnetid, id, type, j, year)
          {
          
               winColor = window.open("../../community/popup/image_background.aspx?subnetid=" + subnetid + "&" + j + "=" + id + "&type=" + type + "&j=" + j + "&year=" + year,"colorPicker","status=no,scrollbars=yes,toolbar=no,location=no,menu=no,maximum=no,resizable=yes,width=600,height=600");
                winColor.focus()
          
          } 


function toggle_article_zone(myArg){

               var zoneCount = document.getElementById('article_zone_count').value;

               for (var i=0;i<zoneCount+1 ;i++ ){
                       var zone = document.getElementById('article_zone_' + i);
                       if (zone) {
                           zone.style.display = "none";
                       }        
                        zoneNum = document.getElementById('article_zone_number_' + i);
                        if (zoneNum) {
                            zoneNum.innerHTML = i
                        }
               }

               zoneNum = document.getElementById('article_zone_number_' + myArg);
              if (zoneNum) {
                   zoneNum.innerHTML = "<u>" + myArg + "</u>"
               }

               var zoneCurrent = document.getElementById('article_zone_current');
               if (zoneCurrent) {
                //   alert("zoneCurrent.innerHTML: " + myArg);
                   zoneCurrent.value = myArg;
               }

               zone = document.getElementById('article_zone_' + myArg);
               if (zone) {
                   zone.style.display = "inline";
               }

}

