// 指定ID名のimgのサイズ取得
function getImageWidth(myid)
{
	var newImg = new Image();
	newImg.src = document.getElementById(myid).src;
	var width = newImg.width;
	return width;
}

function getImageHeight(myid)
{
	var newImg = new Image();
	newImg.src = document.getElementById(myid).src;
	var height = newImg.height;
	return height;
}


// 指定クラス名のdivをウインドウの中央に配置する　※IE7でレイアウト崩れる場合あり調整後使用すること
window.onload = function () {
	// 指定クラス名
	var mdlClass = 'mdlcenter';
	
	// 指定クラスを検索
	var divs = document.getElementsByTagName('div');
	var tardivs = new Array();
	for(i=0; i<divs.length; i++){
		if(divs.item(i).className.indexOf(mdlClass) != -1){
			tardivs.push(divs.item(i));
		}
	}
	
	for(i=0; i<tardivs.length; i++){
	
	tardivs[i].style.position = "absolute";
	ownheight = tardivs[i].offsetHeight;
	ownwidth = tardivs[i].offsetWidth;
	
	if(window.innerHeight){
	h=window.innerHeight;
	}
	if(document.documentElement && document.documentElement.clientHeight){
	h=document.documentElement.clientHeight;
	}
	else if(document.body && document.body.clientHeight){
	h=document.body.clientHeight;
	}
	if(ownheight<=h){
	tardivs[i].style.top=((h-ownheight)/2)+'px';
	if( ((h-ownheight)/2) < 0 ){
	tardivs[i].style.top=0 + 'px';
	}
	}
	else if(ownheight>h){
	tardivs[i].style.top=0+'px';
	}

	if(window.innerWidth){
	h=window.innerWidth;
	}
	if(document.documentElement && document.documentElement.clientWidth){
	h=document.documentElement.clientWidth;
	}
	else if(document.body && document.body.clientWidth){
	h=document.body.clientWidth;
	}
	if(ownwidth<=h){
	tardivs[i].style.left=((h-ownwidth)/2)+'px';
	if( ((h-ownwidth)/2) < 0 ){
	tardivs[i].style.left=0 + 'px';
	}
	}
	else if(ownwidth>h){
	tardivs[i].style.left=0+'px';
	}
	
	}
}


// imgをロールオーバーにする
function imgRollOverSet(type){	// bodyタグにonload="imgRollOverSet();"を入れる
	if(!type) type = '_on';
	// 指定のクラス名
	var roClass = 'rollover';
	
	// 指定クラスを検索
	var imgs = document.getElementsByTagName('img');
	var tarImgs = new Array();
	for(i=0; i<imgs.length; i++){
		if(imgs.item(i).className.indexOf(roClass) != -1){
			tarImgs.push(imgs.item(i));
		}
	}
	
	// 指定クラスに関数を定義
	for(i=0; i<tarImgs.length; i++){
		tarImgs[i].onmouseover = function(){ imgRollOver(this, type) }
		tarImgs[i].onmouseout = function(){ imgRollOver(this, type) }
	}
}

function imgRollOver(o, type){
		var reg = new RegExp('^(file:|http:)(.+?)(' + type + '){0,1}(\.gif|\.jpg|\.jpeg|\.png)');
		xx = o.src.match(reg);
		if(RegExp.$3 == type){
			o.src = RegExp.$1 + RegExp.$2 + RegExp.$4;
		} else {
			o.src = RegExp.$1 + RegExp.$2 + type + RegExp.$4;
		}
}


// リンクボタンをsubmitボタンにする
function Submit(formName){
	document.forms[formName].submit();
	return false;
}


// 画像をプリロードする
function preimg(){
var loadcomp = false;
	var preload = new Array();
	for(i = 0 ; i < preloadlist.length ; i++) {
		preload[i] = new Image();
		preload[i].src = preloadlist[i];
	}
	loadcomp = true;
}


// divを表示／非表示

function closeLayer(divid0){
var divname0 = document.getElementById(divid0);
divname0.style.visibility = "hidden"
}

function openLayer(divid1){
var divname1 = document.getElementById(divid1);
divname1.style.visibility = "visible"
}


