// cleans broken links and spacer gifs
// put a class of keep on your links to keep the text but remove the clickyness
$(document).ready(function(){
	var KEEP_CLASS = "keep";
	$('a').each(function(index) {
		var link = $(this);
		var l = link.attr('href');  
		// if link hrefs are empty hide them
		// or remove the a tag if class is "keep"
		
		if(!l){
			if(link.hasClass("keep")){
				link.replaceWith("" + link.text() + "");
			}else{
				$(this).hide();
			}
		}
	});

	//hide spacer gifs from cms
	$('img').each(function(index) {
		var thisItemsClass = $(this).attr('class');
		if (thisItemsClass != KEEP_CLASS) {
			var s = $(this).attr('src');
			if(s.indexOf('spacer.gif') != -1) $(this).remove();
		}
	});
	
	// put a class of ifExists on items with the attribute you are checking for in the rel attribute
	$('.ifExists').each(function() {
		if ((!$(this).attr('rel')) || ($(this).attr('rel') == '/echotools/images/spacer.gif')) {
			$(this).remove();
		}	
	});
	
});

function log(d){
	try{
		console.log(d);
	}catch(e){
		
	}
}

function spawnWindow(url,name,w,h){
	if(w == undefined) w = 320;
	if(h == undefined) h = 240;
	if(name == undefined) name = "popWindow";
	var newWindow = window.open(url,name,"toolbar=0,scrollbars=1,resizable=1,width="+w+",height="+h+"\"");		
 }
 function spawnJukebox(){
	var newWindow = window.open("content/jukebox.php",'jb',"toolbar=0,scrollbars=1,resizable=1,width=300,height=250");		
 }
