/*
* lm 1.2 Customized
* Copyright: (c) 2007 ludicmind.net
**************************************/

var currentPanel = 1;
var lastPanel = 18;

// Initialization
jQuery.lm = {
	init: function() {
		for (func in jQuery.lm) {
			if (jQuery.lm[func].init)
				jQuery.lm[func].init();
		}
	}
};

jQuery(document).ready(function(){
	jQuery.lm.init();
	jQuery(".stepcarousel").css("width","100%");
	jQuery("#menu a.page01").children("img").attr("src", "shared/img/nav_01_s.gif");
	jQuery("#menu a[class]").click(function(){
		jQuery("#menu a[class]").children("img").attr("src", "shared/img/nav_01.gif");
		jQuery(this).children("img").attr("src", "shared/img/nav_01_s.gif");
		//jQuery("#menu a.page01").children("img").attr("src", "shared/img/label_01.gif");
		var idx = jQuery(this).attr("class").substr(4);
		if (idx.substr(0) == 0) idx = idx.substr(1);
		stepcarousel.stepTo('content', idx);
		currentPanel = idx;
		return false;
	});
	
	/*
	jQuery(".stepcarousel").mousewheel(function(event, delta){
		if(delta > 0){
			if(currentPanel > 1) {
				stepcarousel.stepBy('content', -1);
				currentPanel--;
				setStayButton(currentPanel);
			}
		} else if (delta < 0){
			if(currentPanel < lastPanel){
				stepcarousel.stepBy('content', 1);
				currentPanel++;
				setStayButton(currentPanel);
			}
		}
	});
	*/
	
	jQuery("#menu dd").ahover({toggleSpeed: 350, toggleEffect:"height", hoverEffect: function() {
        jQuery(this)
            .animate({opacity: 0.5}, 750)
            .animate({opacity: 1.0}, 750)
            .dequeue();
        jQuery(this).queue(arguments.callee);
    }});
	
	/*//Below by morld, 2009
	jQuery("#panel14 div").click(function(){
		var i = jQuery(this).css("background-position-y");
		if (i == "0%" || i == "0px") {
			jQuery("#panel14 div").css("background-position", "0 -593px");
		} else {
			jQuery("#panel14 div").css("background-position", "0 0");
		}
	});
	//End of morld*/
	
});


// Set current stay button
function setStayButton(idx){
		var tmp = jQuery("#menu a[class]");
		if(tmp.children("img").attr("class") != "non_Button") {
			tmp.children("img").attr("src", "/shared/img/nav_01.gif");
			tmp.children("img").eq(idx-1).attr("src", "/shared/img/nav_01_s.gif");
		}
}

// Add "nolink" class to Heading without a[href]
jQuery.lm.noLink = {
	init: function() {
		jQuery("a:not([href])").parent("h2").addClass("nolink");
		jQuery("a:not([href])").parent("h3").addClass("nolink");
		jQuery("a:not([href])").parent("h4").addClass("nolink");
	}
};


// Mouse hover on input[type='image']
jQuery.lm.inputHover = {

	init: function() {
		jQuery('input[type="image"]')
			.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]+)jQuery/, "jQuery1_ojQuery2");
	},

	enter: function() {
		this.src = this.src.replace(/^(.+)(\.[a-z]+)jQuery/, "jQuery1_ojQuery2");
	},

	exit: function() {
		this.src = this.src.replace(/^(.+)_o(\.[a-z]+)jQuery/, "jQuery1jQuery2");
	}
};


// Navigation Submenu
jQuery.lm.submenu = {
	init: function() {
		var toggle = function(direction, display) {
			return function() {
				var self = this;
				var ul = jQuery("ul", this);
				if( ul.css("display") == display && !self["block" + direction] ) {
					self["block" + direction] = true;
					ul["slide" + direction]("fast", function() {
						self["block" + direction] = false;
					});
				}
			};
		}
		jQuery("li.hasSubmenu").hover(toggle("Down", "none"), toggle("Up", "block"));
		jQuery("li.hasSubmenu ul").hide();
	}
};


// Replace "abbr" with "acronym" (only IE6)
jQuery.lm.changeAbbr = {
	init: function() {
		var ua = window.navigator;
		if (ua.appName == "Microsoft Internet Explorer" && ua.appVersion.indexOf("MSIE 7.0") == -1) {
			var abbrs = document.getElementsByTagName('abbr');
			for (var i = 0; i < abbrs.length; i++) {
				var oldAbbr = abbrs.item(i);
				var newAbbr = document.createElement('abbr');
				newAbbr.title = oldAbbr.title;
				oldAbbr.parentNode.insertBefore(newAbbr, oldAbbr);
				while (oldAbbr.nextSibling.nodeName != '/ABBR') {
					newAbbr.appendChild(oldAbbr.nextSibling);
				}
				oldAbbr.parentNode.removeChild(oldAbbr.nextSibling);
				oldAbbr.parentNode.removeChild(oldAbbr);
			}
		}
	}
};


// Menu List Add Class "first" and "last" - use to ul
(function(jQuery) {
	jQuery.fn.addClassFL = function(colNum) {
		return this.children("li").each(function(i){
			if (i % colNum == 0){
				jQuery(this).addClass("first");
			}
			if (i % colNum == colNum - 1){
				jQuery(this).addClass("last");
			}
		});
	};
})(jQuery);


// Menu List Add Class "Odd" and "Even" - use to ul
(function(jQuery) {
	jQuery.fn.addClassOE = function() {
		return this.children("li").each(function(i){
			if (i % 2 == 0){
				jQuery(this).addClass("odd");
			}
			if (i % 2 == 1){
				jQuery(this).addClass("even");
			}
		});
	};
})(jQuery);




