﻿function onOk() {
    $get('Paragraph1').className = styleToSelect;
}

function f_clientWidth() {
    return document.documentElement.clientWidth;
}

function f_clientHeight() {
    return document.documentElement.clientHeight;
}

function f_viewportWidth() {
    var test1 = document.documentElement.scrollWidth;
    var test2 = document.documentElement.offsetWidth;

    if (test1 > test2) // all but Explorer Mac
        return document.documentElement.scrollWidth;
    else
        return document.documentElement.offsetWidth;
}

function f_viewportHeight() {
    var test1 = document.documentElement.scrollHeight;
    var test2 = document.documentElement.offsetHeight;

    if (test1 > test2) // all but Explorer Mac
        return document.documentElement.scrollHeight;
    else
        return document.documentElement.offsetHeight;
}

function f_scrollLeft() {
    return f_filterResults(
window.pageXOffset ? window.pageXOffset : 0,
document.documentElement ? document.documentElement.scrollLeft : 0,
document.body ? document.body.scrollLeft : 0);
}

function f_scrollTop() {
    return f_filterResults(
window.pageYOffset ? window.pageYOffset : 0,
document.documentElement ? document.documentElement.scrollTop : 0,
document.body ? document.body.scrollTop : 0);
}

function f_filterResults(n_win, n_docel, n_body) {
    var n_result = n_win ? n_win : 0;
    if (n_docel && (!n_result || (n_result > n_docel)))
        n_result = n_docel;
    return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}


//
// Used on the GetCreatives page to display the overlay with fullsize image and html tags etc...
//
function $(v) { return (document.getElementById(v)); }
function $S(v) { return ($(v).style); }
function agent(v) { return (Math.max(navigator.userAgent.toLowerCase().indexOf(v), 0)); }
function isset(v) { return ((typeof (v) == 'undefined' || v.length == 0) ? false : true); }
function XYwin(v) {
    var z = agent('msie') ?
Array(document.body.clientHeight, document.body.clientWidth)
: Array(window.innerHeight, window.innerWidth);

    return (isset(v) ? z[v] : z);
}

function popupTOG() {
    $S('popupContainer').display = 'none';
    $S('popupBox').display = 'none';
}


function popupBox(imageUrl) {
    var scrollTop = f_scrollTop();
    var scrollLeft = f_scrollLeft();
    var clientWidth = f_clientWidth();
    var clientHeight = f_clientHeight();
    var viewportWidth = f_viewportWidth();
    var viewportHeight = f_viewportHeight();

    // Add extra height and width to accomodate the tag textbox and close button etc...
    var tempImage = new Image;
    tempImage.src = '/images/plans/' + imageUrl + '.gif';
    if (tempImage.width == 0) {
        tempImage = new Image;
        tempImage.src = '/images/plans/' + imageUrl + '.gif';
    }
    var width = tempImage.width;
    var height = tempImage.height;
    var totalWidth = width + 80;
    var totalHeight = height + 70;

    // Set the background height and position to cover all of the page
    $S('popupContainer').height = viewportHeight + 'px';
    $S('popupContainer').width = viewportWidth + 'px';
    $S('popupContainer').display = 'block';
    $S('popupContainer').top = '0';
    $S('popupContainer').left = '0';
    
    $('imagePlaceholder').innerHTML = '<img src="/images/plans/' + imageUrl + '.gif"\/>';
    
   
    $('imagePlaceholder').innerHTML += '<br \/>';

  

    var top = scrollTop + Math.round((clientHeight - totalHeight) / 2);
    if (top < 0)
        top = 0;
    $S('popupBox').top = top + 'px';
    $S('popupBox').left = Math.round((clientWidth - totalWidth) / 2) + 'px';
    $S('popupBox').width = totalWidth + 'px';
    $S('popupBox').height = totalHeight + 'px';
    $S('popupBox').display = 'block';
}

String.prototype.pad = function(l, s, t) {
    return s || (s = " "), (l -= this.length) > 0 ? (s = new Array(Math.ceil(l / s.length)
		+ 1).join(s)).substr(0, t = !t ? l : t == 1 ? 0 : Math.ceil(l / 2))
		+ this + s.substr(0, l - t) : this;
}