/* JavaScript Document */

////////////////////////////////////////////////////////////////
//関数		:call_menu
//説明		:menu.swfを埋込
//			:transparent=透過指定
//継承		:なし
//直接依存	:swfobject.js
//間接依存	:なし
////////////////////////////////////////////////////////////////
function call_menu(path_swf)
{
	var flashvars = {};
	var params = {
	  wmode: "transparent"
	};
	var attributes = {};
	
	swfobject.embedSWF(path_swf , "menu-container", "240", "460", "9.0.0", "", flashvars, params, attributes);
}


////////////////////////////////////////////////////////////////
//クラス		:hide_htmlmenu
//説明		:HTMLメニューを隠す。
//			:menu.swfから呼び出される。
//継承		:なし
//直接依存	:なし
//間接依存	:なし
////////////////////////////////////////////////////////////////
function hide_htmlmenu()
{
	var set_rules = Array();
	set_rules['z-index'] = 300;
	_css.appendRule('div#main-right-fix', set_rules);
	
	set_rules['z-index'] = 1000;
	_css.appendRule('#menu-container', set_rules);
}


////////////////////////////////////////////////////////////////
//クラス		:hide_htmlmenu
//説明		:navigationを埋込
//			:menu.swfから呼び出される。
//継承		:なし
//直接依存	:なし
//間接依存	:なし
////////////////////////////////////////////////////////////////
function call_navigation(){
	var NaviHTML;
	
	NaviHTML  = "<div id='navi-top'>";
	NaviHTML += "</div>";

	NaviHTML += "<div id='navi-festival'>";
	NaviHTML += "</div>";
	
	NaviHTML += "<div id='navi-board'>";
	NaviHTML += "</div>";
	
	NaviHTML += "<div id='navi-question'>";
	NaviHTML += "</div>";
	
	NaviHTML += "<div id='navi-link'>";
	NaviHTML += "</div>";
	
	NaviHTML += "<div id='navi-routary'>";
	NaviHTML += "</div>";	

	NaviHTML += "<div id='navi-volunteer'>";
	NaviHTML += "</div>";

	document.write(NaviHTML);
}


////////////////////////////////////////////////////////////////
//クラス		:DynamicCSS / インスタンス：_css
//継承		:なし
//直接依存	:なし
//関数依存	:なし
////////////////////////////////////////////////////////////////
var DynamicCSS = Class.create();

DynamicCSS.prototype = {

	initialize: function() {

		//IE以外
		if( navigator.userAgent.indexOf("MS", 0) < 0) {
			var element = document.createElement("style");
			element.setAttribute("type", "text/css");
			element.appendChild(document.createTextNode(""));
			document.getElementsByTagName("head")[0].appendChild(element);
			this.sheet = element.sheet;
		}
		//IE
		else
		{
			this.sheet = document.styleSheets[0];
		}		

//		alert("IN initialize " + this.sheet);

	},

	appendRule: function(selector, rules) {
	
		r= new Array();
		for (var i in rules) {
			if (rules.hasOwnProperty(i)) {
				r.push(i + ":" + rules[i]);
			}
		}

		rule = r.join(";");

//		alert(this.sheet);

		//IE以外
		if( navigator.userAgent.indexOf("MS", 0) < 0) {
			this.sheet.insertRule(selector + "{" + rule + ";}", this.sheet.cssRules.length);
		}
		//IE
		else {
			this.sheet.addRule(selector, "{" + rule + ";}");
		}
		
	}
};

var _css = new DynamicCSS();





////////////////////////////////////////////////////////////////
//クラス		:rico_effect
//継承		:なし
//直接依存	:rico.js / ricoEffect.js
//関数依存	:なし
////////////////////////////////////////////////////////////////
rico_effect = Class.create();

rico_effect.prototype = {

	initialize: function(element) {
		this.animator = new Rico.Effect.Animator();
		this.element = $(element);	
	},

	fadeEffectStarted: false,
	
	play: function(effect) {
		this.animator.play(effect, {steps:20, duration:700});
	},

	toggleFade: function(){
		this.play(new Rico.Effect.FadeTo(this.element, this.nextFadeState()));
	},		

	nextFadeState: function(){
		this.fadeEffectStarted = !this.fadeEffectStarted;
		return !this.fadeEffectStarted ? 1 : 0;
	}
};

////////////////////////////////////////////////////////////////
//クラス		:photoframe_custom
//継承		:なし
//直接依存	:rico_effect
//関数依存	:rico.js / ricoEffect.js
////////////////////////////////////////////////////////////////
photoframe_custom = Class.create();

photoframe_custom.prototype = {

	initialize: function(_front_pic, _back_pic, id_keyword) {

		var _photoframe_cover = 'photoframe-cover-' + id_keyword;
		
		this.photoframe_cover = new rico_effect(_photoframe_cover);
		this.front_pic        = new rico_effect(_front_pic);
		this.back_pic         = new rico_effect(_back_pic);

		this.photoframe_title_f = 'photoframe-title-' + id_keyword + '-f';
		this.photoframe_title_b = 'photoframe-title-' + id_keyword + '-b';

	},

	RollOver: function(){

		this.photoframe_cover.toggleFade();
		this.front_pic.toggleFade();

		var set_rules = Array();

		set_rules['display'] = "none";
		_css.appendRule('#' + this.photoframe_title_f, set_rules);

		set_rules['display'] = "block";
		_css.appendRule('#' + this.photoframe_title_b, set_rules);

	},

	RollOut: function(){

		this.photoframe_cover.toggleFade();
		this.front_pic.toggleFade();

		var set_rules = Array();

		set_rules['display'] = "block";
		_css.appendRule('#' + this.photoframe_title_f, set_rules);

		set_rules['display'] = "none";
		_css.appendRule('#' + this.photoframe_title_b, set_rules);		

	}

};

////////////////////////////////////////////////////////////////
//クラス		:photoframe
//継承		:photoframe_custom
//直接依存	:なし
//間接依存	:rico_effect / rico.js / ricoEffect.js
////////////////////////////////////////////////////////////////
photoframe = Class.create();

photoframe.prototype = Object.extend(new photoframe_custom(), {

	initialize: function(id_keyword)
	{
		var _front_pic = 'pic-' + id_keyword + '-f';
		var _back_pic = 'pic-' + id_keyword + '-b';

		photoframe_custom.prototype.initialize.apply(this, [_front_pic, _back_pic, id_keyword]);
	}

});



////////////////////////////////////////////////////////////////
//関数		:display_div, hide_div
//説明		:DOMによるdiv操作
//継承		:なし
//直接依存	:なし
//間接依存	:なし
////////////////////////////////////////////////////////////////
function display_div(id){
	document.getElementById(id).style.display = "block";
}

function hide_div(id){
	document.getElementById(id).style.display = "none";
}

////////////////////////////////////////////////////////////////
//関数		:ShowNowYear
//説明		:現在の年を取得
//継承		:なし
//直接依存	:なし
//間接依存	:なし
////////////////////////////////////////////////////////////////
function ShowNowYear()
{
	var now = new Date();
	var year = now.getFullYear();
	document.write(year);
}
