
if(window.name == "printWindow"){
	document.write('<link rel="stylesheet" href="../../common/css/09-products-detail-print.css" type="text/css" media="all" />');
}


/*▼jquery ロード*/
/* ----------------------------------------------------- */
$(function(){

	/*▼ロールオーバー*/
	/* ----------------------------------------------------- */
	$('.imgover').hover(function()
	{
		Rollover($(this),$(this).attr('src'));	
	},function() {
		Rollover($(this),$(this).attr('src'));	
	});	

	/*▼関数呼び出し*/
	/* ----------------------------------------------------- */
	popupWindow('#styleList li a',730,630);
	popupWindow('#infoArea li a.popup',550,700);
	hoverFunc('#close img');
	hoverFunc('#print img');
	hoverFunc('#printPageBtn img');

	if($('#productsLnav').size()==1){
		changeActive();
	}
	if($('#antiquesLnav').size()==1){
		changeActive2();
	}
	if($('#catetab').size()==1){
		changeActive3();
	}

	if($('.pageview').size()>0){
		pagenation();
	}
	
	if($('.commodityList').size()>0){
		commodityList();
	}
	
	/*▼pop upウィンドウ閉じる*/
	/* ----------------------------------------------------- */
	$('#close').click(function(){
			window.close();
	});
		
	/*▼pop upウィンドウから親ウィンドウ操作*/
	/* ----------------------------------------------------- */
	$('#toDeatail a, .nav01 li a').click(function(){
			focusParent($(this).attr('href'));
			return false;
	});

	/*▼商品詳細ページ　プリントページ開く*/
	/* ----------------------------------------------------- */
	$('#print').click(function(){
			openPrintWin(600,750);
	});
	$('#printPageBtn').click(function(){
			window.print();
	});

	/*▼サイトマップ空span生成*/
	/* ----------------------------------------------------- */
	$('.mapBox li , .mapBoxTop li').append("<span>&nbsp;</span>");

});

/*▼ホバー時　マウスカーソル変更*/
/* ----------------------------------------------------- */
var hoverFunc = function(tar){
		$(tar).hover(function()
		{
			$(this).css("cursor", "pointer");							 
		},function() {
			$(this).css("cursor", "default");							 
		});
};

/*▼プロダクト製品一覧　ページナビ*/
/* ----------------------------------------------------- */
var pagenation = function(){
	/* hrefを取得 */
	var showObj = location.href;
	/* 取得したhrefをindexで分割 */
	if(showObj.match('index')){
		var myData = showObj.split('index')
	}
	else{
		var myData = new Array;
		myData[1] = '.html';
	}
	$('.pageview').each(function(i){
															 
	/* pageview liの数 */
	var Max = $(this).find('li').size();
	/* 何ページ目 */
		var num = eval(myData[1].split('.')[0].split(0)[1]);
	
	/* 1ページ目なら */
	if(myData[1]=='.html'){
		/* prevのリンク削除しクラスactiveを付加*/
		$(this).find('.prev a').addClass('active');
		$(this).find('.prev a').removeAttr('href');
		/* 自分のリンク削除 */
		$(this).find('li:nth-child(2) a').removeAttr('href');
		/* nextにリンク設定 */
		$(this).find('.next a').attr('href','index02.html');
	}
	
	/* .html(index.html)以外（ex index0○.html）なら */
	else{
		/* index02.htmlなら */
		if(num-1==1){
			PrevHtml = 'index.html' ;
			NextHtml = 'index03.html' ; 
		}
		/* 最後のページ */
		else if(num+2 == Max){
			PrevHtml = 'index0' + (num-1) + '.html' ;
			NextHtml = '' ;
		}
		/* その他ページ */
		else{
			PrevHtml = 'index0' + (num-1) + '.html' ;
			NextHtml = 'index0' + (num+1) + '.html' ;
		}
		
		/* prevにリンク設定 */
		$(this).find('.prev a').attr('href',PrevHtml);
		/* nextにリンク設定 */
		$(this).find('.next a').attr('href',NextHtml);
		/* 最後のページならnextのリンク削除しクラスactiveを付加*/
		if(num+2 == Max){
			$(this).find('.next a').removeAttr('href');
			$(this).find('.next a').addClass('active');
		}
		/* 現在ページのリンク削除 */
		$(this).find('li').eq(num).find('a').removeAttr('href');
	}
	});
};


