﻿var PageStack = new Array();
var PageStep=0;

function goSupport() {
    // Build the URL
    var URL = '../../cgi-bin/t2m_support.cgi'

    if (document.getElementById('CountryID').value)
        URL += '?CountryID=' + document.getElementById('CountryID').value
    if (document.getElementById('MobileNumber').value) {
        if (document.getElementById('CountryID').value)
            URL += '&'
        else
            URL += '?'

        URL += 'MobileNumber=' + document.getElementById('MobileNumber').value
    }

    // Go Support	
    window.open(URL);
}

function getCookie(xiName) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(xiName + "=")
        if (c_start != -1) {
            c_start = c_start + xiName.length + 1
            c_end = document.cookie.indexOf(";", c_start)
            if (c_end == -1) c_end = document.cookie.length
            return unescape(document.cookie.substring(c_start, c_end))
        }
    }
    return ""
}

function setCookie(c_name, value, expiredays) {
    var exdate = new Date()
    exdate.setDate(exdate.getDate() + expiredays)
    document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + exdate.toGMTString())
}

function FAQShowPage(xiFAQPage) {
    if (ActiveFAQPage != "") {
        FAQHidePage(ActiveFAQPage);
    }

    ActiveFAQPage = xiFAQPage;
    document.getElementById('div_' + xiFAQPage).style.display = '';
}

function FAQHidePage(xiFAQPage) {
    if (xiFAQPage != "")
        document.getElementById('div_' + xiFAQPage).style.display = 'none';
}

function ShowFAQ() {
    //FAQHidePage(ActiveFAQPage)
    document.getElementById('div_FloatHelp').style.display = 'none';
    document.getElementById('div_FloatFAQNew').style.display = '';
    FAQShowPage('internalFAQHome');
}
function HideFAQ() {
    FAQHidePage(ActiveFAQPage)
    //EnPage();
    document.getElementById('div_FloatHelp').style.display = '';
    document.getElementById('div_FloatFAQNew').style.display = 'none';
}
function StartStepF(xiBasePage,xiStep,xiHidePrev) {
    var PushPage;

    if (xiStep)
        PushPage = xiBasePage+xiStep;
    else
    {
        PageStep = PageStep +1
        PushPage=xiBasePage+PageStep
    }

    if (PageStep == 1) {
        Push('div_StartBase');
        document.getElementById('div_StartBase').style.display = 'none';
        document.getElementById("div_internalStartStep1").style.display = '';
    }
    else if (PageStep >= 5) {
        HidePage('FloatStart');
        PageStep = 4;
        return;
    }   
    Push(PushPage);

    if (xiHidePrev) {
        if (xiHidePrev == true) {
            var LHidePage;
            LHidePage = Pop();
            if (LHidePage != "")
                document.getElementById(LHidePage).style.display = 'none';
        }
    }

    O3_FadeOpacity(PushPage, 1, 100, 0.25, '');

}

function StartStepB() {
    var CurrPage

    CurrPage = Pop();
    
    if (CurrPage != "") {
        document.getElementById(CurrPage).style.display = 'none';
        PageStep = PageStep - 1;
    }
    if (PageStep <= 1) {
        Pop();
        document.getElementById("div_internalStartStep1").style.display = 'none';
        document.getElementById('div_StartBase').style.display = '';
        PageStep = 0;
    }
}

function Push(xiPushPage) {
   
    if (xiPushPage)
        PageStack.push(xiPushPage);
    
}

function Pop(xiPopPage) {
    // If the xiPopPage is a number, then pop that page
    // If xiPopPage is not passed, get the last one
    var retPage = "";
    
    if (xiPopPage)
    {
        if (xiPopPage <= PageStack.length)
        {   
            retPage=PageStack[xiPopPage];
            ReStack(xiPopPage);
         }
    }
    else {
        retPage = PageStack.pop();      
    }
    return retPage
}

function ReStack(xiPopped)
{
    var TempStack = new Array();
    
    if (PageStack.Length > 1)
    for(i=0;i++; i>PageStack.Length)
    {
        if( i == xiPopped)
            continue;
        TempStack[TempStack.Length]=PageStack[i];
    }
    PageStack=TempStack;
}

