$('#main_style').after('<link rel="stylesheet" type="text/css" media="all" href="http://www.kiamaindependent.com.au/structure/onload" />');

$(document).ready(function(){

$('a[@rel$="nofollow"]').click(function(){ this.target = "_blank"; });
$('a[@rel$="external"]').click(function(){ this.target = "_blank"; });

$('input:text').hint();

$('.caption').css("opacity","0.75");

$('.email').html('<a href="http://www.kiamaindependent.com.au/">Sign up to our newsletter:</a>');
$('.email').toggle(function(){
	$('.email-input').fadeIn("slow");
	$(this).html('<a href="http://www.kiamaindependent.com.au/"><strong>Your email address:</strong></a>');
},function(){
	$('.email-input').fadeOut('slow');
	$(this).html('<a href="http://www.kiamaindependent.com.au/">Sign up to our newsletter:</a>');
});

$('.bookmark').click(function() {bookmark('Kiama Independent','http://www.kiamaindependent.com.au/');});

// only load options for specific page





/*
Set states if javascript is on
*/
$(".showmore").removeClass("closed");
$(".bottom").hide();

/* 
Show and Hide Comments 
*/
	var total_comments = $('.total_comments').html(); //Get total comments!

	//Insert button into dom
	if( total_comments > 3 ){
		$("hr.comments").after('<a href="http://www.kiamaindependent.com.au/" class="showmore">show comments ('+total_comments+')</a>');
	}
	
	//show .comments_bottom on clicking the .showmore link
	$("a.showmore").click(function(){
		if($(this).html() == 'show comments ('+total_comments+')') {
			$(".bottom").slideDown("slow");
			$(this).html('hide comments ('+total_comments+')');
			$(this).removeClass("showmore");
			$(this).addClass("showless");
		} else {
			$(".bottom").slideUp("slow");
			$(this).html('show comments ('+total_comments+')');
			$(this).removeClass("showless");
			$(this).addClass("showmore");
		}
		return false;
	});

 
/* 
Show and Hide Archive Months 
*/
	$(".archive_list").not('.open').hide();
	
	$('.archive_title').hover(function(){$(this).addClass('hover');},function(){$(this).removeClass('hover');});

	$(".archive_title").click(function(){
		
		// Remove classes
		$(".archive_list").removeClass('current');

		// Add classes
		$(this).next().addClass('current');

		// Create slide effect
		$(".archive_list:visible").not('.current').slideUp("slow");
		$(this).next().slideDown("slow");

		return false;
	});
	
});

/*
Bookmark function
*/
function bookmark(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}