
//ボタン・ロールオーバー
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_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_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 openWin640(fileName) {
	window.open(fileName,'zoom','toolbar=no,status=no,scrollbars=no,menubar=no,locationbar=no,width=640,height=480');
}
function openZoomWin(fileName) {
	opwin = window.open(fileName,'','toolbar=no,status=no,scrollbars=no,menubar=no,locationbar=no,width=720,height=633');
	opwin.focus();
}
function openWin387(fileName) {
	window.open(fileName,'newwin','toolbar=yes,status=yes,scrollbars=yes,menubar=yes,locationbar=yes,width=387,height=560');
}

function openWinBlank(url) {
	if (url) {
	opwin = window.open(url);
	opwin.focus();
	}
}


document.getElementsByClassName = function (className) {
    var i, j, eltClass;
    var objAll = document.getElementsByTagName ? document.getElementsByTagName("*") : document.all;
    var objCN = new Array();
    for (i = 0; i < objAll.length; i++) {
        eltClass = objAll[i].className.split(/\s+/);
        for (j = 0; j < eltClass.length; j++) {
            if (eltClass[j] == className) {
                objCN.push(objAll[i]);
                break;
            }
        }
    }
    return objCN;
}

var slideFlg = true;
var nowTopPic = 0;
var webInfo = [];
var moreInfo = [];
//var nowTopPic =Math.floor (Math.random ()*3);
//alert(nowTopPic);

function setTopOn() {
	document.getElementsByClassName('topwaku')[nowTopPic].style.filter="alpha(opacity=0)";
	document.getElementsByClassName('topwaku')[nowTopPic].style.MozOpacity=0.0;
	document.getElementsByClassName('topwaku')[nowTopPic].style.cursor="auto";
var iNum = "i"+(nowTopPic+1);
var text = document.getElementById(iNum).innerHTML;
document.getElementById("info").innerHTML = text;
}
function setTopOff() {
	document.getElementsByClassName('topwaku')[nowTopPic].style.filter="alpha(opacity=60)";
	document.getElementsByClassName('topwaku')[nowTopPic].style.MozOpacity=0.6;
	document.getElementsByClassName('topwaku')[nowTopPic].style.cursor="pointer";
}


function topRollOn(num,classNum) {
slideFlg=false;
	if (classNum != nowTopPic) {
	num.childNodes[1].style.filter="alpha(opacity=0)";
	num.childNodes[1].style.MozOpacity=0.0;
	}
}
function topRollOff(num,classNum) {
slideFlg=true;
	if (classNum != nowTopPic) {
	num.childNodes[1].style.filter="alpha(opacity=60)";
	num.childNodes[1].style.MozOpacity=0.6;
	}
}

function topClick(classNum,webSite,moreInfo) {
setTopOff();
nowTopPic=classNum;
nowWebsite = webSite;
nowMoreInfo = moreInfo;
iNum = "i"+(classNum+1);
text = document.getElementById(iNum).innerHTML;
document.getElementById("info").innerHTML = text;
}

function slideShow() {
//alert("slideshow");
if (slideFlg) {
setTopOff();
if (nowTopPic==2) {
nowTopPic=0;
} else {
nowTopPic=nowTopPic+1;
}
nowWebsite = website[nowTopPic];
nowMoreInfo = moreInfo[nowTopPic];
iNum = "i"+(nowTopPic+1);


new Effect.BlindUp("info", {
		from:0.0, // 開始時透明度
		to:1.0, // 終了時透明度
		// delay:0, // 開始までの秒数
		fps:60, // フレームレート
		duration: 0.8, // アニメーションする時間(秒)

		afterFinishInternal: function(effect) {
		Element.hide($("info"));
		text = $(iNum).innerHTML;
		Element.update($("info"), text); 

	document.getElementsByClassName('topwaku')[nowTopPic].style.filter="alpha(opacity=0)";
	document.getElementsByClassName('topwaku')[nowTopPic].style.MozOpacity=0.0;
	document.getElementsByClassName('topwaku')[nowTopPic].style.cursor="auto";
		},
		queue: 'front'
	});

new Effect.BlindDown("info", {
		from:0.0, // 開始時透明度
		to:1.0, // 終了時透明度
		delay:0.0, // 開始までの秒数
		fps:60, // フレームレート
		duration: 1, // アニメーションする時間(秒)

		queue: 'end'
	});


}
}

function goWebsite() {
//alert(nowWebsite);
opwin = window.open(nowWebsite);
opwin.focus();
//location.href=nowWebsite;
}

function goMoreinfo() {
//alert(nowMoreInfo);
location.href=nowMoreInfo;

}



function itemRollOn(num) {
num.style.backgroundColor="#ff3366";
//alert(num.childNodes[0].innerHTML);
num.childNodes[0].style.color="#ffffff";
num.childNodes[0].style.backgroundImage="url(http://www.cyp.co.jp/images/menu_arrow_on.gif)";
}

function itemRollOff(num) {
num.style.backgroundColor="#f5f5f5";
num.childNodes[0].style.color="#999999";
num.childNodes[0].style.backgroundImage="url(http://www.cyp.co.jp/images/menu_arrow.gif)";
}

function imgRollOn(num) {
num.childNodes[1].style.borderWidth="2px";
}
function imgRollOff(num) {
num.childNodes[1].style.borderWidth="0px";
}

