function swap_text(id, text, style, on_style)
{
    e = document.getElementById(id);
    e.className = on_style;
    if (e.value == '' || e.value == text) {
        e.value = '';
    };
    e.onblur = new Function("e = document.getElementById('"+id+"');if (e.value == '') {e.className = '"+style+"';e.value='"+text+"'}");
}

function hide_objects()
{
    els = $$('select');
    for (i in els) {
        if (els[i].style) {
            els[i].style.visibility = "hidden";
        }
    }
}

function show_objects()
{
    els = $$('select');
    for (i in els) {
        if (els[i].style) {
            els[i].style.visibility = "visible";
        }
    }
}

function trackLink(url, event) {
    urchinTracker(event);
    self.location = url;
}

function dollar_format(amount) {
    amount = parseFloat(amount);
    var sign = amount < 0 ? '-' : '';
    return sign + '$' + Math.abs(amount).toFixed(2);
}

function noDoubleClick(id,url, text)
{
    if (text == null) {
        text = "Processing, please wait...";
    }
    e = document.getElementById(id);
    e.innerHTML = "<span id=\""+id+"\">"+text+"</span>";
    //javascript redirect is required by ie. 
    if(url)
        window.location = url;
    return true;
}

//
// addLoadEvent()
// Adds event to window.onload without overwriting currently assigned onload functions.
// Function found at Simon Willison's weblog - http://simon.incutio.com/
//
function addLoadEvent(func)
{
    var oldonload = window.onload;
    if (typeof window.onload != 'function'){
        window.onload = func;
    } else {
        window.onload = function(){
        oldonload();
        func();
        }
    }

}

function WinOpen(mypage, myname, w, h, winl, wint, scroll) { 
    var wint = (screen.height - h) / 2;
    if (winl = 0 ){
        var winl = (screen.width - w) / 2 + winl;
    } else {
        var winl = (screen.width - w) / 2;
    }

    winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl
       + ',scrollbars='+scroll+',resizable=no, horizontalscrollbar=no, screenX='
       +winl+',screenY='+wint+'';
    win = window.open(mypage, myname, winprops);
    if (parseInt(navigator.appVersion) >= 4) {
        win.window.focus();
    }
}

// hides shopping shortcuts
function hideShoppingShortcuts(){
    new Effect.BlindUp('shopping_shortcuts_content', {duration: 0.3}); 
    $('shopping_shortcuts_menu').innerHTML = "<a href='#' id='shopping_shortcuts_btn' onclick='showShoppingShortcuts();return false;'>"
                                           + "<img src='/images/shopping_shortcuts/show.jpg' id='shopping_shortcuts_btnimg' /></a>'";
}

// shows shopping shortcuts
function showShoppingShortcuts(){
    new Effect.BlindDown('shopping_shortcuts_content', {duration: 0.3}); 
    $('shopping_shortcuts_menu').innerHTML = "<a href='#' id='shopping_shortcuts_btn' onclick='hideShoppingShortcuts();return false;'>"
                                           + "<img src='/images/shopping_shortcuts/hide.jpg' id='shopping_shortcuts_btnimg' /></a>'";
}
