if (top.location != location) {
	top.location.href = document.location.href;
}

function textCounter(field, countfield, maxlimit, displayIn) {

	if (field.value.length > maxlimit) {
		field.value = field.value.substring(0, maxlimit);
	} 
	else{
		jQuery('#'+countfield).text((maxlimit - field.value.length));
	}
	
}


jQuery(document).ready(function(){
	if(typeof post_load == 'function') {
		post_load(); // load the stuff in loader.js
	}
	jQuery('#success, #error').click(function(){
		jQuery(this).fadeOut()
		jQuery('#' + jQuery(this).attr('id') + '-bottom').fadeOut()
	});
	jQuery('#navigation a').click(function(){
		jQuery(this).parent().removeClass('dashboard').removeClass('register').addClass('active').siblings().removeClass('active');
	});

	// this function soft scrolls the window when you hit to top of page
	$('#topofpage').click(function() {
	
		var $target = $(this.hash);
		
		$target = $target.length && $target || $('[name=' +  this.hash.slice(1) + ']');
		
        if ($target.length) {
            var targetOffset = $target.offset().top;
            $('html,body').animate({scrollTop: targetOffset}, 1000);
            return false;
        }

	
	});
	
	// this is for the mainmenu
	$('#navigation ul li').each(function() {
		$(this).hover(function() {
			$(this).addClass("sfhover");
		},function() {
			$(this).removeClass("sfhover");
		});
	});


	$("a.zoom").each(function(){
		$(this).fancybox();
	});
		
});