function imgClick(num,classNum) {
//alert(num.childNodes[0].src);
var myImgName = num.childNodes[0].src;
var imgName = myImgName.substring(0,(myImgName.length)-5)+".jpg";
var obj = document.getElementsByClassName('chgimg')[classNum];
obj.src =imgName;
}


//詳細表示
function showDetail(imgName) {
var obj = document.getElementById('mainpic');
obj.src =imgName;
}

//ヒストリーバック
function hback() {
	history.back();
}


// Fade-to colour without the # (6 character value only!)
var fadeTo = "FF3366";

// Fade in colour increment/decrement by
var fiBy = 10;

// Fade out colour increment/decrement by
var foBy = 10;

// Speed - milliseconds between each colour change in the fade
// Less than 10ms doesn't really make all that much difference, so
// 10 is the minimum effective value.
var speed = 10;

// Class name of links to NOT fade (i.e. ignore)
// var ignoreClass = "somebogusvalue" if you don't want to
// use this feature. Alternatively, add onmouseover="clearFade()"
// to the link you do not wish to fade.
var ignoreClass = "ignore";

// No more changes required (unless you know what you are doing)
// Enjoy... and email me and let me know what site(s) you are using it on :)
var opera, ie, dom, x = 0, oc, fader, ocs = new Array();

if (navigator.userAgent.indexOf("Opera") != -1) opera = true
else if (document.all && !opera) ie = true
else if (!document.all && document.getElementById) dom = true;

function convertRGB(z)
	{
		var newfcS = "", splitter = "";
		splitter = z.split(",");
		splitter[0] = parseInt(splitter[0].substring(4, splitter[0].length));
		splitter[1] = parseInt(splitter[1]);
		splitter[2] = parseInt(splitter[2].substring(0, splitter[2].length-1));
		for (var q = 0; q < 3; q++)
			{
				splitter[q] = splitter[q].toString(16);
				if (splitter[q].length == 1) splitter[q] = "0" + splitter[q];
				newfcS += splitter[q];
			}
		return newfcS;
	}

function currentColour(index)
	{
		var temp, cc;
		if (opera) cc = document.links[index].style.color
		else if (ie) cc = document.links[index].currentStyle.color
		else if (dom) 
		{
			var style = document.defaultView.getComputedStyle(document.links[index], '');
			if(style)
				cc = style.getPropertyValue("color");
			else
				return null;
		}
		if (cc.length == 4 && cc.substring(0, 1) == "#")
			{
				temp = "";
				for (var a = 0; a < 3; a++)
					temp += cc.substring(a+1, a+2) + cc.substring(a+1, a+2);
				cc = temp;
			}
		else if (cc.indexOf("rgb") != -1) cc = convertRGB(cc)
		else if (cc.length == 7) cc = cc.substring(1, 7)
		else cc = fadeTo;
		return cc;
	}


function convert2Dec(hex)
	{	
		var rgb = new Array();
		for (var u = 0; u < 3; u++)
		{
			rgb[u] = parseInt(hex.substring(u*2, u*2+2), 16);
		}
		return rgb;
	}

function newRGB(f, n, d)
	{
		var change;
		if (d == 1) change = fiBy
		else change = foBy;
		for (var g = 0; g < 3; g++)
			{
				if (n[g] > f[g] && n[g] - change >= 0) n[g] -= change;
				if (n[g] < f[g] && n[g] + change <= 255) n[g] += change;
			}
		return n;
	}

function fade(index, d)
	{
		var fc, nc, temp = new Array(), finished = false;
		nc = convert2Dec(currentColour(index));
		if (d == 1) fc = convert2Dec(fadeTo)
		else fc = convert2Dec(ocs[x]);
		temp = convert2Dec(currentColour(index));
		nc = newRGB(fc, nc, d);
		if ((nc[0] == temp[0]) && (nc[1] == temp[1]) && (nc[2] == temp[2]))
			finished = true;
		if (!finished) document.links[x].style.color = "rgb(" + nc[0] + "," + nc[1] + "," + nc[2] + ")"
		else clearInterval(fader);
	}

function findLink(over)
	{
		if (document.layers) return;
		if (fader)
			{
				clearInterval(fader);
				document.links[x].style.color = "#" + ocs[x];
			}
		x = 0;
		while (!(this.id == document.links[x].id) && (x < document.links.length))
			x++;
		if (this.id == document.links[x].id)
			{
				oc = currentColour(x);
				fader = setInterval("fade(" + x  + ", 1)", speed);
			}
	}

function clearFade()
	{
		if (document.layers) return;
		if (fader) clearInterval(fader);
		fader = setInterval("fade(" + x + ", 0)", speed);
	}

function init()
	{
		for (var i = 0; i < document.links.length; i++)
			{
				ocs[i] = currentColour(i);
				var currentOver = document.links[i].onmouseover;
				var currentOut = document.links[i].onmouseout;
				var ignoreIt = document.links[i].className == ignoreClass;
				if (!ignoreIt && document.links[i].id.length == 0) document.links[i].id = "link" + i;
				if (!currentOver && !currentOut && !ignoreIt)
					{
						document.links[i].onmouseover = findLink;
						document.links[i].onmouseout = clearFade;
					}
			}		
}

if (opera || ie || dom) window.onload = init;
