
	/*
	** content
	*/
	function showContent () 
	{
		$('div#service')
			.hide()
				.fadeIn('slow');
	}

	/*
	** menu
	*/
	function initMenu () 
	{
		$('ul.menu li.item').hover(
			function() {
				$(this)
					.children('div.submenu')
						.fadeIn('fast');
				$(this).css('z-index', 100);
			},
			function() {
				$(this).children('div.submenu').hide();
				$(this).css('z-index', 1);
			}
		);
	}

	/*
	** top
	*/
	function initTop () 
	{
		$('div#top a').attr('href', 'javascript:;');
	 	$('div#top a').click (
			function(){ 
				$('body').scrollTo(0, 500);
			}
		);
	}

	/*
	** tooltip
	*/
	function initToolTip ()
	{
		$(".tooltip").tooltip({ 
		    track: true, 
		    delay: 0, 
		    showURL: false, 
		    showBody: " - ", 
		    fade: 250
		});
	}
	
	/*
	** modal
	*/
	var closeModalAjax = function (hash)
	{
		var $modalWindow = $(hash.w);
		$modalWindow.fadeOut('fast', function()
		{
			hash.o.remove();
		});
	};

	var openModalAjax = function (hash)
	{
		var $modalWindow = $(hash.w);
		$modalWindow.fadeIn('fast');
	}

	function initModalAjax (jqModalWindowName)
	{
		$('#' + jqModalWindowName).remove();

		//
		var html = '<div id="' + jqModalWindowName + '" class="jqmWindowAjax jqmWindow">'
		html += '<div class="jqmClose"><span>close</span></div>'
		html += '<div class="jqmContent"></div>'
		html += '</div>'
		$('body').append(html);

		//
		var t = $('#' + jqModalWindowName + ' div.jqmContent');
	    $('#' + jqModalWindowName).jqm(
		{
			overlay: 85,
			trigger: 'a.trigger-' + jqModalWindowName,
			ajax: '@href',
			target: t,
			onHide: closeModalAjax,
			onShow: openModalAjax
	    });
	}

	/*
	** popup
	*/
    function initPopup () 
	{
		$('body').append('<div id="popup-background"></div>');
		$('#popup-background').click(function () {
			hidePopup();
		});
		
		//
		var html = "<div class='close'></div>";
		$('div.popup').append(html);
		$('div.popup div.close').click(
			function () {
				hidePopup();
		});
	}

	function hidePopup () 
	{
		$('div.popup').hide();
		$('#popup-background').hide();
    }

    function showPopup (name) 
	{
		hidePopup();
		
		//
		$(name).show();
		$(name).css ('top', (($(window).height() - $(name).height()) /2) + $(window).scrollTop() + 'px');
		$('#popup-background').show();
    }

	/*
	** h2 cufon for Wysiwyg
	*/
	function addCufon () 
	{
		$('div.wysiwyg h2').addClass('cufon');
		$('div.wysiwyg h2').after('<div class="h2-after"></div>');
		Cufon.replace('.cufon');
	}

	/*
	** modules
	*/
	function iniModules () 
	{
		$('div.module').each(function(index) {

			var button = $(this).children('div.module-trigger');
			var content = $(this).children('div.module-content');

			button.click(function(){

				if (button.hasClass('module-open'))
				{
					button.removeClass('module-open');
					button.addClass('module-close');
					content.show();
				}
				 else
				{
					button.removeClass('module-close');
					button.addClass('module-open');
					content.hide();
				}
			})
		});
	}

	
	/*
	** on load
	*/
	$(function() 
	{
		initMenu();
		initTop();
		initToolTip();
		initPopup();
		addCufon();
		iniModules();
		//showContent();
	});
