// General scripts and functions

function GetControlID(vControl, vControlTag) {
    var vObjects = document.getElementsByTagName(vControlTag);
	
    for (var j=0;j<vObjects.length;j++) {
        var vID = vObjects[j].id;

        if (vID.indexOf('' + vControl + '') >= 0) {
            return vID;
            break;
        }
    }
}    

//Used for hidden buttons on the page - click
function HiddenButtonClick(vButtonName) {
    vButtonName = GetControlID(vButtonName, 'input');
    
    if (vButtonName != undefined) {
        //Only do button click if button is found               
        window.document.getElementById('' + vButtonName + '').click();
    }
}

//Image Rollover
$(function() {
    $('img.hover').hover(function() {
        $(this).attr('src', $(this).attr('src').replace( /_off/i, '_on'));
    }, function() {
        $(this).attr('src', $(this).attr('src').replace( /_on/i, '_off'));
    });
});

//Opens lightbox from any form in an iFrame
//On URL Always pass ? at end of URL even if not querystring parameter is specified
function openTB(vURL, vWidth, vHeight){
    tb_show("","" + vURL + "&height=" + vHeight + "&width=" + vWidth + "&placeValuesBeforeTB_=savedValues&TB_iframe=true&modal=true");
}

function closeTB() {
    window.top.tb_remove();
}
