﻿/* ------------------------------------
use top page
------------------------------------ */
$(document).ready(function() {
	//xml slide configure
	var xmlSlideConfig = {
		xml: "./api/work_top.xml",
		before: '<img src="/shared/images/icon_slide_left.gif" alt="左へスライド" width="17" height="17" />',
		after : '<img src="/shared/images/icon_slide_right.gif" alt="右へスライド" width="17" height="17" />',
		boxWidth: 190,
		boxHeight: 265,
		speed: 20,
		basemover: 25
	}
	$("div#xmlSlide").xmlSlide(xmlSlideConfig);
	
	/**********************
	* main navigation clickable
	************************/
	//like a clickable
	var $targetAnchor = $("div#mainNav dl dt a");
	var aPreLoad = new Array();
	$targetAnchor.each(function(i){
		aPreLoad[i] = new Array();
		if($(this).attr("href")) {
			$(this).parent().next().css("cursor","pointer");
			$(this).find("img").each(function(j){
				$(this).attr("src").match(/^(.+)\.(gif|jpg)$/);
				var hsrc = RegExp.$1+"_on."+RegExp.$2;
				$(this).attr("hsrc",hsrc);
				aPreLoad[i][j] = new Image();
				aPreLoad[i][j].src = $(this).attr("hsrc");
			});
		}
	});
	$targetAnchor
		.mouseover(function(){
			$(this).children("img").each(function() {
				$(this).attr("src",$(this).attr("hsrc"));
			});
			$(this).parent().next().css("color","#a2a2a2");
		})
		.mouseout(function(){
			$(this).children("img").each(function() {
				$(this).attr("src",$(this).attr("hsrc").replace(/(_on\.)/,"."));
			});
			$(this).parent().next().css("color","#444444");
		});
	
	$("div#mainNav dl dd")
		.mouseover(function(){
			$(this).prev().children("a").trigger("mouseover");
		})
		.mouseout(function(){
			$(this).prev().children("a").trigger("mouseout");
		})
		//get href and set.
		.click(function(){
			var targetUri = $(this).prev().find("a").attr("href");
			if(!$(this).prev("dt").children("a").attr("target")) {
				if(!targetUri) return false;
				location.href = targetUri;
			}else {
				window.open(targetUri);
			}
			return;
		})
		//trigger rollover
		.mouseover(function(){
			$(this).prev("dt").trigger("mouseover");
		});
});