
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


function openwin( srcname, winname, w, h){
	win_para = 'toolbar=no,location=0,directories=no,status=no,menubar=0,scrollbars=1,resizable=no,width='+w+',height='+h ;
	wins = window.open( srcname, winname, win_para );
	wins.focus();
}


//--エージェントによってHASH文字列生成
function setHash( hash ){

	var rehash = hash;

//checkAlert();

	if( saf == 1 ){
		// safari.
		if( hash == '' ){
			// 空白だと同一URLになりループする
			rehash = 'top';
		}
	}else
	if( op == 1 ){
		// opera.
	}else{
		rehash = "#" + hash;
	}

	return rehash;
}

// 共通プリロードイメージ
function commonPreload(){

	MM_preloadImages(
	'../images/motorimoda_over.gif',
	'../images/home/topmenu0_over.gif',
	'../images/home/topmenu1_over.gif',
	'../images/home/topmenu2_over.gif',
	'../images/home/topmenu3_over.gif',
	'../images/home/topmenu4_over.gif',
	'../images/home/topmenu9_over.gif',
	'../images/onlineshop/catename00_over.gif',
	'../images/onlineshop/catename01_over.gif',
	'../images/onlineshop/catename02_over.gif',
	'../images/onlineshop/catename03_over.gif',
	'../images/onlineshop/catename04_over.gif',
	'../images/onlineshop/catename05_over.gif',
	'../images/onlineshop/catename06_over.gif',
	'../images/onlineshop/catename07_over.gif',
	'../images/onlineshop/catename08_over.gif',
	'../images/onlineshop/catename09_over.gif',
	'../images/onlineshop/brandnamesub0_over.gif',
	'../images/onlineshop/brandnamesub1_over.gif',
	'../images/onlineshop/brandnamesub2_over.gif',
	'../images/onlineshop/brandnamesub3_over.gif',
	'../images/onlineshop/brandnamesub4_over.gif');
}

function openImage( src, title ){

	var i = new Image();
	i.src = src;

	if( !i.complete ){
		// ロードするまで待つ
		i.onload = function() { 
			openImageSync( i, title );
		};
	}else{
		openImageSync( i, title );
	}
}

function openImageSync( i, title ){
	//var i = new Image(); i.src = src;

	if( i.width == 0 ){
		return;
	}

	if( typeof title == 'undefined' || title == '' ){
		title = i.width + " x " + i.height;
	}

	var pop_win = window.open(
					"",
					"_blank",
					"width="+i.width+",height="+i.height+",scrollbars=no,resizable=yes"
				);

	pop_win.window.document.open();
	pop_win.window.document.write(
			'<html>'
			+'<head><title>'+title+'</title></head>'
			+'<body style="margin:0;padding:0;border:0;">'
			+'<a href="javascript:window.close();">'
			+'<img src="'+i.src+'" width="100%" alt="close" title="close" border=0 />'
			+'</a>'
			+'</body>'
			+'</html>'
		);
	pop_win.window.document.close();
}
/**
 * ラジオボタン値取得
 * 
 * @param name
 * @return
 */
function getRadioValue( name ){

	var radio = document.getElementsByName( name );

	for( var i=0; i < radio.length; i++){
		if( radio[i].checked ){
			return radio[i].value;
		}
	}
	return undefined;
}
/**
 * チェックボックス値取得
 * 
 * @param name
 * @return
 */
function getCheckValue( name ){

	var check = document.getElementsByName( name );

	if( check[0].checked ){
		return check[0].value;
	}
	
	return undefined;
}

