// creator Katz Web Services
(function ($) {
// VERTICALLY ALIGN FUNCTION
$.fn.vAlign = function() {
	return this.each(function(i){
	var ah = $(this).height();
	var ph = $(this).parent().height();
	var mh = (ph - ah) / 2;
	$(this).css('padding-top', mh);
	});
};
})(jQuery);

$(document).ready(function() {	
	// target="_blank"
	$("a[rel='nofollow'], a[rel='external'], a[rel='map']").click( function() {
		if ($(this).attr('rel') == 'map')
        	window.open(this.href, "Gynics Map", "width=700,height=600");
        else
        	window.open(this.href);
        return false;
    });
    
    // scroll to same-page anchors
	 $('a[href^=#]:not(.noscroll)').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
		&& location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top - 100;
				$('html,body').animate({scrollTop: targetOffset}, 1000);
			  return false;
			}
		}
	});
	
	var t = setTimeout(function() {
		if ($('.fb_iframe_widget').length > 0)
		{
			$("#home #content .main").vAlign();
			clearTimeout(t);
		}
	},100);
});
