

/*	=========================================================================================

						雪印メグミルクサイト共通処理

	 ……………………………………………………………………………………………………………………
		※検証コード用コメント：[10120401]0000-0001 for debug


	=========================================================================================		*/


/*	------------------------------------------------------------------

					初期値

	------------------------------------------------------------------		*/
var lay02 = '';		//	第二階層カテゴリー：	値は、各ページにて設定。
var lay03 = '';		//	第三階層カテゴリー：	値は、各ページにて設定。
var lay04 = '';		//	第四階層カテゴリー：	値は、各ページにて設定。
var lay05 = '';		//	第五階層カテゴリー：	値は、各ページにて設定。












/*	------------------------------------------------------------------

			ポップアップ展開処理

	------------------------------------------------------------------		*/
function setPopupBtn()	{

	$("a.ppw01").click(function(){
		// サイズ：600px × 620px
		var tgturl = $(this).attr('href');
		var wname = 'mspop01';
		var w = 600;
		var h = 620;
		var scr = 'yes';
		wo=window.open(tgturl,wname,"width="+w+",height="+h+",left=0,top=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars="+scr+",favorites=no,resizable=yes");
		wo.focus();
		return false;
	});

	$("a.ppw02").click(function(){
		// サイズ：755px × 490px
		var tgturl = $(this).attr('href');
		var wname = 'mspop02';
		var w = 755;
		var h = 490;
		var scr = 'yes';
		wo=window.open(tgturl,wname,"width="+w+",height="+h+",left=0,top=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars="+scr+",favorites=no,resizable=yes");
		wo.focus();
		return false;
	});

	$("a.ppw03").click(function(){
		// サイズ：750px × 580px
		var tgturl = $(this).attr('href');
		var wname = 'mspop03';
		var w = 750;
		var h = 580;
		var scr = 'yes';
		wo=window.open(tgturl,wname,"width="+w+",height="+h+",left=0,top=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars="+scr+",favorites=no,resizable=yes");
		wo.focus();
		return false;
	});

	$(".b-close a").click(function(){
		window.close();
		return false;
	});
}


/*	------------------------------------------------------------------

			ポップアップ展開処理(引数対応)

	------------------------------------------------------------------		*/
function openPPW(tgturl,n,w,h)	{

	var scr = 'yes';
	wo=window.open(tgturl,n,"width="+w+",height="+h+",left=0,top=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars="+scr+",favorites=no,resizable=yes");
	wo.focus();
	return false;

}


/*	------------------------------------------------------------------

			旧サイト用 ポップアップ展開処理(引数対応)

	------------------------------------------------------------------		*/

function subwin01(url,wname,w,h) {
	wo=window.open(url,wname,"width="+w+",height="+h+",left=0,top=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,favorites=no,resizable=yes");
	wo.focus();
	return false;
}


/*	------------------------------------------------------------------

					ブランクページリンク設定処理

	------------------------------------------------------------------		*/
function initBlankLink() {
	//http:// , https://  _blank add
	//pdf,excel,word _blank add

	$('a').click(function(){
		var cls0 = $(this).attr('class');
		if(cls0.indexOf('ppw') == -1) {
			var href0 = $(this).attr('href');
			if( (href0.indexOf('://') != -1)
			||	(href0.indexOf('.pdf') != -1)
			||	(href0.indexOf('.doc') != -1)
			||	(href0.indexOf('.xls') != -1)	) {
				window.open(href0, '_blank');
				return false;
			}else if(cls0.indexOf('tblank') != -1) {
					window.open(href0, '_blank');
					return false;
			}
		}
	});

}




/*	------------------------------------------------------------------

					ブロックリンク設定処理

	------------------------------------------------------------------		*/
function setBlockLink() {

	var href0,idx,cls0,w_cm;
	var wname,w,h;

	$('.lnkblk').hover(function(){
		$(this).css('cursor','pointer');
		$(this).addClass('hovr');
	},
	function(){
		$(this).css('cursor','default');
		$(this).removeClass('hovr');
	});

	$('.lnkblk').click(function(){
		idx = $('.lnkblk').index(this);
		href0 = $('a.lnkblklnk:eq(' + idx +')').attr('href');
		cls0 = $('a.lnkblklnk:eq(' + idx +')').attr('class');
		if(cls0.indexOf('cmppw') != -1) {
			wname = 'cm';
			w = 560;
			h = 520;
			w_cm = window.open(href0,wname,"width="+w+",height="+h+",left=0,top=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,favorites=no,resizable=yes");
			w_cm.focus();
			return false;
		}else {
			location.href = href0;
		}
	});

}




/*	------------------------------------------------------------------

					画像ロールオーバ処理

	------------------------------------------------------------------		*/
