var $jslide = jQuery.noConflict();
function goTo(ancre){
		
		jQuery('html,body').animate({scrollTop:jQuery(ancre).offset().top},1000,'swing',function(){
	            if(ancre != 'body')
	                window.location.hash = ancre;
	            else
	                window.location.hash = '#';
	            jQuery(ancre).attr('tabindex','-1');
	            jQuery(ancre).focus();
	            jQuery(ancre).removeAttr('tabindex');
	        });
	    }

$jslide(document).ready(function() {



$jslide('.post').each(function(){

// initialise the visibility check
var is_visible = false;

// append show/hide links to the element directly preceding the element with a class of "toggle"
txt = $jslide(this).children('.entry').children('.toggle').children('.more').text();
if(txt != "") showText = txt;
//$jslide('.toggle').next('.bottom').append(' <a href="#" class="toggleLink">'+showText+'</a>');
$jslide(this).children('.entry').children('.toggle').next('.bottom').append('<a href="#" class="toggleLink">'+showText+'</a>');


// hide all of the elements with a class of 'toggle'
//$jslide('.toggle').hide();

$jslide(this).children('.entry').children('.toggle').hide();

// capture clicks on the toggle links
//$jslide('a.toggleLink').click(function() {
$jslide(this).children('.entry').children('.bottom').children('a.toggleLink').click(function() {

// switch visibility
is_visible = !is_visible;
postid = $jslide(this).parent().parent().parent().attr('id');

if(!is_visible){
	ancre = "#"+postid;
 	//self.location.hash="#"+postid;
	goTo(ancre);
}
else {
	ancre = "#"+postid+"-more";
	goTo(ancre);
}

// change the link depending on whether the element is shown or hidden
$jslide(this).html( (!is_visible) ? showText : hideText);

// toggle the display - uncomment the next line for a basic "accordion" style
// (is_visible) ? $jslide(this).parent().next('.toggle').slideDown(1000):$jslide(this).parent().next('.toggle').slideUp(1000);
 (is_visible) ? $jslide(this).parent().prev('.toggle').slideDown(1000):$jslide(this).parent().prev('.toggle').slideUp(1000, function() {
 $jslide(this).parent().prev('.toggle').css("display","none");
 $jslide("#main").css("height","auto");
  });
//self.location.hash=#ancre;



// return false so any link destination is not followed
return false;

});
});
});




