
if (typeof DynValidator == 'undefined') DynValidator = function() { };

DynValidator.isTelenorScratchcardNumber = function(str) { return str.match(/(^[a-bA-B]{1,1}\d{9,9}$)/) != null; }
DynValidator.isIridiumScratchcardNumber = function(str) { return str.toUpperCase().match(/(^\d{6,6}PROD\d{5,5}$)/) != null; }

var iPopup = null;

function showInfoPopup(url) {
    iPopup = window.open(url,'info','toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,width=332,height=350,resizable=no,left=20,top=20,screenX=20,screenY=20' );
    iPopup.focus();
}

function showBigInfoPopup(url) {
    iPopup = window.open(url,'biginfo','toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,width=632,height=450,resizable=no,left=20,top=20,screenX=20,screenY=20' );
    iPopup.focus();
}

function showTour(url) {
    iPopup = window.open(url,'tour','toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,width=614,height=428,resizable=no,left=20,top=20,screenX=20,screenY=20' );
    iPopup.focus();
}
function showFlashTour(url) {
    iPopup = window.open(url,'tour','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,width=762,height=480,resizable=no,left=20,top=20,screenX=20,screenY=20' );
    iPopup.focus();
}
function showNewFlashTour(url) {
    iPopup = window.open(url,'tour','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,width=790,height=610,resizable=no,left=20,top=20,screenX=20,screenY=20' );
    iPopup.focus();
}

Toggle = function(id) {
    var elm = document.getElementById(id);
    elm.style.display = elm.style.display == 'block' ? 'none' : 'block';
}

ReadMore = function() { }
ReadMore.defaultId = null;
ReadMore.currentId = null;
ReadMore.toggle = function(readMoreId,defaultId) {
    if (defaultId) ReadMore.defaultId = ReadMore.currentId = defaultId;
    document.getElementById(ReadMore.currentId).style.display = 'none';
    document.getElementById(readMoreId ? readMoreId : ReadMore.defaultId).style.display = 'block';
    ReadMore.currentId = readMoreId;
}

Related = function() { }
Related.ontoggle = function() {}
Related.currentId = 0;
Related.toggle = function(relatedId) {
    if (Related.currentId) {
        document.getElementById(Related.currentId).style.display = 'none';
        document.getElementById("img_" + Related.currentId).src = '/gfx/bullet_toggle_closed.gif';
    }
    if (relatedId && relatedId != Related.currentId) {
        document.getElementById(relatedId).style.display = 'block';
        document.getElementById("img_" + relatedId).src = '/gfx/bullet_toggle_open.gif';
        Related.currentId = relatedId;
    } else { Related.currentId = 0; }
    Related.ontoggle();
}
Related.disable = function(relatedId) {
    var elm = document.getElementById('RelatedContent_' + relatedId);
    if (elm != null) {
        elm.style.display = 'none';
    }
}

if (typeof DynForm != 'undefined') {
    DynForm.globalValidator = function(s) {
        if (typeof s == 'string') {
            for (var i = 0; i < s.length; i++) {
                if (s.charCodeAt(i) > 256) return false;
            }
        }
        return true;
    }
}

// DynInterface

function isDefined(v)  { return typeof v != 'undefined'; }
function notDefined(v) { return typeof v == 'undefined'; }

function isNull(v)     { return v == null && isDefined(v)  && v != 0; }
function notNull(v)    { return v != null || notDefined(v) || v == 0; }

function isValid(v)    { return isDefined(v) && notNull(v) && v; }