/*▼プロダクト製品一覧　背景変更*/
/* ----------------------------------------------------- */
var commodityList = function(){
	$('.commodityList').each(function(i){
		var num = $(this).find('li').size();
		switch(num){
			case 3:$(this).css('width','426px');break;
			case 2:$(this).css('width','284px');break;
			case 1:$(this).css('width','142px');break;
		}
	});
};

/*▼アクティブページのボタン変更*/
/* ----------------------------------------------------- */
var changeActive = function(){
	var showObj = location.href;
	myData = showObj.split("/");
	for (var i = 0; i < myData.length; i++) {
			var active = '#'+myData[i]+'-a';
			if($('#productsBoxL li img').filter(active).size()==1) {
					$(active).removeClass("imgover");
					var src = $(active).attr('src');
					var ftype = src.substring(src.lastIndexOf('.'), src.length);
					var hsrc = src.replace(ftype, '_over'+ftype);	
					$(active).attr('src',hsrc);
			}
	}
};

/*▼アクティブページのボタン変更 アンティーク用 */
/* ----------------------------------------------------- */
var changeActive2 = function(){
	var showObj = location.href;
	myData = showObj.split("/");
	for (var i = 0; i < myData.length; i++) {
			var active = '#'+myData[i]+'-a';
			if($('#antiquesBoxL li img').filter(active).size()==1) {
					$(active).removeClass("imgover");
					var src = $(active).attr('src');
					var ftype = src.substring(src.lastIndexOf('.'), src.length);
					var hsrc = src.replace(ftype, '_over'+ftype);	
					$(active).attr('src',hsrc);
			}
	}
};

/*▼アクティブページのボタン変更 アンティーク用 タブ*/
/* ----------------------------------------------------- */
var changeActive3 = function(){
	var showObj = location.href;
	myData = showObj.split("/");
	for (var i = 0; i < myData.length; i++) {
			var active = '#'+myData[i]+'-b';
			if($('#antiquesBoxR #catetab li img').filter(active).size()==1) {
					$(active).removeClass("imgover");
					var src = $(active).attr('src');
					var ftype = src.substring(src.lastIndexOf('.'), src.length);
					var hsrc = src.replace(ftype, '_over'+ftype);
					$(active).attr('src',hsrc);
			}
	}
};




/*▼pop upウィンドウから親ウィンドウ操作*/
/* ----------------------------------------------------- */
var focusParent = function(myURL){
	window.opener.location.href = myURL;
	window.blur();
}

/*▼ポップアップ*/
/* ----------------------------------------------------- */
var popupWindow = function(tar,w,h){
	$(tar).click(function(){
		var Loc = $(this).attr('href');
		var features="scrollbars=yes";
		features+=", left="+(window.screen.width-w)/2;
		features+=", top="+(window.screen.height-h)/2;
		features+=", width="+w;
		features+=", height="+h;
		var newWin=window.open(Loc,"puwindow",features);
		newWin.focus();
		return false;
	});
}

/*▼印刷用ページポップアップ*/
/* ----------------------------------------------------- */
var openPrintWin= function(w,h){
		var features="scrollbars=yes";
		features+=", left="+(window.screen.width-w)/2;
		features+=", top="+(window.screen.height-h)/2;
		features+=", width="+w;
		features+=", height="+h;
		var newWin = window.open(window.location.href,"printWindow",features);
		newWin.focus();
}


/*▼ロールオーバー*/
/* ----------------------------------------------------- */
var Rollover = function(obj,thisSrc) {
	/*---変数宣言---*/
	var sTempSrc = thisSrc;
	var ftype = thisSrc.substring(thisSrc.lastIndexOf('.'), thisSrc.length);
	var hsrc = thisSrc.replace(ftype, '_on'+ftype);	
	var aPreLoad = new Image();

	/*---プリロード---*/
	aPreLoad.src = hsrc;

	re = new RegExp("_on");
	re2 = 	new RegExp("_over");
	if(!sTempSrc.match(re2)){

		if(!sTempSrc.match(re)){
			$(obj).attr('src', hsrc);
		}
		
		if (sTempSrc.match(re)) {
			sTempSrc = $(obj).attr('src').replace('_on'+ftype, ftype);
			$(obj).attr('src', sTempSrc);
		}
	}
	
}

/*▼イメージプリロード*/
/* ----------------------------------------------------- */
var PreLoad = function(tar){
	$(tar).each(function(i){               
		var PreLoad = new Image();
		var src = $(this).attr('src');
		var ftype = src.substring(src.lastIndexOf('.'), src.length);
		var hsrc = src.replace(ftype, '-b'+ftype);
		PreLoad[i] = new Image();
		PreLoad[i].src = hsrc;
	});
}
