/*
 * basic.js - Pommefood Group
 *
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 */

var pommefood = {
	preloader: {
		loadedImages: [],
		load: function (url){
			var img = this.loadedImages;
			var l = img.length;
			img[l] = new Image();
			img[l].src = url;
		}
	},
	uri: {
		dirName: function(uri){
			var ary = uri.split('/');
			ary.pop();
			return ary.join('/');
		},
		path: function (uri){
			return uri.split('#')[0];
		},
		anchorName: function (uri){
			return uri.split('#')[1];
		},
		isSelfLink: function(href){
			return ((this.path(href) == this.path(location.href)) || (this.path(href) == this.dirName(location.href)+'/'));
		}
	}
};

$(function(){
		
		
//リンク画像はロールオーバーを設定

function initRollOverImages() {
  var image_cache = new Object();
  $("img.btn").each(function(i) {
    var imgsrc = this.src;
    var dot = this.src.lastIndexOf('.');
    var imgsrc_on = this.src.substr(0, dot) + '_on' + this.src.substr(dot, 4);
    image_cache[this.src] = new Image();
    image_cache[this.src].src = imgsrc_on;
    $(this).hover(
      function() { this.src = imgsrc_on; },
      function() { this.src = imgsrc; });
  });
}

$(document).ready(initRollOverImages);


//ページ内リンク

	$('a[@href^="#"]').click(function(){
		var href = pommefood.uri.anchorName($(this).href());
		$('#'+href).ScrollTo(500,'easeout');
		return false;
	});

});


//フォーム

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}


//アイコンの説明

$(function(){

    if ($("a#iconDescription")){
      $("div#shopDetail ul li.description").append('<div id="explanatoryNote" style="position: absolute; width: 157px; height: 139px; top: 30px; left: 230px; z-index:3;"><img src="images/icon_description.gif" alt="" usemap="#mapLink" /><map name="mapLink" id="mapLink"><area shape="rect" coords="135, 7, 150, 21" href="#" id="explanatoryNoteClose" title="閉じる" /></map></div>');
//$("div#explanatoryNote").hide();
    $("div#explanatoryNote").fadeOut(1);
}

  $("area#explanatoryNoteClose").click(function(){
    $("div#explanatoryNote").fadeOut(500);
    return false;
  });

  $("a#iconDescription").click(function(){
    $("div#explanatoryNote").fadeIn(500);
    return false;
  });

});