// openNew - Open new window.
// @param url Url to open.
// @param width (optional) Window width.
// @param height (optional) Window height.
function openNew(url, width, height) {
    if (!width)  { width = 550; }
    if (!height) { height = 650; }

    var newWin = window.open(url, "newWin", "width=" + width + ", height=" + height);
    newWin.focus();
}

// objRotatorImage - Data item for object rotator.
// @param imgSrc Image location.
// @param text HTML description (optional)
function objRotatorItem(imgSrc, text) {
    this.imgSrc = imgSrc;
    this.text = text;
}

// objRotator - Image rotator object. Add objRotatorItems then rotate through with rotate().
// @param imgID ID of image to rotate.
// @param textID ID of text to rotate.
function objRotator(imgID, textID) {
    // variables
    this.imgID = imgID;
    this.textID = textID;
    this.arrImages = new Array();
    this.rotatorImage = document.getElementById(imgID);
    this.rotatorText = document.getElementById(textID);
    this.position = 0;

    // methods
    function addItem(item) {
        var count = this.arrImages.length;
        this.arrImages[count] = item;
    }

    function rotate() {
        var count = this.arrImages.length;
        this.position++;
        if (this.position == count) { this.position = 0; }
        this.rotatorImage.src = this.arrImages[this.position].imgSrc;
        if (this.rotatorText) { this.rotatorText.innerHTML = this.arrImages[this.position].text; }
    }

    this.addItem = addItem;
    this.rotate = rotate;

    // add in the base image
    var initialText = (this.rotatorText ? this.rotatorText.innerHTML : null);
    this.addItem(new objRotatorItem(this.rotatorImage.src, initialText));
}
