// JavaScript Document

var $message=new Array();
$message[0]="バンフガイドサービスのホームページへようこそ。";

var $numMessage=$message.length;															// Get the number of scroll messages

var $aa=0;
var $bb=0;
var $speed=50;																								// Set msec value of scroll speed. -->
var $hold=50;																									// Set number of count to hold a whole message displayed -->
var $currentMsg="";

function scroll() {																							// This function displays scrolling texts
	if (!document.getElementById) return false;											// Checking browser compatibility
	$msgLen=$message[$aa].length;																// Get the number of letters in a message
	if($bb<=$msgLen) {																						// If the count($bb) is equal to or less than the number of  letters in a message ...
		$currentMsg=$message[$aa].substring(0,$bb);											// Set the current message to index 0 to index $bb-1 of the message
	}
		else if(($bb>$msgLen)&&($bb<=$msgLen+$hold)) {									
			$currentMsg=$message[$aa];																// Set the whole message as current for the number of $hold
		}
		else if($bb>$msgLen+$hold) {																	// When the hold expires ...
			$currentMsg=$message[$aa].substring($bb-$hold-$msgLen,$msgLen);	//  Erase one letter at the top of the message
		}
	setObject("scroller").firstChild.nodeValue=$currentMsg;	// Replace texts in the scroller
	
	$bb++;																											//  Increment the counter
	if($bb-$hold-$msgLen>=$msgLen) {															//  When the counter went past the hold count ...,
		$bb=0;																										// Initialize the counter		
		$aa++;																										// Increment message index counter
		if($aa>($numMessage-1)) {$aa=0;}														// Initialize the message index counter, when it exceeds the number of messages			
	}
	setTimeout("scroll()",$speed);																	// Re-call the function itself every $speed msec
	
}	// ------------------------------------------------------------------------------------------ End function scroll()

var $cc=1;
function slideshow(){
	if($cc>5) $cc=0;
	setObject("slide").src="images/slide"+$cc+".jpg";
	$cc++;
	setTimeout("slideshow()",3000);
}	// ------------------------------------------------------------------------------------------ End function slideshow()

var $info=new Array(7);
$info[0]="サマーツアー<br />神秘的な青をたたえる湖や切り立つ山々を見ながらアサバスカ氷河へ…。コロンビア大氷原観光は世界中の人々に大人気。様々な観光ツアーやハイキングをはじめ、乗馬、ラフティング、フィッシングなど、ロッキーならではの楽しくワイルドなアクティビティーをお楽しみいただけます。";
$info[1]="ウィンターツアー<br />カナディアンロッキーは冬も楽しいアクティビティーでいっぱい。スキー・スノーボードだけでなく、犬ぞり、スノーシューハイキングや観光もお楽しみいただけます。";
$info[2]="ツアー予約<br />ツアーの予約、お問い合わせ、ならびにツアー参加時の注意事項についてのご案内。";
$info[3]="現地情報 (更新停止中/過去記事は閲覧できます)<br />スキー、道路情報や最近の話題など、ガイドブックからは得られない現地発の情報を不定期にお届けします。";
$info[4]="リンク<br />カナダ、ならびにカナディアンロッキーをご旅行の際に情報源として役立ちそうな各種リンクを集めてみました。";
$info[5]="クーポン<br />休止中";
$info[6]="会社案内<br />弊社 バンフガイドサービスについてのご案内。";

var $br=document.createElement("br");
var $tex1=document.createTextNode(null);
var $tex2=document.createTextNode(null);
var $tex00=document.createTextNode("このウェブサイトは Internet Explorer 7, Firefox 3, Safari 3");
var $tex01=document.createTextNode("で動作確認をしています。それ以外のブラウザをご利用の場合、正常に表示されないことがあります。また、すべての機能をご利用いただくためには JavaScript を有効にしてください (ほとんどのブラウザでは初期設定で有効になっています)。");

function changeInfo($i,$k){
	if(setObject("info").childNodes.length) {								// Only if the info box has any child node inside ...
		var $numChild=setObject("info").childNodes.length;		// Assign the number of  child nodes to $numChild
		for (var $h=$numChild;$h--;$h>-1) {						// This loop removes all the child nodes in the info box
			var $delete=setObject("info").childNodes[$h];			// Set the node to be removed
			setObject("info").removeChild($delete);						// Remove the child node
		}																					// The info box now do not have any child node 
	}
	if ($i==1) {																		// "onmouseover"のときの処理
		var $brPos=$info[$k].indexOf("<br />");					// Find the position(index) of <br />tag inside the info string
		$tex1.nodeValue=$info[$k].substring(0,$brPos);		// Assing the sub string before <br />tag to $tex1
		$tex2.nodeValue=$info[$k].substring($brPos+6,$info[$k].length);	// Assign the sub string after <br />tag to $tex2
		setObject("info").appendChild($tex2);							// Append $tex2 to the info box
		setObject("info").insertBefore($br, $tex2);						// Insert <br />tag before $tex2
		setObject("info").insertBefore($tex1, $br);						// Insert $tex1 before <br />tag
	}
	else{																				//　"onmouseout"のときの処理
		setObject("info").appendChild($tex01);							// Append the second string of the default info to the info box
		setObject("info").insertBefore($br, $tex01);					// Insert line break
		setObject("info").insertBefore($tex00, $br);					// Insert the first string of the defaust info before the line break
	}
}
