$(function() {
	$('a').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			var target = $(this).attr("href");
            target = $(target);
			target = target.length && target;
			if (target.length) {
				var sclpos = 30;
				var scldurat = 1200;
				var targetOffset = target.offset().top - sclpos;
				$('html,body')
					.animate({scrollTop: targetOffset}, {duration: scldurat, easing: "easeOutExpo"});
				return false;
			}
		}
	});
});

$.auto = {
	init: function() {
		for (module in $.auto) {
			if ($.auto[module].init)
				$.auto[module].init();
		}
	}
};

$(document).ready($.auto.init);

$.auto.hide = {
	init: function() {
		$('.Hide').hide();
	}
};

$.auto.hover = {

	init: function() {
		$('IMG.Hover')
			.bind('mouseover', this.enter)
			.bind('mouseout', this.exit)
			.each(this.preload);
	},

	preload: function() {
		this.preloaded = new Image;
		this.preloaded.src = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1_over$2");
	},

	enter: function() {
		this.src = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1_over$2");
	},

	exit: function() {
		this.src = this.src.replace(/^(.+)_over(\.[a-z]+)$/, "$1$2");
	}
};

$.auto.submit = {
	init: function() {
		$('SELECT.Submit').bind('change', this.on_change);
	},

	on_change: function() {
		if (this.value) this.form.submit();
	}
};

$.auto.select = {
	init: function() {
		$('LABEL.Select').each(this.label_action);
		$('INPUT.Select').bind('click', function(){ this.select(); });
	},

	label_action: function() {
		var field = $('#'+this.htmlFor).get(0);
		if (field && field.focus && field.select) {
			$(this).bind('click', function(){ field.focus(); field.select(); });
		}
	}
};

$.auto.tabs = {

	init: function() {

		$('.Tabs').each(function(){
			var f = $.auto.tabs.click;
			var group = this;
			$('.Tab', group).each(function(){
				this.group = group;
				$(this).click(f);
				$('#'+this.id+'_body').hide();
			}).filter(':first').trigger('click');
		});

	},

	click: function() {
		var tab = $('#'+this.id+'_body').get(0);
		$('.Tab', this.group).each(function(){
			$(this).removeClass('Active');
			$('#'+this.id+'_body').hide();
		});

		$(this).addClass('Active');
		$(tab).show();
		this.blur();

		return false;
	}

};

$(function(){
$('.popup').click(function(){

var myid = $(this).parent().attr('id');
//alert(myid);
var url = $(this).parent().get(0).action;
var windownames = "win"+myid;

window.open(url,windownames,"width=700,height=500, menubar=no, toolbar=no, scrollbars=yes");
return false;
});
});

$(function(){
$('.close').click(function(){
    window.close();
});
});


/**
 * .disableTextSelect - Disable Text Select Plugin
 *
 * Version: 1.1
 * Updated: 2007-11-28
 *
 * Used to stop users from selecting text
 *
 * Copyright (c) 2007 James Dempster (letssurf@gmail.com, http://www.jdempster.com/category/jquery/disabletextselect/)
 *
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 **/

/**
 * Requirements:
 * - jQuery (John Resig, http://www.jquery.com/)
 **/
(function($) {
    if ($.browser.mozilla) {
        $.fn.disableTextSelect = function() {
            return this.each(function() {
                $(this).css({
                    'MozUserSelect' : 'none'
                });
            });
        };
        $.fn.enableTextSelect = function() {
            return this.each(function() {
                $(this).css({
                    'MozUserSelect' : ''
                });
            });
        };
    } else if ($.browser.msie) {
        $.fn.disableTextSelect = function() {
            return this.each(function() {
                $(this).bind('selectstart.disableTextSelect', function() {
                    return false;
                });
            });
        };
        $.fn.enableTextSelect = function() {
            return this.each(function() {
                $(this).unbind('selectstart.disableTextSelect');
            });
        };
    } else {
        $.fn.disableTextSelect = function() {
            return this.each(function() {
                $(this).bind('mousedown.disableTextSelect', function() {
                    return false;
                });
            });
        };
        $.fn.enableTextSelect = function() {
            return this.each(function() {
                $(this).unbind('mousedown.disableTextSelect');
            });
        };
    }
})(jQuery);

(function($) {
	$.fn.equalHeights = function(Height) {
		Height = (Height) ? Height : 0;
        Height = (1717 > Height) ? Height-210 : Height;
        
		return this.each(function() {
			$(this).height(Height).css("overflow","visible");
		});
	}
})(jQuery);

$(function(){
    var h = Math.max( document.body.clientHeight , document.body.scrollHeight );   
    h = Math.max( h , document.documentElement.scrollHeight );   
    h = Math.max( h , document.documentElement.clientHeight ); 
    $('.topicsheight').equalHeights(h);
    });