$(document).ready(function () {

check_location_href();
convert_a();

var odata='';
read_more(); 
});
function convert_a(){

    $('a').not('a[href^="http://"]').not(".a_converted").not('.external').not('a[href^="#"]').each(function() {
	var a=$(this);
	a.attr('href',"#page="+a.attr('href'));
	a.addClass('a_converted');
	a.click(function() {location.href=$(this).attr('href');check_location_href();return false;});
    });

}

function check_location_href() {
if (!(location.hash.match(/^#page=/))) {return};
hash=location.hash + '';
current=$('#current_page_name').text().replace(/\n/g,'');
hash=hash.replace(/#page=/,'');
if (hash==current) {return}
$('#current_page_name').text(hash);
$.get(hash,function(data) {
var button=$("#read_more");
button.remove();
data=data.replace(/<html[^>]*>/,'');
data=data.replace(/<head>.*<\/head>/,'');
data=data.replace(/<body[^>]*>/,'');
data=data.replace(/<\/body>/,'');
data=data.replace(/<\/html>/,'');

//$('#pre_display_area').html(data);
var initme;
var content=$(data).find('.content').first();

if (content.length==0) {content=$(data).find('div').html();}
//alert (content);
//$('#pre_display_area').html('');
$('.content').first().hide();
setTimeout(function() {
//Edited by fyrye - 6/29/2010 Fixed flaw where this element would inherit the content element instead of the content element's HTML
$('.content').first().html(content.html());
$(content).find('.radio_feed').first().each(function() 
{
//url=$(this).find('#url').html();
//pref=$(this).find('#preferences');
initradio();
});

//$('.content').find('.radio_feed').remove();
$('.content').first().hide();
$('.content').first().css('display','block');
read_more();
//Edited by fyrye - 6/25/2010 get rid of reveal effect
//$('.content').first().css('display','none');
//$('.content').first().slideDown();
convert_a();
},200);

}

)
}

function LoadFeeds() {
feedobj=$('.content .radio_feed #url');
feedurl=feedobj.text();
$('.content .radio_feed').remove();

var feed = new google.feeds.Feed(feedurl);
 feed.includeHistoricalEntries();
 feed.setNumEntries(250);
 feed.load(feedLoaded);

}

function feedLoaded(result) {
if (!result.error) {
var newhtml='';
var container =$("#feed-control");
for (var i = 0; i < result.feed.entries.length; i++) {
var entry = result.feed.entries[i];
var comment=entry.title;
var mp3=entry.link;
newhtml+='<script type="text/javascript">'+
"AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0','width','30','height','30','id','Healer','src','http://www.parkavenuediet.com/wimpy_button','flashvars','theFile="+mp3+"&buttonStyle=square&wimpyReg=10wtkyh&myid=Healer','bgcolor','#FFFFFF','loop','false','menu','false','quality','high','name','LRRH','align','middle','allowscriptaccess','sameDomain','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','http://www.parkavenuediet.com/wimpy_button' ); //end AC code"+
'</script><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="30" height="30" id="Healer">'+
'<param name="movie" value="http://www.parkavenuediet.com/wimpy_button.swf" />'+
'<param name="loop" value="false" />'+
'<param name="menu" value="false" />'+
'<param name="quality" value="high" />'+
'<param name="bgcolor" value="#FFFFFF" />'+
'<param name="flashvars" value="theFile=http://www.parkavenuediet.com/audio/Healer.mp3&buttonStyle=square&wimpyReg=10wtkyh&myid=Healer" />'+
'<embed src="http://www.parkavenuediet.com/wimpy_button.swf" flashvars="theFile='+mp3+'&buttonStyle=square&wimpyReg=10wtkyh&myid=Healer" width="30" height="30" bgcolor="#FFFFFF" loop="false" menu="false" quality="high" name="Healer" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>'+comment+'<br>';
}
container.html(newhtml);
}
}

function LoadDynamicFeedControl() {
feedobj=$('.content .radio_feed #url');
feedurl=feedobj.text();
$('.content .radio_feed').remove();
//    alert(feed);
     var feeds = [{title: 'Shows:',
	url:feedurl
	}];
//var feeds = [
//{title: 'Google Sites - Bug blog',
//url: 'http://www.goopal.org/goopal---google-sites-vs-drupal/bugs/posts.xml'
//}];
//google.feeds=feeds;
      var options = {
        stacked : false,
        horizontal : false,
        title : "",
	feedTransitionCallback: radio_parse,
	feedLoadCallback: loadcallback
      };

      new GFdynamicFeedControl(feeds, 'feed-control', options);
}
    // Load the feeds API and set the onload callback.
function initradio() {
//    if (! $.browser.msie) {google.setOnLoadCallback(LoadDynamicFeedControl)} else {
//    	setTimeout(LoadDynamicFeedControl,200)}
LoadFeeds();

}
function loadcallback(feed) {
var url=feed.url;
}
function radio_parse() {
	setTimeout(function() {	$('.gfg-listentry').find('a[href$="mp3"]').each(function () {
var mp3=$(this).attr('href');
var comment=$(this).html();
var par=$(this).parent();
var newhtml='<script type="text/javascript">'+
"AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0','width','30','height','30','id','Healer','src','http://www.parkavenuediet.com/wimpy_button','flashvars','theFile="+mp3+"&buttonStyle=square&wimpyReg=10wtkyh&myid=Healer','bgcolor','#FFFFFF','loop','false','menu','false','quality','high','name','LRRH','align','middle','allowscriptaccess','sameDomain','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','http://www.parkavenuediet.com/wimpy_button' ); //end AC code"+
'</script><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="30" height="30" id="Healer">'+
'<param name="movie" value="http://www.parkavenuediet.com/wimpy_button.swf" />'+
'<param name="loop" value="false" />'+
'<param name="menu" value="false" />'+
'<param name="quality" value="high" />'+
'<param name="bgcolor" value="#FFFFFF" />'+
'<param name="flashvars" value="theFile=http://www.parkavenuediet.com/audio/Healer.mp3&buttonStyle=square&wimpyReg=10wtkyh&myid=Healer" />'+
'<embed src="http://www.parkavenuediet.com/wimpy_button.swf" flashvars="theFile='+mp3+'&buttonStyle=square&wimpyReg=10wtkyh&myid=Healer" width="30" height="30" bgcolor="#FFFFFF" loop="false" menu="false" quality="high" name="Healer" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>'+comment;

$(this).replaceWith(newhtml);


})},200);
}

//EDITED BY fyrye - 6/25/2010
//GET RID OF THE READ MORE BUTTON, Switch to style="overflow-y: scroll;" on index.php
function read_more() {
return;
var c=$('.content').first();
c.height('auto');

var hh=c.height();
var h=($(window).height()-$('#Footer').height()-$('.main_banner').height()-20);
h=400;

if (c.height()>h && c.height() >311) {
c.height(h+30);
c.css('overflow','hidden');



var button=$('<div style="position:relative" id="read_more"><a class="a_converted" href="javascript:return false"> Read_more<a></div>');
c.parent().append(button);
button=$("#read_more");
button.css('top',-(hh-h-10));
button.click(function (){button.remove();c.css('height','auto')})

var topp=$('#Footer img').first().position().top;
var left=$('#Footer img').first().position().left;

button.css('position','absolute');
button.css('top',topp-30);
button.css('zindex',999);


}
}
