function swf_object(SWF,WID,HEI){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width='+ WID +' height='+ HEI +'>');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="allowFullScreen" value="false" />');
	document.write('<param name="movie" value="'+ SWF +'.swf" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="bgcolor" value="#000000" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<embed src="'+ SWF +'.swf" quality="high" wmode="transparent" bgcolor="#000000" width='+ WID +' height='+ HEI +' name="coverflow" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}

window.onload = init;

function init() {
	if(navigator.userAgent.indexOf("Mac") != -1){
		document.body.style.letterSpacing = "-0.1em";
	}
	try { 
		document.execCommand('BackgroundImageCache', false, true); 
	}catch(e){
		
	}
	initRollovers();
	border_none();
	popupWindow(740, 690);
	popupcos(350, 515);
	pageReturn();
	toggle();
	infoBerLoad();
	crossfade("pickuplist",1000,3000);
}

//-----------------------------------------------
//	西暦表示
//-----------------------------------------------
function setYear() {
	var date = new Date();
	document.write(date.getFullYear());
}



//-----------------------------------------------
//	ロールオーバー
//-----------------------------------------------
function initRollovers() {
	if (!document.getElementById) return;

	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {	
		if (aImages[i].className == 'rollover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			hsrc = src.replace(ftype, '_over'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);

			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;

			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	

			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_over'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

//-----------------------------------------------
//	クリック時のフォーカスを非表示に
//-----------------------------------------------
function border_none(){
	var all_link = document.links;
	for(i=0;i<all_link.length;i++){
		all_link[i].onfocus = function(){
			this.blur();
		}
	}
}

//-----------------------------------------------
//	ポップアップ
//-----------------------------------------------
function popupWindow(_width, _height) {
	var options = "width=" + _width + ",height=" + _height + ",scrollbars=no";
	var open = function(url) {
		var newWindow = window.open(url, "popup", options);
		//newWindow = window.open(url,"popup","width=740,height=690,scrollbars=no");
		newWindow.focus();
	}
	
	var links = document.getElementsByTagName("a");
	for(var i = 0; i < links.length; i++) {
		if(links[i].className == "popup") {
			links[i].onclick = function() {
				open(this.getAttribute("href"));
				return false;
			}
		}
	}
}
//-----------------------------------------------
//	ポップアップ
//-----------------------------------------------
function popupcos(_width, _height) {
	var options = "width=" + _width + ",height=" + _height + ",scrollbars=no";
	var open = function(url) {
		var newWindow = window.open(url, "popupcos", options);
		//newWindow = window.open(url,"popup","width=740,height=690,scrollbars=no");
		newWindow.focus();
	}
	
	var links = document.getElementsByTagName("a");
	for(var i = 0; i < links.length; i++) {
		if(links[i].className == "popupcos") {
			links[i].onclick = function() {
				open(this.getAttribute("href"));
				return false;
			}
		}
	}
}

function winClose(){
	if(!document.getElementById("close")){
		return false;
	}
	var btnClose = document.getElementById("close");
	btnClose.onclick = function(){
		window.close();
	}
}

function prepareLinks() {
    if(!document.getElementsByTagName){
    	return false;
    }
    var links = document.getElementsByTagName("a");
    for (var i=0; i<links.length; i++) {
        if(links[i].getAttribute("className") == "popup" || links[i].getAttribute("class") == "popup") {
            links[i].onclick = function() {
                popUp(this.getAttribute("href"));
                return false;
            }
        }
    }
}
function pageReturn(){
	if(!document.getElementById("pageReturn")){
		return false;
	}
	var returnBtn = document.getElementById("pageReturn");
	returnBtn.onclick = function(){
		history.back(-1)
	}
}

function toggle() {
	if(!document.getElementById("change")){
		return false;
	}
	var btn_pickup = document.getElementById("btn_topics").firstChild;
	var btn_newface = document.getElementById("btn_event").firstChild;
	var pickup = document.getElementById("topics");
	var newface = document.getElementById("event");
	btn_pickup.onclick = function(){
		if(this.getAttribute("src").match("_off.")){
			this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));
			btn_newface.setAttribute("src", btn_newface.getAttribute("src").replace("_on.", "_off."));
			pickup.style.display='block';
			newface.style.display='none';
			btn_pickup.style.cursor='defult';
			btn_newface.style.cursor='pointer';
		}
	}
	btn_newface.onclick = function(){
		if(this.getAttribute("src").match("_off.")){
			this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));
			btn_pickup.setAttribute("src", btn_pickup.getAttribute("src").replace("_on.", "_off."));
			newface.style.display='block';
			pickup.style.display='none';
			btn_newface.style.cursor='defult';
			btn_pickup.style.cursor='pointer';
		}
		
	}
}

