$(document).ready(function() {
	$('#slideholder:eq(0)> div.slider').hide();
	$('.leavecomments').hide();
	
	$("img").lazyload();
	
	var showCommText="show comments";
	var hideCommText="hide comments";
	
    // automatically create external link class and open in new window if link is not local or ID anchor
    $("a[@href^='http']").not("[@href*=http://jaypremack.net]").not("[href^=#]").addClass("external").attr('target','_blank');

  
	$('#toggle1').click(function() { 
		
		if ($('div.slider:eq(1)').is(":visible")) {
			
			$('div.slider:eq(1)').hide();
		};
		
		$('div.slider:eq(0)').slideToggle('slow');
			sIFR.replace(sanscaps, {
			selector: 'h4',
			wmode: 'transparent',
			fitExactly: true,
			css: '.sIFR-root { color: #efefef; font-size: 30px; font-weight: normal; margin: 0; padding-right: 25px; }'
			});
	});
	
	$('#close1').click(function() { 
				$('div.slider:eq(0)').slideToggle('normal');
	});
	
	
	$('a.togcommform').click(function() {
		var id = $(this).attr('id'); 	
		$('#commentform' + id).slideToggle('normal');
		return false;	
	});
	
	$('a.togcomm').click(function() {
		var cid = $(this).attr('name'); 	
		$('#allcomments' + cid).slideToggle('normal');
		
		// change the link text
		if ($('.vertical_status'+ cid).html()==hideCommText) {
		$('.vertical_status'+ cid).html(showCommText);
		}
		else {
		$('.vertical_status'+ cid).html(hideCommText);
		}
		return false;
	
	});

	
		
	
	$('#toggle2').click(function() {
		if ($('div.slider:eq(0)').is(":visible")) {
			
			$('div.slider:eq(0)').hide();
		};
		
		$('div.slider:eq(1)').slideToggle('slow');
		
		sIFR.replace(sanscaps, {
		selector: 'h4',
		wmode: 'transparent',
		fitExactly: true,
		css: '.sIFR-root { color: #efefef; font-size: 30px; font-weight: normal; margin: 0; padding-right: 25px; }'
		});
	});
	
	$('#close2').click(function() { 
				$('div.slider:eq(1)').slideToggle('normal');
	});
	
});