var lgth_unit0 = 4;		//	the length of '.gif' or '.jpg'
var lavel_on0 = '_1';
var lavel_off0 = '_2';

$(function(){ 

	$('img.rovr').live('mouseover',function()	{		//	onmouseover event
			var this_img0 = $(this).attr('src');
			var dat0 = this_img0.split('/');
			var img_name0 = dat0[dat0.length-1];
			var start0 = this_img0.length - lgth_unit0;
			var end0 = this_img0.length;
			var unit0 = this_img0.slice(start0,end0);			//	'.gif' or '.jpg'
			var name_nml0 = img_name0.split(unit0);
			var name_tgl0 = img_name0.replace(lavel_on0,lavel_off0);
			var img_tgl0 = this_img0.replace(img_name0,name_tgl0);
			$(this).attr('src',img_tgl0);
		});

	$('img.rovr').live('mouseout',function()	{		//	onmouseout event
			var this_img0 = $(this).attr('src');
			var dat0 = this_img0.split('/');
			var img_name0 = dat0[dat0.length-1];
			var start0 = this_img0.length - lgth_unit0;
			var end0 = this_img0.length;
			var unit0 = this_img0.slice(start0,end0);			//	'.gif' or '.jpg'
			var name_tgl0 = img_name0.replace(lavel_off0,lavel_on0);
			var img_tgl0 = this_img0.replace(img_name0,name_tgl0);
			$(this).attr('src',img_tgl0);
		});
	


});


/*	------------------------------------------------------------------

			パンくず関連処理

	------------------------------------------------------------------		*/
function setBreadCrumbs()	{
var arw = '&gt;';

	$('#breadcrumbs li a').each(function () {
		$(this).parent().append(arw);
	});
	
}



/*	------------------------------------------------------------------

			ローカルナビゲーションアクティブ処理

	------------------------------------------------------------------		*/
function actLnav()	{
	var act_i = 0;
	var id0,src0,txt0;
	var $tgt0 = '';

	var act_id_02 = 'l-' + lay02;
	var act_id_03 = 'l-' + lay02 + '-' + lay03;
	var act_id_04 = 'l-' + lay02 + '-' + lay03 + '-' + lay04;


	if(lay02 != 'top') {

		$('#lnav li.lay02').each(function(){
			if(act_id_02 == $(this).attr('id')) {

				$(this).children('ul').css('display','block');

				if(lay03 != 'top') {
					$tgt0 = $('#' + act_id_02 + '>p a');
					img0 = $tgt0.html();
					img0 = img0.replace('_1.','_2.');
					img0 = img0.replace('rovr','bovr');
					$tgt0.html(img0);
				}else {
					$tgt0 = $('#' + act_id_02 + '>p');
					img0 = $tgt0.children('a').html();
					img0 = img0.replace('_1.','_2.');
					img0 = img0.replace('rovr','');
					$tgt0.html('<span class="act">' + img0 + '</span>');
				}
			}
		});

		$('#lnav li.lay03').each(function(){
			if(act_id_03 == $(this).attr('id')) {
	
				if(lay04 != 'top') {
					$('#' + act_id_03 + '>p').addClass('act');
				}else {
					$tgt0 = $('#' + act_id_03 + '>p');
					txt0 = $tgt0.text();
					$tgt0.html('<span class="act">' + txt0 + '</span>');
				}
			}
			
			if($(this).children('p').children('a').length == 0) {
				$(this).children('ul').css('display','block');
			}
		});

	}

}


/*	------------------------------------------------------------------

			旧サイト 印刷処理
			使用ページ「骨太なカルシウム強化メニュー」 POPUP
			/cooking/01.html　02.html　03.html　04.html

	------------------------------------------------------------------		*/


/* -----------------------------------------------------------
					初期設定
	-----------------------------------------------------------	*/
var bodyid;
var doc = document;

/* -----------------------------------------------------------
					IDオブジェクト検索
	-----------------------------------------------------------	*/
function get_element(idname) {
	var el_buf = doc.getElementById?doc.getElementById(idname):doc.all?doc.all[idname]:doc.layers[idname];
	
	return el_buf;
}

/* -----------------------------------------------------------
					ページの印刷処理
	-----------------------------------------------------------	*/
function goPrint(){
	if(doc.getElementById || doc.layers){
		window.print();		//印刷をします
	}
}


/* -----------------------------------------------------------
					印刷シーケンス
	-----------------------------------------------------------	*/
function printPgae01() {

	goPrint();														//	印刷処理の実行
}


/*	------------------------------------------------------------------

					処理実行

	------------------------------------------------------------------		*/

$(function(){

	setPopupBtn();
	initBlankLink();
	setBlockLink();

	setBreadCrumbs();
	actLnav();

});



