/////jump
function getScrollTop() {
 if ((navigator.appName.indexOf("Microsoft Internet Explorer",0) != -1)) {
	return document.body.scrollTop;
 } else if (window.pageYOffset) {
  return window.pageYOffset;
 } else {
  return 0;
 }
}

/////
var pageScrollTimer;
function pageScroll(toY,speed,cuY) {
 if (pageScrollTimer) clearTimeout(pageScrollTimer);
 if (!toY || toY < 0) toY = 0;
 if (!cuY) cuY = 0 + getScrollTop();
 cuY += (toY - getScrollTop()) / speed;  if (cuY < 0) cuY = 0;
 var posY = Math.floor(cuY);
 window.scrollTo(0, posY);
 if (posY != toY) {
  pageScrollTimer = setTimeout("pageScroll("+toY+","+speed+")",16);
 }
}
//
function jumpToPageTop() {
  pageScroll(0,5);
}
//-->


// 画像プリロード
var imgs = new Array();


// 画像プリロード
function chgimg(id, imgname) {
	if(document.images) {
		if(imgs[imgname]) {
			document.images[id].src = imgs[imgname].src;
		}
		else {
			document.images[id].src = imgname;
		}
	}
}

// 画像プリロード
function AD_location(id, imgname) {
	if(document.images) {
		if(imgs[imgname]) {
			document.images[id].src = imgs[imgname].src;
		}
		else {
			document.images[id].src = imgname;
		}
	}
	
	imgname2 = imgname - 1;
	imgs[imgname2].src = imgs[imgname].src;
	
}

//テキストロケーション表示

function Lefter_Menu_location(id) {

document.getElementById(id).style.backgroundColor = "#dddddd";

}


//---------------------------------------------------------------------

//メニューロケーション用

//グローバルメニュー
function Head_Menu_location(id) {

document.getElementById(id).style.backgroundColor = "#08107B";
//document.getElementById(id).style.backgroundImage="url('/common/gm_on.gif')";

}

//ローカルメニュー
function Menu_location(id) {

document.getElementById(id).style.backgroundColor = "#08107B";
//document.getElementById(id).style.backgroundImage="url('/common/lm_on.gif')";

//function Menu_location(i,c){
// if(document.all) document.all(i).className=c;
// else if(document.getElementById)
//  document.getElementById(i).className=c; 
}



//---------------------------------------------------------------------



//レガシーオープンウィンド
function openWin( w, h ){
       wo=window.open("","exp","scrollbars=no,resizable=yes,toolbar=no,location=no,status=no,menubar=no,width="+w+",height="+h);
wo.resizeTo(w,h);
wo.focus();}

function openWin2( w, h ){
       wo=window.open("","exp","scrollbars=yes,resizable=yes,toolbar=no,location=no,status=no,menubar=no,width="+w+",height="+h);
wo.resizeTo(w,h);
wo.focus();}

function openGallery( url, w, h ){
sWidth = screen.availWidth;
sHeight = screen.availHeight;
x = (sWidth - w) / 2;
y = (sHeight - h) / 2;
       wo=window.open(url,"gallery","scrollbars=yes,resizable=yes,toolbar=no,location=no,status=no,menubar=no,width="+w+",height="+h+", left="+x+", top="+y);
}


//被写界深度表
function TableChng(hishakai){
			document.
			getElementById('hishakai_1').style.display='none';
			document.getElementById('hishakai_2').style.display='none';
			document.getElementById('hishakai_3').style.display='none';
			document.getElementById(hishakai).style.display='block';

}
//サンプル画像
function SampleimageChng(sampleimage,number){

		//number(枚数)が1だと、ページに入ったとき。
	n=1;
		for(i=0; i<number; i++){
		document.getElementById('sampleimage_'+n).style.display='none';
		n++;
		}
//		document.getElementById('sampleimage_'+2).style.display='none';
		document.getElementById('sampleimage_'+sampleimage).style.display='block';
}



// メニューロケーション表示-------------------------------------------------------------------

function lefter_menu(i,c){
 if(document.all) document.all(i).className=c;
 else if(document.getElementById)
  document.getElementById(i).className=c; 
}

function hover_menu(i,c){
 if(document.all) document.all(i).className=c;
 else if(document.getElementById)
  document.getElementById(i).className=c; 
}



//ロールオーバー
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 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 GrayOff(img){
//	img.filters["Gray"].enabled = false;
}
function GrayOn(img){
//	img.filters["Gray"].enabled = true;
}

//プルダウン
function selectProduct(selectObj) {
	if(selectObj.options[selectObj.selectedIndex].value){
		top.location.href = selectObj.options[selectObj.selectedIndex].value;
	}
}

var gAlt;
function viewPhoto(path) {
	new Ajax.Request(path+'photo.xml', {method: "get", onComplete: setPhoto });
}
function setPhoto(httpObj) {
	var setPhotoObj = document.getElementsByTagName("h1")[0];
	photoXml = httpObj.responseXML;
	photoFiles = httpObj.responseXML.getElementsByTagName("filename");
	photoLink = httpObj.responseXML.getElementsByTagName("link");
	photoAlt = httpObj.responseXML.getElementsByTagName("alt");
	photoTarget = httpObj.responseXML.getElementsByTagName("target");
	photoNo = Math.round(Math.random() * (photoFiles.length - 1));
//	alert(photoLink[photoNo].firstChild.nodeValue);
//	alert(photoNo);
	if(photoLink[photoNo].firstChild.nodeValue != "none") {
		setPhotoObj.innerHTML = '<a href="' + photoLink[photoNo].firstChild.nodeValue + '" target="' + photoTarget[photoNo].firstChild.nodeValue + '"><img src="' + photoFiles[photoNo].firstChild.nodeValue + '" width="570" height="242" alt="' +photoAlt[photoNo].firstChild.nodeValue + '"></a>';
	} else {
		setPhotoObj.innerHTML = '<img src="' + photoFiles[photoNo].firstChild.nodeValue + '" width="570" height="242" alt="' +photoAlt[photoNo].firstChild.nodeValue + '">';
	}
}
