function checkEnter(e){ //e is event object passed from function invocation
    var characterCode; //literal character code will be stored in this variable

    if(e && e.which){ //if which property of event object is supported (NN4)
            e = e;
            characterCode = e.which; //character code is contained in NN4's which property
    }
    else{
            e = event;
            characterCode = e.keyCode; //character code is contained in IE's keyCode property
    }

    if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
            bloginfo(); //submit the form
            return false;
    }
    else{
            return true;
    }
}

function toggleArtist(){
    $("#artists ul li div").each( function(){
        $(this).hide();
        
    });
    $(this).find("div").show();
}

function toggleVideoBGon(){
    var id = this.id;
    id = id.replace("vid","");
    this.style.backgroundImage = "url(/images/vid-numbers/5E7A8F-" + id + ".png)";
}

function toggleVideoBGoff(){
    var id = this.id;
    id = id.replace("vid","");
    this.style.backgroundImage = "url(/images/vid-numbers/4E6577-" + id + ".png)";
}

function redirect(type,id,blog_id,url){
    var post = id;
    post = post.replace('item','');
    post = post.replace('image','');
    post = post.replace('mp3','');
    var url ='/redirect/' + type + '/' + post  + '/?u=' + escape(url) + '&f_id=' + blog_id;
    return url;
}

function bloginfo() {
    var url = $("#url").val();
    if(url.length > 0) {        
        $("#blogform").html('<div style="padding: 50px;"><img src="/img/lime-load.gif"/> Loading...</div>');
        $("#blogform").load('/includes/ajax_functions.php?function=bloginfo&url=' + url);
    }
}

function fillStripSearch(sbox,focus){
    if(focus){
        if(sbox.value == 'Search Elbows...'){
            sbox.value = '';
            sbox.style.color = '#000';
        }
    } else {
        if(sbox.value == ''){
            sbox.value = 'Search Elbows...';
            sbox.style.color = '#999';
        }
    }
}

$(document).ready(function () {    

    //show artist pane
    $("#artists ul li").click(toggleArtist);
    
    //hot video rollovers
    $("#divHotVideos a").hover(toggleVideoBGon,toggleVideoBGoff);
    
    //remove blank thumbs
    $(".thumbnail img").each(function(){
        if($(this).width() == 1){
            $(this).remove();
        }
    });
    
    var hh = new HelpHover();
    hh.init();
  
    //$("a.lightbox").lightbox();
});
