function toBottom(id){
    document.getElementById(id).scrollTop=document.getElementById(id).scrollHeight;
}

function toTop(id){
    document.getElementById(id).scrollTop=0;
}
            
//Generic Box Toggle
function toggleBox(boxname){
    $('#' + boxname + 'Box').toggle();
    $('#' + boxname + 'Toggle').toggleClass('showhideArw');
}

//Share Room Toggles    
function roomShareToggle(num){
        $('#shareRoom' + num).toggle();
        $('#roomDetails' + num).toggle();
    return false;
}

function shareEmailToogle(num) {
    hideTabs(num);
    $('#shareEmail' + num).show();
    tabsOff(num);
    $('#tabEmail' + num).addClass('tabOn');
    return false;
}

function shareCodeToogle(num) {
    hideTabs(num);
    $('#shareCode' + num).show();
    tabsOff(num);
    $('#tabCode' + num).addClass('tabOn');
    return false;
}

function shareUrlToogle(num) {
    hideTabs(num);
    $('#shareUrl' + num).show();
    tabsOff(num);
    $('#tabEmbed' + num).addClass('tabOn');
    return false;
}

function shareGroupToogle(num) {
    hideTabs(num);
    $('#shareGroup' + num).show();
    tabsOff(num);
    $('#tabGroup' + num).addClass('tabOn');
    return false;
}

function tabsOff(tabSet){
    $('#tabCode' + tabSet).removeClass('tabOn');
    $('#tabEmbed' + tabSet).removeClass('tabOn');
    $('#tabGroup' + tabSet).removeClass('tabOn');
    $('#tabEmail' + tabSet).removeClass('tabOn');
}

function hideTabs(tabSet){
    $('#shareCode' + tabSet).hide();
    $('#shareUrl' + tabSet).hide();
    $('#shareGroup' + tabSet).hide();
    $('#shareEmail' + tabSet).hide();
}


//// this trim was suggested by Tobias Hinnerup
if (!String.prototype.trim) {
    String.prototype.trim = function () {
        return this.replace(/(^\s+)|(\s+$)/g, "");
    }
}
        
        
$(document).ready(function() {
                 
    //call new window function on any <a> with the class of "newWin"
    $('a.newWin').click(function() {
        openWin(this.href);return false;
    });
        
    //rollover code for X close icon
    $('.btnClose').hover(function(){this.src='i/btn_close_over.gif'},function(){this.src='i/btn_close.gif'});


    //$('.addComment').hover(function(){this.src='i/icon_comment_add_on.gif'},function(){this.src='i/icon_comment_add_off.gif'});
        
    //Button Rollover Function
        $('img.hoverBtn').mouseover(function(){
            imgsrc = $(this).attr("src");
            matches = imgsrc.match(/_on/);
            if (!matches) {
                imgsrcON = imgsrc.replace('_off.gif','_on.gif');
                $(this).attr("src", imgsrcON);
            }
        });
        $('img.hoverBtn').mouseout(function(){
            $(this).attr("src", imgsrc);
        });    
            
});
