
function nextBox(src, target) {
    var max = src.getAttribute('maxlength');
    
    if (src.value.length == max)
    { $(target).focus(); }
}





function openWindow(url, windowName) {
    var w = 1050;
    var h = 768;
    windowOpener(url, windowName, w, h);
}


function windowOpener(url, windowName, w, h) {
    var LeftPosition = (screen.width) ? (screen.width - w) / 2 : 0;
    var TopPosition = (screen.height) ? (screen.height - h) / 2 : 0;
    var win = window.open(url, windowName, 'location=0,top=' + TopPosition + ',left=' + LeftPosition + ',resizable=1,status=0,titlebar=0,directories=0,toolbar=0,menubar=0,scrollbars=1,width=' + w + ',height=' + h + ',outerWidth=' + w + ',outerHeight=' + h + '');
    win.focus();
}



function toggleCustCentre(divId, imgId) {
    var cImg = $(imgId);
    if (cImg.src.endsWith('down.gif')) {
        cImg.src = cImg.src.replace('down', 'up');
        cImg.alt = "Collapse Customer Centre"
        cImg.title = "Collapse Customer Centre"
        $('liTest').show()
        Effect.BlindDown('liTest', { duration: 0.1 });
        Effect.BlindDown(divId, { duration: 1.5, queue: 'end' });
    }
    else {
        Effect.BlindUp(divId, { duration: 1.5 });
        Effect.BlindUp('liTest', { duration: 0.1, queue: 'end' });
        cImg.src = cImg.src.replace('up', 'down');
        cImg.alt = "Expand Customer Centre"
        cImg.title = "Expand Customer Centre"
    }
}





/* Cookie functions */

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 getCookie(c_name) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=");
        if (c_start != -1) {
            c_start = c_start + c_name.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 "";
}



/* Create a temporary form for posting / opening */
function secureForm(url, uid) {
    var w = 1050;
    var h = 768;

    var LeftPosition = (screen.width) ? (screen.width - w) / 2 : 0;
    var TopPosition = (screen.height) ? (screen.height - h) / 2 : 0;
    var win = window.open('/_lib/DISPLAYWINDOW.HTM', uid, 'location=0,top=' + TopPosition + ',left=' + LeftPosition + ',resizable=1,status=0,titlebar=0,directories=0,toolbar=0,menubar=0,scrollbars=1,width=' + w + ',height=' + h + ',outerWidth=' + w + ',outerHeight=' + h + '');
    win.focus();

    setTimeout(function() {
        var frm = '<form id="' + uid + '" method="post" action="' + url + '">';
        frm += '<input type="hidden" name="a"  value="doContactStep2" />';
        frm += '<input type="hidden" name="nature"  value="' + uid + '" />';
        frm += '</form>';
        win.document.body.innerHTML = frm;

    }, 500);

    setTimeout(function() { win.document.getElementById(uid).submit(); }, 500);
}


