﻿var _networkCountries;
var _map;
var _txtId;
var _pnlHelpEmail;

function onload1(networkCountries, map, txtId, pnlHelpEmail) {
    _networkCountries = networkCountries;
    _map = map;
    _txtId = txtId;
    _pnlHelpEmail = pnlHelpEmail;
    var ddl = document.getElementById(_networkCountries);
    var ddlMap = document.getElementById(_map);
    ddlMapChanged(ddlMap);
    FillEmailID(ddl);
}

function TestSMS() {
    var ddl = document.getElementById(_networkCountries);
    var txtMobileId = document.getElementById(_txtId);
    if (txtMobileId.value == '') {
        alert("Mobile Number field cannot be empty!");
        return;
    }
    window.open(
    "testSMS.aspx?id=" + txtMobileId.value + "&val=" + ddl.options[ddl.selectedIndex].value,
    "SMSTest",
    "toolbar=0,location=0, menubar=0, height=200, width=300, status=0"
    );
}

function FillEmailID(ddl) {
    if (ddl == null) return;
    var helpEmail = document.getElementById(_pnlHelpEmail);
    var txtMobileId = document.getElementById(_txtId);
    var btnTest = document.getElementById('btnTest');
    helpEmail.style.display = 'none';
    if (ddl.selectedIndex == 0) {
        txtMobileId.disabled = 'disabled';
        btnTest.disabled = 'disabled';
        txtMobileId.style.background = '#CCCCCC';
        txtMobileId.value = '';
        return;
    }
    else {
        txtMobileId.disabled = '';
        btnTest.disabled = '';
        helpEmail.style.display = 'block';
        txtMobileId.style.background = '#ffffff';
    }
    var selVal = ddl.options[ddl.selectedIndex].value;
    selVal = selVal.split(" ")[0];
    var helpNumber = '';
    if (ddl.selectedIndex > 1) {
        if (selVal.indexOf('n@') > -1) {
            helpNumber = selVal.replace('n@', '{Mobile-Number}@')
            helpEmail.innerHTML = 'Email will be sent using <i>\"' + helpNumber + '\"</i>. Service charges may apply for receiving Text Messages.';
        }
        if (selVal.indexOf('u@') > -1) {
            helpNumber = selVal.replace('u@', '{User-Name}@');
            helpEmail.innerHTML = 'Email will be sent using <i>\"' + helpNumber + '\"</i>. Contact your mobile provider for User Name. Service charges may apply for receiving Text Messages.';
        }
        return;
    }
    if (ddl.selectedIndex == 1) {
        helpEmail.innerHTML = 'Contact your mobile provider to get email address of your device. Type the email in place of Mobile Number. Service charges may apply for receiving Text Messages.';
        return;
    }
}

function addBookmark(title, url) {
    if (window.sidebar) { // firefox
        window.sidebar.addPanel(title, url, "");
    } else if (document.all) { //MSIE
        window.external.AddFavorite(url, title);
    } else {
        alert("Sorry, your browser doesn't support this");
    }
}

function ddlMapChanged(ddl) {
    divId = document.getElementById("divMap");
    if (ddl.selectedIndex == 5) {
        divId.style.visibility = 'visible';
        divId.style.display = 'block';
    }
    else {
        divId.style.visibility = 'hidden';
        divId.style.display = 'none';
    }
}
