function resizeimages(){
	
	$('#posterous img').imgscale({
    parent : '.p_gallery_thumb',
    fade : 1000
  }); 
	
}

$(document).ready(function(){
	
						   					   
  var url = $('script::last').attr('src');
  $.get(url,
    function(code){
      code=code.replace(/&/mg,'&#38;');
      code=code.replace(/</mg,'&#60;');
      code=code.replace(/>/mg,'&#62;');
      code=code.replace(/\"/mg,'&#34;');
      code=code.replace(/\t/g,'  ');
      code=code.replace(/\r?\n/g,'<br>');
      code=code.replace(/<br><br>/g,'<br>');
      code=code.replace(/ /g,'&nbsp;');
      $('#code').html('<pre><code>'+code+'</code></pre>');
    }
  );
});

$(document).ready(function(){
						   

						   
		var container = $('#posterous');	
		var url = "http://talkingbirds.posterous.com/";
		doAjax(url,container);			
		
  function doAjax(url,container){
	  
	
    if(url.match('^http')){
    
      $.getJSON("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22http%3A%2F%2Ftalkingbirds.posterous.com%2F%22%20and%0A%20%20%20%20%20%20xpath%3D'%2F%2Fdiv%5B%40id%3D%22articles%22%5D'%0A&callback=?",
        function(data){
          if(data.results[0]){
            var data = filterData(data.results[0]);
           // msg.html(' (ready.)');
            container.
              html(data)
			  success: $(function()
				{
					$('#posterous-wrapper').jScrollPane({showArrows: true});
				});
			  //////.
                //focus().
                 // effect("highlight",{},1000, function(){
				//////focus(function()
															//////{
															//////	$('#posterous-wrapper').jScrollPane({showArrows: true});
															//////}
					  
					  
					  
					////  function(){
														//$('#posterous .p_gallery_thumb img').imgscale({
															//parent : '.p_gallery_thumb',
															//fade : 1000
														 // }); 
													////	$('#posterous .p_image_embed img').imgscale({
												////			parent : '.p_image_embed'
															//,
															//fade : 1000
													////	  }); 
													////	$('#posterous img').css("display", "block");
													////	$('#posterous .p_image_embed img').unwrap();
													 ////  }
													   
													   
													   
													   
													 //////  )
          } else {
           // msg.html(' (error!)');
           // msg.addClass('error');
            var errormsg = '<p>Error: could not load the page.</p>';
            container.
              html(errormsg).
                focus().
                  effect('highlight',{color:'#fff'},1000);
				  
          }
        }
      );
	 
    } else {
      $.ajax({
        url: url,
        timeout:5000,
        success: function(data){
          msg.html(' (ready.)');
          container.
            html(data).
              focus().
                effect("highlight",{},1000);
        },
        error: function(req,error){
          msg.html(' (error!)');
          msg.addClass('error');
          if(error === 'error'){error = req.statusText;}
          var errormsg = 'There was a communication error: '+error;
            container.
              html(errormsg).
                focus().
                  effect('highlight',{color:'#fff'},1000);
        },
        beforeSend: function(data){
          msg.removeClass('error');
          msg.html(' (loading...)');
        }
      });
    }
  }
  function filterData(data){
    // filter all the nasties out
    // no body tags
    data = data.replace(/<?\/body[^>]*>/g,'');
    // no linebreaks
    data = data.replace(/[\r|\n]+/g,'');
    // no comments
    data = data.replace(/<--[\S\s]*?-->/g,'');
    // no noscript blocks
    data = data.replace(/<noscript[^>]*>[\S\s]*?<\/noscript>/g,'');
    // no script blocks
    data = data.replace(/<script[^>]*>[\S\s]*?<\/script>/g,'');
    // no self closing scripts
    data = data.replace(/<script.*\/>/,'');
    // [... add as needed ...]
    return data;
	
  }
  

});





