function objExists(theVal) {
    if (document.getElementById(theVal) != null) {
        return true;
    } else {
        return false;
    }
}

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            oldonload();
            func();
        }
    }
}

function addUnloadEvent(func) {
    var oldonunload = window.onunload;
    if (typeof window.onunload != 'function') {
        window.onunload = func;
    } else {
        window.onunload = function() {
            oldonunload();
            func();
        }
    }
}

function doBlind(thisGroupId, otherIndex, thisIndex) {

    var targetElementId = thisGroupId + 'Dropdown';
    var targetElement = document.getElementById(targetElementId);

    if (targetElement != null) {
        if (otherIndex==thisIndex) {
            if (targetElement.style.display=='none') {
                Effect.BlindDown(targetElement, {duration: 0.4});
            }
        } else {
            if (targetElement.style.display!='none') {
                Effect.BlindUp(targetElement, {duration: 0.4});
            }
        }
    }
}

function pullDown(targetElementId, linkTargetId) {
    var targetElement = document.getElementById(targetElementId);

    if (linkTargetId!='') {
        var linkTarget = document.getElementById(linkTargetId);
    }

    if (targetElement.style.display == "none") {
        Effect.BlindDown(targetElementId, {duration: 0.4});
        if (linkTargetId!='') {
            linkTarget.className = "drillUpLink";
        }
    } else {
        Effect.BlindUp(targetElementId, {duration: 0.4});
        if (linkTargetId!='') {
            linkTarget.className = "drillDownLink";
        }
    }
}

function confirmDelete(formId, thisDeleteId) {
    var result = confirm("Are you sure you want to delete this item?");
    if (result==true) {
        document.getElementById(formId).submit;
    } else {
        document.getElementById(thisDeleteId).value = '';
        return false;
    }
}

function leagueSlide(slideTo) {
    var sliderPosition = $('leagueSlider').offsetLeft;
    if (slideTo == 'riders' && sliderPosition==0) {
        new Effect.Move('leagueSlider', {  x:-700, y:0, duration: 0.4});
    } else if (sliderPosition==-700) {
        new Effect.Move('leagueSlider', {  x:700, y:0, duration: 0.4});
    }
    return false;
}


