$.fn.search = function(o) {

    var o = jQuery.extend({
        text: ''
    }, o);

    var obj = $(this);

    obj.val(o.text).bind('focus', function() {
        if (obj.val() == o.text)
            obj.val('');
    }).bind('blur', function() {
        if (obj.val() == '')
            obj.val(o.text);
    });
}

$.fn.typeselect = function(o) {

    var obj = $(this);
    var a = $('#all', obj);
    var c = $('#categories', obj);
    var t = $('.types');
    var b = $('.setfilter');

    a.bind('click', function() {
        t.hide();
        b.hide();
    });

    c.bind('click', function() {
        t.show();
        b.show();
    });
}

$('div.tabs > ul').delegate('li:not(.current)', 'click', function() {
    $(this)
        .addClass('current')
        .siblings()
        .removeClass('current')
        .parents('div.tabs')
        .find('div.box')
        .hide()
        .eq( $(this).index() )
        .show();
})

    
$(document).ready( function() {

    DD_belatedPNG.fix('a, img, h1, span, div, li, dt, dd, .png');

    $('.random-project .carousel').jCarouselLite({
        btnNext: '.random-project .scroll-right a',
        btnPrev: '.random-project .scroll-left a',
        visible: 1,
        mouseWheel: true
    });

    $('input[name="search"]').search();

    $('ul.show').typeselect();

/*
    // add a "rel" attrib if Opera 7+
    if(window.opera) {
        if ($("a.bookmark").attr("rel") != ""){ // don't overwrite the rel attrib if already set
            $("a.bookmark").attr("rel","sidebar");
        }
    }

    $("a.bookmark").click(function(event){
        event.preventDefault(); // prevent the anchor tag from sending the user off to the link
        var url = this.href;
        var title = this.title;

        if (window.sidebar) { // Mozilla Firefox Bookmark
            window.sidebar.addPanel(title, url,"");
        } else if( window.external ) { // IE Favorite
            window.external.AddFavorite( url, title);
        } else if(window.opera) { // Opera 7+
            return false; // do nothing - the rel="sidebar" should do the trick
        } else { // for Safari, Konq etc - browsers who do not support bookmarking scripts (that i could find anyway)
             alert('Unfortunately, this browser does not support the requested action,'
             + ' please bookmark this page manually.');
        }

    });
    * 
*/
});



function addBookmark(url, title) {
    if (!url) url = location.href;
    if (!title) title = document.title;
    if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) window.sidebar.addPanel (title, url, "");
    else if (typeof window.external == "object") window.external.AddFavorite(url, title);
    else if (window.opera && document.createElement) {
        var a = document.createElement('A');
        if (!a) return false; //IF Opera 6
        a.setAttribute('rel','sidebar');
        a.setAttribute('href',url);
        a.setAttribute('title',title);
        a.click();
    }
    else return false;
}