/*------------インフォメーションバー---------------*/
var flowValue = 0;
var scrollArea = "";
var firstPoint = 0;
var interval = 1;
function infoBerLoad(){
	if(!document.getElementById("newsbar")){
		return;
	}
	var targetPoint = document.getElementById("newsbar");
	firstPoint = targetPoint.offsetWidth;
	flowValue = firstPoint;

	if(targetPoint == ""){
		return;
	}
	
	if(navigator.userAgent.indexOf("Chrome") != -1){
		interval = 12;
	}
	nowURL = location.href;
	info = createAjax();
	//if(nowURL.indexOf("ladies") != -1 || nowURL.indexOf("schedule") != -1){
		path = "../newsbar/xml/info.xml";
	//}else{
	//	path = "info/xml/info.xml";
	//}
	info.open("GET",path);
	info.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
	info.setRequestHeader( 'If-Modified-Since', 'Thu, 01 Jun 1970 00:00:00 GMT');
	info.send(null);
	info.onreadystatechange = function(){
		if(info.readyState == 4 && info.status == 200){
			infoData = info.responseXML;
			var description = infoData.getElementsByTagName("description")[0].firstChild.nodeValue;
			var description2 = infoData.getElementsByTagName("description")[0].firstChild.nodeValue;
			var mask = document.createElement("div");
			scrollArea = document.createElement("div");
			scrollArea2 = document.createElement("div");
			mask.style.position = "relative";
			scrollArea.style.position = "relative";
			scrollArea.style.left = firstPoint+"px";
			scrollArea.style.whiteSpace = "nowrap";
			scrollArea.innerHTML = description;
			scrollArea2.style.position = "relative";
			scrollArea2.style.left = firstPoint+"px";
			scrollArea2.style.whiteSpace = "nowrap";
			scrollArea2.innerHTML = description2;
			mask.appendChild(scrollArea);
			mask.appendChild(scrollArea2);
			if(targetPoint.firstChild){
				targetPoint.replaceChild(mask,targetPoint.firstChild);
			}else{
				targetPoint.appendChild(mask);
			}
			
			setInterval("textMarquee();",interval);
		}
	}
}
function textMarquee(){
	
	flowValue -= 1;
	scrollArea.style.left = flowValue+"px";
	if(flowValue <= (0-(scrollArea.offsetWidth+200))){
		flowValue = firstPoint;
	}
}

function createAjax(){

	if(window.XMLHttpRequest){
		Ajax = new XMLHttpRequest();
	}else if(window.ActiveXObject){
		try {
			Ajax = new ActiveXObject("Msxm21.XMLHTTP");
		} catch(e) {
			Ajax = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return Ajax;
}

//-----------------------------------------------
//	クロスフェード
//-----------------------------------------------

function crossfade(IDname , fadetime , speed){
	if(!document.getElementById(IDname)){
		return;
	}
	var news = document.getElementById(IDname);
	var newslinks = news.getElementsByTagName("li");
	for(var i=0; i<newslinks.length; i++){
		newslinks[i].id = [i];
		newlength = new Array([i]);
	}
	for(var j=0; j<newslinks.length; j++){
		newlength[j]=[j];
	}
	new Crossfader(newlength, fadetime, speed );
}

var useBSNns;

if (useBSNns){
	if (typeof(bsn) == "undefined")
		bsn = {}
	var _bsn = bsn;
}else{
	var _bsn = this;
}

_bsn.Crossfader = function (divs, fadetime, delay ){
	this.nAct = -1;
	this.aDivs = divs;
	
	for (var i=0;i<divs.length;i++){
		document.getElementById(divs[i]).style.opacity = 0;
		document.getElementById(divs[i]).style.position = "absolute";
		document.getElementById(divs[i]).style.filter = "alpha(opacity=0)";
		document.getElementById(divs[i]).style.visibility = "hidden";
	}
	
	this.nDur = fadetime;
	this.nDelay = delay;
	this._newfade();
}

_bsn.Crossfader.prototype._newfade = function(){
	if (this.nID1)
		clearInterval(this.nID1);
	
	this.nOldAct = this.nAct;
	this.nAct++;
	if (!this.aDivs[this.nAct])	this.nAct = 0;
	
	if (this.nAct == this.nOldAct)
		return false;
	
	document.getElementById( this.aDivs[this.nAct] ).style.visibility = "visible";
	
	this.nInt = 50;
	this.nTime = 0;
	
	var p=this;
	this.nID2 = setInterval(function() { p._fade() }, this.nInt);
}

_bsn.Crossfader.prototype._fade = function(){
	this.nTime += this.nInt;
	
	var ieop = Math.round( this._easeInOut(this.nTime, 0, 1, this.nDur) * 100 );
	var op = ieop / 100;
	document.getElementById( this.aDivs[this.nAct] ).style.opacity = op;
	document.getElementById( this.aDivs[this.nAct] ).style.filter = "alpha(opacity="+ieop+")";
	
	if (this.nOldAct > -1){
		document.getElementById( this.aDivs[this.nOldAct] ).style.opacity = 1 - op;
		document.getElementById( this.aDivs[this.nOldAct] ).style.filter = "alpha(opacity="+(100 - ieop)+")";
	}
	
	if (this.nTime == this.nDur){
		clearInterval( this.nID2 );
		
		if (this.nOldAct > -1)
			document.getElementById( this.aDivs[this.nOldAct] ).style.visibility = "hidden";
		
		var p=this;
		this.nID1 = setInterval(function() { p._newfade() }, this.nDelay);
	}
}

_bsn.Crossfader.prototype._easeInOut = function(t,b,c,d){
	return c/2 * (1 - Math.cos(Math.PI*t/d)) + b;
}
