﻿/* by Jeff McClung */


/* background image preloader
bgImg = new Image();
bgImg.src = "/sports/images/i/main_bg.jpg"; */


/* 'FindControl' can be used to find element names in JavaScript, since .NET mangles the ID tag. */
function FindControl(ControlName, ReturnType) {
    var theForm = document.forms[0];
    var iMax = theForm.elements.length;
    var ElementName = '';

    for (i = 0; i < iMax; i++) {
        if (theForm.elements[i].name.indexOf(ControlName) > 0) {
            ElementName = theForm.elements[i].name;
            break;
        }
    }

    if (ReturnType == 'string') {
        return ElementName;
    } else {
        return eval('theForm.' + ElementName);
    }
}


function ChangeImages() {
    if (document.images) {
        for (var i = 0; i < ChangeImages.arguments.length; i += 2) {
            document[ChangeImages.arguments[i]].src = ChangeImages.arguments[i + 1];
        }
    }
}


function ShowHide(item) {
    //if the browser supports this...
    if (document.getElementById) {
        //if the user specifically passed in a state to use for the item in question (inline, none)
        if (arguments.length > 1) {
            document.getElementById(item).style.display = arguments[1];
        } else {
            //otherwise, we want to take the current state of this item, and flip it.
            if (document.getElementById(item).style.display == 'none') {
                document.getElementById(item).style.display = 'inline';
            } else {
                document.getElementById(item).style.display = 'none';
            }
        }
    }
}


function OpenWindow(url) {
    var params;

    if (arguments.length > 1)
        params = arguments[1];
    else
        params = 'scrollbars=yes,resizable=yes,width=640,height=480'

    var win = window.open(url, 'NewWin', params);
}


function SetHomePage(obj) {
    //This script fails in anything but IE, so the "return false" never happens.
    // Therefore, homepage is set automagically in IE, and others get manual instructions.
    obj.style.behavior = 'url(#default#homepage)';
    obj.setHomePage('http://www.tulsaworld.com');
    return false;
}