var buttons = window.getElementsByClassName("ButtonUI");
for (var i = 0; i < buttons.length; i++) {
    buttons[i].OnClick = "OnClick";
}

var guideOption1 = window.getElementByName("Guid_Option1");
var guideOption2 = window.getElementByName("Guid_Option2");
var guideOption3 = window.getElementByName("Guid_Option3");
var guideOption4 = window.getElementByName("Guid_Option4");
var guideOption5 = window.getElementByName("Guid_Option5");
var guideOption6 = window.getElementByName("Guid_Option6");
var guideOption7 = window.getElementByName("Guid_Option7");
var pageTab = window.getElementByName("switch");

var btnPriv = window.getElementByName("priv_step");
var btnNext = window.getElementByName("next_step");
var btnFinish = window.getElementByName("finish");

function WndNotify(a, b) {
    if ("selectchanged" == b) 
    {
        if (guideOption1.getName() == a) {
          var bSelected = guideOption1.isSelected();
          if (bSelected == true) {
            pageTab.selectItem(0);
            btnPriv.setVisible(false);
            btnNext.setVisible(true);
            btnFinish.setVisible(false);        
          }
        }    
        else if (guideOption2.getName() == a) {
         var bSelected = guideOption2.isSelected();
         if (bSelected == true) {
            pageTab.selectItem(1);
            btnPriv.setVisible(true);
            btnNext.setVisible(true);
            btnFinish.setVisible(false);        
         }
        }
        else if (guideOption3.getName() == a) {
         var bSelected = guideOption3.isSelected();
         if (bSelected == true) {
            pageTab.selectItem(2);
             btnNext.setVisible(true);
             btnFinish.setVisible(false);        
             btnPriv.setVisible(true);
             }
        }
        else if (guideOption4.getName() == a) {
         var bSelected = guideOption4.isSelected();
         if (bSelected == true) {
            pageTab.selectItem(3);
             btnNext.setVisible(true);
             btnFinish.setVisible(false);        
             btnPriv.setVisible(true);
             }
        }
        else if (guideOption5.getName() == a) {
         var bSelected = guideOption5.isSelected();
         if (bSelected == true) {
            pageTab.selectItem(4);
             btnNext.setVisible(true);
             btnFinish.setVisible(false);        
             btnPriv.setVisible(true);
             }
        }
        else if (guideOption6.getName() == a) {
         var bSelected = guideOption6.isSelected();
         if (bSelected == true) {
            pageTab.selectItem(5);
             btnNext.setVisible(true);
             btnFinish.setVisible(false);        
             btnPriv.setVisible(true);
             }
        }
        else if (guideOption7.getName() == a) {
         var bSelected = guideOption7.isSelected();
         if (bSelected == true) {
            pageTab.selectItem(6);
             btnNext.setVisible(false);
             btnFinish.setVisible(true);        
             btnPriv.setVisible(true);
             }
        }
    }
}

function OnClick(obj) {
    if (obj.getName() == "closebtn") {
        window.closeWnd();
    }
    else if (obj.getName() == "Skip") {
        window.closeWnd();        
    }
    else if (obj.getName() == "priv_step") {
       var nSel = pageTab.getCurSel();
        if (nSel == 6) {
            btnNext.setVisible(true);
            btnFinish.setVisible(false);        
            guideOption6.selected(true);
        }
        else if (nSel == 5) {
            guideOption5.selected(true);
        }        
        else if (nSel == 4) {
            guideOption4.selected(true);
        }        
        else if (nSel == 3) {
            guideOption3.selected(true);
        }        
        else if (nSel == 2) {
            guideOption2.selected(true);
        }        
        else if (nSel == 1) {
            guideOption1.selected(true);
        }        
    }
    else if (obj.getName() == "next_step") {
       var nSel = pageTab.getCurSel();
       if (nSel == 6) {
            btnNext.setVisible(false);
            btnFinish.setVisible(true);
       }
       else if (nSel == 0) {
          guideOption2.selected(true);
       }
       else if (nSel == 1) {
           guideOption3.selected(true);
       }
       else if (nSel == 2) {
           guideOption4.selected(true);
       }
       else if (nSel == 3) {
           guideOption5.selected(true);
       }
       else if (nSel == 4) {
           guideOption6.selected(true);
       }
       else if (nSel == 5) {
           guideOption7.selected(true);
       }
//         pageTab.selectItem(nSel + 1);    
    }
    else if (obj.getName() == "finish") {
           window.closeWnd();        
      }
}