// JavaScript Document



	function URLEncode (clearString) {
	  var output = '';
	  var x = 0;
	  clearString = clearString.toString();
	  var regex = /(^[a-zA-Z0-9_.]*)/;
	  while (x < clearString.length) {
		var match = regex.exec(clearString.substr(x));
		if (match != null && match.length > 1 && match[1] != '') {
			output += match[1];
		  x += match[1].length;
		} else {
		  if (clearString[x] == ' ')
			output += '+';
		  else {
			var charCode = clearString.charCodeAt(x);
			var hexVal = charCode.toString(16);
			output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
		  }
		  x++;
		}
	  }
	  return output;
	}


	function URLDecode (encodedString) {
	  var output = encodedString;
	  var binVal, thisString;
	  var myregexp = /(%[^%]{2})/;
	  while ((match = myregexp.exec(output)) != null
				 && match.length > 1
				 && match[1] != '') {
		binVal = parseInt(match[1].substr(1),16);
		thisString = String.fromCharCode(binVal);
		output = output.replace(match[1], thisString);
	  }
	  return output;
	}
	





function popFeed(zeURL) {
	var n=window.open(zeURL,'popup','width=655,height=610,scrollbars=1,resizable=1');
	try {n.focus();} catch(e) {}
}

function showNoise(zeURL) {
	var n=window.open(zeURL,'popup','width=450,height=200');
	try {n.focus();} catch(e) {}
}


$(document).ready(function(){


	//zebra stripe table rows
	$(".stripeMe div:odd").addClass("alt");

	var resizeFrame = function(){
		var zeNewChangingHeight = $('#zePodcastsContent').height();
		$('#zePodcastsContainer').stop(true, true).animate({height: zeNewChangingHeight},65);
	}


	// show/hide
	$('.showHideItem div.showMe').hide();
	$('.showHideItem h2').bind('click', function() {
		$(this).siblings('div.showMe').stop(true, true).slideToggle(250, resizeFrame);
		var toggleImage = $('img', this).attr('src');
		$(this).find('img').attr('src', toggleImage == '/_img/icon.less.png' ? '/_img/icon.more.png': '/_img/icon.less.png').end();
		
	});
	
	
	
	
	
	$('#expandHideAll p').mouseenter(function(){
			$(this).stop(true, true).animate({opacity:'0.25'},100).stop(true, true).animate({opacity:'1'},350);
		}).bind('click',function() {
			$('.wharf').toggle();
	});
	
	$('#expandMe').bind('click',function() {
			$('.showMe').show(0, resizeFrame);
			$('.showHideItem h2').find('img').attr('src', '/_img/icon.less.png').end();
	});
	
	$('#hideMe').bind('click',function() {
			$('.showMe').hide(0, resizeFrame);
			$('.showHideItem h2').find('img').attr('src', '/_img/icon.more.png').end();
	});
	
	
	
	
	
	
	
	
	var tabQueryStart = location.search.indexOf("tab=");
		var tabQuery = "";
		if (tabQueryStart > -1) {
			var multipleQuery = location.search.indexOf("&", tabQueryStart);
			if (multipleQuery > -1) {
				var tabQuery = location.search.substring(tabQueryStart+4, multipleQuery);
			}
			else {
				var tabQuery = location.search.substring(tabQueryStart+4);
			}
		}
		
	
	
	function scrollOverThere(){
		var target_offset = $("#"+tabQuery).offset();
		var target_top = target_offset.top;

		//goto that anchor by setting the body scroll top to anchor top
		$('html, body').animate({scrollTop:target_top}, 0);
	}
	
	
	
	
	if (tabQuery.length) { // if there is a tab specified
			//$('#'+ tabQuery).siblings('.showHideItem h2').find('img').attr('src', '/_img/icon.less.png').end();
			//$('#'+ tabQuery).siblings('div.showMe').stop(true, true).slideToggle(250, resizeFrame);
			$('.showMe').show(0, resizeFrame);
			$('.showHideItem h2').find('img').attr('src', '/_img/icon.less.png').end();
			scrollOverThere();
			$('.wharf').toggle();
		}
		else {
		
		}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
		//console.log($('div.showMe'));
	
	
});
