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 redirectPost(){
	var post = this.id;
	post = post.replace("post-","");
	top.location.href='/redirect/posts/' + post  + '/';
	return false;
}

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 redirectItem(){
	var id = this.id;
	id = id.replace('item','');
	id = id.replace('image','');
	top.location.href='/redirect/items/' + id + '/';
	return false;
}

function redirectMP3(){
	var id = this.id;
	top.location.href='/redirect/mp3s/' + id.replace('mp3','') + '/';
	return false;
}

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);
    
    //add mp3 redirects
    $(".lnk-mp3").click(redirectMP3);
    
    //add item redirects
    $(".lnk-item").click(redirectItem);
	
    //remove blank thumbs
    $(".thumbnail img").each(function(){
    	if($(this).width() == 1){
    		$(this).remove();
    	}
    });
    
	var hh = new HelpHover();
	hh.init();
  
   	//$("a.lightbox").lightbox();
});