jQuery.fn.SGwordCount = function(params){
	var p = {
		counterElement:"display_count"
	};
	var total_words;
	
	if(params) {
		jQuery.extend(p, params);
	}
	
	//for each keypress function on text areas
	this.bind("input paste",function(){ 
		total_words=(this.value.split(/[\s]+/).length);
		jQuery('#'+p.counterElement).html(total_words);
		if(total_words > 250 && total_words < 501) { 
		jQuery('#countert').addClass('redcountert');
		jQuery('#warn').show();		
		jQuery('#countert, #warn').removeClass('hredcountert');
		jQuery('#huisregels').hide();
		}
		if(total_words > 500) {
                jQuery('#countert, #warn').addClass('hredcountert');
                jQuery('#warn').show();
                jQuery('#huisregels').hide();
                }
		if(total_words <= 250) { 
		jQuery('#countert').removeClass('redcountert');
		jQuery('#countert').removeClass('hredcountert');
		jQuery('#warn').hide();
		jQuery('#huisregels').show();
		}

	});	
};

 jQuery(document).ready(function(){
jQuery('#masthead').click(function(){
window.location.href= "/";
});
jQuery('a.sg-soc').mouseover(function() {
  jQuery(this).parent().find('.sg-soc-tab').slideDown(150);
});
jQuery('a.sg-soc').mouseout(function() {
  jQuery(this).parent().find('.sg-soc-tab').slideUp(150);
});
jQuery('a.sg-soc').attr('target','_blank');

jQuery(".sg-arch>a").click(function(event){
jQuery(this).parent().children("ul").addClass("sg-arch-x");
jQuery(this).parent().children("ul").removeClass("sg-arch");
jQuery("ul.sg-arch-x").slideDown("slow");
jQuery("ul.sg-arch").slideUp("slow");
jQuery(this).parent().children("ul").addClass("sg-arch");
jQuery(this).parent().children("ul").removeClass("sg-arch-x");
event.preventDefault();
}); 
jQuery('#sg-submit').attr('disabled', 'disabled');
jQuery('.poll-options').change(function() {
  jQuery('#poll-comment').val(jQuery(this).val());  
  jQuery('#sg-submit').removeAttr('disabled');
  jQuery('#sg_poll .button').removeClass('disabled');
});

jQuery('#sg-results').click(function() {
  jQuery('#poll-results').css('display','block')
  jQuery('#poll-respond').css('display','none')
  jQuery('#sg-results').css('display','none')
  jQuery('#sg-stem').css('display','inline')
  return false;
});
 
jQuery('#sg-stem').click(function() {
  jQuery('#poll-results').css('display','none')
  jQuery('#poll-respond').css('display','block')
  jQuery('#sg-results').css('display','inline')
  jQuery('#sg-stem').css('display','none')
  return false;
});


jQuery("div.entry-content").find("p:first a.more-link").css('margin-top','30px');
jQuery("select, input:checkbox, input:radio, input:file, input:submit, input:button").uniform();

jQuery(".tt").click(function(e){
e.preventDefault();
jQuery(".tt").removeClass("tt-sel");
jQuery(this).addClass("tt-sel");
jQuery("#tt-frame").attr("src","/wp-content/plugins/StaatGeschreven/trending-topic.php?s="+escape(jQuery(this).text()));
if(jQuery("#tt-container").is(":hidden")){
jQuery("#tt-container").slideDown();

}
});
jQuery('#tt-slideup').click(function(){
jQuery("#tt-container").slideUp();
jQuery(".tt").removeClass("tt-sel");
});

jQuery('.word_count').SGwordCount();
jQuery('.comment-less').children('p').last().append('<span class="comment-punt">...</span>');


jQuery('.comment-klik').click(function(e){
e.preventDefault();
var str = jQuery(this).parent().children('.comment-more').children('p').first().text();
jQuery(this).parent().children('.comment-more').children('p').first().remove();
jQuery(this).parent().children('.comment-less').children('p').last().append(str);
jQuery(this).parent().find('.comment-punt').remove();
jQuery(this).parent().find('.comment-place').show();
jQuery(this).parent().find('.comment-more').slideDown();
jQuery(this).fadeOut();
});

if(jQuery('div#sg_melding').length != 0 && jQuery.cookie('sg_melding') != 'weg')
{
jQuery('div#sg_melding').delay(700).slideDown();
}

jQuery('#sg_melding_weg').click(function(){
jQuery('div#sg_melding').slideUp();
jQuery.cookie('sg_melding','weg');
});

});


