//Studio Rikiy Function Script 2006/8/6

//Function Import -----------

//ポップアップウィンドウスクリプト Ver.1.00
function openWin(wUrl , wName , Width , Height , Resize , Status , Scroll){
wOption = "toolbar=no,location=no,directories=no,status=" + Status +",menubar=no,scrollbars=" + Scroll +",resizable=" + Resize +",width=" + Width + ",height=" + Height + ",left=";
w = window.open(wUrl,wName,wOption);
w.focus();
}

//SWFファイル表示スクリプト　Ver.1.20
//2006/8/6 Programed By Rikiya Takazawa

//設定ここから--------------------

//モード設定（代替画像表示モード=0,ページリダイレクトモード=1）
var Mode = 0;

//出力するswfファイルのバージョン設定
var FlashVarsion = "5";

//設定ここまで、以下編集禁止--------------------

function checkFlash(varsion){

	var browser = navigator.appName;

	if (browser != "Microsoft Internet Explorer" ){
		for(i = 0; i < navigator.plugins.length; i++) {
			if(navigator.plugins[i].name ==  "Shockwave Flash"){ 
				if(parseInt(navigator.plugins["Shockwave Flash"].description.substring(navigator.plugins["Shockwave Flash"].description.indexOf(".")-1)) < varsion ){ return 2; }
				else{ return 0; }
			}
		}
		return 1;
	}else{ return 0; }

}

function writeSWF(flashObj , Bg , Width , Height , noFlash ){

	var flag = checkFlash(FlashVarsion);

	if( flag == "0"){
		document.open();
			document.write('<div>');
				document.write('<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" width=\"' + Width + '\" height=\"' + Height + '\">');
				document.write('<param name=\"movie\" value=\"' + flashObj + '\">');
				document.write('<param name=\"quality\" value=\"high\">');
				document.write('<param name=\"bgcolor\" value=\"#'+ Bg +'\">');
				document.write('<param name=\"menu\" value=\"false\">');
				document.write('<embed src=\"' + flashObj + '\" quality=\"high\" bgcolor=\"#'+ Bg +'\"  width=\"' + Width + '\" height=\"' + Height + '\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" menu=\"false\"></embed>');
				document.write('</object>');
		document.write('</div>' + '\n');
		document.close();
	}else if(Mode == "1"){
		location.href = noFlash ;
	}else if(Mode == "0"){
		document.open();
		document.write('<img src=\"' + nonFlash + '\" width=\"' + Width + '\" height=\"' + Height + '\" border=\"0\" alt=\"\">');
		document.close();
	}
}

//フォントサイズ可変スクリプト　Ver.1.10 ---------------------
//2006/8/6 Programed By Rikiya Takazawa

//設定ここから --------------------------------

//サイズリスト
SizeList = new Array (75,87.5,100,130,150);

//デフォルトサイズのインデックス数
DefaultKey = 2;

//Bodyタグに挿入するID名
BodyID = "default";

//設定ここまで、以下編集禁止 --------------------------------


if(GetCookie("StudioRikiyFSS") == "none"){
	key = DefaultKey;
}else{
	key = Number(GetCookie("StudioRikiy"));
}

document.writeln('<style type="text/css"><!--');
document.writeln('#'+BodyID+'{font-size: '+SizeList[key]+'%;}');
document.writeln('//--></style>');

function cgfont(value){
	if(value=="large" && key < SizeList.length-1){
		key += 1;
	}else if(value=="small" && key > 0){
		key -= 1;
	}else if(value=="default"){
		key = DefaultKey;
	}
	size = SizeList[key] + "%";
	if(document.all){
		document.all(BodyID).style.fontSize = size;
	}
	if(document.getElementById){
		document.getElementById(BodyID).style.fontSize = size;
	}
	WriteCookie("StudioRikiyFSS",key)
}


function WriteCookie(name,value){
	tmp = name+"="+value+";";
	tmp += "expires=Fri, 31-Dec-2030 23:59:59;";
	tmp += "path=/;";
	document.cookie = tmp;
}

function GetCookie(value){

	data = document.cookie+";";
	tmp = data.indexOf(value,0);
	if(tmp != -1){
		size = data.substring(tmp,data.length);
		start = size.indexOf("=",0);
		end = size.indexOf(";",start);
		return(unescape(data.substring(start+1,end)));
	}else{
		return "none";
	}
}


//ページトップモーションスクリプト ---------------------


// [MODE] 1:一定間隔で移動します  2:上に近づくに伴い移動幅は短くなります。
MODE = 2;

// [SPEED] 移動スピードです。
// オススメ：MODEが1の場合は35, MODEが2の場合は10
SPEED = 10;


SCROLLMOVE = null;
IE7CHECK = navigator.userAgent;
IE7CHECK = IE7CHECK.indexOf("MSIE 7.0",0);

function goToTop(){
	var yy = getScreenY();
	if(yy>0){
		if(MODE == 1){ yy -= SPEED; }
		else{ var editY = yy/SPEED; yy -= editY; yy = Math.floor(yy); }
		toTop(yy); SCROLLMOVE = setTimeout("goToTop()",1);
	}
	else{ clearTimeout(SCROLLMOVE); return; }
}

function toTop(snum){
	if(document.all && (IE7CHECK == -1)){
		document.body.scrollTop = snum;
	}else{
		window.scrollTo(0,snum);
	}
}

function getScreenY(){
	if(IE7CHECK !== -1){
		return document.documentElement.scrollTop;
	}else if(document.all){
		return document.body.scrollTop;
	}else{
		return window.pageYOffset;
	}
}



//スワップイメージ --------------------
function SwImg(filename,target){
	document.images[target].src = filename;
}



