
function openwin() {
	window.open("yougo.html", "", "width=870,height=800");
}

/**
 * テロップ表示
 * msg   : 表示するメッセージ
 * moveW : 移動距離
 * time  : 移動間隔
 * id    : テロップ表示要素
 */
function terop(msg, moveW, time, id){
	// テロップを表示する要素を取得
	var base = document.getElementById(id);

	var stylePosition = getElementStyle(id, "position", "position");

	if(stylePosition == "" || stylePosition == "static"){
		base.style.position = "relative";
	}

	var styleWidth = getElementStyle(id, "width", "width");
	if(styleWidth == "" || styleWidth == "auto"){
		base.style.width = "100%";
	}

	base.style.overflow = "hidden";

	var message = document.createElement("span");
	base.appendChild(message);
	message.innerHTML = msg;
	message.style.position = "relative";
	message.style.left = base.offsetWidth + "px";
	message.style.whiteSpace = "nowrap";

	var move = function(){
		if(parseInt(message.style.left) < -(message.offsetWidth)){
			message.style.left = (base.offsetWidth + 1)+"px";
		}
		if(parseInt(message.style.left) > base.offsetWidth){
			message.style.left = base.offsetWidth + "px";
		}else{
			message.style.left = (parseInt(message.style.left) - moveW) + "px";
		}
		setTimeout(move, time);
	}

	move();


}


/**
 * スタイル値取得関数
 * elemID       : 対象要素ID
 * IEStyleProp  : IE用CSS属性名(aaaBbb形式)
 * CSSStyleProp : その他用CSS属性名(aaa-bbb形式)
 */
function getElementStyle(elemID, IEStyleProp, CSSStyleProp){
	var elem;
	if(typeof(elemID) == "string"){
		elem = document.getElementById(elemID);
	}else{
		elem = elemID;
	}
	if(elem.currentStyle){
		return elem.currentStyle[IEStyleProp];
	}else if(window.getComputedStyle){
		var compStyle = window.getComputedStyle(elem, "");
		return compStyle.getPropertyValue(CSSStyleProp);
	}
}


/**
 * テロップ文取得
 */
function getTeropMessage(){
	crossRequest(true, "get", "./files/terop.txt", function(data){
		if(!data){return;}
		else{
			terop(data, 1, 30, "terop");
		}
	}, 1000);
}


/**
 * Ajax通信
 * async      : 非同期通信を行うか
 * method     : get/post
 * requestURL : 取得するファイル
 * callBack   : 取得後に実行する処理
 * timeout    : 通信タイムアウト時間
 * cross      : クロスドメインを利用するか
 * */
function crossRequest(async, method, requestURL, callBack, timeout, cross){

	var xhr = null;
	var ie = (/*@cc_on!@*/false) ? true : false;

	// キャッシュしないようにミリ秒をつける
	(requestURL.match(/\?/)) ? requestURL += "&" : requestURL += "?";
	requestURL += "cache=" + new Date().getTime();

	// IE のときはXDomainRequestを使う
	if(ie){
		if( window.XDomainRequest && cross){
			xhr = new XDomainRequest();
		}else{
			try{
				xhr = new XMLHttpRequest();
			}
			// IE5, IE6
			catch(e){
				// MSXML3
				try{
					xhr = new ActiveXObject("Msxml2.XMLHTTP");
				}
				// MSXML2まで
				catch(e){
					try{
						xhr = new ActiveXObject("Microsoft.XMLHTTP");
					}
					//どれにもあてはまらない場合
					catch(e){
						return null;
					}
				}
			}
		}
	}else{
		// その他の場合はXMLHttpRequest level2 でいけるので普通に
		xhr = new XMLHttpRequest();
	}

	if(xhr == null){ return;}


	// タイマーセット。 タイムアウトしたら処理終了
	var timer = setTimeout(function(){ xhr.abort(); xhr.onload = null;}, timeout);

	// 結果をロードできたら
	if((ie && cross) || !ie){
		xhr.onload = function(){

			// タイマー解除
			clearTimeout(timer);

			// 関数があったらそれを呼ぶ
			if(callBack){
				callBack(xhr.responseText);
			}
		}
	}else{
		xhr.onreadystatechange = function(){
			if(xhr.readyState != 4){
				return;
			}
			/** タイマーを停止 */
			clearTimeout(timer);

			if(xhr.status == 200){
				/** httpリクエスト成功 */
				if(callBack){
					callBack(xhr.responseText);
				}
			}
			
		}
	}

	xhr.open(method, requestURL, async);
	xhr.send(null);

}





