
if (! GetStarted)
{
    var GetStarted = {};  
}

function RunServerScript() {
    var p = window.setTimeout('ServerScript()', 2000);
 }

 function ServerScript() {
     window.location.href = "get_started_wizard.asp?HideWizard=true";
  }
 
function confirmClose() {
    var closeWizard = confirm("Are you sure to hide this wizard permanently?");
    if (closeWizard == true) {
        var page = window.parent.location.pathname;
        if (page.indexOf(".aspx") > 0) {
            $(parent.document).find('#ctl00_pnl_GetStartedWizard').fadeOut('slow');
            RunServerScript();
        }
        else {
            $(parent.document).find('#pnl_GetStartedWizard').fadeOut('slow');
            RunServerScript();
        }        
        return true;
    }
    else {
        return false;
    }
}

GetStarted.Wizard = function() {
    this.wizard_title = "";
    this.step_count = 0;
    this.curr_step = 1;
    this.steps = [];
    this.AddStep = GetStarted.Wizard.Add_Step;
    this.MoveNext = GetStarted.Wizard.Move_Next;
    this.MovePrev = GetStarted.Wizard.Move_Prev;
    this.Render = GetStarted.Wizard.Render;
    this.MoveTo = GetStarted.Wizard.Move_To;
    this.steplist = document.createElement("OL");
    this.steplist.className = "wizlist";
    this.SetBtns = GetStarted.Wizard.Set_Btns;
    this.SetNextLbl = GetStarted.Wizard.Set_Next_Lbl;
    this.SetPrevLbl = GetStarted.Wizard.Set_Prev_Lbl;    
    this.SetSeparatorLbl = GetStarted.Wizard.Set_Separator_Lbl;

    this.nextVal = "Next";
    var btnNext = document.createElement("A");
    btnNext.setAttribute("href", "javascript:void(0);");
    btnNext.setAttribute("class", "clsHideThis");
    this.lblNext = document.createTextNode(this.nextVal);
    btnNext.appendChild(this.lblNext);
    btnNext.id = "btnnext";
    btnNext.onclick = this.MoveNext;
    btnNext.wzrd = this;
    this.nextBtn = btnNext;

    this.prevVal = "Previous";
    var btnPrev = document.createElement("A");
    btnPrev.setAttribute("href", "javascript:void(0);");
    btnPrev.setAttribute("class", "clsHideThis");
    this.lblPrev = document.createTextNode(this.prevVal);
    btnPrev.appendChild(this.lblPrev);
    btnPrev.id = "btnprev";
    btnPrev.onclick = this.MovePrev;
    btnPrev.wzrd = this;
    this.prevBtn = btnPrev;

    this.SeparatorVal = "Separator";
    var btnSeparator = document.createElement("A");
    btnSeparator.setAttribute("href", "javascript:void(0);");
    btnSeparator.setAttribute("class", "TextDecorationNone");
    this.lblSeparator = document.createTextNode(this.SeparatorVal);
    btnSeparator.appendChild(this.lblSeparator);
    btnSeparator.id = "btnSeparator";
    btnSeparator.wzrd = this;
    this.SeparatorBtn = btnSeparator;

    document.getElementById("wizbtns").appendChild(btnPrev);
    document.getElementById("wizbtns").appendChild(btnSeparator);
    document.getElementById("wizbtns").appendChild(btnNext);
}

GetStarted.Wizard.Set_Next_Lbl = function(p_label)
{
    this.lblNext.data = p_label;    
}

 
GetStarted.Wizard.Set_Prev_Lbl = function(p_label)
{
    this.lblPrev.data = p_label;    
}

GetStarted.Wizard.Set_Separator_Lbl = function(p_label) {
    this.lblSeparator.data = p_label;
}

GetStarted.Wizard.WizardStep = function()
{
    //step_name is the text that appears in the ordered list of steps
    this.step_name = "";
    
    //step_hint is the text that describes the step.
    this.step_hint = "";
}