//Dock風メニュー --------------------

itv3 = 8; // フェイドイン・アウト速度(ミリ秒単位)
MinFontSize = 75;
MaxFontSize = 175;
FontSize = new Object();
StatesFlag = new Object();
timerID = 10;

function FontMotion(TargetID,MotionFlag){
	clearTimeout(timerID);
	StatesFlag[TargetID] = MotionFlag;
	FunMotion(TargetID);
}


function FunMotion(TargetID){

	if(document.all) TargetFont = document.all[TargetID];
	if(document.getElementById) TargetFont = document.getElementById(TargetID);

	if(!FontSize[TargetID]) FontSize[TargetID] = MinFontSize;
	if(StatesFlag[TargetID] == 0) FontSize[TargetID] +=10;
	if(StatesFlag[TargetID] == 1) FontSize[TargetID] -=10;

	if(FontSize[TargetID] < MinFontSize) FontSize[TargetID] = MinFontSize;
	if(FontSize[TargetID] > MaxFontSize) FontSize[TargetID] = MaxFontSize;
	TargetFont.style.fontSize = FontSize[TargetID]+"%";
	if(FontSize[TargetID] > MinFontSize && FontSize[TargetID] < MaxFontSize) setTimeout("FunMotion('" + TargetID + "')",itv3);

}

itv4 = 5; // フェイドイン・アウト速度(ミリ秒単位)
MinImgSize = 36;
MaxImgSize = 72;
ImgSize = new Object();
StatesFlag = new Object();
timerID = 10;

function ImgMotion(TargetID,MotionFlag){
	clearTimeout(timerID);
	StatesFlag[TargetID] = MotionFlag;
	FunImgMotion(TargetID);
}

function FunImgMotion(TargetID){

	if(document.all) TargetImage = document.all[TargetID];
	if(document.getElementById) TargetImage = document.getElementById(TargetID);

	if(!ImgSize[TargetID]) ImgSize[TargetID] = MinImgSize;
	if(StatesFlag[TargetID] == 0) ImgSize[TargetID] +=6;
	if(StatesFlag[TargetID] == 1) ImgSize[TargetID] -=6;

	if(ImgSize[TargetID] < MinImgSize) ImgSize[TargetID] = MinImgSize;
	if(ImgSize[TargetID] > MaxImgSize) ImgSize[TargetID] = MaxImgSize;
	TargetImage.style.width = ImgSize[TargetID]+"px";
	TargetImage.style.height = ImgSize[TargetID]+"px";
	if(ImgSize[TargetID] > MinImgSize && ImgSize[TargetID] < MaxImgSize) setTimeout("FunImgMotion('" + TargetID + "')",itv4);

}



//インフォメーションバー --------------------

function LoadNews(){
	NewsID = document.getElementById("news");

	n = NewsID.getElementsByTagName('LI').length;

	NewsValue = new Array();
	NewsLink = new Array();
	NewsTarget = new Array(); 
	NewsTitle = new Array(); 


	for(i=0; i<n; i++){
		NewsValue[i] = NewsID.getElementsByTagName('LI').item(i).firstChild.firstChild.nodeValue;
		NewsLink[i] = NewsID.getElementsByTagName('LI').item(i).firstChild.href;
		NewsTarget[i] = NewsID.getElementsByTagName('LI').item(i).firstChild.target;
		if(NewsTarget[i]==""){ NewsTarget[i] = "_self";}
		NewsTitle[i] = NewsID.getElementsByTagName('LI').item(i).firstChild.title;
	}

	for(i=1; i<n; i++){ NewsID.removeChild(NewsID.getElementsByTagName('LI').item(1)); }

	NewsID.style.display = "block";

	strFade('headline');

}

InfoFlag = 0;


FadeText = "edcba987654";
itv = 40;
itv2 = 3000;
cnt = 0;
FadeFlag = "In";


function strFade(str){
	if(document.all){ HeadLine = document.all(str); }
	if(document.getElementById){ HeadLine = document.getElementById(str); }

	HeadLine.firstChild.nodeValue = NewsValue[InfoFlag];
	HeadLine.href = NewsLink[InfoFlag];
	HeadLine.target = NewsTarget[InfoFlag];
	HeadLine.title = NewsTitle[InfoFlag];

	if(FadeFlag == "In") c = FadeText.charAt(cnt++);
	if(FadeFlag == "Out"){
	cnt-=1;
	c = FadeText.charAt(cnt);
	}

	HeadLine.style.color = "#"+c+c+c+c+c+c;
	if(cnt < FadeText.length) setTimeout("strFade('" + str + "')",itv);
	if(cnt == FadeText.length){
		FadeFlag = "Out";
		setTimeout("strFade('" + str + "')",itv2);
	}
	if(cnt == 0){
		FadeFlag = "In";
		if(InfoFlag == n-1){ InfoFlag = 0; }
		else{ InfoFlag++; }
	}
}


var SboxFlag = 0;
function Sbox(){
	if(SboxFlag == 0){
		document.getElementById('sc').style.backgroundImage= 'url("/common/img/m-sc2.gif")';
		document.getElementById('ss').style.backgroundImage= 'url("/common/img/bg_hd2.gif")';
		document.getElementById('form0').style.display = "block";
		document.form0.q.focus();
		SboxFlag = 1;
	}else{
		document.getElementById('ss').style.backgroundImage= 'url("/common/img/bg_hd.gif")';
		document.getElementById('sc').style.backgroundImage= 'url("/common/img/m-sc.gif")';
		document.getElementById('form0').style.display = "none";
		SboxFlag = 0;
	}
}
