/**
 * jQuery - Plugin and Function
 */


/**
 * Google Analytics
 *
 * @param string ga_code
 */
function MyGoogleAnalytics(ga_code)
{
	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
	$.getScript(gaJsHost + "google-analytics.com/ga.js", function()
	{
		var pageTracker = _gat._getTracker(ga_code);
		pageTracker._trackPageview();
	});
}


/**
 * Plugins
 */
(function()
{
	/**
	 * NewWinOpen
	 *
	 * @param string option
	 */
	jQuery.fn.NewWinOpen = function(option)
	{
		$(this).click(function()
		{
			if (option != null) {
				window.open(this.href, null, option);
			} else {
				window.open(this.href, null);
			}
			return false;
		});
	}

	/**
	 * ImageRollover
	 *
	 * @param string postfix
	 */
	jQuery.fn.ImageRollover = function(postfix)
	{
		postfix = (postfix != null) ? postfix : '_on';
		var image_cache = new Object();
		$(this).not('[@src*="' + postfix + '."]').each(function(i) {
			var imgsrc = this.src;
			var dot = this.src.lastIndexOf('.');
			var imgsrc_on = this.src.substr(0, dot) + postfix + this.src.substr(dot, 4);
			image_cache[this.src] = new Image();
			image_cache[this.src].src = imgsrc_on;
			$(this).hover(
				function() { this.src = imgsrc_on; },
				function() { this.src = imgsrc; }
			);
		});
	}

})(jQuery);

