/**
 * jQuery - Plugin and Function
 */

/**
 * NewWinOpen v1.0
 *
 * Copyright (c) 2009 Rewish (http://rewish.org/)
 * Dual licensed under the MIT and GPL licenses.
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.opensource.org/licenses/gpl-license.php
 *
 * Date: 2009-02-09 13:00
 *
 */
(function($) {
	/**
	 * Google Analytics
	 *
	 * @param string ga_code
	 */
	$.googleAnalytics = function(ga_code) {
		var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
		jQuery.getScript(gaJsHost + "google-analytics.com/ga.js", function()
		{
			var pageTracker = _gat._getTracker(ga_code);
			pageTracker._trackPageview();
		});
	}

	$.fn.NewWinOpen = function(option) {
		$(this).click(function() {
			if (option != null) {
				window.open(this.href, null, option);
			} else {
				window.open(this.href, null);
			}
			return false;
		});
	}

	$.fn.rollover = function(postfix) {
		postfix = (postfix != null) ? postfix : '_on';
		return this.not('[src*="'+ postfix +'."]').each(function() {
			var img = $(this);
			var src = img.attr('src');
			var src_on = src.substr(0, src.lastIndexOf('.'))
			           + postfix
			           + src.substring(src.lastIndexOf('.'));
			$('<img>').attr('src', src_on);
			img.hover(
				function() {
					img.attr('src', src_on);
				},
				function() {
					img.attr('src', src);
				}
			);
		});
	};
})(jQuery);