GetStarted.Wizard.Add_Step = function(p_step) {
    this.steps[this.step_count] = p_step;
    this.step_count = this.steps.length;

    //create the step list element for this step
    var step = document.createElement("LI");
    var steplink = document.createElement("a");
    steplink.href = "javascript:void(0)";
    steplink.className = "offstep";
    steplink.id = "lnk" + this.step_count;
    var stepTxt = document.createTextNode(p_step.step_name);
    step.stepText = p_step.step_name;
    step.nbr = this.step_count;
    step.onclick = this.MoveTo;
    step.wiz = this;
    steplink.appendChild(stepTxt);
    step.appendChild(steplink);
    this.steplist.appendChild(step);
}


GetStarted.Wizard.Move_Next = function() {
    if (this.wzrd.curr_step < this.wzrd.step_count) {

        for (var i = 1; i <= this.wzrd.step_count; i++) {
            document.getElementById("step" + i).className = "step_hidden";
            document.getElementById("lnk" + i).className = "offstep";
        }
        var nextstep = this.wzrd.curr_step + 1;
        document.getElementById("step" + nextstep).className = "step_visible";
        document.getElementById("lnk" + nextstep).className = "onstep";
        this.wzrd.curr_step += 1;
        document.getElementById("step_name").innerHTML =
            this.wzrd.steps[this.wzrd.curr_step - 1].step_hint;
    }

    this.wzrd.SetBtns();
}


GetStarted.Wizard.Move_Prev = function()
{
    if(this.wzrd.curr_step > 1)
    {
        
        for(var i = 1; i <= this.wzrd.step_count; i++)
        {
            document.getElementById("step" + i).className = "step_hidden";
            document.getElementById("lnk" + i).className = "offstep";
        }
        var nextstep = this.wzrd.curr_step - 1;
        document.getElementById("step" + nextstep).className = "step_visible";
        document.getElementById("lnk" + nextstep).className = "onstep";
        this.wzrd.curr_step -= 1;
       
        document.getElementById("step_name").innerHTML =
            this.wzrd.steps[this.wzrd.curr_step - 1].step_hint;
    }
    this.wzrd.SetBtns();
}


GetStarted.Wizard.Move_To = function()
{
    
    this.wiz.curr_step = this.nbr; 
  
    for(var i = 1; i <= this.wiz.step_count; i++)
    {
        document.getElementById("step" + i).className = "step_hidden";   
        document.getElementById("lnk" + i).className = "offstep"; 
    }
    var curstep = document.getElementById("step" + this.nbr);
    curstep.className = "step_visible";
     
    document.getElementById("lnk" + this.nbr).className = "onstep";
              
    document.getElementById("step_name").innerHTML = this.wiz.steps[this.wiz.curr_step - 1].step_hint;
                       
    this.wiz.SetBtns();
}


GetStarted.Wizard.Render = function(p_elem) {
    var wizdiv = document.getElementById(p_elem);
    wizdiv.appendChild(this.steplist);

    document.getElementById("lnk1").className = "onstep";
    document.getElementById("btnprev").className = "step_hidden";

    //document.getElementById("wiztitle").innerHTML = this.wizard_title;

    document.getElementById("step_name").innerHTML = this.steps[0].step_hint;

    document.getElementById("step1").className = "step_visible";

    var btnNext = document.getElementById("btnnext");
    btnNext.className = "btnvisible";

    var btnSeparator = document.getElementById("btnSeparator");
    btnSeparator.className = "TextDecorationNone";
    btnSeparator.style.visibility = "hidden";

    var btnPrev = document.getElementById("btnprev");
    btnPrev.className = "btnhidden";
}


GetStarted.Wizard.Set_Btns = function() {
    var btnnext = document.getElementById("btnnext");
    var btnprev = document.getElementById("btnprev");
    var btnSeparator = document.getElementById("btnSeparator");
    switch (this.curr_step) {
        case 1:
            {
                btnprev.className = "btnhidden";
                btnnext.className = "btnvisible";
                btnSeparator.classname = "btnhidden";
                btnSeparator.style.visibility = "hidden";
                break;
            }
        case this.step_count:
            {
                btnprev.className = "btnvisible";
                btnnext.className = "btnhidden";
                btnSeparator.classname = "btnhidden";
                btnSeparator.style.visibility = "hidden";
                break;
            }
        default:
            {
                btnprev.className = "btnvisible";
                btnnext.className = "btnvisible";
                btnSeparator.classname = "TextDecorationNone";
                btnSeparator.style.visibility = "visible";
                break;
            }
    }
}
