//メニューロールオーバー
$(document).ready(function(){
    $('#glovalnavi').spritemenu({
    	grid:'http://clubharie.jp/mold/common/images/glovalnavi.jpg'
    });
});

//ライトボックス
$(document).ready(function(){
	$('a.fancybox').fancybox({
		'frameWidth'			: 400,
		'frameHeight'			: 600,
		'overlayOpacity'		: 0.8,
		'hideOnContentClick'    : false,
		'padding':0
	});
});

//tools ギャラリー
$(function() {
	var imgWrapper = $('#slideshow > img');
	// only show the first image, hide the rest
	imgWrapper.hide().filter(':first').show();
	
	$('ul.recentlist li a').click(function () {
	
		// check if this item doesn't have class "current"
		// if it has class "current" it must not execute the script again
		if (this.className.indexOf('current') == -1){
			imgWrapper.hide();
			imgWrapper.filter(this.hash).fadeIn(500);
			$('ul.recentlist li a').removeClass('current');
			$(this).addClass('current');
		}
		return false;
	});
});

//page scroll
jQuery.easing.quart = function (x, t, b, c, d) {
    return -c * ((t=t/d-1)*t*t*t - 1) + b;
};  
$(function () {
        $('#pagetop_go').click(function () {
            $(this).blur();

            $('html,body').animate({ scrollTop: 0 }, 500, 'quart');

            return false;
        });
});

//コンタクト
function contact(){

	//URLの？以降の引数を取得
	var arg = location.search;
 
	//?を削除
	arg = arg.substring(1);
	
	//セミコロンで引数を分割して配列
	var pair = arg.split("&");
 
	var i, temp, key = new Array();
 
	//配列に代入
	for (i = 0; i < pair.length; i++) {
 
		//ペアを = でさらに分割（temp[0] = "name" と temp[1] = "名前" で分かれる）
		temp = pair[i].split("=");
 
		//キー名(name, sex, interest_car, interest_cinema, interest_music, interest_js)
		keyName = temp[0];
 
		//キーの値(名前, male, true, false, true, false)
		keyValue = temp[1];
 
		//key["name"] = "名前"; の形にする(連想配列)
		key[keyName] = keyValue;
	}
 
 	//お問い合わせ項目処理
	var title;
	if (key["title"]) {
		
		switch(key["title"]){
			case "0":
				title=0;
				break;
			case "1":
				title=1;
				break;
			case "2":
				title=2;
				break;
			case "3":
				title=3;
				break;
			default:
				title="";
				break;
		}
		document.form.title[title].checked = true;
	} else{
		title="";
	}
 
	//商品名処理
	var pname;
	if (!key["pname"] || key["pname"] == "") {
		pname = "";
	} else {
		key["pname"] = unescape(key["pname"]); //送信する時にコードに変換したのでunescape()で元に戻す
		pname = key["pname"];
		document.form.name.value=pname;
	}
	
}

//popup
function popupwin1(theURL) {
    var win1 = window.open(theURL, 'popup', 'width=500, height=600, location=no, menubar=no, toolbar=no, scrollbars=yes, resizable=yes');
   win1.focus();
}

// jquery rolloverimage
function initRollOverImages() {
	var image_cache = new Object();
	$("img.rollover").not("[src*='_ro.']").each(function(i) {
		var imgsrc = this.src;
		var dot = this.src.lastIndexOf('.');
		var imgsrc_on = this.src.substr(0, dot) + '_ro' + 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);
