/* ================================================================== */
/*                                                                    */
/* ! Home */
/*                                                                    */
/* ------------------------------------------------------------------
*
*    1. Visual Box Slide Show
*
*    2. News Ticker
*
*    3. Global Navigation and Dropdown Menu
*       3.1. ドロップダウンメニューの配置処理
*            3.1.1. ナビゲーションからマウスアウトした時の処理
*       3.2. グローバルナビゲーションのボタン制御
*            3.2.1. ドロップダウンメニューのトリガーの挙動を設定
*
* =================================================================== */

/* ================================================================== */
/*                                                                    */
/* ! jquery.newsticker.js */
/*                                                                    */
/* ================================================================== */

(function($){$.fn.newsTicker=$.fn.newsticker=function(delay,fade)
{delay=delay||4000;fade=fade||2000;initTicker=function(el)
{stopTicker(el);el.items=$("li",el);el.items.not(":eq(0)").hide().end();el.currentitem=0;startTicker(el);};startTicker=function(el)
{el.tickfn=setInterval(function(){doTick(el)},delay)};stopTicker=function(el)
{clearInterval(el.tickfn);};pauseTicker=function(el)
{el.pause=true;};resumeTicker=function(el)
{el.pause=false;};doTick=function(el)
{if(el.pause)return;el.pause=true;$(el.items[el.currentitem]).fadeOut(fade,function()
{$(this).hide();el.currentitem=++el.currentitem%(el.items.size());$(el.items[el.currentitem]).fadeIn(fade,function()
{el.pause=false;});});};this.each(function()
{if(this.nodeName.toLowerCase()!="ul")return;initTicker(this);}).addClass("newsticker").hover(function()
{pauseTicker(this);},function()
{resumeTicker(this);});return this;};})(jQuery);


$(document).ready(function() {

	/* ================================================================== */
	/*                                                                    */
	/* ! 1. Visual Box Slide Show */
	/*                                                                    */
	/* ================================================================== */

	var slideImages = '<img src="/images/visual25.jpg" alt="" width="424" height="548" /><img src="/images/visual26.jpg" alt="" width="424" height="548" /><img src="/images/visual23.jpg" alt="" width="424" height="548" /><img src="/images/visual20.jpg" alt="" width="424" height="548" /><img src="/images/visual16.jpg" alt="" width="424" height="548" /><img src="/images/visual17.jpg" alt="" width="424" height="548" /><img src="/images/visual12.jpg" alt="" width="424" height="548" />';

	j_visualBox = $("#visualBox");
	j_visualBox.append(slideImages);

	j_visualBox.onImagesLoad({
    	callback: function() {
		    j_visualBox.cycle({ 
    			fx: 'fade',
    			speed: 2000,
    			timeout: 12000,
    			delay: -7000
			});
    	}
    });



	/* ------------------------------------------------------------------ */
	/*    各パネルの挙動を制御 */
	/* ------------------------------------------------------------------ */

	$("#homeBtn .cont").each(function() {
	    /* ---------------------------------
	    *    各パネルをクリックした際のページ遷移処理    */
	    $(this).click(function() {
	    	var url = $(this).find(".btnText").attr("href");
	    	if (url) {
	    		location.href = url;
	    	}
	    });
	    
	    
	    /* ---------------------------------
	    *    各パネル ホバー時の挙動を制御    */
	    $(this).hover(
	    	function() {
	    		if (browser == "IE6") {
	    			$(this).find(".thumb img").css({ "opacity" : 0.5 });
	    		} else {
	    			$(this).find(".thumb img").animate({ "opacity" : 0.5 }, "fast");
	    		}
	    
	    		j_btnText = $(this).find(".btnText");
	    		var targetId = j_btnText.closest("li").attr("id");

	    		var posStr = getXpos(targetId) + " 0";
	    		j_btnText.css("background", posStr);
	    	},
	    	function() {
	    		if (browser == "IE6") {
	    			$(this).find(".thumb img").css({ "opacity" : 1 });
	    		} else {
	    			$(this).find(".thumb img").animate({ "opacity" : 1 }, "fast");
	    		}
	    
	    		j_btnText = $(this).find(".btnText");
	    
	    		var posStr = getXpos(j_btnText.closest("li").attr("id")) + " -43px";				
	    		j_btnText.css("background-position", posStr);
	    	}
	    );
	});


	/* ================================================================== */
	/*                                                                    */
	/* ! 3. News Ticker */
	/*                                                                    */
	/* ================================================================== */

	$("#ticker").newsTicker();

});

