﻿/*
* $Id$
*/
var dmaxUtils = {

	'navHover': function () {
		jQuery("#dmax_nav").children("li").each(function () {
			jQuery(this).hover(
				function () { jQuery(this).addClass("hover")},
				function () { jQuery(this).removeClass("hover")}
			)
		});
	},

	'toggleSrc': function (elem, attr) {
		if (!attr) var attr = "src";
		var regex = RegExp('(.*[\\w])(off|on)([\\w\.].*)');
		var match = elem[attr].match(regex);
		if ((match !== null) && (match.length == 4)) {
			var value = null;
			switch (match[2]) {
				case "on": value = "off";
					break;
				case "off": value = "on";
					break;
			}
			value = match[1] + value + match[3];
		}
		if (value) {
			elem.src = value;
		}
	},


	'goHover': function () {
		var cls = "dm_go_button";
		jQuery("." + cls).each(function () {
			jQuery(this).hover(
				function () { dmaxUtils.toggleSrc(this);},
				function () { dmaxUtils.toggleSrc(this);}
			);
		});
	},

	'init': function () {
		this.navHover();
		this.goHover();
	}

}

jQuery(document).ready(function () {
	dmaxUtils.init();
});
