/*@cc_on
(function() {
var newIeElements = [
	"article","aside","footer","header",
	"hgroup","nav","section","figure","source",
	"video","audio","canvas","output","details",
	"menu","bb","command","datagrid","datalist",
	"dialog","progress","meter","time","mark"];
for (var i=0; i<newIeElements.length; i++)
	document.createElement(newIeElements[i]);
})();
@*/

/**
 * google analytics
 */
window.___gcfg = {lang: 'ja'};
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-10360146-7']);
_gaq.push(['_trackPageview']);
(function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

var cfg = cfg || {
	twitter: "mexrollingmikan"
};
var SiteCommand = SiteCommand || {
	_unity: null,
	login: function(){
		location.href = "/user/login";
		/*
		var win = window.open(
			"/user/login",
			"_mikanLoginWindow",
			['width=700','height=500','location=yes','resizable=yes','toolbar=no','menubar=no','scrollbars=no','status=no'].join(',')
		);
		*/
		return false;
	},
	termsWindow: function(){
		return SiteCommand.winOpen("/info/terms", 570, 550, "_termsWindow", true);
	},
	checkLogin: function(){
		try{
			if(this._unity){
				this._unity.SendMessage("UrlFetchController", "loginCheck");
			}
		}catch(e){};
	},
	changeCursor: function(type){
		switch(type){
			case 1:
				$("*").css("cursor", "pointer");
				break;
			default:
				$("#unity-box").css("cursor", "default");
				break;
		}
	},
	setUnityTarget: function(unity){
		this._unity = unity;
	},
	getUnityTarget: function(){
		return this._unity;
	},
	track: function(category, action){
		_gaq.push(['_trackEvent', category, action]);
	},
	getTitle: function(){
		return $("meta[property='og:title']").attr("content") || document.title;
	},
	getPageUrl: function(isEnc){
		var url = $("meta[property='og:url']").attr("content") || "";
		if(isEnc)
		{
			url = encodeURIComponent(url);
		}
		return url;
	},
	winOpen: function(src, w, h, name, scroll, top, left){
		w = w || 632;
		h = h || 456;
		left = left || (screen.width - w) / 2;
		top = top || (screen.height - h) / 2;
		name = name || '_blank';
		scroll = scroll ? "yes" : "no";
		var win = window.open(
			src,
			name,
			['width='+w,'height='+h,'location=yes','resizable=yes','toolbar=no','menubar=no','scrollbars='+scroll,'status=no', 'left='+left, 'top='+top].join(',')
		);
		win.focus();
		return false;
	}
};

(function(){
	function unityOnLoad(result){
		if(result.success){
			SiteCommand.setUnityTarget(result.ref);
			/*
			var version = SiteCommand.getUnityTarget().GetUnityVersion("3.x.x");
			try{
				console.log(version);
			}catch(e){};
			*/
		}else{
			alert("最新の Unity Web Player をインストールして御覧ください。");
			$("#unity-player").css({border:"3px solid #E12713",background:"none"})
							  .empty()
							  .append('<div class="missing">'
									+ '<h1 style="margin-top:71px;">'
									+ '<img alt="ローリングみかん3D" src="images/unity_title.gif" width="415" height="122" />'
									+ '</h1>'
									+ '<p>'
									+ '<img alt="このコンテンツをお楽しみいただくには、Unity Web Playerがインストールされた環境が必要です。下記より最新のプラグインをダウンロードしてください。" src="images/unity_text.gif" width="415" height="93" />'
									+ '</p>'
									+ '<p style="margin-bottom:34px;">'
									+ '<a href="http://unity3d.com/webplayer/" title="Unity Web Player. Install now!">'
									+ '<img alt="Unity Web Player. Install now!" src="images/unity_btn.gif" width="206" height="72" />'
									+ '</a>'
									+ '</p>'
									+ '<p style="margin-bottom:13px;">'
									+ '<img alt="※Unity Web Playerは、3Dゲームエンジン「Unity」をwebブラウザで再生するためのプラグインで、いま最も注目を集めている技術のひとつです。" src="images/unity_text02.gif" width="747" height="15" />'
									+ '</p>'
									+ '</div>');
		}
	}
	if(typeof unityObject != "undefined") {
		var param = {
			disableContextMenu: true,
			backgroundcolor: "FFFFFF",
			bordercolor: "FFFFFF",
			textcolor: "000000",
			logoimage: "./images/loading_logo.png",
			progressbarimage: "./images/loading_bar_base.png",
			progressframeimage: "./images/loading_bar.png",
			id: "unity-box"
		};
		unityObject.embedUnity("unity-player", "unity/mikan.unity3d", 800, 420, param, null, unityOnLoad);
	}
})();

$(function($){
	$(window).resize(function(){
		var box = $("#container");
		var m = Math.max(($(this).height() - box.height()) / 2, 0);
		box.css("margin-top", m);
	}).resize();
	//$("p.howto, p.otoshidama").click(function(){
	$("p.howto").click(function(){
		var link = $(this).find("a").attr("href");
		SiteCommand.winOpen(link, 814, 435, "_howtoWindow", true);
		return false;
	});
});


















