
/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: JTricks.com :: http://www.jtricks.com/ */


function move_box(box) {
    var myWidth;
    var myHeight;

    if (typeof (window.innerWidth) == 'number') {
        //Non-IE 

        myWidth = window.innerWidth;
        myHeight = window.innerHeight;

    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {

        //IE 6+ in 'standards compliant mode' 

        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;

    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {

        //IE 4 compatible 

        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;

    }

    box.style.left = (myWidth / 3.5) + 'px';
    box.style.top = (myHeight / 4.5) + 'px';
}

function show_hide_box(an, width, height, borderStyle) {

    var href = an.href;
    var boxdiv = document.getElementById(href);

    if (boxdiv != null) {
        if (boxdiv.style.display == 'none') {
            move_box(an, boxdiv);
            boxdiv.style.display = 'block';
        } else
            boxdiv.style.display = 'none';
        return false;
    }

    boxdiv = document.createElement('div');
    boxdiv.setAttribute('id', href);
    boxdiv.style.display = 'block';
    boxdiv.style.position = 'absolute';
    boxdiv.style.width = width + 'px';
    boxdiv.style.height = height + 'px';
    boxdiv.style.border = borderStyle;
    boxdiv.style.backgroundColor = '#FFF';

    var inClosebox = document.createElement("div");
    inClosebox.setAttribute('id', 'Close');
    inClosebox.style.position = 'absolute';
    inClosebox.style.right = '-15px';
    inClosebox.style.top = '-15px';

    var inImage = document.createElement("img");
    inImage.onclick = function () {
        document.body.removeChild(boxdiv);
    };
    inImage.setAttribute('src', 'Images/closebox.png');
    inImage.setAttribute('alt', 'Close');
    inImage.setAttribute('width', '30');
    inImage.setAttribute('height', '30');
    inImage.setAttribute('border', '0');
    inImage.style.cursor = 'pointer';
    inClosebox.appendChild(inImage);


    var contents = document.createElement('iframe');
    contents.scrolling = 'yes';
    contents.frameBorder = '0';
    contents.style.width = width + 'px';
    contents.style.height = height + 'px';
    contents.src = href;

    boxdiv.appendChild(contents);
    boxdiv.appendChild(inClosebox);
    document.body.appendChild(boxdiv);
    move_box(boxdiv);

    return false;
}

